<!-- **************************************************************** -->
<!-- *************** script pour les recherches            ********** -->
<!-- **************************************************************** -->

<!-- -----------------------------------------------------------------  -->
<!-- lance une recherche sur le serveur : le resultat est une page XML. -->
<!-- charge dans la frame cachée BufferResultat la page HTML issue du parse -->
<!-- serveur du flux XML, transformé par la feuille de style recherche.XSL -->  
<!-- OnLoad cette frame appel loadResultat pour mettre à jour le divResultat -->       
<!-- ----------------------------------------------------------------- -->

var lastszNomRecherche="";
var lastszAlphaJ;
var lastszChamp1;
var lastszChamp2;
var lastszTarget = "";
var lastxc;
var lastyc;
var newwin;
var newwinprint;
var xslInfo = "info.xsl";
var openInfo = false;

var tSelected = new Array(2000);
var curselect = "";
var curTailleExport = "300@300";
var curmodelword = "1";
var curTailleExportWord = "500@400";
var currentProcess="";
var curTailleWindow = "width=800,height=600";


/* fonction déstiné à éffacer la liste de selection pour les exports */
function resetSelected()
{
var k;
 for(k=0;k<tSelected.length;k++)
 {
 tSelected[k]="";
 }
}

/* Obtient la feuille de style pour imprimer */
function getCurrentXSLPrint()
{
var objSel = document.getElementById("selectFormat");
var curXSL = "imprimer.xsl";
curTailleExport = "300@300";
if(objSel!=null)
{
  if(objSel.value == "1")
  {
    curXSL = "imprimer.xsl";
    curTailleExport = "500@500";
		
  }
	if(objSel.value == "2")
  {
  
    curXSL = "imprimersanslegende.xsl";
    curTailleExport = "630@800";
		
  
  }
	if(objSel.value == "3")
  {
     curXSL = "imprimerpaysage.xsl";
    curTailleExport = "800@600";
  }
	if(objSel.value == "4")
  {
  curXSL = "imprimerpaysagesanslegende.xsl";
    curTailleExport = "950@520";
  }


}
return(curXSL);
}
/* Obtient la feuille de style pour la fiche d'information */

function getCurrentXSLInfo()
{
var objSel = document.getElementById("selectFormat");
var curXSL = "info.xsl";
curTailleExport = "300@300";
curmodelword = "1";
if(objSel!=null)
{
  if(objSel.value == "1")
  {
    if(curselect == "Propriété")
    {
    curXSL = "microfiche.xsl";
		curTailleExport = "500@300";
		curmodelword = "2";
		curTailleExportWord = "1000@530";
		curTailleWindow = "width=1000,height=700";
		
    }
    else
    {
    curXSL = "infoportrait.xsl";
		curTailleExport = "500@300";
		curmodelword = "1";
		curTailleExportWord = "600@400";
		curTailleWindow = "width=600,height=700";
    }
  }
	if(objSel.value == "2")
  {
    if(curselect == "Propriété")
    {
    curXSL = "microfiche.xsl";
		curTailleExport = "500@300";
		curmodelword = "2";
		curTailleExportWord = "1000@400";
		curTailleWindow = "width=1000,height=700";
    }
    else
    {
    curXSL = "infoportrait.xsl";
		curTailleExport = "500@300";
		curmodelword = "1";
		curTailleExportWord = "600@400";
		curTailleWindow = "width=600,height=700";
		
    }
  }
	if(objSel.value == "3")
  {
    if(curselect == "Propriété")
    {
    curXSL = "microfiche.xsl";
		curTailleExport = "500@300";
		curmodelword = "2";
		curTailleExportWord = "1000@500";
		curTailleWindow = "width=1000,height=700";
    }
    else
    {
    curXSL = "infopaysage.xsl";
		curTailleExport = "300@500";
		curmodelword = "2";
		curTailleExportWord = "1000@500";
		curTailleWindow = "width=1000,height=700";
    }
  }
	if(objSel.value == "4")
  {
    if(curselect == "Propriété")
    {
    curXSL = "microfiche.xsl";
		curTailleExport = "500@300";
		curmodelword = "2";
		curTailleExportWord = "1000@500";
		curTailleWindow = "width=1000,height=700";
    }
    else
    {
    curXSL = "infopaysage.xsl";
		curTailleExport = "300@500";
		curmodelword = "2";
		curTailleExportWord = "1000@500";
		curTailleWindow = "width=1000,height=700";
    }
  }


}
return(curXSL);
}
/* Ajoute un élément à la liste de selection pour les export (via un click sur la checkBox dans la recherche */
function selectObject(geo,recherche,ischecked,indice)
{
    curselect = recherche;
		
		if(ischecked)
		{
		tSelected[indice] = geo;
		}
		else
		{
		tSelected[indice] = "";
		}
   
    

}
/* Export dans word la liste des elements séléctionés */
function ExportElementRecherche()
{
var k=0;
var strExport = "";
var loc = location.href;
for(k=0;k<tSelected.length;k++)
{
  if( tSelected[k]!="")
  {
	 
  	newString = "{arobas}";
		tSelected[k] = tSelected[k].replace("@", newString);
		

		newString = "{plus}";
		tSelected[k] = tSelected[k].replace("+", newString);
		
   		strExport = strExport + tSelected[k]+"@";
  }
}
var currentXSL = getCurrentXSLInfo();

var chaine = szHttpServeur + "&XSL=" + currentXSL + "&ACTION=GetInfo!EMPRISE=ALL!OUTPUTSIZE=" + curTailleExportWord + "!SELECT="+ curselect + "!ALPHAJ=" + strExport + "!OFFICE=" + curmodelword + "!LOCATION=" + loc + "&PORT=" + szPort ;
newwinprint = window.open("./imprimer.html");

frames['bufferPrint'].location.href=chaine;

}

