// Allianz Informatique

function execSurSelect(value) {
		// On vérifie que la chaîne n'est pas vide
		sTemp = value;
		if(sTemp != "") {
			// Détermine la position du séparateur
			iPos = sTemp.indexOf("_@_",0);
			if(iPos == -1) {
				cMode = "";
				sURL = sTemp;
			} else {
				cMode = sTemp.charAt(0);
				// Récupère l'url (3 est le nb de car du séparateur)
				sURL = sTemp.slice(iPos+3);
			}
			switch(cMode) {
				case "O" :
					document.location=sURL;
					break;
				case "P" :
					//window.open(sURL,"","");
					ouvrirFenetreSites(800,600,0,0,sURL,'');
					break;
				case "M" :
					document.location='mailto:' + sURL;
					break;
				case "W" :
					window.open(sURL,"","");
					break;
				default :
					document.location=value;
			}
		}
}

/********************************************/
// Dt de créa : 31/08/2006
// ouvrirSurSelect(objet) par BC
//	Permet de déterminer le routage d'une URL d'après son préfixe
//	Paramètre en entré : l'objet contenant l'URL dans son champ value
//		Séparateur URL : "_@_"
/********************************************/
function ouvrirSurSelect(objet)
{
	// On vérifie que c'est bien un objet
	if(typeof(objet) == "object")
	{
		// On vérifie que la chaîne n'est pas vide
		sTemp = objet.value;
		if(sTemp != "")
		{
			// Détermine la position du séparateur
			iPos = sTemp.indexOf("_@_",0);
			if(iPos == -1)
			{
				cMode = "";
				sURL = sTemp;
			}
			else
			{
				cMode = sTemp.charAt(0);
				// Récupère l'url (3 est le nb de car du séparateur)
				sURL = sTemp.slice(iPos+3);
			}
			switch(cMode)
			{
				case "O" :
					document.location=sURL;
					break;
				case "P" :
					//window.open(sURL,"","");
					ouvrirFenetreSites(800,600,0,0,sURL,'');
					break;
				case "M" :
					document.location='mailto:' + sURL;
					break;
				case "W" :
					window.open(sURL,"","");
					break;
				default :
					document.location=objet.value;
			}
		}
	}
}
// Ouvrir d'une fenetre dimensionnée à l'avance
function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}

// Ouverture d'une fenetre plein ecran
function openBigWindow(theURL,winName)
{
	ss = "status=no,location=no,toolbar=no,directories=no,resizable=yes,scrollbars=yes,width=800,height=550,top=0,left=0";
	window.open(theURL,winName,ss);
}

// Ouverture d'une fenetre d'impression
function openImprime(theURL,winName) 
{
  ss = "toolbar=yes,directories=no,menubar=yes,scrollbars=yes,resizable=no,status=no,width=550,height=600";
  window.open(theURL,winName,ss);
}

// Ouverture d'une fenetre pop up pour consultation contrat
function openPopUp(theURL,winName) 
{
  ss = "toolbar=no,directories=no,menubar=no,scrollbars=yes, resizable=yes,status=no,width=500,height=300";
  window.open(theURL,winName,ss);
}

// Ouverture d'une fenetre 
function openWindow(theURL,winName) 
{
  ss = "status=no,location=no,toolbar=no,directories=no,resizable=yes,scrollbars=yes,width=600,height=650,top=10,left=10";
  popup = window.open(theURL,winName,ss);
  popup.focus();
}

// PG V23-R8 : creation fonction OpenWindowL 
// Ouverture d'une fenetre 
function openWindowL(theURL,winName) 
{
  ss = "status=no,location=no,toolbar=no,directories=no,resizable=yes,scrollbars=yes,width=800,height=650,top=10,left=10";
  popup = window.open(theURL,winName,ss);
  popup.focus();
}  	

