// JavaScript Document
function change_menu(id,img) {

	mydiv = document.getElementById(id);
	if(mydiv)
	    mydiv.src = img;
}

function plus_critere() {

	mydiv = document.getElementById("ctl00_cph_pluschamp");
	mydiv.className = "visible";
		
	mydiv = document.getElementById("ctl00_cph_plusubmit");
	mydiv.className = "invisible";
}

function AffichAlerte() {
	mydiv = document.getElementById("ctl00_cph_alerte1");
	mydiv.className = "votre-alerte-email";
}
function FermeAlerte() {
	mydiv = document.getElementById("ctl00_cph_alerte1");
	mydiv.className = "invisible";
	
	mydiv = document.getElementById("alerte2");
	mydiv.className = "invisible";
	
}
function AffichSend() {
	mydiv = document.getElementById("SendFriend");
	mydiv.className = "block-send";
}
function FermeSend() {
	mydiv = document.getElementById("SendFriend");
	mydiv.className = "invisible";
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function linkParent(thisBox,i)
{
	var Parent = eval('document.aspnetForm.ctl00_cph_type_' + i);
	
	if(thisBox.checked)
	{
	    Parent.checked = thisBox.checked;
	    return;
	}    
     switch(i)
    {
        case 0:
        if (!document.aspnetForm.ctl00_cph_b1.checked && !document.aspnetForm.ctl00_cph_b9.checked && !document.aspnetForm.ctl00_cph_b6.checked && !document.aspnetForm.ctl00_cph_b14.checked)
            Parent.checked = false;
        break;
        
        case 1:
        if(!document.aspnetForm.ctl00_cph_b15.checked && !document.aspnetForm.ctl00_cph_b23.checked && !document.aspnetForm.ctl00_cph_b5.checked && !document.aspnetForm.ctl00_cph_b10.checked && !document.aspnetForm.ctl00_cph_b11.checked && !document.aspnetForm.ctl00_cph_b20.checked && !document.aspnetForm.ctl00_cph_b8.checked && !document.aspnetForm.ctl00_cph_b12.checked && !document.aspnetForm.ctl00_cph_b13.checked)
            Parent.checked = false;
        break;
        
        case 2:
        if(!document.aspnetForm.ctl00_cph_b19.checked && !document.aspnetForm.ctl00_cph_b22.checked && !document.aspnetForm.ctl00_cph_b17.checked && !document.aspnetForm.ctl00_cph_b3.checked)
            Parent.checked = false;
        break;
    }
}

function linkChoice(thisBox,i)
{
    switch(i)
    {
        case 0:
        document.aspnetForm.ctl00_cph_b1.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b9.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b6.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b14.checked = thisBox.checked;
        break;
        
        case 1:
        document.aspnetForm.ctl00_cph_b15.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b23.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b5.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b10.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b11.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b20.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b8.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b12.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b13.checked = thisBox.checked;
        break;
        
        case 2:
        document.aspnetForm.ctl00_cph_b19.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b22.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b17.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b3.checked = thisBox.checked;
        break;
        
        case 3:
        document.aspnetForm.ctl00_cph_b2.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_b4.checked = thisBox.checked;
        document.aspnetForm.ctl00_cph_bFondCommerce.checked = thisBox.checked;
        break;

    }
}


function OnFocus(obj, val)
{
    if(obj.value == val)
        obj.value = '';
}

function OnDelFocus(obj, val)
{
    if(obj.value == '')
        obj.value = val;
}

function assCommune(strNew)
{
    document.aspnetForm.ctl00_cph_txtDepartement.value = strNew;
}

function setLocalisation(obj)
{
    if(document.aspnetForm.rdCommune)
    {
        for(var i = 0; i < document.aspnetForm.rdCommune.length; i++)
            document.aspnetForm.rdCommune[i].checked = false;

    	mydiv = document.getElementById("ctl00_cph_pError");
	    mydiv.style.visibility = "hidden";
    }
    
    //-------Secteur
    mySec = document.getElementById("ctl00_cph_hSecteur");
    mySec.value = "0";
}

function suppressionCompte(sender,args)
{
    args.IsValid = (window.confirm("Voulez-vous supprimer votre compte personnel ?"));
}
function LimitNum()
{
	if(event.keyCode >= 48 && event.keyCode <= 57)
		return;

	event.keyCode = "0";  
	alert("Veuillez n'entrer que des chiffres svp !")
}

//---------Proposer un bien
var ckAgence = null;

function selAgence(obj)
{
    if (ckAgence != null)
    {
        if(confirm("Vous ne pouvez proposer votre bien qu'à une seule agence Square Habitat, souhaitez vous valider votre choix"))
        {
           ckAgence.checked = false;
           ckAgence = obj;        
        }           
        else
            obj.checked = false;   
           
    }
    else
        ckAgence = obj;        
}

/*
var x = 0;
var y  = 0;
//document.onmousemove = SourisXY;
//function SourisXY(e)
{
    if(e)
    {
        x = e.pageX;
        y = e.pageY;
    }
    else
    {
        x = event.x + document.body.scrollLeft;
        y = event.y + document.body.scrollTop;
    }
}
*/
function radopenEx(url)
{
    var m = GetRadWindowManager()
    var w = m.getWindowByName('rdLocal');
    w.setUrl(url);
    w.show();
    w.center();
}
function MyradopenEx(url, sName)
{
    var m = GetRadWindowManager()
    var w = m.getWindowByName(sName);
    w.setUrl(url);
    w.show();
    w.center();
}

function radopenVisite(url)
{
    var m = GetRadWindowManager()
    var w = m.getWindowByName('rdVisite');
    w.setUrl(url);
    w.show();
    w.center();
}
function radopenVideo(url)
{
    var m = GetRadWindowManager()
    var w = m.getWindowByName('rdVideo');
    w.setUrl(url);
    w.show();
    w.center();
}

function Zoom(ID, WidthImg, HeightImg) 
{
    var width = ((WidthImg + 35) > screen.width) ? screen.width - 35 : WidthImg + 35;
    var height = ((HeightImg + 60) > screen.height) ? screen.height - 60 : HeightImg + 60;

    open("zoom.asp?ID=" + ID, "", "toolbar=0,location=0,directories=0,scrollbars=1,resizable=1, status=0,menubar=0,width=" + width + ",height=" + height + ",left=5,top=5");
}
