/*******************************************************************
******************    Script des fonctionalité générée *************
********************************************************************/

/**
 *  mise à jour des fonctions
 * charge dans la frame cachée BufferFonction la page HTML issue du parse
 * serveur du flux XML, transformé par la feuille de style fonction.XSL 
 * OnLoad cette frame appel loadFonction pour mettre à jour le divMAP 
 *
 **/
 
var isMinNS4=(navigator.appName.indexOf("Netscape")>=0&&parseFloat(navigator.appVersion)>=4)?1:0;
var nbMenu=0;
var xmlFileSRCFonction="";
function hideAll()
{
        var i;

if(isMinNS4)
        {
if(activeOnglet!="")
        ShowOng(activeOnglet);
}
        for(i=1;i<= nbMenu;i++)
        {
                hideObject("sousMenu"+i);
        }
        sousMenuVisible=0;

        return true;
}

function hideObject(id)
{  
        var obj = null;
       
        if(isMinNS4)
        {
                obj = document.getElementById(id);
                if(obj!=null)
                {
if(id.indexOf("menu")>=0)
{

if(activeOnglet!="")
        ShowOng(activeOnglet);
}
                        
                obj.style.visibility="hidden";

		
                }
        }
        else
        {
                obj = document.getElementById(id);
                if(obj!=null)
                {
                        if(obj.style!=null)
                        {
                                obj.style.visibility="hidden"; 
                        }
                }
        }
        return true;
}

function hideObjectDisplay(id)
{  
        var obj = null;
       
        if(isMinNS4)
        {

                obj = document.getElementById(id);
                if(obj!=null)
                {
                        
                obj.style.display="none";
		
                }
        }
        else
        {
                obj = document.getElementById(id);
                if(obj!=null)
                {
                        if(obj.style!=null)
                        {
                                obj.style.display="none"; 
                        }
                }
        }
        return true;
}

function setVar(nb)
{
        nbMenu = nb;
}

function showObject(id)
{  
        
        var obj = null;
        if(isMinNS4)
        {

                 obj = document.getElementById(id);
                if(obj!=null)
                {
if(id.indexOf("sousMenu")>=0)
{

 hideObjectDisplay("fLegende");
 hideObjectDisplay("divLegende");
 hideObjectDisplay("iframRes");
 hideObjectDisplay("divResultat");
 hideObjectDisplay("fFiltre");
 hideObjectDisplay("divFiltre");

}
                obj.style.visibility="visible";
                obj.style.display="block";
                }
        }
        else
        {
                  obj = document.getElementById(id);
                if(obj!=null)
                {
                obj.style.visibility="visible";
obj.style.display="block";
                }
        }
        return true;
}


function loadscript(src) 
{
        var JS = document.createElement('script');
        JS.setAttribute('type', 'text/javascript');
        JS.setAttribute('text', src);
        document.getElementsByTagName('head').item(0).appendChild(JS);
}

function updateBufferFonction(target)
{
        frames['bufferFonction'].location.href=target; 
}

function loadFonction() 
{
        var inner;
        inner =  frames['bufferFonction'].document.body.innerHTML;
       
				if(flashMenu==true)
				{
				
				 		if(xmlFileSRCFonction!="")
						{
  				  	  var szInner = "";
  			 			szInner = szInner + "<object id=\"MenuFlash\" width=\"" + 600 + "\" height=\"" + 500 + "\" data=\"canvasMenu.swf\" ALIGN=\"\" type=\"application/x-shockwave-flash\">";
   						szInner = szInner + "<param name=wmode VALUE=\"transparent\"/> <param name=quality value=high/> <param name=bgcolor value=#FFFFFF/>  <param name=salign value=LT/>  <param name=\"movie\" value=\"canvasMenu.swf\" />";
							szInner =  szInner + "<param name=\"FlashVars\" value=\"xmlParametres=" + xmlFileSRCFonction + "|" + bkColorMenu + "|" + bkColorSubMenu + "|" + hlColorMenu + "|" + bdColorMenu + "\"/>";
  				 	  szInner = szInner + "<EMBED id=\"MenuFlash\" name=\"MenuFlash\" src=\"canvasMenu.swf\"  swLiveConnect=\"true\" quality=high bgcolor=#FFFFFF  WIDTH=\"600\" HEIGHT=\"500\" NAME=\"MenuFlash\" ";
						
          		szInner = szInner + " FlashVars=\"xmlParametres=" + xmlFileSRCFonction + "|" + bkColorMenu + "|" + bkColorSubMenu + "|" + hlColorMenu + "|" + bdColorMenu + "\"";
		
							szInner = szInner + " ALIGN=\"\" salign=LT";
              szInner = szInner + " TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED>";
  						szInner = szInner + "</object>";
  						document.getElementById("divFonction").innerHTML=szInner;
							UpdateUserConnection();
       				FitImage();
						}
				}
				else
				{
				 	if (inner!="")
        	{
               document.getElementById("divFonction").innerHTML=inner;
							   UpdateUserConnection();
        FitImage();
					}
				}
      


}