// Ouverture d'une fenetre avec barre menu + taille et positionnement
function ouvrirFenetreAvecBarre(width,height,top,left,theURL,winName)
{       ss = "status=yes,location=yes,menubar=yes,toolbar=yes,directories=yes,resizable=yes,scrollbars=yes,width="+width+",height="+height+",top="+top+",left="+left;
	window.open(theURL,winName,ss);
}

// ouvre une popup sans aucune barre avec l'url passe en parametre, le nom de la fenetre, sa largeur et sa hauteur
function openWindowTaille(URL, titre, taillewidth, tailleheight)
{
	window.open(URL,titre,'menubar=no,toolbar=no,locationbar=no,personalbar=no,scrollbars=no,statusbar=no,width='+taillewidth+',height='+tailleheight);
}

var msgWindowAvecScrollbarsTailleXY=0;
// ouvre une popup avec bar de scrolling avec l'url passe en parametre, le nom de la fenetre, sa largeur, sa hauteur, x et y
function openWindowAvecScrollbarsTailleXY(URL, titre, taillewidth, tailleheight, tailletop, tailleleft)
{
	if(msgWindowAvecScrollbarsTailleXY)
  		{
    			if(!msgWindowAvecScrollbarsTailleXY.closed) msgWindowAvecScrollbarsTailleXY.close();
  		}	
	msgWindowAvecScrollbarsTailleXY = window.open(URL,titre,'status=no,resizable=yes,directories=no,menubar=no,toolbar=no,locationbar=no,personalbar=no,scrollbars=yes,statusbar=no,width='+taillewidth+',height='+tailleheight+',top='+tailletop+',left='+tailleleft);
}  


// ouvre une popup sans aucune barre avec la scroll barre, avec l'url passe en parametre, le nom de la fenetre, sa largeur et sa hauteur
function openWindowTailleScroll(URL, titre, taillewidth, tailleheight)
{
	window.open(URL,titre,'menubar=no,toolbar=no,locationbar=no,personalbar=no,resizable=yes,scrollbars=yes,statusbar=no,top=10,left=10,width='+taillewidth+',height='+tailleheight);
}

// ouvre une popup sans aucune barre avec la scroll barre, avec l'url passe en parametre, le nom de la fenetre, sa largeur et sa hauteur
function openWindowTailleScrollAuto(URL, titre, taillewidth, tailleheight)
{
	window.open(URL,titre,'menubar=no,toolbar=no,locationbar=no,personalbar=no,scrollbars=auto,statusbar=no,top=10,left=10,width='+taillewidth+',height='+tailleheight);
}

// Fonction  de controle de longueur des champs en saisie  
function check_lngText(ctrl,lngmax)
{
	if (ctrl.value.length > lngmax)
  	 ctrl.value = ctrl.value.substring(0,lngmax);
}


// Fonction  d'impression 
function imprimer() 
{
  if (window.print != null) 
  	{   window.print();  } 
  else
   {   alert('Votre navigateur ne supporte pas cette fonctionnalité. Veuillez utilisez la fonction Imprimer de la barre d\'outil.');  }
}

// Gestion des simulateurs 
function simuler() 
{
  var form = document.simulateur;
  var index = form.D1.selectedIndex;
  if (index!=0) 
		{ 
			openWindowTailleScroll(form.D1[index].value, "", 800, 610); 
			form.D1.selectedIndex=-1;
		}
}

function cryptage() 
{
	var taille1 = document.flogin.logpwd.value.length;
	if (taille1 > 3 && taille1 < 7) 
		{  return true; }
	else
	 	{  alert("la taille du mot de passe doit être comprise entre 4 et 6 caractères");
  			return false;
		}
}

function effacerChamp(i) 
{
	document.flogin.elements[i].value = "";
}

