self.name="mainframe";
	
function lance_inters(){

	var afficher = document.getElementById("flash_type").value;
	var lediv = $("affiche_flash");		
	
	if (afficher == 1 ){ /* crise */
	
		lediv.style.display = 'block';
		lediv.style.left = "50%";
		lediv.style.marginLeft = "-"+300+"px";  
					
		/* cache tous les selects */
		var lesSelects = document.getElementsByTagName("select");			
		for (i = 0; i < lesSelects.length; i++) { 			
			lesSelects[i].style.display = "none";	
			lesSelects[i].style.visibility = "hidden";
		} 
		
		
		
	}
	
	if (afficher == 2 ){ /* evenement */
	
		/* cache tous les selects */
		var lesSelects = document.getElementsByTagName("select");			
		for (i = 0; i < lesSelects.length; i++) { 			
			lesSelects[i].style.display = "none";	
			lesSelects[i].style.visibility = "hidden";
		}
		
		var lenom = document.getElementById("nom_flash").value;	
		var larg = document.getElementById("flashWidth").value;
		var haut = document.getElementById("flashHeight").value;
		var extension = document.getElementById("flash_extension").value;
		var marginLeft= Math.floor(larg/2);
		var marginTop= Math.floor(haut/2);
				
		lediv.style.width = larg+"px";
		lediv.style.height = haut+"px";	
		lediv.style.left = "50%";	
		//lediv.style.top = "50%"; 
		lediv.style.top = "36px"; 
		//lediv.style.marginLeft = "-"+marginLeft+"px";	
		//lediv.style.marginTop = "-"+marginTop+"px";	
		/*si margintop fix */
		/*if(navigator.appName=='Microsoft Internet Explorer' && navigator.appVersion.substring(22,23)=='8'){
			//lediv.style.marginTop = "-326px";
			lediv.style.marginTop = "-220px";
			lediv.style.marginLeft = "-265px";			
		}else if(navigator.platform=='MacIntel'){
			lediv.style.marginTop = "-333px";
			lediv.style.marginLeft = "-265px";				
		}else{
			lediv.style.marginTop = "-375px";
			lediv.style.marginLeft = "-265px";			
		}*/
		
		lediv.style.marginLeft = "-265px";


		var nb = LireCookie("nbDisplayEvenement"+lenom);					
		nb = nb ? parseInt(nb, 10) : 0;
		if( nb < 3 )
		{
																				
			lediv.style.display = 'block';				
			if(extension == "swf"){	  //si swf 	
				//fo = new SWFObject("/commun/medias/"+lenom+"."+extension, "contient_flash", larg, haut, "8");				
				fo = new SWFObject("/commun/medias/flash-banner/bin/"+lenom+"."+extension, "733x404", larg, haut, "9");
				fo.addVariable('libpath', '/commun/medias/flash-banner/bin/' );
				fo.addVariable('imgpath', '/commun/medias/flash-banner/bin/img/' );
				fo.addParam('wmode', 'transparent' );
				fo.addParam('allowscriptaccess', 'always' );
				fo.write("affiche_flash");	
				
				// ne pas afficher la bannere du header 
				var ledivBanner = $("flashcontent2_folded");
				ledivBanner.style.display = 'none';
			}
			/*if(extension == "flv"){	 // si video 	
				fo = new SWFObject("/commun/medias/lecteur.swf", "contient_flash", larg, haut, "8");
				fo.addParam('allowscriptaccess', 'always' );
				fo.addVariable('/commun/medias/', lenom+"."+extension);
				fo.write("affiche_flash");								
			}*/	
			
			
			
			/*if(extension == "swf"){  
				var flashvars = {};
				flashvars.libpath = "";
				flashvars.imgpath = "/commun/medias/flash-banner/bin/img/";
				var params = {};
				params.bgcolor = "#FFFFFF";
				params.quality = "high";
				params.allowscriptaccess = "always";
				var attributes = {};
				attributes.id = "interstitiel_santepass";
				attributes.name = "interstitiel_santepass";
				attributes.align = "middle";
				swfobject.embedSWF("/commun/medias/flash-banner/bin/"+lenom+"."+extension, "affiche_flash", "733", "404", "9.0.0", "/commun/medias/flash-banner/bin/js/swfobject/expressInstall.swf", flashvars, params, attributes);
				fo.write("affiche_flash");	
				
					var ledivBanner = $("flashcontent2_folded");
					ledivBanner.style.display = 'none';	
					
			}	*/		
							
		}
		else
		{
			fermer_flash(); 
			/* ferme et reaffiche la bannere du header */
			fermeInterstitiel(); 
			
		}
		EcrireCookie("nbDisplayEvenement"+lenom, nb+1, new Date((new Date()).valueOf()+31536000000));
		
	}		
}
	

