function affichage_popup(nom_de_la_page, nom_interne_de_la_fenetre){
window.open(nom_de_la_page, nom_interne_de_la_fenetre, config='height=500, width=800, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, directories=no, status=no, top=200px , left=320px');
}

msOver=0;
function testHover(){		

	$("#recherche").bind("mouseover",function(){
	msOver=0;					
	});
	}
function compteur(size,max,text)
{
document.getElementById(max).style.fontWeight="normal";
document.getElementById(max).style.color="black";
document.getElementById(max).innerHTML=size-(document.getElementById(text).value.length);
if(size-(document.getElementById(text).value.length)<=0)
{
document.getElementById(max).style.color="#FF0000";
document.getElementById(max).innerHTML=size-(document.getElementById(text).value.length);
}
if((size-(document.getElementById(text).value.length)<=20)&&(size-(document.getElementById(text).value.length)>=0))
{
document.getElementById(max).style.fontWeight="bold";
document.getElementById(max).innerHTML=size-(document.getElementById(text).value.length);
}
}



/////wi
function calculer(){
var PAY,rateType;
if($('#montantCo').val()>1000000000){
	alert("Le montant a emprunter est limité a 1 000 000 000 Dh");
	return;
}
if($('#tauxCo').val()>100){
	alert("Le taux d'emprunte est limité  a 100%");
	return;
}

var PAY = ($('#montantCo').val() * ($('#tauxCo').val()/12) * 0.01 * 1.10) / (1 - Math.pow(1 + (($('#tauxCo').val()/12) * 0.01 * 1.10), -($('#duree').html()*12)));
//var PAY = ($('#montantCo').val() * ($('#tauxCo').val()/12) / 100) / (1 - Math.pow(1 + (($('#tauxCo').val()/12) / 100), -($('#duree').html()*12)));

$('#mensuelleCo').text(Math.round(PAY)+' Dhs');


//if(document.getElementsByName("choix")[0].checked==true)
//rateType=1;
//else
//rateType=2;
$.post("http://wi.ma/ajax/echo.php?ratetype_id=1&montant="+$('#montantCo').val()+"&tauxCo="+$('#tauxCo').val()+"&duree="+$('#duree').html()+"&total="+PAY, function(data){
});
return false;
}

$(document).ready(function(){

$("#ban").bind("mouseover",function(){
	$(".subMenu").hide();
});
           

$('#price').keyfilter("/[\dA-F]/");
$('#montantCo').keyfilter("/[\dA-F]/");





/*$("#prefecture_id").bind("change",function(){
$.post("http://wi.ma/ajax/echo.php?pref="+$('#prefecture_id').val()+"", function(data){


$("#quartier_id").html(data);
$("#quartier_id").show();
	$("#labelQuartier").show();
	$("#quartier_id").attr("disabled","")
	
	
});
});*/







$('a[rel*=facebox]').facebox({
        loading_image : 'loading.gif',
        close_image   : 'closelabel.gif'
      });
$("#paymentForm .paymenttype").bind("change",function(){
if(document.getElementsByName("paymenttype_id")[0].checked==true){

$("#paymentForm").attr("action","http://wi.ma/index/paiementconf")
}
else{
$("#paymentForm").attr("action","")
}
});



		$(".subMenu a").bind("click",function(){
		
		$(".subMenu").hide();
	});
		
	

$("#faxSug").bind("focus",function(){
	if($("#faxSug").val()=="ex : 0661224433" ){
	$("#faxSug").val("");
	$("#faxSug").removeClass("ex");
	
	}
	
});
$("#telSug").bind("focus",function(){
if($("#telSug").val()=="ex : 0661224433" ){
	$("#telSug").val("");
	$("#telSug").removeClass("ex");
	
	}
	});
$("#formLo #login").bind("focus",function(){
	if($("#formLo #login").val()=="login"){
	$("#formLo #login").val("");
	
	}
});
$("#formLo #password").bind("focus",function(){
	if($("#formLo #password").val()=="0000000"){
	$("#formLo #password").val("");
	
	}
});
	
	$("#vente").bind("click",function(){
    document.location=$("#vente a").attr("href");
});
$("#location").bind("click",function(){
    document.location=$("#location a").attr("href");
});
$("#credit").bind("click",function(){
    document.location=$("#credit a").attr("href");
});
$("#evaluation").bind("click",function(){
    document.location=$("#evaluation a").attr("href");
});
$("#magazine").bind("click",function(){
    document.location=$("#magazine a").attr("href");
});
$("#aide").bind("click",function(){
    document.location=$("#aide a").attr("href");
});
	$("#content form input:submit,#contentPanier input:button").bind("mouseover",function(){
		$("input:submit").prev(".leftBtn").addClass("selected");
		$("input:submit").next(".rightBtn").addClass("selected");		
		$("input:button").prev(".leftBtn").addClass("selected");
		$("input:button").next(".rightBtn").addClass("selected");
	});
	$("#content form input:submit,#contentPanier input:button").bind("mouseout",function(){
	
		$("input:submit").prev(".leftBtn").removeClass("selected");
		$("input:submit").next(".rightBtn").removeClass("selected");		
		$("input:button").prev(".leftBtn").removeClass("selected");
		$("input:button").next(".rightBtn").removeClass("selected");
	});
	$("#rech").bind("mouseover",function(){
		$(".subMenu").hide();
		$("#recherche").show();
	});		
	/*$("#rech").bind("mouseout",function(){
	msOver=0;
	testHover();
	if(msOver==1){
	setTimeout(function(){ $("#recherche").hide(); }, 3000);
	}			
	});*/
	$("#ser").bind("mouseover",function(){
		$(".subMenu").hide();
		$("#service").show();
	});
	$("#ann").bind("mouseover",function(){
		$(".subMenu").hide();
		$("#annonces").show();
	});
	$("#info").bind("mouseover",function(){
		$(".subMenu").hide();
		$("#inf").show();
	});
	$("#acc").bind("mouseover",function(){
		$(".subMenu").hide();
		
	});
	$("#ins").bind("mouseover",function(){
		$(".subMenu").hide();
		$("#recup").show();
		
		
	});
	$(".subMenu").bind("mouseleave",function(){
		$(".subMenu").hide();
		
		
		
	});
	
	
	 
	 /*$(".multiSelectContent").bind("mouseleave",function(){
	 	
	 	$(".multiSelectContent").addClass("collapsed");
	 });
	 
	 $(".multiSelect").bind("click",function(){
	 		$(".multiSelectContent").addClass("collapsed");
	 		$(this).next(".multiSelectContent.collapsed").removeClass("collapsed");
	 });*/
	 $("#search-btnRef").bind("click",function(){
	 	if($("#reference").val()==""){
	 		$("#reference").css("border","2px solid red");
	 		return false;
	 	}
	 	});
	 	
	 $("#typebien_id option").bind("click",function(){
	 	if($(this).attr("rel")!="piece"){
	 		$("#chambreTr").hide();
	 		}else{
	 			$("#chambreTr").show();
	 		}
	 });
	 	 	$("#multiSelect-regionlist-content li input").bind("change",function(){
	 	
	 	
	$.post("http://wi.ma/ajax/echo.php?region="+$(this).val().substring(0,$(this).val().indexOf('-'))+"", function(data){
	$("#multiSelect-prefecturelist-content ul").html(data);
});
});

	 	 	
	 	
	 
	
});