var msgWindow=0;
function Windowpopup(TitreFenetre, UrlRessource, TypeAppel, LargeurFenetre, LongueurFenetre, left, top)
{
  //var left = (screen.width/2) - LargeurFenetre/2;
  //var top = (screen.height/2) - LongueurFenetre/2;  
  var regex=/ /gi;
  TitreFenetre = TitreFenetre.replace(regex,"%20");
  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+LargeurFenetre+',height='+LongueurFenetre+',left='+left+',top='+top+',screenX='+left+',screenY='+top+'';
  var Url = ('/allianz/util/affpopup.jsp?UrlRessource='+UrlRessource+'&LargeurFenetre='+LargeurFenetre+'&LongueurFenetre='+LongueurFenetre+'&TypeAppel='+TypeAppel+'&TitreFenetre='+TitreFenetre);
  if(msgWindow)
  {
    if(!msgWindow.closed) msgWindow.close();
  }
  msgWindow = window.open(Url,"msgWindow" + Math.round(Math.random()*4), styleStr);
}

//Fonctions pour locker des liens
var suivre = true;
function SuivreLien()
{
	if (suivre) {
		suivre = false;
		return true;
	} else {
		return false;
	}
}
function initSuivreLien()
{
	suivre = true;
}

//Fonction pour formulaire redéfini dans formulaire.js ( sert pour Onload choix agence )
function initFormGen()
{
}
//Fonction pour formulaire redéfini dans formulaire.js ( sert pour la génération des infobulles dans les pages formulaires)
function initialisationBulle() {
}
//Fonction pour formulaire redéfini dans formulaire.js ( sert pour l'affichage des infobulles dans les pages formulaires)
function positionnerBulle(abs6){
}

var winBanqueAGF=null;
function openfenetreBanqueAGF(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	winBanqueAGF=window.open(mypage,myname,settings);
}

var msgWindowImpression=0;
function WindowpopupImpression(UrlRessource, LargeurFenetre, LongueurFenetre)
{
  var left = (screen.width/2) - LargeurFenetre/2;
  var top = (screen.height/2) - LongueurFenetre/2;  
  var styleStr = 'toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width='+LargeurFenetre+',height='+LongueurFenetre+',left='+left+',top='+top+',screenX='+left+',screenY='+top+'';  
  var Url = (UrlRessource + '&impression=true');
  if(msgWindowImpression)
  {
    if(!msgWindowImpression.closed) msgWindowImpression.close();
  }
  msgWindowImpression = window.open(Url,"msgWindowImpression" + Math.round(Math.random()*4), styleStr);
}

var msgWindowPlan=0;
function WindowpopupPlan(UrlRessource, LargeurFenetre, LongueurFenetre)
{
  var left = (screen.width/2) - LargeurFenetre/2;
  var top = (screen.height/2) - LongueurFenetre/2;  
  var styleStr = 'toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width='+LargeurFenetre+',height='+LongueurFenetre+',left='+left+',top='+top+',screenX='+left+',screenY='+top+'';  
  var Url = (UrlRessource);
  if(msgWindowPlan)
  {
    if(!msgWindowPlan.closed) msgWindowPlan.close();
  }
  msgWindowPlan = window.open(Url,"msgWindowPlan" + Math.round(Math.random()*4), styleStr);
}

// Info bulle Espace client
var posX=0;
var posY=0;
var xOffset=200;
var yOffset=3;

//poistionnement info bulle différente suivant gabarit										//Netscape 4
var positBulle = 0;

function positionSouris(e) {
	if (!document.all) {
		posX=e.pageX;
		posY=e.pageY;
	}	
	else if (document.getElementById) {
           	//IE 5+, Netscape 6+
                posX=event.x+document.body.scrollLeft;
                posY=event.y+document.body.scrollTop;
        }
	else if (document.all) {      	
		//IE 4+
		posX=event.x;	
                posY=event.y;	
	}
	else if (document.layers) {
                posX=e.pageX;
                posY=e.pageY; 
        }
               
}

function positionnerBulleClient(abs6) 
{
	positBulle=abs6;
}

