﻿// 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.forms['aspnetForm'].PN1_Text1.value;
var ReplaceValue = "";


if(ReccupValue.slice(-1)!=";"){
ReccupValue = ReccupValue;
}

if (ReccupValue.indexOf(num)>=0){

		ReplaceValue = ReccupValue.replace(num,'');
		document.forms['aspnetForm'].PN1_Text1.value = ReplaceValue;
		
if(num == 'Achat ancien'){
document.forms['aspnetForm'].PN1_achat.style.borderColor="#FFFFFF";
}		
if(num == 'Location'){
document.forms['aspnetForm'].PN1_location.style.borderColor="#FFFFFF";
}	
if(num == 'Location saisonière'){
document.forms['aspnetForm'].PN1_saisonniere.style.borderColor="#FFFFFF";
}				
}else{

var reccupval = document.forms['aspnetForm'].PN1_Text1.value;

if((reccupval.slice(-1)!=";") && (reccupval.lenght > 1)){
reccupval = reccupval;
document.forms['aspnetForm'].PN1_Text1.value = num;
}else{
document.forms['aspnetForm'].PN1_Text1.value = num;
}


//#FF6600
if(num == 'Achat ancien'){
document.forms['aspnetForm'].PN1_achat.style.borderColor="#FF6600";
document.forms['aspnetForm'].PN1_location.style.borderColor="#ffffff";
document.forms['aspnetForm'].PN1_saisonniere.style.borderColor="#ffffff";
}		
if(num == 'Location'){
document.forms['aspnetForm'].PN1_location.style.borderColor="#FF6600";
document.forms['aspnetForm'].PN1_achat.style.borderColor="#ffffff";
document.forms['aspnetForm'].PN1_saisonniere.style.borderColor="#ffffff";
}	
if(num == 'Location saisonière'){
document.forms['aspnetForm'].PN1_saisonniere.style.borderColor="#FF6600";
document.forms['aspnetForm'].PN1_achat.style.borderColor="#ffffff";
document.forms['aspnetForm'].PN1_location.style.borderColor="#ffffff";
}
	
}

var area = document.getElementById('vignette');
if(document.forms['aspnetForm'].PN1_Text1.value == ''){
area.style.display ="block";
}else{area.style.display = "none";}

if(document.forms['aspnetForm'].PN1_Text1.value =="Achat ancien"){
document.forms['aspnetForm'].PN1_achat.style.borderColor="#FF6600";
}

if(document.forms['aspnetForm'].PN1_Text1.value != ""){
document.forms['aspnetForm'].PN1_TypeBienDemande.disabled = false;
document.forms['aspnetForm'].PN1_Dep.disabled = false;

}else{
document.forms['aspnetForm'].PN1_TypeBienDemande.disabled = true;
if(document.forms['aspnetForm'].PN1_Dep.value ==''){
document.forms['aspnetForm'].PN1_VilleDemande.disabled = true;
}else{document.forms['aspnetForm'].PN1_VilleDemande.disabled = false;}
document.forms['aspnetForm'].PN1_Budget.disabled = true;
document.forms['aspnetForm'].PN1_VotreNom.disabled = true;
document.forms['aspnetForm'].PN1_VotreCp.disabled = true;
document.forms['aspnetForm'].PN1_Tel.disabled = true;
document.forms['aspnetForm'].PN1_VotreEmail.disabled = true;
document.forms['aspnetForm'].PN1_VotreDemande.disabled = true;
document.forms['aspnetForm'].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";
}
}