<!-- **************************************************************** -->
<!-- *************** 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 currentQuery="";
var lastszTarget = "";
var lastxc;
var lastyc; 
var newwin;
var newwinprint;
var xslInfo = "info.xsl";
var openInfo = false;
var showFiche = true;
var IDENTFICHE = "";
var CallFiche = "";
var tGeo = new Array(2000);

var tSelected = new Array(2000);
var curselect = "";
var currentProcess="";
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]="";
 }
}

/* Zoom la liste de recherche sur la carte */

/* Zoom la liste de recherche sur la carte */
function ZoomAll( szNomRecherche, allAlphaJ )
{

	objDebug.Push('ZoomAll');

var chaine = "";
chaine = szHttpServeur ;

chaine = chaine.substring ( 0, chaine.indexOf ( "?" ) );

var szFormu = szNomRecherche.replace("'","_");

		
var formulaire = document.forms['frmAll'+szFormu];

	document.forms['frmAll'+szFormu].elements["WMTVER"].value = "SERVLET_GEOMATIQUE_1.0.1";
	document.forms['frmAll'+szFormu].elements["USER"].value = szUser + "!" + szClientID;
	document.forms['frmAll'+szFormu].elements["PORT"].value = szPort;
 							
	isloading = true;
	showObject("divProgress");
	
 	var movieprogress = document.getElementById('movieprogress');
  	var souschaine = "!SHOWECHELLE=" + szShowEchelle;
  	
	document.forms['frmAll'+szFormu].elements ["LOCATION"].value = window.location;
	if(szFormat=="4")
	{
		
		document.forms['frmAll'+szFormu].elements["XSL"].value = "carteFlash.xsl";
	}
	else
	{ 
		document.forms['frmAll'+szFormu].elements["XSL"].value = "carte.xsl";
	}
	
	document.forms['frmAll'+szFormu].elements["ACTION"].value = "BuildMap" + "!EMPRISE=ALL!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
								"!SELECT=" + szNomRecherche + souschaine + "!ALPHAJ="+allAlphaJ + "!SHOWLEGENDE=1"+"!LOCATION=" + window.location;
								//"!LOCATION=" + window.location + souschaine;
								
	document.forms['frmAll'+szFormu].elements["FORMAT"].value = szFormat;
	document.forms['frmAll'+szFormu].elements["LOCATION"].value = window.location;
	
	document.forms['frmAll'+szFormu].action = chaine;
						
	document.forms['frmAll'+szFormu].target = "bufferMap";
	document.forms['frmAll'+szFormu].submit();
								
}

/* 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!ANTIALIAS=1!LABELED=1!TOOLTIP=0!EMPRISE=" + mapleft + "@" + mapbottom + "@" + width + "@" +  height + "!OUTPUTSIZE=" + 620 + "@" + 700 + "!LOCATION=" + loc + "&PORT=" + szPort ;
        updateBufferPrint(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 curXsl = getCurrentXSLPrint();
				var chaine = szHttpServeur + "&XSL=" + curXsl + "&ACTION=BuildMap!EMPRISE=" + mapleft + "@" + mapbottom + "@" + width + "@" +  height + "!OUTPUTSIZE=" + curTailleExport + "!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;
        newwinprint.document.getElementById("divContent").innerHTML = inner;
				newwinprint.focus();
}
 

}
function LanceRechercheGraphique()
{
 var loc = location.href;
 var chaine = szHttpServeur  +
                "&ACTION=Recherche!NAME="+currentQuery+"!LOCATION=" + loc + "&USE_SELECTION=on";
						
				
				updateBufferResultat(chaine)
}

/* fonction destiner ? lancer une recherche*/
function LanceRecherche(szNomRecherche,numChamp,valeurChamp)
{

 currentProcess="";
  				 if(szNomRecherche=="Secteur")
				 {
				 	 if(szdrawMode==0) drawMode();
					currentProcess = "graphicSearch";
					currentQuery = szNomRecherche;
					document.getElementById('iframRes').innerHTML = "<p class='Texte'>Veuillez dessiner une s?lection ? l'aide des outils de la palette graphique, une fois la s?l?ction dessin?e, envoyer ? l'aide du bouton 'Sub'</p>";
					document.getElementById('fFiltre').innerHTML = "<p class='Texte'>Veuillez dessiner une s?lection ? l'aide des outils de la palette graphique, une fois la s?l?ction dessin?e, envoyer ? l'aide du bouton 'Sub'</p>";
					showOnglet("fFiltreContainer","divOngletFiltre","Critères");
				 }
				 else
				 {
 				 var loc = location.href;
				
var Allfilled  = 1;
if(szNomRecherche.indexOf("rue")>0)
{
Allfilled = 0;
}
else
{
Allfilled = 1;
}

                var chaine = szHttpServeur  + "&ACTION=Recherche!NAME="+szNomRecherche+"!NUMCHAMP=" + numChamp + "!VALEURCHAMP=" + valeurChamp + "ALLFILLED="+Allfilled +"!ALLFILTERS=1!!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 = "";
 if(showFiche)
 {
inner = frames['bufferInfo'].document.body.innerHTML;
 if(usePopupInfo==true)
 {
    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;
						
    }
 
 }
 else
 {


    if(inner!="")
    {
            frames['resInfo'].divres.innerHTML =inner ;
           showObject("resInfo");
            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";
          }
     }
	}
	}
	else
	{
		ClickItemRechercheInfo(CallFiche,IDENTFICHE,'','');
	}
}


