/* pour ne selectionner qu'une check box lors de la recherche par type de residence */
function recherche_check_type_res(i) {
	doc = document.form_recherche;
	for (j = 1; j < 4 ; j ++) {
		if (j != i) {
			document.getElementById( "formsearch_type_res"+j).checked = false;
		}
	}
}

// Gestion des popup
function popup_rapide(PageUrl, PageName, height, width){
	window.open (PageUrl, 'PageName', config='height='+height+', width='+width+', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
}

function popup_rapide_centered(PageUrl, PageName, height, width){
	var top=(screen.height-height)/2;
  	var left=(screen.width-width)/2;
	window.open (PageUrl, 'PageName', config='height='+height+', width='+width+', top='+top+', left='+left+', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
}

function popup_rapide_scrollable(PageUrl, PageName, height, width){
	window.open (PageUrl, PageName, config='height='+height+', width='+width+', toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
}

function lhc(mc){
	window.location.href = "/"+mc+".php";
}
function lhcd(mc){
	window.location.href = "/"+mc+"/";
}

function showDiv(div_id, class_name, flash_url, flash_id, width, height){
	var el = document.getElementById(div_id);
		if(el){
			if(el.className != class_name){
				var so = new SWFObject(flash_url, flash_id, width, height, "8", "#ffffff", "high");
				so.setAttribute('xiRedirectUrl', 'http://www.nexity-logement.com/');
				so.addParam("wmode", "transparent");
				//so.addVariable("name", "value");
				so.write(div_id);
				
				el.className = class_name;
			}
	}
}
function hideDiv(div_id){
	var el = document.getElementById(div_id);
		if(el){
			if(el.className != 'invisible'){
				el.className = 'invisible';
				
				el.innerHTML = "";
			}
	}
}

function bug (){
	window.alert("bo");
}

function open_liste2 (id){
	
	if(document.getElementById("s_m_"+id).style.display == "none") {
		document.getElementById("s_m_"+id).style.display = "";
	}
	else
	{
			document.getElementById("s_m_"+id).style.display = "none";
	}
}

function check_form_email_nl(p_email){
	
	if (p_email.search(/^.+@.+\..+$/) != -1
		&& p_email != ""
		&& p_email.length >= 2 ){
			
		return true;
	} 
	
	return false;
}

function check_form_numero(p_numtel){
	if (p_numtel.search(/^[0-9-.+][0-9-. ]*$/) != -1 && p_numtel != ""){
		return true;
	} 
	
	return false;
}

function check_WCB_numero(telephone){
	if (isNaN(telephone) || telephone.length < 10 || telephone.substr(0,1)!="0" || telephone.substr(1,1)=="0" || telephone.substr(1,1)=="7"){
		alert("Numéro de téléphone erroné.");
		return false;
	}
	xt_med('C','11','CONFIRMATION::WCB_LINKEO','N');
	return true;
}

function openWCB(url, t2s, direct, post) {
	if(post){
		if(check_WCB_numero(document.getElementById("formcontact_WCB_TELEPHONE").value)){
			if(direct){
				window.open("http://www.linkeo.net/accueil.nsf/banniere?Open&CODEBOUTON="+document.getElementById("code_bouton").value+"&DELAI=0&POPUP=1&HORAIREOK=1&T2S=Mise en relation avec un internaute qui a demandé un rappel immédiat&LANGUET2S=fr4&TELEPHONE="+document.getElementById("formcontact_WCB_TELEPHONE").value+"&TELAGENT="+document.getElementById("tel_agent").value+"&CHECKSUM="+document.getElementById("checksum").value, "WCB", 'width=550, height=350, top='+(screen.height-350)/2 +', left='+(screen.width-550)/2 +', menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no');
			} else {
				window.open(url+"?t2s="+t2s+"&is_post=1", "WCB", 'width=550, height=350, top='+(screen.height-350)/2 +', left='+(screen.width-550)/2 +', menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no');
			}
		}
		return false;
	}
	
	window.open(url+"?t2s="+t2s, "WCB", 'width=550, height=350, top='+(screen.height-350)/2 +', left='+(screen.width-550)/2 +', menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no');
	
}

function openWCB_prg(url, t2s, direct, e) {
	if(check_WCB_numero(e.TELEPHONE.value)){
		if(direct){
			window.open("http://www.linkeo.net/accueil.nsf/banniere?Open&CODEBOUTON="+document.getElementById("code_bouton").value+"&DELAI=0&POPUP=1&HORAIREOK=1&T2S="+t2s+"&LANGUET2S=fr4&TELEPHONE="+e.TELEPHONE.value+"&TELAGENT="+document.getElementById("tel_agent").value+"&CHECKSUM="+document.getElementById("checksum").value, "WCB", 'width=550, height=350, top='+(screen.height-350)/2 +', left='+(screen.width-550)/2 +', menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no');
		} else {
			window.open(url+"?t2s="+t2s+"&is_post=1", "WCB", 'width=550, height=350, top='+(screen.height-350)/2 +', left='+(screen.width-550)/2 +', menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no');
		}
	}
	return false;
}
