
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 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_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_showHideLayers() 
{
  var i,p,v,obj,args=MM_showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null)
  { 
    v=args[i+2];
    if (obj.style) 
    { 
      obj=obj.style;
      v=(v=='show')?'visible':(v=='hide')?'hidden':v;
    }
    
    obj.visibility=v; 
  }
}

function showHideLayers()
{
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}

function getE(id)
{
    if(document.getElementById) {
        return document.getElementById(id);
    } else if(document.all) {
        return document.all[id];
    } else return;
}

function openClose(id)
{
    element = getE(id);
    img = getE('img_'+id);
    
    if(element.style) {
    
        if(element.style.display == 'block' ) {
            element.style.display = 'none';
        } else {
            element.style.display = 'block';
        }
    }
}
function ouvertureimage(url)
{                         
  window.open(url,'affichageimage','menubar=no,scrollbars=no,statusbar=no');
}


// **************** Fonction Affichage Menu IE 5.5 ******************** //
function initMenuHaut() 
{
    if(navigator.appVersion.indexOf("MSIE 5.5")!=-1)
    {
        temp=navigator.appVersion.split("MSIE");
        version=parseFloat(temp[1]);

        if (version==5.5)
        {
            document.getElementById("btnmenu1").attachEvent("onmouseover",displaySsmenu1);
            document.getElementById("btnmenu1").attachEvent("onmouseout",hideSsmenu1);
            
            document.getElementById("btnmenu2").attachEvent("onmouseover",displaySsmenu2);
            document.getElementById("btnmenu2").attachEvent("onmouseout",hideSsmenu2);
            
            document.getElementById("btnmenu3").attachEvent("onmouseover",displaySsmenu3);
            document.getElementById("btnmenu3").attachEvent("onmouseout",hideSsmenu3);
            
            document.getElementById("btnmenu4").attachEvent("onmouseover",displaySsmenu4);
            document.getElementById("btnmenu4").attachEvent("onmouseout",hideSsmenu4);
            
            document.getElementById("btnmenu5").attachEvent("onmouseover",displaySsmenu5);
            document.getElementById("btnmenu5").attachEvent("onmouseout",hideSsmenu5);
        }
    }
    /* Gestion du positionnement de la page en fonction de la resolution de l'ecran */
    getInfosDocument();
}

function openShim()
{
    if(navigator.appVersion.indexOf("MSIE")!=-1)
    {
      var newElem = document.createElement("<iframe scrolling='no' frameborder='0' style='position:absolute; top:0px; left:0px; display:none'></iframe>"); 
      newElem.id="shim_1";
      document.getElementById("btnmenu1").appendChild(newElem);
      
      newElem.style.width = '120px';
      newElem.style.top = '145px';
      newElem.style.zIndex= '90';
      newElem.style.left = '16px';
      newElem.style.display = 'block';
    }
}

//Closes the shim associated with the menu
function closeShim()
{    
    if(navigator.appVersion.indexOf("MSIE")!=-1)
    {
      document.getElementById("btnmenu1").removeChild(document.getElementById("shim_1"));
    }
}

function displaySsmenu1() 
{
    var menu = document.getElementById("ssmenu1");
    menu.style.width = '120px';
    menu.style.left = '4px';
    menu.style.top = '94px';
    menu.style.zIndex= '100';
    menu.style.display = 'block';
}

function displaySsmenu2() 
{
    document.getElementById("ssmenu2").style.width = '118px';
    document.getElementById("ssmenu2").style.left = '138px';
    document.getElementById("ssmenu2").style.top = '94px';
    document.getElementById("ssmenu2").style.display = 'block';
    document.getElementById("ssmenu2").style.zIndex= '1';
}

function displaySsmenu3() 
{
    document.getElementById("ssmenu3").style.width = '118px';
    document.getElementById("ssmenu3").style.left = '247px';
    document.getElementById("ssmenu3").style.top = '94px';
    document.getElementById("ssmenu3").style.display = 'block';
    document.getElementById("ssmenu3").style.zIndex= '1';
}

function displaySsmenu4() 
{
    document.getElementById("ssmenu4").style.width = '118px';
    document.getElementById("ssmenu4").style.left = '350px';
    document.getElementById("ssmenu4").style.top = '94px';
    document.getElementById("ssmenu4").style.display = 'block';
    document.getElementById("ssmenu4").style.zIndex= '1';
}

function displaySsmenu5() 
{
    document.getElementById("ssmenu5").style.width = '118px';
    document.getElementById("ssmenu5").style.left = '449px';
    document.getElementById("ssmenu5").style.top = '94px';
    document.getElementById("ssmenu5").style.display = 'block';
    document.getElementById("ssmenu5").style.zIndex= '1';
}