function updateBufferInfo(target)
{
lastszTarget = target;
if(usePopupInfo==true)
{
newwin = window.open("./blankinfo.html",'visu','scrollbars=no,width=' + widthPopupInfo + ',height='+ heightPopupInfo +',resizable=0');
newwin.moveTo(400,300);
}

frames['bufferInfo'].location.href=target+"XSL="+ xslInfo + "&FORMAT=" + szFormat + "&PORT=" + szPort;


}


function loadFiltres() 
{
	var inner  = "";
       
    	var obj = document.getElementById("iframMiniInfo");
	if(obj!=null)
	{
	obj.innerHTML="";
	}
	 var obfFiltre = document.getElementById('fFiltre');
   if(obfFiltre!=null)
	 {     
	
	 					if( frames['bufferFiltre']!=null)
						{													 
	        			inner =  frames['bufferFiltre'].document.body.innerHTML;
					}
	
        
        if (inner!="")
        {
				
				hideObject("iframResContainer");
				hideObject("iframRes");
				showObject("fFiltre");
				showObject("fFiltreContainer");
        obfFiltre.innerHTML = frames['bufferFiltre'].document.body.innerHTML;
				if(isMinNS4 != 1)
                 		setupAllPickList("","frmFilter");
              
      				showOnglet("fFiltreContainer","divOngletFiltre","Critères");
					if(scrollerfilter!=null)
				scrollerfilter.updateScroller();
      	}
      	else
      	{
      	//hideObject("iframRes");
      	}
	}
}


function loadResultat() 
{
	var inner  = "";
  var obIfram = document.getElementById('iframRes');
	var obj = document.getElementById("iframMiniInfo");
	if(obj!=null)
	{
	obj.innerHTML="";
	}
	
	
	if(obIfram!=null)
	{
	 					if( frames['bufferResultat']!=null)
						{													 
	        		inner =  frames['bufferResultat'].document.body.innerHTML;
					}
	}
        
        if (inner!="")
        {
             obIfram.innerHTML = frames['bufferResultat'].document.body.innerHTML;
						 
						
             if(!useOnglet)
                 setupAllPickList("","frmFilter");
                 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");
		 		showObject("iframResContainer");
			
				hideObject("fFiltre");
				hideObject("fFiltreContainer");
				
    	}
    	else
    	{
			showOnglet("iframResContainer","divOngletResultat","Résultats");
				showObject("iframRes");
		 		showObject("iframResContainer");
			
				hideObject("fFiltre");
				hideObject("fFiltreContainer");
    	}
			if(scrollerres!=null)
				scrollerres.updateScroller();
			
	}
	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,preservesel) {
var loc = location.href;
var szPreserve = "";
if(preservesel)
{

	szPreserve = "PRESERVESEL=1!";
}
	var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=ALL!"+szPreserve+"OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
								"!SELECT=" + szNomRecherche + "@1" +
								"!ALPHAJ=" + szAlphaJ + "!CHAMPS1="+szChamp1+
								"!LOCATION=" + loc ;

		
	updateBufferMap(chaine);
	
}

function MouseOnItemRechercheMap(xp,yc)
{
 if(szFormat=="2")
 {
 			addSquare(xp,yc)
 }
 else
 {
    var emprise = GetMapEmpriseView();
                
		ConvertSysToView(xp,yc);
		{
		
		var maxx;
		var maxy;
		var minx;
		var miny;
		
		minx = parseFloat(emprise.x);
		maxx = parseFloat(emprise.x) + parseFloat(emprise.width)-12;
		miny = parseFloat(emprise.y);
		maxy = parseFloat(emprise.y) + parseFloat(emprise.height);
		
             if( (viewCurrentX > minx) && (viewCurrentX < maxx) && ( viewCurrentY > miny) && ( viewCurrentY < maxy ) )
		        {
				
                 var obj = document.getElementById("divBubble");
                 showObject("divBubble");
                 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;

  if(infoBulle!=null)
 {


	infoBulle.setVisible(false);
	infoBulle.mustMove = false;
 }
	var chaine = szHttpServeur +
                "&ACTION=GetInfo!EMPRISE=ALL!" + heightwidthmapInfo +
								"!SELECT=" + szNomRecherche + "@1" +
								"!ALPHAJ=" + szAlphaJ + "!CHAMPS1=" + szChamp1 + "!CHAMPS2=" + szChamp2 +
								"!LOCATION=" + loc ;
	updateBufferInfo(chaine);

}