function initialisationBulleClient() {
        if (document.layers) {
                window.captureEvents(Event.MOUSEMOVE);window.onMouseMove=positionSouris;
                document.write("<LAYER name='bulle' top=0 left=0 visibility='hide'></LAYER>");
        }
        if (document.all) {        	
                document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden;z-index:100'></DIV>");
                document.onmousemove=positionSouris;
        }
        else if (document.getElementById) {        	
                document.onmousemove=positionSouris;
                var oInfobulle=document.createElement("DIV");
                oInfobulle.id="bulle2";
                oInfobulle.style.display="block";
                oInfobulle.style.position="absolute";
                oInfobulle.style.zIndex=1000;
                oInfobulle.style.left=0;
		oInfobulle.style.top=0;				
		document.body.appendChild(oInfobulle);
	}
}

function DL_GetElementLeft(eElement)
{
    var nLeftPos = eElement.offsetLeft;          // initialise var
    var eParElement = eElement.offsetParent;      
    while (eParElement != null)
    {                                            // parcours de la hierarchie d'éléments
        nLeftPos += eParElement.offsetLeft;      // calcul des positions gauche
        eParElement = eParElement.offsetParent;   
    }
    return nLeftPos;                             
}
function InfoBulleIndispoEspaceClient(texte,x,y,xDiff,yDiff) {

var posX=x;posY=y;
var xOffset=xDiff;yOffset=yDiff;

  contenu="<TABLE width=\"140px\" border=0 ><TR><TD style=\"padding: 5px; background-color: #B9DEFF; color:#113388;\"><span style='font-size:9px;font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;'>"+texte+"</span></TD></TR></TABLE>";
  var finalPosX=posX+xOffset;
  var finalPosY=posY+yOffset;
  if (document.layers) {
    document.layers["bulleIndispoClient"].document.write(contenu);
    document.layers["bulleIndispoClient"].document.close();
    document.layers["bulleIndispoClient"].top=finalPosY;
    document.layers["bulleIndispoClient"].left=finalPosX;
    document.layers["bulleIndispoClient"].visibility="show";}
  if (document.all) {
    bulleIndispoClient.innerHTML=contenu;
    document.all["bulleIndispoClient"].style.top=finalPosY;
    document.all["bulleIndispoClient"].style.left=finalPosX;//f.x-xOffset;
    document.all["bulleIndispoClient"].style.visibility="visible";
  }
  else if (document.getElementById) {
    document.getElementById("bulleIndispoClient").innerHTML=contenu;
    document.getElementById("bulleIndispoClient").style.top=finalPosY;
    document.getElementById("bulleIndispoClient").style.left=finalPosX;
    document.getElementById("bulleIndispoClient").style.visibility="visible";
  }
}
function HideInfoBulleIndispoEspaceClient() {
	if (document.layers) {document.layers["bulleIndispoClient"].visibility="hide";}
	if (document.all) {document.all["bulleIndispoClient"].style.visibility="hidden";}
	else if (document.getElementById){document.getElementById("bulleIndispoClient").style.visibility="hidden";}
}

function afficherBulleClient(texte) {
	positBulle=DL_GetElementLeft(document.positionbulle)+190;
        contenu="<TABLE border=0 width='125' height='100' cellspacing=0 cellpadding=1><TR bgcolor='black'><TD><TABLE border=0 cellpadding=1 cellspacing=0 bgcolor='#F8EFCD'><TR><TD><span style='font-size:11'>"+texte+"</SPAN></TD></TR></TABLE></TD></TR></TABLE>";
        var finalPosX=posX-xOffset;
        if (finalPosX<0) finalPosX=0;
        if (document.layers) {
        	document.layers["bulle"].document.write(contenu);
                document.layers["bulle"].document.close();
                document.layers["bulle"].top=posY+yOffset;
                document.layers["bulle"].left=positBulle;
                document.layers["bulle"].visibility="show";
        }
        if (document.all) {
		document.all("bulle").innerHTML=contenu;
		document.all("bulle").style.top=posY+yOffset;
		document.all("bulle").style.left=positBulle;
		document.all("bulle").style.visibility="visible";		
        }
        else if (document.getElementById) {        	
        	document.getElementById("bulle2").innerHTML=contenu;        	
                document.getElementById("bulle2").style.top=posY+yOffset+"px";
                document.getElementById("bulle2").style.left=positBulle;               
                document.getElementById("bulle2").style.display="block";
        }
        
   }