/* affiche tous les selects */
function reafficheSelect(){
			var lesSelects = document.getElementsByTagName("select");			
			for (i = 0; i < lesSelects.length; i++) { 			
				lesSelects[i].style.display = "inline";	
				lesSelects[i].style.visibility = "visible";
			} 	
}


function fermer_flash()
{
    var div = $("affiche_flash");
    if(div.style)
    {
        div.style.display = "none";		  
    }			
}


function HideSWF()
{ 

	var div = $("affiche_flash");
	if(div.style)
	{
		div.style.display = "none";		  
	}

}	

function loadIndexSecure()
{
    
    var numlog = document.LogonForm.login.value;
    
    if ((numlog == "")) {
		alert("Vous devez renseigner votre numéro de societaire");
		return (false);
	}
	
	var l_cle = numlog.substring(0, 1);
   	var l_numeroCourt = numlog.substring(1, numlog.length);
   	var l_completionZero = "";
	for (i=numlog.length; i<11; i++) {
		l_completionZero += "0";
	}
	
	numlog = l_cle + l_completionZero + l_numeroCourt;
	
	if ((numlog.length != 11)) {
		alert("Votre numéro de sociétaire n'est pas au bon format");
		return (false);
	}
	
	document.LogonForm.login.value = numlog;
    
    var url = "/index_securise.jsp";
    var prefixeParamHTTP;
	//if (window.location.href.indexOf('?', 0) > -1){
	//	prefixeParamHTTP = '&';
	//} else {
	//	prefixeParamHTTP = '?';
	//}

	prefixeParamHTTP = '?';

	if(window.location.hostname == "localhost"){
		window.location.href="http://"+ window.location.hostname + ":9080"+url+prefixeParamHTTP+"isHTTPS=N"+"&soc="+numlog;
	} else if(window.location.hostname == "test.gmf.fr" 
		|| window.location.hostname == "test2.gmf.fr" 
		|| window.location.hostname == "integration.gmf.fr" 
		|| window.location.hostname == "integration-principale.gmf.fr" 
		|| window.location.hostname == "integration-secondaire.gmf.fr" 
		|| window.location.hostname == "integration-design.gmf.fr" ){
		window.location.href="http://"+ window.location.hostname + url+prefixeParamHTTP+"isHTTPS=N"+"&soc="+numlog;
	} else { 
		window.location.href="https://"+ window.location.hostname + url+prefixeParamHTTP+"isHTTPS=O"+"&soc="+numlog;
	}
}     

function gotoPage()
{
    ctrl = document.Agents.select;
    id = ctrl.value;
   	if (id != "") {
			nextpage= id;
			document.Agents.action = nextpage;
			document.Agents.submit();
            }

    }                
  function gotoPage2()
    {
        ctrl = document.Services.select2;
        id = ctrl.value;
	   	if (id != "") {
		nextpage= id;
		document.Services.action = nextpage;
		document.Services.submit();
        }

}
function gmf_menu_home_startMenuText()
  {
     	 if (navigator.appName.indexOf("Microsoft") != -1) objCote=window["gmf_menu_home_cote"];
          else objCote=document["gmf_menu_home_cote"];
		  	 if(objCote) objCote.startAnim();
	  }
      
   /* GESTION COOKIE */

function EcrireCookie(nom, valeur )
{
    var argv=EcrireCookie.arguments;
    var argc=EcrireCookie.arguments.length;
    var expires=(argc > 2) ? argv[2] : null;
    var path=(argc > 3) ? argv[3] : null;
    var domain=(argc > 4) ? argv[4] : null;
    var secure=(argc > 5) ? argv[5] : false;
    document.cookie=nom+"="+escape(valeur)+
    ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
    ((path==null) ? "" : ("; path="+path))+
    ((domain==null) ? "" : ("; domain="+domain))+
    ((secure==true) ? "; secure" : "");
}
function getCookieVal(offset)
{
    var endstr=document.cookie.indexOf (";", offset);
    if (endstr==-1) endstr=document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}