function hideSsmenu1() 
{
    document.getElementById("ssmenu1").style.display = 'none';
}

function hideSsmenu2() 
{
    document.getElementById("ssmenu2").style.display = 'none';
}

function hideSsmenu3() 
{
    document.getElementById("ssmenu3").style.display = 'none';
}

function hideSsmenu4() 
{
    document.getElementById("ssmenu4").style.display = 'none';
}

function hideSsmenu5() 
{
    document.getElementById("ssmenu5").style.display = 'none';
}
// **************** FIN Fonction Affichage Menu IE 5.5 ******************** //    

function changerespace(espace,publication)
{
   index=espace.selectedIndex;
   nouvelespace=espace.options[index].text;

   if(publication=='non')
   {
   	  id=espace.options[index].value;
   }

   if(publication=='non')
   {
	   if(nouvelespace=='federal finance')
	   {
	   		url='homepage.jspz?espace='+'societe'+'&objet=documentff&id='+id+'&rubriquemenugauche=2&rubriquemenusel=0';
	   }
	   else
	   {
	   		url='homepage.jspz?espace='+espace.options[index].text;
	   }
   }
   else
   {
       url='/federalfinance/site/'+espace.options[index].value;  
   }
   document.location.href=url;
}

//***********************
// Redimensionne la taille de l'iframe pour les onglets fonds
//***********************
function rezizeIframeOnglet()
{
    rezizeIframeOnglet(700);
    
}	

//***********************
// Redimensionne la taille de l'iframe pour les onglets fonds
//***********************
function rezizeIframeOnglet(taille)
{
    // on initialise le filtre investisseur en focntion de l'espace
    var iframeCentre = parent.document.getElementById("iframecentre");
    if (iframeCentre!= null) {
    	iframeCentre.height= taille;
    }
    
}

//**************************
// changement url
//**************************
function changeLocation(url)
{
      location.href=url;
}

//**************************
// changement src pour les iframes sur les pages fonds
//**************************
/*
function getUrlIframe(context,rubrique)
{
	//fonds  
	var locationHref="";
	var selection = "#selection";
	var index = location.href.indexOf(selection);
	
	//typefonds
	var paramTypeFonds = "";

	// Ancre nommée
	if (index!=-1){
		selection = selection + location.href.substring(index+selection.length); 
		locationHref = location.href.substring(0,index);
	} else {
		locationHref = location.href;
	}
	
	if (document.getElementById("iframecentre") == null) {
		// si ce n'est pas une page contenant l'iframe, on ne fait rien.
		return;
	}
	
	//Site FF
	if (context !='/noheto' ) {
		
		var espace = location.href.substring(location.href.lastIndexOf("site/")+5,location.href.length);
		espace = espace.substring(0,espace.indexOf("/"));
	
		var paramsUrl = location.href.substring(location.href.lastIndexOf("?")+1,location.href.length);
	    var params = paramsUrl.split("&");
	    var redirect = "";
		
		//recuperation parametres
		for(var i=0; i<params.length; i++) {
			var item = params[i];
			var param = item.split("=");
			
			if(param[0]=='id') {
				paramTypeFonds = param[1];
			}
		}
		
		var paramUrlTypeFonds = "&typefonds="+paramTypeFonds;
		
		redirect= context+"/fonds/TableauFonds.jsp?"+paramsUrl;
		document.getElementById("iframecentre").src= redirect;
		
	}	
	 else {
		//Site Noheto
		var paramsUrl = locationHref.substring(locationHref.lastIndexOf("?")+1,locationHref.length);

		var params = paramsUrl.split("&");
		var isFcp =0;
		
			for(var i=0; i<params.length; i++) {
				var item = params[i];
				var param = item.split("=");
						
				if(param[0]=='id') {
					paramTypeFonds = param[1];
				}
			}
			
			redirect = context+"/fonds/TableauFonds.jsp?" + paramsUrl;
			document.getElementById("iframecentre").src= redirect;
	}
} 
*/
//**************************
// lancement recherche 
//**************************
function submitForm(name)
{	
	var form = document.forms[name];
	form.submit();
	return false;		
}
//**************************
//submitFormulaire('formConnection')
//**************************
function submitFormulaire(nomFormulaire, urlEPS, urlGP){

	var selectedIndex = document.forms[nomFormulaire].profil.selectedIndex;
	var selectedText = document.forms[nomFormulaire].profil.options[selectedIndex].text;
	
	if(selectedText=='Gestion privée'){
		ctrlgpForm(nomFormulaire,urlGP);
	}else{
		ctrlepsForm(nomFormulaire,urlEPS);
	}
}
//**************************
// ctrl appel site privé 
//**************************
function ctrlepsForm(name, urlEPS)
{
     if(document.forms[name].identifiant.value=='')
     {
        alert("Vous devez saisir l'identifiant");
        return false;
     }   
     if(document.forms[name].motdepasse.value=='')
     {
        alert("Vous devez saisir le mot de passe");
        return false;
     }

     document.forms[name].action= urlEPS + "/bffsalariale/servlet/identificationServlet";
     document.forms[name].submit();
   
     document.forms[name].identifiant.value='';
     document.forms[name].motdepasse.value='';
}
//**************************
// ctrl appel site privé 
//**************************
function ctrlgpForm(name,urlGP)
{
	
     if(document.forms[name].identifiant.value=='')
     {
        alert("Vous devez saisir l'identifiant");
        return false;
     }   

     if(document.forms[name].identifiant.value.length < 8)
     {
        alert("L'identifiant doit faire au moins 8 caractères");
        return false;
     }    
 
     if(document.forms[name].motdepasse.value=='')
     {
        alert("Vous devez saisir le mot de passe");
        return false;
     }   

	
     document.forms[name].noPersonne.value = document.forms[name].identifiant.value;
     
     document.forms[name].motDePasse.value = document.forms[name].motdepasse.value;

   


     document.forms[name].action= urlGP + "/bffdirect/servlet/IdentificationServlet";

     document.forms[name].submit();

     document.forms[name].identifiant.value='';
     document.forms[name].motdepasse.value='';
     document.forms[name].motDePasse.value='';
     document.forms[name].noPersonne.value='';
}

