function foc(input, text) {
	if(input.value==text){input.value='';} 	
	else {input.select();}		
}

function CheckUncheckCheckBox(checkBox) {
	var par = window.document;
	if(checkBox.checked) {
		$(checkBox).parent('label').addClass("Lchecked");
	}
	else {
		$(checkBox).parent('label').removeClass('Lchecked');
	}
	return checkBox.checked;
}
function CheckUncheckRadio(el) {
	var par = window.document;
	var radio = par.getElementById(el.id);
	if(radio.className == 'radio ' + radio.value + 'Lchecked') {
		radio.checked=false;
		radio.className = 'radio ' + radio.value;
		radio.parentNode.className = 'label_radio ' + radio.value;
	}
	else {
		var listRadio = par.getElementsByName(radio.name);
		for (i = 0; i < listRadio.length; i++) {
			var reg = new RegExp('Lchecked');
			listRadio[i].className = listRadio[i].className.replace(reg,' ');
			listRadio[i].parentNode.className = listRadio[i].parentNode.className.replace(reg,' ');
		}
		radio.className = 'radio ' + radio.value + 'Lchecked';
		radio.parentNode.className = 'label_radio ' + radio.value + ' Lchecked';
		
	}
}


function aff_div_recherche_detail() {
	var par = window.document;
	var tick = '';
	//if ($('#li_fieldset_Annonce_Recherche_avancee #li_fieldset_searchAnnonce_Detail').is(':visible')) {
		aff_div_detail('', par.getElementById("Recherche_SousRubrique_Id").value, '', tick, true);
	//}
}
function aff_Recherche_avancee() {
	if ($('#li_fieldset_Annonce_Recherche_avancee #li_fieldset_searchAnnonce_Detail').is(':visible')) {
		$('#li_fieldset_Annonce_Recherche_avancee #li_fieldset_searchAnnonce_Detail').slideUp(300);
		$('#AdvancedSearch').remove();
	}
	else {
		$('#li_fieldset_Annonce_Recherche_avancee #li_fieldset_searchAnnonce_Detail').slideToggle(300);
		$('<input type="hidden" name="AdvancedSearch" id="AdvancedSearch" value="1">').appendTo($('#li_fieldset_Annonce_Recherche_avancee'));
	}
	aff_div_recherche_detail();
	return false;
}


function removeHiddenFromForm(form, search) {
	var par = window.document;
	var id = '';
	
	var li_fieldset_div = par.getElementById('li_fieldset_Annonce_Detail');
	var liste_li = $("#li_fieldset_Annonce_Detail li.li_form_Annonce_Detail");
	if (search) {
		id = 'search';
	}
	$("#li_fieldset_" + id +"Annonce_Detail  li.li_form_Annonce_Detail").each(function(){if ($(this).css('display') == "none") {$(this).remove();}});
}

function hideEmptyFromSearch(form) {
	var par = window.document;
	
	removeHiddenFromForm(form, true);
	
	var form = par.getElementById("id_fieldset_Recherche").getElementsByTagName("form")[0];
	
	var inputList = form.getElementsByTagName("input");
	//var input;
	var selectList = form.getElementsByTagName("select");
	//var select;
	var textareaList = form.getElementsByTagName("textarea");
	//var textarea;
	var i;
	
	for (var j=0;j<inputList.length;j++) {
			i = inputList[j];
		if (i.value == '' || i.name == 'tick' || i.value == i.getAttribute("strDf")) {
			i.disabled = 'true';
		}
	}
	for (var j=0;j<selectList.length;j++) {
		i = selectList[j];
		if (i.value == '') {
			i.disabled = 'true';
		}
	}
	for (var j=0;j<textareaList.length;j++) {
		i = textareaList[j];
		if (i.value == '') {
			i.disabled = 'true';
		}
	}
}

function aff_div_detail(Rubrique_Id, SousRubrique_Id, Annonce_Id, tick, advancedsearch) {
	var search='',id='',combo='';
	var par = window.document;
	//alert(SousRubrique_Id);
	if (advancedsearch) {
		search = '&AdvancedSearch=1';
		id = 'search';
		//nom = $("#Recherche_SousRubrique_Id option[value=" + SousRubrique_Id + "]").text();
		//nom = par.getElementById("Recherche_SousRubrique_Id").options[selectedIndex.text;alert(nom + "j");
		combo = '#dr';
		$('#li_aff_Recherche_avancee').remove();
	}
	else {
		//nom = $("#Annonce_SousRubrique_Id option[value=" + SousRubrique_Id + "]").text();
		//nom = $("#Annonce_SousRubrique_Id").children( ":selected" ).text();
		combo = '.form';
	}
	var par = window.document;
	var li_fieldset_div = par.getElementById('li_fieldset_' + id +'Annonce_Detail');
	//li_fieldset_div.style.display='none';
	$('#li_fieldset_' + id +'Annonce_Detail .li_form_Annonce_Detail').hide();
	//$('#li_fieldset_' + id +'Annonce_Detail .li_form_Annonce_Detail').slideUp(400);
	
	if (SousRubrique_Id!=''){
		var div = $('#div_form_' + id + 'Annonce_Detail_' + Annonce_Id + SousRubrique_Id);
		var lienAdv = '<li class="lif li_lien lienSearch" id="li_aff_Recherche_avancee"><a href="?AdvancedSearch=1" class="aff_Recherche_avancee lien_lienSearch" onclick="return aff_Recherche_avancee();">' + strLienAdv + '</a></li>';
		
		var idDiv = 'div_form_' + id +'Annonce_Detail_' + Annonce_Id + SousRubrique_Id;
		if (div.length) {
			div.parent('li').show();
			if ($('#' + idDiv + ' fieldset').length && advancedsearch) {
				$(lienAdv).appendTo($('#fieldset_Annonce_Recherche #fbs ul'));
				//div.parent('li').slideToggle(400);
			}
		}
		else {
		// create new div
			var li = par.createElement('li');
			li.className = 'li_div li_form_Annonce_Detail';
			var new_div = par.createElement('div');
			var ul_div = par.getElementById('fieldset_' + id +'Annonce_Detail').getElementsByTagName("ul")[0];
			new_div.className = 'div_form_Annonce_Detail';
			new_div.setAttribute('id', idDiv);
			var getTick='';
			if (tick != '') {
				getTick = '&tick_Annonce_Detail=' + tick;
			}
			
			li.appendChild(new_div);
			ul_div.appendChild(li);
			if (!window.__media_prefix__)window.__media_prefix__ = '';
			$.ajax(
                {
                     type: "GET",
                     url: window.__media_prefix__ + '/Annonce_Detail.php?Langue_Id='+window.__lang__+window.__lat__+'&new_Annonce_Detail=&Rubrique_Id='+Rubrique_Id+'&SousRubrique_Id='+SousRubrique_Id+'&Annonce_Detail_Annonce_Id='+Annonce_Id+getTick+search,
                     success: function(msg){
                     if (msg!='') {
						 if (advancedsearch) {
							  $(lienAdv).appendTo($('#fieldset_Annonce_Recherche #fbs ul'));
						 }
						$(msg).appendTo('#'+idDiv);
					  }
                    }
                })
		}
		
	if ($('#li_fieldset_Annonce_Recherche_avancee #li_fieldset_searchAnnonce_Detail').is(':visible')) {
		li_fieldset_div.style.display='block';
	}
			
	}
	return false;
}
	