function GetFonctions()
{
  hideObject("divParametre");
  hideObject("champLib1");
  hideObject("champLib2");
  
  var loc = location.href;
  

        if(szClientID == 0)
        {
        
        GetUserFromURL();
        UpdateUserConnection();
				 var chaine;
        if(flashMenu)
				{
         chaine = szHttpServeur +
                        "&ACTION=GetFonction!FORMATMENU=4!LOCATION=" + loc + "&XSL=fonctionFlash.xsl&PORT="+szPort;
												}
												else
												{
												 chaine = szHttpServeur +
                        "&ACTION=GetFonction!LOCATION=" + loc + "&PORT="+szPort;
												}
          updateBufferFonction(chaine);
        }
}

<!-- -----------------------------------------------------------------  -->
<!-- Active une fonction : typeFonction = 1 dans le cas d'une recherche -->
<!-- szNomFonction = nom de la fonction à activer -->
<!-- szParam1 = nom du libellé 1 dans le cas d'une recherche -->
<!-- szParam2 = nom du libellé 2 dans le cas d'une recherche -->
<!-- -----------------------------------------------------------------  -->
function ActivateFonction(typeFonction,szNomFonction,szParam1,szParam2,iIntercative) 
{
hideAll();
if(flashMenu)
CollapseMenu();

	szCurrentRecherche = "";
        
        hideObject("divParametre");
        hideObject("divResultat");
        hideObject("champLib2");
        hideObject("champLib1");
        hideObject("iframRes");

	if (typeFonction==1)
	{
	if(editSvg)
	{
					alert(msgEditionInProgress);
					return;
					}
   	 szCurrentRecherche = szNomFonction;
	if(iIntercative==0)
	{
       /*  showObject("divParametre");
	 document.getElementById('champLib1').innerHTML = szParam1;
	 showObject("champLib1");
	 document.getElementById('champLib2').innerHTML = szParam2;
	 showObject("champLib2");*/
LanceRecherche(szCurrentRecherche,-1,'');
	}
	else
	{
		LanceRecherche(szCurrentRecherche,-1,'');
	}
 
	}
	else if (typeFonction == 2)
	{
			if(editSvg)
	{
					alert(msgEditionInProgress);
					return;
					}
		LanceAnalyse(szNomFonction, szParam1,0,iIntercative);
	}	
		//Statistique
	else if (typeFonction == 3)
	{
		LanceStatistique(szNomFonction, '', '', iIntercative);
	}
	else if (typeFonction == 4)
	{
		LanceTableauBord(szNomFonction, '', '', iIntercative);
	}
	else if (typeFonction == 5)
	{
 		var loc = location.href;
		var chaine = szHttpServeur  +
                "&ACTION=Plugin!NAME="+szNomFonction+"!LOCATION=" + loc + "!INTERACTIVE="+iIntercative;
		updateBufferResultat(chaine)
		
	}	
	else if (typeFonction == 6)
	{
						
			if(isMinNS4)
				 {
				 alert("Cette fonctionalité n'est disponible que sur Internet Explorer");
				 }
				 hideObject("divRight");
			var loc = location.href;
			var chaine;
		
			{
				newwidth = (mapright - mapleft);
	  		newheight = (maptop - mapbottom);
				newbottom = mapbottom;
				newleft = mapleft;
				    chaine = szHttpServeur  +
						"&ACTION=EditLayer!NAME="+szNomFonction+"!EMPRISE="+ newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +"!LOCATION=" + loc + "!LAYER_EDITION";
						}
						
			updateBufferEditLayer(chaine);
			editSvg=true;
			currentEditedLayer=szNomFonction;
			showObject("divEditLayer");
			showObject("divResultat");
			 showObject("iframRes");
		
	}
	else if (typeFonction == 100)
	{
							
		updateListPoint();
		
	}
	else if (typeFonction == 99)
	{
 		if(szNomFonction=="Format Flash")
		{
		szFormat = 4;
		RedrawMap();
		}
		if(szNomFonction=="Format Image")
		{
		szFormat = 0;
		RedrawMap();
		}
		if(szNomFonction=="Activer l'aide")
		{
		useHelp = true;
		}
		if(szNomFonction=="Désactiver l'aide")
		{
		useHelp = false;
		}
		
	}	

}
