﻿// MENU
//http://jquery.sanchezsalvador.com/jquery/page/jquerycomboboxexamplealternatestyle.aspx
        $(function() {
            $("#A1").lavaLamp({
                fx: "backout",
                speed: 700,
                click: function(event, menuItem) {
                    //return false;
                }
            });
        });


// RECHERCHE
function Atype(num){
    var cumul = document.form1.TypeBien.value
    var ReccupValue = document.form1.TypeBien.value;
    var ReplaceValue = "";
    var AvecVirgule = ',' + num;
    var SansVirgule = num;
    
    if(cumul=="Types de biens"){
    cumul = cumul.replace('Types de biens','');
    ReccupValue = cumul.replace('Types de biens','');
    }
    
    if (ReccupValue.indexOf(num)>=0){
		ReplaceValue = ReccupValue.replace(AvecVirgule,'').replace(SansVirgule,'');
		document.form1.TypeBien.value = ReplaceValue;
		
		if(document.form1.TypeBien.value.substring(0,1)==","){
		document.form1.TypeBien.value = document.form1.TypeBien.value.substring(1);
		}	
		}
		else
		{
		if(cumul != ""){
        cumul = cumul + ","
        }
		document.form1.TypeBien.value = cumul + num
		}
		
	    if(document.form1.TypeBien.value==""){
		document.form1.TypeBien.value = "Types de biens";
		}
    }
    
    function Bp(num){
    var cumul = document.form1.Piece.value
    var ReccupValue = document.form1.Piece.value;
    var ReplaceValue = "";
    var AvecVirgule = ',' + num;
    var SansVirgule = num;
    
    if(cumul=="Les pièces"){
    cumul = cumul.replace('Les pièces','');
    ReccupValue = cumul.replace('Les pièces','');
    }
    
    if (ReccupValue.indexOf(num)>=0){
		ReplaceValue = ReccupValue.replace(AvecVirgule,'').replace(SansVirgule,'');
		document.form1.Piece.value = ReplaceValue;
		
		if(document.form1.Piece.value.substring(0,1)==","){
		document.form1.Piece.value = document.form1.Piece.value.substring(1);
		}
		}
		else
		{
		if(cumul != ""){
        cumul = cumul + ","
        }
		document.form1.Piece.value = cumul + num
		}	
		if(document.form1.Piece.value==""){
		document.form1.Piece.value = "Les pièces";
		}
    }
    
    
    
    function AfficheBoutonCalcul(){
document.getElementById("BoutonCalcul").style.display = "block";
document.getElementById("CalculMensualite").style.display = "block";
}

function MaskBoutonCalcul(){
document.getElementById("BoutonCalcul").style.display = "none";
document.getElementById("CalculMensualite").style.display = "none";
}

//CALCUL
function AfficheCalcul(){
if (document.form1.Calcul.checked == true){
if((document.form1.BudgetMini.value =='')||(document.form1.BudgetMaxi.value =='')||(document.form1.BudgetMini.value =='Budget mini')||(document.form1.BudgetMaxi.value =='Budget maxi')){
alert('Vous devez choisir un budget minimum et maximum pour le calcul de vos mensualitées');
document.form1.Calcul.checked = false;
}else{
document.getElementById("CalculMensualite").style.display = "block";
document.getElementById("Ville").style.display = "none";
}
}
if (document.form1.Calcul.checked == false){
document.getElementById("CalculMensualite").style.display = "none";
document.getElementById("Ville").style.display = "block";
}
}
 

            function DisableButton() {
            if(((document.form1.Localite.value == "")||(document.form1.Localite.value == "Indiquez la localité ou le code postal"))) {
            alert('Vous devez indiquer une localité ou un code postal ex : 75000'); 
            return(true);
            }else{document.getElementById("TdScan").style.display = "block";
                 }
            }

            function disableButton2(buttonID) {
                document.getElementById("TdScan").style.display = "block";
                return true;
            }
            
            
// COMPTE            
function mon_compte(num){
var valeur = num;
if(valeur=="perdu"){
document.getElementById("txt_accueil").style.display = "none";
document.getElementById("IdPerdus").style.display = "block";
document.getElementById("laconnexion").style.display = "none";
}
if(valeur=="identification"){
document.getElementById("txt_accueil").style.display = "none";
document.getElementById("IdPerdus").style.display = "none";
document.getElementById("laconnexion").style.display = "block";
}
}


// ----- Popup Control ---------------------------------------------------------
function at_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- Show Aux -----
function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ----- Show -----
function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);

  clearTimeout(c["at_timeout"]);
}
// ----- Hide ----
function at_hide()
{
  var c = document.getElementById(this["at_child"]);
  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
 }
function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible")
       at_show_aux(p.id, c.id);
  else c.style.visibility = "hidden";
 
  return false;
}

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}
function Nombre(){
if(event.keyCode < 45 || event.keyCode > 57) event.returnValue = false; if(event.which < 45 || event.which > 57) return false;
} 