/* fonction destiner à ouvrir la carte dans une grande fenetre pour imprimer*/

function printMap() 
{

 				var loc = location.href;
        var width;
        var height;
        width=mapright - mapleft;
        height=maptop - mapbottom;
				
				var chaine = szHttpServeur + "&XSL=imprimer.xsl&ACTION=BuildMap!EMPRISE=" + mapleft + "@" + mapbottom + "@" + width + "@" +  height + "!OUTPUTSIZE=" + 500 + "@" + 500 + "!LOCATION=" + loc + "&PORT=" + szPort ;
        updateBufferPrint(chaine);
}

function updateBufferPrint(target)
{

newwinprint = window.open("./blank.html");

frames['bufferPrint'].location.href=target;


}

function loadPrint()
{

var inner = "";
inner = frames['bufferPrint'].document.body.innerHTML;

if ((newwinprint!=null)&&(inner!=""))
{
       
        var obj = newwinprint.document.body;
        obj.innerHTML = inner;
				newwinprint.focus();
}
 

}

/* fonction destiner à lancer une recherche*/
function LanceRecherche(szNomRecherche,numChamp,valeurChamp)
{
 				 var loc = location.href;
				 var chaine = szHttpServeur  +
                "&ACTION=Recherche!NAME="+szNomRecherche+"!NUMCHAMP=" + numChamp + "!VALEURCHAMP=" + valeurChamp + "!LOCATION=" + loc + "!INTERACTIVE=1";
						
				
				updateBufferResultat(chaine)

}


function updateBufferResultat(target)
{
if(useOnglet)
{
 						 frames['bufferFiltre'].location.href=target+"&FORMAT="+ szFormat + "&PORT=" + szPort; 
}
else
{
 						 frames['bufferResultat'].location.href=target+"&FORMAT="+ szFormat + "&PORT=" + szPort; 
}
}

function updateBufferResultatClick(target)
{
//frames['bufferResultat'].location.href=target+"&FORMAT="+ szFormat + "&PORT=" + szPort; 
frames['bufferResultat'].location.href=target+"&FORMAT="+ szFormat + "&PORT=" + szPort; 
}


function loadInfo()
{

var inner = "";
inner = frames['bufferInfo'].document.body.innerHTML;
 
if ((newwin!=null)&&(inner!=""))
{
        newwin.szClientID = szClientID;
        newwin.szPort = szPort;
        newwin.szHttpServeur= szHttpServeur;
        newwin.cmd = lastszTarget;
				newwin.parentwindow = this;
        newwin.focus();
        var obj = newwin.document.getElementById("divres");
        obj.innerHTML = inner;
}
 

/*

if(inner!="")
{
frames['resInfo'].divres.innerHTML =inner ;
var sty = document.getElementById("resInfo").style 
sty.visibility = "visible";

frames['resInfo'].cmd = lastszTarget;
frames['resInfo'].szHttpServeur = szHttpServeur;
frames['resInfo'].szPort = szPort;
frames['resInfo'].parentwindow = this;
}
 else
 {
 if(frames['resInfo'].divres!=null)
 {
 frames['resInfo'].divres.innerHTML = "";
var sty = document.getElementById("resInfo").style 
sty.visibility = "hidden";
}
 }
*/
}

function getBufferInfo(target)
{
lastszTarget = target;

frames['bufferInfo'].location.href=target+"XSL="+ xslInfo + "&FORMAT=" + szFormat + "&PORT=" + szPort;
}


function updateBufferInfo(target)
{
  var strcmd = "";
	newwin = window.open("./blankinfo.html",'visu','scrollbars=yes,width=760,height=400,resizable=1');
	
	strcmd = 'getBufferInfo(\"' + target + '\")';
	setTimeout(strcmd,1000);

}