function LireCookie(nom)
{
    var arg=nom+"=";
    var alen=arg.length;
    var clen=document.cookie.length;
    var i=0;
    while (i<clen)
    {
        var j=i+alen;
        if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
        i=document.cookie.indexOf(" ",i)+1;
        if (i==0) break;

    }
    return null;
}   


/* FLASH MANAGMENT */
function $(e)
{
    if(typeof(e)!='string') return e;
        if(document.getElementById) e=document.getElementById(e);
        else if(document.all) e=document.all[e];
        else e=null;
        return e;
    }
   function Unfold()
    {
        var folded = $("flashcontent2_folded");
    var unfolded = $("flashcontent2_unfolded");
			var flashcontent = $("flashcontent");
    if(folded.style&&unfolded.style)
    {
        fo = new SWFObject("/commun/medias/banner_gmf.swf", "banner_gmf", "735", "430", "8");
				fo.addParam("style"," z-index:5000;");
        fo.write("flashcontent2_unfolded");
        unfolded.style.display = "";
        folded.style.display = "none";
					flashcontent.style.display = "none";
        //$("banner_gmf").onmouseout=function(e){Fold();};
    }
}

 function Fold()
{
    var folded = $("flashcontent2_folded");
    var unfolded = $("flashcontent2_unfolded");
			var flashcontent= $("flashcontent");
			HideBigFlash();
    if(folded.style&&unfolded.style)
    {
        unfolded.style.display = "none";
        folded.style.display = "";
					flashcontent.style.display = "";
        unfolded.innerHTML = "";
        }
    }
 
    function HideBigFlash()
    {
        var bigFlash = $("flashcontent2_unfolded");
    if(bigFlash.style)
    {
        bigFlash.style.display = "none";

    }
}
	
function ToolTipAppear()
{
    var d = document.getElementById("login_tooltip");
    if(d) d.style.display = "block";
}
function ToolTipDisappear()
{
    var d = document.getElementById("login_tooltip");
    if(d) d.style.display = "none";
}

function clearfield(field){
    if (field.defaultValue = field.value){
        field.value="";
    }
}

function ControlForm_spec(form){

	// On met la chaine en majuscule pour passer les dep 2a et 2b en 2A et 2B automatiquement
	// parceque PlanFax comprend 2A mais pas 2a
	form.dept.value = form.dept.value.toUpperCase();

	// Le departement ET la ville sont vide 
	if ((form.dept.value == "") && (form.cityTxt.value == "")) {
		window.alert("Le département ou la ville doit être renseigné.");
		return false;
	}
	

	
	//le champ département ne compte qu'un seul caractère, on ajout un 0 automatiquement devant
	if (form.dept.value.length == 1) {
	// Ajouter un zéro devant
		form.dept.value = "0" + form.dept.value;	
	} 
	
	// Le departement n'est pas formaté correctement 		
	// On teste par une REGEX (le cas de la Corse : 2A - 2a et 2B - 2b est pris en compte) 		
	if ((form.dept.value != "") && (form.dept.value.search(/^\d+$|^\d[ABab]+$/) == -1)) {		
		alert("Département " + form.dept.value + " incorrect : saisissez un code de département valide.");
		return false; 
	}
	
	// Le departement avec 3 caracteres n'existe pas (n'est pas un DOM)
	// On fait un test systématique
	if ((form.dept.value != "") && (form.dept.value.length == 3)) {
			if (form.dept.value != "971" && form.dept.value != "972" && form.dept.value != "973" && form.dept.value != "974"){ 
				alert("Département " + form.dept.value + " incorrect : saisissez un code de département valide.");
				return false; 
	
			}
	}
}


function fermeInterstitiel()
{
    var div = $("affiche_flash");
    if(div.style)
    {
        div.style.display = "none";		  
    }	
	/* afficher la bannere du header */
	var ledivBanner = $("flashcontent2_folded");
	ledivBanner.style.display = 'block';
	/* afficher les selects cachés afin de pallier le bug ie6 */	
	reafficheSelect();
}