// MODAL POPUP AJAX
        function pageLoad() {
            $addHandler($get("showModalPopupClientButton"), 'click', showModalPopupViaClient);
            $addHandler($get("hideModalPopupViaClientButton"), 'click', hideModalPopupViaClient);  
            
            $addHandler($get("showModalPopupClientButton2"), 'click', showModalPopupViaClient2);
            $addHandler($get("hideModalPopupViaClientButton2"), 'click', hideModalPopupViaClient2);     
        }
        
        function showModalPopupViaClient(ev) {
            ev.preventDefault();
            var modalPopupBehavior = $find('programmaticModalPopupBehavior');
            modalPopupBehavior.show();
        }
        
        function hideModalPopupViaClient(ev) {
            ev.preventDefault();        
            var modalPopupBehavior = $find('programmaticModalPopupBehavior');
            modalPopupBehavior.hide();
        }
        
        
        function showModalPopupViaClient2(ev) {
            ev.preventDefault();
            var modalPopupBehavior = $find('programmaticModalPopupBehavior2');
            modalPopupBehavior.show();
        }
        
        function hideModalPopupViaClient2(ev) {
            ev.preventDefault();        
            var modalPopupBehavior = $find('programmaticModalPopupBehavior2');
            modalPopupBehavior.hide();
        }
        
        
//PN1_
// FORMULAIRE ACCUEIL
function ref(num){
var ReccupValue = document.form1.PN1_Text1.value;
var ReplaceValue = "";


if(ReccupValue.slice(-1)!=";"){
ReccupValue = ReccupValue;
}

if (ReccupValue.indexOf(num)>=0){

		ReplaceValue = ReccupValue.replace(num,'');
		document.form1.PN1_Text1.value = ReplaceValue;
		
if(num == 'Achat ancien'){
document.form1.PN1_achat.style.borderColor="#FFFFFF";
}		
if(num == 'Location'){
document.form1.PN1_location.style.borderColor="#FFFFFF";
}	
if(num == 'Location saisonière'){
document.form1.PN1_saisonniere.style.borderColor="#FFFFFF";
}				
}else{

var reccupval = document.form1.PN1_Text1.value;

if((reccupval.slice(-1)!=";") && (reccupval.lenght > 1)){
reccupval = reccupval;
document.form1.PN1_Text1.value = num;
}else{
document.form1.PN1_Text1.value = num;
}


//#FF6600
if(num == 'Achat ancien'){
document.form1.PN1_achat.style.borderColor="#FF6600";
document.form1.PN1_location.style.borderColor="#ffffff";
document.form1.PN1_saisonniere.style.borderColor="#ffffff";
}		
if(num == 'Location'){
document.form1.PN1_location.style.borderColor="#FF6600";
document.form1.PN1_achat.style.borderColor="#ffffff";
document.form1.PN1_saisonniere.style.borderColor="#ffffff";
}	
if(num == 'Location saisonière'){
document.form1.PN1_saisonniere.style.borderColor="#FF6600";
document.form1.PN1_achat.style.borderColor="#ffffff";
document.form1.PN1_location.style.borderColor="#ffffff";
}
	
}

var area = document.getElementById('vignette');
if(document.form1.PN1_Text1.value == ''){
area.style.display ="block";
}else{area.style.display = "none";}

if(document.form1.PN1_Text1.value =="Achat ancien"){
document.form1.PN1_achat.style.borderColor="#FF6600";
}

if(document.form1.PN1_Text1.value != ""){
document.form1.PN1_TypeBienDemande.disabled = false;
document.form1.PN1_Dep.disabled = false;

}else{
document.form1.PN1_TypeBienDemande.disabled = true;
if(document.form1.PN1_Dep.value ==''){
document.form1.PN1_VilleDemande.disabled = true;
}else{document.form1.PN1_VilleDemande.disabled = false;}
document.form1.PN1_Budget.disabled = true;
document.form1.PN1_VotreNom.disabled = true;
document.form1.PN1_VotreCp.disabled = true;
document.form1.PN1_Tel.disabled = true;
document.form1.PN1_VotreEmail.disabled = true;
document.form1.PN1_VotreDemande.disabled = true;
document.form1.PN1_ButtonValider.disabled = true;
}
}     


// ENCART
function Accord(IdAccordeon){
d = document.getElementById(IdAccordeon).style.display;
if (d == "none" || d == undefined || d == ""){
document.getElementById(IdAccordeon).style.display = "none";
document.getElementById("" + IdAccordeon + "-z").src="images/CarrePlusJaune.gif";
}

if (d == "none"){
document.getElementById(IdAccordeon).style.display = "block";
document.getElementById("" + IdAccordeon + "-z").src="images/CarrePlus.gif";
}

if (d == "block"){
document.getElementById(IdAccordeon).style.display = "none";
document.getElementById("" + IdAccordeon + "-z").src="images/CarrePlusJaune.gif";
}
}