function afficherBulleClientSante(texte) {
	positBulle=DL_GetElementLeft(document.positionbulle)-20;
        contenu="<TABLE border=0 width='125' height='100' cellspacing=0 cellpadding=1><TR bgcolor='black'><TD><TABLE border=0 cellpadding=1 cellspacing=0 bgcolor='#F8EFCD'><TR><TD><span style='font-size:11'>"+texte+"</SPAN></TD></TR></TABLE></TD></TR></TABLE>";
        var finalPosX=posX-xOffset;
        if (finalPosX<0) finalPosX=0;
        if (document.layers) {
        	document.layers["bulle"].document.write(contenu);
                document.layers["bulle"].document.close();
                document.layers["bulle"].top=posY+yOffset;
                document.layers["bulle"].left=positBulle;
                document.layers["bulle"].visibility="show";
        }
        if (document.all) {
		document.all("bulle").innerHTML=contenu;
		document.all("bulle").style.top=posY+yOffset;
		document.all("bulle").style.left=positBulle;
		document.all("bulle").style.visibility="visible";		
        }
        else if (document.getElementById) {        	
        	document.getElementById("bulle2").innerHTML=contenu;        	
                document.getElementById("bulle2").style.top=posY+yOffset+"px";
                document.getElementById("bulle2").style.left=positBulle;               
                document.getElementById("bulle2").style.display="block";
        }
        
   }
   
   function afficherBulleClientSante1(texte) {
	positBulle=DL_GetElementLeft(document.positionbulle)-250;
        contenu="<TABLE border=1 width='370' height='20' cellspacing=0 cellpadding=1><TR bgcolor='black'><TD><TABLE border=0 cellpadding=1 cellspacing=0 bgcolor='#F8EFCD'><TR><TD><span style='font-size:11'>"+texte+"</SPAN></TD></TR></TABLE></TD></TR></TABLE>";
        var finalPosX=posX-xOffset;
        if (finalPosX<0) finalPosX=0;
        if (document.layers) {
        	document.layers["bulle"].document.write(contenu);
                document.layers["bulle"].document.close();
                document.layers["bulle"].top=posY+yOffset-20;
                document.layers["bulle"].left=positBulle;
                document.layers["bulle"].visibility="show";
        }
        if (document.all) {
		document.all("bulle").innerHTML=contenu;
		document.all("bulle").style.top=posY+yOffset-20;
		document.all("bulle").style.left=positBulle;
		document.all("bulle").style.visibility="visible";		
        }
        else if (document.getElementById) {        	
        	document.getElementById("bulle2").innerHTML=contenu;        	
                document.getElementById("bulle2").style.top=posY+yOffset-20+"px";
                document.getElementById("bulle2").style.left=positBulle;               
                document.getElementById("bulle2").style.display="block";
        }
        
   }

	function afficherBulleClientSante1(srcBulle,texte) {
   		contenu="<div style='width: 270px; height: 27px; border: 1px solid #000000; background-color: #F8EFCD; padding: 2px; font-size: 11px; font-weight: normal; color: #000000;'>"+texte+"</div>";
	   	if (document.all) {
		   	var bulle = document.getElementById("bulle");
		   	srcBulle.style.position = "relative";   	
		   	bulle.innerHTML = contenu;
		   	bulle.style.position = "absolute";
		   	bulle.style.left = "100px";
		   	bulle.style.top = "-13px";   	
		   	srcBulle.appendChild(bulle);   	
		   	bulle.style.display = "block";
		   	bulle.style.visibility = "visible";
		   	bulle.style.zIndex = "999";
		} else if (document.getElementById) {
			var bulle = document.getElementById("bulle2");
		   	srcBulle.style.position = "relative";   	
		   	bulle.innerHTML = contenu;
		   	bulle.style.position = "absolute";
		   	bulle.style.left = "100px";
		   	bulle.style.top = "-13px";   	
		   	srcBulle.appendChild(bulle);   	
		   	bulle.style.display = "block";
		   	bulle.style.visibility = "visible";
		   	bulle.style.zIndex = "1000";
		}
   }