function loadFiltres() 
{
	var inner  = "";
        
        hideObject("divParametre");
        hideObject("champLib1");
     /*   hideObject("champLib2");
        showObject("divResultat");*/
   if(frames['fFiltre']!=null)
	 {     
	if(frames['fFiltre'].document!=null)
	{
	 					if( frames['bufferFiltre']!=null)
						{													 
	        														 inner =  frames['bufferFiltre'].document.body.innerHTML;
					}
	}
        
        if (inner!="")
        {
                 frames['fFiltre'].document.body.innerHTML = frames['bufferFiltre'].document.body.innerHTML;
                 setupAllPickList('fFiltre');
              
	showOnglet('divFiltre','fFiltre','divOngletFiltre','Filtres');
	}
	else
	{
	//hideObject("iframRes");
	}
	}
}


function loadResultat() 
{
	var inner  = "";
       
        hideObject("divParametre");
        hideObject("champLib1");
        hideObject("champLib2");
        showObject("divResultat");
        
	if(frames['iframRes'].document!=null)
	{
	 					if( frames['bufferResultat']!=null)
						{													 
	        														 inner =  frames['bufferResultat'].document.body.innerHTML;
					}
	}
        
        if (inner!="")
        {
                 frames['iframRes'].document.body.innerHTML = frames['bufferResultat'].document.body.innerHTML;
                 setupAllPickList('iframRes');
                 if ((lastszNomRecherche!="")&&(openInfo==true))
		 {
		 	ClickItemRechercheInfo(lastszNomRecherche,lastszAlphaJ,lastszChamp1,lastszChamp2);
			MouseOnItemRechercheMap(lastxc,lastyc);
			 lastszNomRecherche="";
 			 lastszAlphaJ="";
 			 lastszChamp1="";
 			 lastszChamp2="";
 			 lastxc=0;
 			 lastyc=0;
			 openInfo=false;
		 }
		 if(!useOnglet)
		 {
		 							 		 			 showObject("iframRes");
    	}
    	else
    	{
    	 											 showOnglet('divResultat','iframRes','divOngletResultat','Résultat');
    	}
	}
	else
	{
	hideObject("iframRes");
	}
}
<!-- -----------------------------------------------------------------  -->
<!-- lance une recherche sur le serveur : le resultat est une page contenant la carte -->
<!-- zoomée sur l'objet selectioné                                      -->
<!------------------------------------------------------------------------>
function ClickItemRechercheMap(szNomRecherche,szAlphaJ,szChamp1,szChamp2) {
var loc = location.href;

	var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=ALL!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
								"!SELECT=" + szNomRecherche + "@1" +
								"!ALPHAJ=" + szAlphaJ + 
								"!LOCATION=" + loc ;

		
	updateBufferMap(chaine);
	
}

function MouseOnItemRechercheMap(xp,yc)
{
 if(szFormat=="2")
 {
 			addSquare(xp,yc)
 }
 else
 {
                var emprise = GetMapEmpriseView();
                
		ConvertSysToView(xp,yc);
		{
                        if( (viewCurrentX > emprise.x) && (viewCurrentX < emprise.x + emprise.width) && ( viewCurrentY > emprise.y) && ( viewCurrentY < emprise.y + emprise.height ) )
		        {
                                var obj = document.getElementById("divBubble");
                                obj.style.visibility = "visible";
                                obj.style.left = viewCurrentX-14;
                                obj.style.top = viewCurrentY-14;	
                                obj.style.width = 30;
                                obj.style.height = 30;			
                                obj.style.color  = "#FF0000";
                        }
                        else
                        {
                                hideObject("divBubble");
                        }
		}
 }
}

<!-- -----------------------------------------------------------------  -->
<!-- lance une recherche sur le serveur : le resultat est une page contenant la carte -->
<!-- zoomée sur l'objet selectioné                                      -->
<!------------------------------------------------------------------------>
function ClickItemRechercheInfo(szNomRecherche,szAlphaJ,szChamp1,szChamp2) {
var loc = location.href;
 
	var chaine = szHttpServeur +
                "&ACTION=GetInfo!EMPRISE=ALL!" +
								"!SELECT=" + szNomRecherche + "@1" +
								"!ALPHAJ=" + szAlphaJ + "!CHAMPS1=" + szChamp1 + "!CHAMPS2=" + szChamp2 +
								"!LOCATION=" + loc ;
	updateBufferInfo(chaine);
 
/*
	var chaine = szHttpServeur +
                "&ACTION=GetInfo!EMPRISE=ALL!" +
								"!SELECT=" + szNomRecherche + "@1" +
								"!ALPHAJ=" + szAlphaJ + "!CHAMPS1=" + szChamp1 + "!CHAMPS2=" + szChamp2 +
								"!LOCATION=" + loc ;
	updateBufferInfo(chaine);
*/
}








