/*****************************************************/
/* Fichier Javascript de PASCAL TRANSACTION          */
/*Créé le  : 5/11/2007                               */
/*Mise à jour : 5/11/2007                            */
/*Auteur : Fournot Francois (ffournot@sopragroup.com)*/
/*****************************************************/
//Définition des sous menus

/*var aListLien = new Array();
aListLien[0] = new Array();
aListLien[1] = new Array();

aListLien[0][0] ="<a href=\"#\" class=\"sousMenu\">Ma recherche</a>" ;
aListLien[0][1] ="<a href=\"#\" class=\"sousMenu\">Mes sélections</a>" ;
aListLien[0][2] ="<a href=\"http:\//"+window.location.hostname+":"+window.location.port+"\/Pascal_Transaction\/pages\/Account\/myAccount.aspx\" class=\"sousMenu\">Mon compte</a>" ;
 
aListLien[1][0] ="<a href=\"http:\//"+window.location.hostname+":"+window.location.port+"\/Pascal_Transaction\/pages\/Sale\/sale.aspx\" class=\"sousMenu\">Ma vente</a>" ;
document.onclick = cacheMenu;*/

/**************************************************************/
/*function permettant de valider si un caractère est un nombre*/
/*Si il ne s'agit pas d'un nombre alors                       */
/*elle efface la valeur dans le control passé en paramêtre    */
/*@param : control par exemple un "input type text"           */
function validateChar(control)
{

    if(isNaN(control.value))
    {
        control.value = control.value.substring(0,control.value.length-1);
    }

}

/**************************************************************/
/*function permettant de changer la photo principal           */
/*dans le détail bien                                         */
/*                                                            */
/*@param : nomPhoto le nom de la nouvelle photo               */
function changerPhoto(nomPhoto){
    if (nomPhoto == "noimage.jpg")
        document.getElementById("photoPrincipale").innerHTML="<img alt=\""+nomPhoto+"\" src=\"../../img/"+nomPhoto+"\" width=\"320\" height=\"240\" style=\"border:1px solid #d4d600\"/>";   
    else
        document.getElementById("photoPrincipale").innerHTML="<img alt=\""+nomPhoto+"\" src=\"../../img/images_biens/"+nomPhoto+"\" width=\"320\" height=\"240\" style=\"border:1px solid #d4d600\"/>";   
}
 
/**************************************************************/
/*function permettant d'afficher une popup pour l'impression  */
/*                                                            */
/*                                                            */
/*@param : numMandat le numéro de mandat du bien              */ 
function popup(numMandat)
{
     window.open ("http://"+window.location.hostname+":"+window.location.port+"/pages/Print/print.aspx?nummandat="+numMandat,"impression","toolbar =0,status=0,menubar=0,resizable=0,width=750,height=900"); 
}

/**************************************************************/
/*function permettant d'afficher le sous menu                 */
/*                                                            */
/*                                                            */
/*@param : num le numéro du sous menu considéré               */ 
/*function afficheMenu(num)
{


   document.getElementById("sousMenu").style.position="absolute";
   document.getElementById("sousMenu").style.top=aPosition[num][0]+"px";
   document.getElementById("sousMenu").style.marginLeft=aPosition[num][1]+"px";
    
    var sousMenu;
    sousMenu = "<table class=\"sousMenu\" width=\"135\"  border=\"0\" cellspacing=\"5\" cellpadding=\"0\" >";
    for(i=0;i<aListLien[num].length;i++)
    {
        sousMenu +="<tr><td class=\"sousMenu\">&nbsp;"+aListLien[num][i]+"</td>";
        
        if(i<aListLien[num].length-1)
        {
            sousMenu +="<tr><td><div align=\"center\"><img src=\"http:\//"+window.location.hostname+":"+window.location.port+"\\/img/separateurSousMenu.gif\" width=\"112\" height=\"1\"></div></td></tr>";
         }
    }
    sousMenu +="</table>";
    sousMenu +="</div>"; 
    document.getElementById("sousMenu").innerHTML=sousMenu;
    document.getElementById("sousMenu").style.display="inline";
       
}*/
/**************************************************************/
/*function permettant de cacher le sous menu                  */
/*                                                            */
/*                                                            */
/*                                                            */ 
/*function cacheMenu()
{
    new Effect.Fade("sousMenu");
}
*/
/**************************************************************/
/*function permettant de trouver la position (x,y) d'un       */
/*élément dans un page                                        */
/*                                                            */
/*@param:obj l'objet dont on cherche la position              */ 
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

/****************************************************************/
/*function permettant d'imprimer une page en faisant disparaitre*/ 
/*le bouton imprimer                                            */
/*                                                              */
/*                                                              */
/*                                                              */ 
function printDocument(btn)
{
    btn.style.display="none";
    window.print();
}

var _UPtoPlay;
function UPtoPlay(sender) {
    _UPtoPlay = sender;
}
function ToPlay(sender) {
    return sender == _UPtoPlay ? true:false;
}