function afficherBulleClientAvecTaille(texte,longueur,hauteur) {
	positBulle=DL_GetElementLeft(document.positionbulle)+190;
        contenu="<TABLE border=0 width='"+longueur+"' height='"+hauteur+"' cellspacing=2 cellpadding=1><TR bgcolor='black'><TD><TABLE width='100%' border=0 cellpadding=1 cellspacing=2 bgcolor='#F8EFCD'><TR><TD><span style='font-size:11'>"+texte+"</SPAN></TD></TR></TABLE></TD></TR></TABLE>";
        var finalPosX=posX-xOffset;
        if (finalPosX<0) finalPosX=0;
        if (document.layers) {
        	document.layers["bulle"].document.write(contenu);
                document.layers["bulle"].document.close();
                document.layers["bulle"].top=posY+yOffset;
                document.layers["bulle"].left=positBulle;
                document.layers["bulle"].visibility="show";
        }
        if (document.all) {
		document.all("bulle").innerHTML=contenu;		
		document.all("bulle").style.top=posY+yOffset;
		document.all("bulle").style.left=positBulle;
		document.all("bulle").style.visibility="visible";		
        }
        else if (document.getElementById) {        	
        	document.getElementById("bulle2").innerHTML=contenu;        	
                document.getElementById("bulle2").style.top=posY+yOffset+"px";
                document.getElementById("bulle2").style.left=positBulle;               
                document.getElementById("bulle2").style.display="block";
        }
        
   }

function cacherBulleClient() {
         if (document.layers) {document.layers["bulle"].visibility="hide";}
        if (document.all) {document.all["bulle"].style.visibility="hidden";}
        else if (document.getElementById){document.getElementById("bulle2").style.display="none";}
}
/* Pour les acc‚s direct sur sites externes au niveau 2 */
function ouvrirFenetreSites(width,height,top,left,theURL,winName)
{ ss = "status=yes,location=yes,toolbar=yes,directories=yes,resizable=yes,scrollbars=yes,width="+width+",height="+height+",top="+top+",left="+left;
  if(theURL !='')
  {
 	window.open(theURL,winName,ss);
  }	
}  
function ouvrirSurSelect(objet)
{
	// On vérifie que c'est bien un objet
	if(typeof(objet) == "object")
	{
		// On vérifie que la chaîne n'est pas vide
		sTemp = objet.value;
		if(sTemp != "")
		{
			// Détermine la position du séparateur
			iPos = sTemp.indexOf("_@_",0);
			if(iPos == -1)
			{
				cMode = "";
				sURL = sTemp;
			}
			else
			{
				cMode = sTemp.charAt(0);
				// Récupère l'url (3 est le nb de car du séparateur)
				sURL = sTemp.slice(iPos+3);
			}
			switch(cMode)
			{
				case "O" :
					document.location=sURL;
					break;
				case "P" :
					//window.open(sURL,"","");
					ouvrirFenetreSites(800,600,0,0,sURL,'');
					break;
				case "M" :
					document.location='mailto:' + sURL;
					break;
				case "W" :
					window.open(sURL,"","");
					break;
				default :
					document.location=objet.value;
			}
		}
	}
}