//**************************
// changement src pour les iframes pour la page de recherche
//**************************
function getUrlIframeSearch(firstpage, lastpage, query, movepage, espace)
{
    var redirect = '';
    if(location.href.lastIndexOf("/nohetoff")>-1)
    {
        redirect = "/nohetoff/lucene/resultSearch.jsp?firstpage="+firstpage+"&lastpage="+lastpage+"&movepage="+movepage+"&query="+query;
    }
    else
    {
        redirect = "/federalfinance/lucene/resultSearch.jsp?firstpage="+firstpage
                                          +"&lastpage="+lastpage
                                          +"&movepage="+movepage
                                          +"&query="+query
                                          +"&espace="+espace;
    }
    
    var form = document.getElementById("FormSearch");
    
    document.getElementById("search").src= redirect;
}

//**************************
// Infos document
//**************************
function getInfosDocument()
{
    var largeur = screen.width;
    if(largeur<=800)
    {
        var container = document.getElementById("contenu");
        container.style.marginLeft=((largeur/2)*-1)+5;
    }
}

//**************************
// Gestion du # site publié
//**************************
function deleteDieze()
{
    if(location.href.lastIndexOf("/nohetoff")==-1)
    {
        var lien = location.href 
        location.href=lien;
    }
}

function deleteDiezeForFonds()
{
    if(location.href.lastIndexOf("/nohetoff")==-1)
    {
        var contextepath=document.forms['champscachees'].urlpath.value;
    	var espacecourant=document.forms['champscachees'].espacecourant.value;
        var lien = contextepath+'/site/'+espacecourant+'/fondsformule.jsp';
        location.href=lien;
    }
}

//**************************
// url des fonds dans l'editeur wysivig
//**************************
function urlFonds(type,codeisin)
{
    var contextepath=document.forms['champscachees'].urlpath.value;
    var espacecourant=document.forms['champscachees'].espacecourant.value
    if (type=='1' || type=='2')
    {
       url=contextepath+'/site/'+espacecourant+'/fondsfcpe.jsp?typeFonds='+type+'&idFonds='+codeisin;
    }
    else
    {
       url=contextepath+'/site/'+espacecourant+'/fondsfcpe.jsp?typeFonds='+type+'&idFonds='+codeisin;
    }
    location.href=url;
}

function changeIframeAFP()
{
  var isNewsItem = location.href.indexOf('NewsItem');
  var isRetour = location.href.indexOf('#');

  if (isNewsItem!=-1)
  {
    if(isRetour==-1)
    {
      var newsItem = location.href.substring(location.href.indexOf('NewsItem'),location.href.length); 
      var iframe = document.getElementById("newsafp");
      var lien = iframe.src+'?'+newsItem;
      iframe.src=lien;
    }
    else
    {
      var lien = location.href.substring(0,location.href.indexOf('NewsItem')-1);
      location.href= lien;
    }
  }
}
//****************************************************************//
//* fonction utilisé pour le sondage vers hippocampe via un flash*//
//****************************************************************//
function OuvrirPopup(page,nom,option)
{
      window.open(page,nom,option);
}