function displayImage(object,num)
{
    var pos = findPos(object);
    var x=pos[0];
    var y=pos[1];
    var src = object.src
    var oImg = document.getElementById("imageBig");
    
    if (oImg != null){
	    oImg.innerHTML="<a href=\"detailRealEstate.aspx?nummandat="+num+"\"><img src=\"..\/..\/img/images_biens/"+src.substring(src.lastIndexOf('/')+1)+"\" width=\"240\" height=\"180\" style=\"border:2px solid black;\"/></a> ";
	    oImg.style.display="inline";
    }
}
function eraseImage()
{
    var oImg = document.getElementById("imageBig");
    if (oImg != null)
	document.getElementById("imageBig").style.display="none";
}


function displayErreur(message)
{
    document.getElementById("errorMessage").innerHTML=message;
    document.getElementById("errorMessage").style.display="block";
}

function displayDivKoi2Neuf(oDocument, visible,what)
{ 
  var oDiv = oDocument.getElementById("divKoi2Neuf");
  if (visible ){
    //oDivInfo.visible = false;
    var sTable = "<table width=\"430\" cellpadding=\"0\" cellspacing=\"0\" style=\"font-size:12px;color:black;\">";
    /*sTable += "<tr>";
    sTable += "<td><img src=\"img/cale.gif\" width=\"10\" height=\"1\"/></td>";
    sTable += "<td>";
    sTable += "<strong>Le Domaine Saint-Laurent</strong>";
    sTable += "</td>";
    sTable += "</tr>"; */   
    sTable += "<tr>";
    sTable += "<td><img src=\"./img/cale.gif\" width=\"10\" height=\"1\"/></td>";
    sTable += "<td align=\"center\">";
    sTable += "<img src=\"./img/promotion/myosotis_cadastre.jpg\" />";
    sTable += "</td>";
    sTable += "</tr>";
    /*sTable += "<tr>";
    sTable += "<td><img src=\"img/cale.gif\" width=\"10\" height=\"1\"/></td>";
    sTable += "<td align=\"center\">";
    sTable += "&nbsp;&nbsp;<img src=\"img/puce.gif\" />&nbsp;&nbsp;Prestations raffinées";
    sTable += "</td>";
    sTable += "</tr>";
    sTable += "<tr>";
    sTable += "<td><img src=\"img/cale.gif\" width=\"10\" height=\"1\"/></td>";
    sTable += "<td align=\"center\">";
    sTable += "&nbsp;&nbsp;<img src=\"img/puce.gif\" />&nbsp;&nbsp;Grandes terrasses";
    sTable += "</td>";
    sTable += "</tr>";
    sTable += "<tr>";
    sTable += "<td><img src=\"img/cale.gif\" width=\"10\" height=\"1\"/></td>";
    sTable += "<td align=\"center\">";
    sTable += "&nbsp;&nbsp;<img src=\"img/puce.gif\" />&nbsp;&nbsp;Piscine privée";
    sTable += "</td>";
    sTable += "</tr>";
    sTable += "<tr>";
    sTable += "<td><img src=\"img/cale.gif\" width=\"10\" height=\"1\"/></td>";
    sTable += "<td align=\"center\">";
    sTable += "&nbsp;&nbsp;<img src=\"img/puce.gif\" />&nbsp;&nbsp;du T3 au T5 duplex";
    sTable += "</td>";
    sTable += "</tr>"; */   
    oDiv.innerHTML = sTable;
    oDiv.visible = true;
  }else{
   // oDivInfo.visible = true;
    oDiv.visible = false;
    oDiv.innerHTML = "";
  }
}

function gererScroll(oDocument){
  var oDiv = oDocument.getElementById("divMiniRech");
  var scrollY;
  if (oDiv != null){
    if (document.all)
    { 
      if (!document.documentElement.scrollTop)
        scrollY = document.body.scrollTop;
      else
        scrollY = document.documentElement.scrollTop;
    }else{
      scrollY = window.pageYOffset;
    } 

    oDiv.style.top = 200 + scrollY + "px";
  }    
}
var inhibeEntreRecherche=false;
function desinhibeRech(){

if(inhibeEntreRecherche){
  alert("on desihibe");
  inhibeEntreRecherche=false;
  }
}
function inhibeRech()
{

if(!inhibeEntreRecherche){
  inhibeEntreRecherche=true;
  }
}
function validRecherche()
{

 // alert("Ehohunbon" + inhibeEntreRecherche + "OK");
  if(event.keyCode == 13 && !inhibeEntreRecherche)
  {
   alert("Recherche OK");
   document.getElementById("ctl00_cphCentral_typeOk").value="recherche";
  document.getElementById("ctl00_cphCentral_Search1_imgBtRechercheOk").click();
   // __doPostBack('ctl00_cphCentral_Search1_imgBtRechercheOk','');
  }else if(event.keyCode == 13 && inhibeEntreRecherche){
     alert("Compte OK");
   document.getElementById("ctl00_cphCentral_typeOk").value="compte";
    document.getElementById("ctl00_cphCentral_Login_okCompte").click();
  }
  //alert("FIN validRecherche");
}
/*function validLogin()
{
  if(event.keyCode == 13 && inhibeEntreRecherche)
  {
   inhibeEntreRecherche=true;
   document.getElementById("ctl00_cphCentral_Login_okCompte").click();
    //__doPostBack('ctl00_cphCentral_Login_okCompte','');
  }
}*/
