// JavaScript Document
var Choix = 0;
var AcienChoix = 0;

var MenuSelect = 0;
var AncienMenuSelect = 0;

var SSmenuSelect = 0
var AncienSSmenuSelect = 0;

var AncienMenuSurvole = 0;

var AucunMenuSelect = 0 ;
var AncienSSMenuSelect = 0;

var CouleurSSmenu = 0;

/// initialisation du produit selectionné au lancement du site
var AncienProdSelect = 'PROD_01';
var AncienFicheProdSelect = 'DESCRIP_01';
var PREMIERE_SELECTION = 0;


function Teste_Navigateur()
{

		Nom_Browser = navigator.appName;
		
		Version_Browser = navigator.appVersion;
		
		if ( Nom_Browser == "Netscape" )
		{
			return 1;
		}
		if ( Nom_Browser == "Microsoft Internet Explorer" )
		{
			return 2;
		}
		return 2;
}
//// mise a taille de l'iframe
function RedimIframe( Objet )
{
	
	
	
	
	var iNav = Teste_Navigateur();
	/// particularité pour IE 
	if( iNav == 2)
	{
		document.getElementById('CONTENU').style.height = '100%';
	}
	/*var Taille01 = Objet.getElementById('TETE').clientHeight;
	var Taille02 = Objet.getElementById('CORPS').clientHeight+15;
	var Taille2 = Taille01+Taille02;*/
	
	//Taille = Objet.getElementById('CONTENU').clientHeight;
	
	var Taille = document.getElementById('CONTENU').clientHeight;
	
	if(Taille <= 450)
	{
		Taille = 450;
	}
	
	
	var iNav = Teste_Navigateur();
	
	if( iNav == 1) //safari
	{
		//alert('vous utilisez Safari ou mozilla');
		//Taille += 10;
		var Taille2 = Taille+80;
		Taille += 75;
		var obj = document.getElementById('PAGE');
		if( obj != null ) obj.setAttribute('style',"height:"+Taille2+"px; position:static;width:980px;background:#FFFFFF;text-align:left;  padding-top:5px; vertical-align:top;"  );
		
		var obj = document.getElementById('IFRAME');
		if( obj != null ) obj.setAttribute('style',"height:"+Taille+"px;" );
		
		var obj = document.getElementById('COLONNEDROITE');
		if( obj != null ) obj.setAttribute('style',"height:"+Taille+"px;"  );
		
		var obj = document.getElementById('COLONNEGAUCHE');
		if( obj != null ) obj.setAttribute('style',"height:"+Taille+"px; z-index:50; float:left; position:static; display:block; width:200px; background:url(../images/fond_coeur.png) left bottom no-repeat;border:1px solid #008966; margin-left:3px; padding-top:5px; vertical-align:top;"  );
		
	}
	if( iNav == 2)//ie
	{
		/*Taille += 10
		
		var obj = document.getElementById('PAGE');
		if( obj != null ) obj.style.height = Taille ;
		
		/*var obj = document.getElementById('IFRAME');
		if( obj != null ) obj.style.height = '99%' ;
		
		var obj = document.getElementById('IFRAME_PLUS_COLDROITE');
		if( obj != null ) obj.style.height = '99%' ;
		
		var obj = document.getElementById('COLONNEDROITE');
		if( obj != null ) obj.style.height = '99%' ;
		
		Taille = document.getElementById('COLONNEDROITE').clientHeight-5;
		
		var obj = document.getElementById('COLONNEGAUCHE');
		if( obj != null ) obj.style.height = Taille;*/
		
		
	}
}
/// AFFICHAGE DES SOUS MENUS PRESENTATION
function Affiche_SSMenus(ID)
{
		 var iNav = Teste_Navigateur();
		 
		 if( iNav == 1)
				{		
					// masquage des sous menu présentation
					var obj = document.getElementById(ID);
					if( obj != null ) obj.setAttribute('style', 'display:block;' );
					// masquage autre menu si selectionné avant
					if(AncienMenuSelect != ID)
				 	{
						var obj = document.getElementById(AncienMenuSelect);
						if( obj != null ) obj.setAttribute('style', 'display:none;' );
						
						var obj = document.getElementById(AncienSSMenuSelect);
						if( obj != null ) obj.setAttribute('style', 'display:none;' );
					}
				}
		if (iNav == 2)
				{
					var obj = document.getElementById(ID);
					if( obj != null ) obj.style.display = 'block' ;
					// masuqage autre menu si selectionné avant
					if(AncienMenuSelect != ID)
				 	{
						var obj = document.getElementById(AncienMenuSelect);
						if( obj != null ) obj.style.display = 'none' ;
						
						var obj = document.getElementById(AncienMenuSelect);
						if( obj != null ) obj.style.display = 'none';
					}
				 
				 }
		///  memorisation de la selection		 
		if(AncienMenuSelect != ID)
		{
		 	AncienMenuSelect = ID;
		}	
 
}
/// AFFICHAGE DES SOUS MENUS PRESENTATION
function Affiche_SousSSMenus(ID)
{
		 var iNav = Teste_Navigateur();
		 
		 if( iNav == 1)
				{		
					// masquage des sous menu présentation
					var obj = document.getElementById(ID);
					if( obj != null ) obj.setAttribute('style', 'display:block;' );
					// masquage autre menu si selectionné avant
					if(AncienSSMenuSelect != ID)
				 	{
						var obj = document.getElementById(AncienSSMenuSelect);
						if( obj != null ) obj.setAttribute('style', 'display:none;' );
					}
				}
		if (iNav == 2)
				{
					var obj = document.getElementById(ID);
					if( obj != null ) obj.style.display = 'block' ;
					// masuqage autre menu si selectionné avant
					if(AncienSSMenuSelect != ID)
				 	{
						var obj = document.getElementById(AncienSSMenuSelect);
						if( obj != null ) obj.style.display = 'none' ;
					}
				 
				 }
		///  memorisation de la selection
		if(AncienSSMenuSelect != ID)
		{		 
			AncienSSMenuSelect = ID;
		}
 
 }

/////// AFFICHAGE DES SOUS MENUS 
function Affiche_SousMenus( ID , OrigineduClick , CouleurRubrique )
{
		
		
		var MenuSelect = ID;
		
		var iNav = Teste_Navigateur();
		
		/////  SAFARI ET MOZILLA'S
				if( iNav == 1)
				{		
					// masquage des sous menu présentation
					var obj = document.getElementById('SSMENUPRESENTATION');
					if( obj != null ) obj.setAttribute('style', 'display:none;' );
					
					if( MenuSelect != AncienMenuSelect )
					{
					
						var obj = document.getElementById('ListeSSmenu_'+AncienMenuSelect);
						if( obj != null ) obj.setAttribute('style', 'display:none;' );
						/// Class du bouton de menu principal
						var obj = document.getElementById('Bouton_'+AncienMenuSelect);
						if( obj != null ) obj.setAttribute('class', 'MenuPrincipalHaut' );
						
						var obj = document.getElementById('ListeSSmenu_'+ID);
						if( obj != null ) obj.setAttribute('style', 'display:block;' );
						
						/// Class du bouton de menu principal
						var obj = document.getElementById('Bouton_'+ID);
						if( obj != null ) obj.setAttribute('class', 'MenuPrincipalHautOver');
							
						AucunMenuSelect = false;					
					}
					else if( MenuSelect == AncienMenuSelect )
					{
						if(OrigineduClick != 'autre')
						{
								if(AucunMenuSelect == true)
								{
									var obj = document.getElementById('ListeSSmenu_'+ID);
									if( obj != null ) obj.setAttribute('style', 'display:block;' );
									
									/// Class du bouton de menu principal
									var obj = document.getElementById('Bouton_'+ID);
									if( obj != null ) obj.setAttribute('class', 'MenuPrincipalHautOver' );
		
									
									AucunMenuSelect = false;
								}
								else if(AucunMenuSelect == false)
								{
									var obj = document.getElementById('ListeSSmenu_'+ID);
									if( obj != null ) obj.setAttribute('style', 'display:none;' );
									
									/// Class du bouton de menu principal
									var obj = document.getElementById('Bouton_'+ID);
									if( obj != null ) obj.setAttribute('class', 'MenuPrincipalHaut' );
		
									
									AucunMenuSelect = true;
								}
						}
						
					
					}
					
					AncienMenuSelect = ID;
					
				}
	// IE
				if( iNav == 2 )
				{
					// masquage des sous menu présentation
					var obj = document.getElementById('SSMENUPRESENTATION');
					if( obj != null ) obj.style.display = 'none' ;
					
					
					if( MenuSelect != AncienMenuSelect )
					{
					
						var obj = document.getElementById('ListeSSmenu_'+AncienMenuSelect);
						if( obj != null ) obj.style.display = 'none' ;
						/// Class du bouton de menu principal
						var obj = document.getElementById('Bouton_'+AncienMenuSelect);
						if( obj != null ) obj.className = 'MenuPrincipalHaut';
						
						var obj = document.getElementById('ListeSSmenu_'+ID);
						if( obj != null ) obj.style.display = 'block' ;
						/// Class du bouton de menu principal
						var obj = document.getElementById('Bouton_'+ID);
						if( obj != null ) obj.className = 'MenuPrincipalHautOver';
						
						AucunMenuSelect = false;
					}
					else if( MenuSelect == AncienMenuSelect )
					{
						if(OrigineduClick != 'autre')
						{
								if(AucunMenuSelect == true)
								{
									var obj = document.getElementById('ListeSSmenu_'+ID);
									if( obj != null ) obj.style.display = 'block' ;
									/// Class du bouton de menu principal
									var obj = document.getElementById('Bouton_'+ID);
									if( obj != null ) obj.className = 'MenuPrincipalHautOver';
									
									AucunMenuSelect = false;
								}
								else if(AucunMenuSelect == false)
								{
									var obj = document.getElementById('ListeSSmenu_'+ID);
									if( obj != null ) obj.style.display = 'none' ;
									/// Class du bouton de menu principal
									var obj = document.getElementById('Bouton_'+ID);
									if( obj != null ) obj.className = 'MenuPrincipalHaut';
									
									AucunMenuSelect = true;
								}
						}
					}
					AncienMenuSelect = ID;
				}		
		}
//// changement de la couleur de fond du menu survolé
function Change_ColorFond( ID, Statut, CouleurRubrique )
{
	
	if(ID != AncienMenuSelect & Statut == 'on')
	
				{
					// on verifie si l'ancien menu survolé n'est selectionné
					if(AncienMenuSurvole != AncienMenuSelect)
					{
						var obj = document.getElementById('Bouton_'+AncienMenuSurvole);
						if( obj != null ) obj.className = "MenuPrincipalHaut";
					}
					
					var obj = document.getElementById('Bouton_'+ID);
					if( obj != null ) obj.className = "MenuPrincipalHautOver";
				}
		if(ID != AncienMenuSelect & Statut == 'out')
	
				{					
					var obj = document.getElementById('Bouton_'+ID);
					if( obj != null ) obj.className = "MenuPrincipalHaut";
				}
	
	
	AncienMenuSurvole = ID;
		
}

//******************************  FONCTION AJAX ********************************/

function OnLoadTEST1(DATA)
{
	Charge_HTML( 'IFRAME' , DATA );	
	RedimIframe( document );
}

  	function Test_OS()
{
	var OSName="Inconnu";
	if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
	if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
	if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
	if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
	
	return OSName;
}

function Charge_Page( url,sessionid )
{
	

// initialisation du produit selectionné au lancement du site
	AncienProdSelect = 'PROD_01';
	AncienFicheProdSelect = 'DESCRIP_01';
	
	
	url2 = url.replace( "templates/" , "" );
	Load_Data( 'templates/'+ url2 , OnLoadTEST1 );
	  
	var ref= document.referrer.replace(/[<>]/g,'');

	var url = "http://www.france-prevoyance.fr/needcms2/cimstats/traceur.php?PHPSESSID="+sessionid+"&IDSITE=11&RES_X="+screen.width+"&RES_Y="+screen.height+"&REF="+ref.replace(/&/g,'µ')+"&PAGE="+url2+"&DOMAINE=mfp&LIBELLE=''&NAVIGATEUR="+navigator.appName+"&NAVIGATEUR_VERSION="+navigator.appVersion+"&OS="+Test_OS()+"&NB_COUL="+screen.colorDepth;
	var obj = document.getElementById('STAT');
	obj.src=url;
}

function Charge_Page2( url )
{
	

// initialisation du produit selectionné au lancement du site
	AncienProdSelect = 'PROD_01';
	AncienFicheProdSelect = 'DESCRIP_01';
	
	
	url2 = url.replace( "templates/" , "" );
	Load_Data( 'templates/'+ url2 , OnLoadTEST1 );

}

function Charge_PageVlidFormContact( url )
{	
	var iNav = Teste_Navigateur();
		
	/////  SAFARI ET MOZILLA'S
	if( iNav == 1)
		{
				AncienProdSelect = 'PROD_01';
				AncienFicheProdSelect = 'DESCRIP_01';
				
				url2 = url.replace( "templates/" , "" );
				Load_Data(  url2 , OnLoadTEST1 );
		}
	///// IE
	if( iNav == 2)
		{
				AncienProdSelect = 'PROD_01';
				AncienFicheProdSelect = 'DESCRIP_01';
				
				url2 = url.replace( "" , "" );
				Load_Data(  url2 , OnLoadTEST1 );
		}
	
	
}
function initPassage()
{
	//alert("yes");
	PREMIERE_SELECTION = 0;
	//alert(PREMIERE_SELECTION);
	
}

///*****************************  FONCTIONS DE LA PAGE PRODUITS PARTICULIERS  **/

function ChangeStyleProd(id, iddessous, FicheProd, Selected)
{
		/// verification du nombre de fois ou la fonction à été utilisée
		// si > à 1 ce qui suit est inutile
		//alert(PREMIERE_SELECTION);
		
		if(PREMIERE_SELECTION == 0)
		{
			
			if(Selected == 'GALAXIE')
			{
				AncienProdSelect = 'PROD_01';
				AncienFicheProdSelect = 'DESCRIP_01';
			}
				if(Selected == 'MUTHOSPIT')
			{
				AncienProdSelect = 'PROD_02';
				AncienFicheProdSelect = 'DESCRIP_02';
			}
				if(Selected == 'MUTOBSEQUES')
			{
				AncienProdSelect = 'PROD_03';
				AncienFicheProdSelect = 'DESCRIP_03';
			}
			if(Selected == 'COREM')
			{
				AncienProdSelect = 'PROD_07';
				AncienFicheProdSelect = 'DESCRIP_07';
			}
			PREMIERE_SELECTION = 1;
		}
		
		if(id != AncienProdSelect)
		{
		
				var iNav = Teste_Navigateur();
				
				/////  SAFARI ET MOZILLA'S
						if( iNav == 1)
						{	
						
								
												
								var obj = document.getElementById(id);
								if( obj != null ) obj.setAttribute('class', 'PROD_PART_SELECTED' );
								
								var obj = document.getElementById(AncienProdSelect);
								if( obj != null ) obj.setAttribute('class', 'PROD_PART' );
								
								//// gestion d'affichage des fiches produits
								var obj = document.getElementById(FicheProd);
								if( obj != null ) obj.setAttribute('style', 'display:block; float:left; width:260px; height:390px;' );
								
								var obj = document.getElementById(AncienFicheProdSelect);
								if( obj != null ) obj.setAttribute('style', 'display:none; float:left; width:260px; height:390px;' );
								
								
								AncienProdSelect = id;
								AncienFicheProdSelect = FicheProd;
						}
						if( iNav == 2)
						{	
								var obj = document.getElementById(id);
								if( obj != null ) obj.className = "PROD_PART_SELECTED";
								
								var obj = document.getElementById(AncienProdSelect);
								if( obj != null ) obj.className = "PROD_PART";
								
								
								//// gestion d'affichage des fiches produist
								var obj = document.getElementById(FicheProd);
								if( obj != null ) obj.style.display = 'block' ;
								
								var obj = document.getElementById(AncienFicheProdSelect);
								if( obj != null ) obj.style.display = 'none' ;
								
								
								AncienProdSelect = id;
								AncienFicheProdSelect = FicheProd;
						}
		}
}

///@@@@@@@@@@@@@@@@@@@@   	validation du formulaire de contact    @@@@@@@@@@@@@@@@@@@@@@@@@@@*/
function Valide()
{
		// TEST DES CHAMPS
	/*
	nom
	prenom
	organisme
	fonction
	adresse
	codepostal
	ville
	phone
	gsm
	fax
	mail
	message
	*/
	
	
	var obj = document.getElementById( "nom" );
	
	if (obj != null )

	{
		if( obj.value == "" )
		{
			alert('Vous devez saisir un nom');

			return;
		}
	}	
	
	var obj = document.getElementById( "prenom" );
	
	if (obj != null )

	{
		if( obj.value == "" )
		{
			alert('Vous devez saisir un prenom');

			return;
		}
	}
	
	var obj = document.getElementById( "organisme" );
	
	if (obj != null )

	{
		if( obj.value == "" )
		{
			alert('Vous devez saisir un nom d\'organisme ou entreprise');

			return;
		}
	}	
	
	var obj = document.getElementById( "adresse" );
	
	if (obj != null )

	{
		if( obj.value == "" )
		{
			alert('Vous devez saisir une adresse');

			return;
		}
	}
	
	var obj = document.getElementById( "codepostal" );
	
	if (obj != null )

	{
		if( obj.value == "" )
		{
			alert('Vous devez saisir code postal.');

			return;
		}
	}	
	var obj = document.getElementById( "phone" );
	
	if (obj != null )

	{
		if( obj.value == "" )
		{
			alert('Vous devez saisir un numéro de téléphone.');

			return;
		}
	}
	
	var obj = document.getElementById( "mail" );
	
	if (obj != null )

	{
		if( obj.value == "" )
		{
			alert('Vous devez saisir une adresse email.');

			return;
		}
	}
	
	var obj = document.getElementById( "message" );
	
	if (obj != null )

	{
		if( obj.value == "" )
		{
			alert('Vous devez saisir un message.');

			return;
		}
	}
	
	
	
	// validation du formulaire après vérification
	
	var obj = document.getElementById("FORM_CONTACT");

	if (obj != null )

	{
		
		obj.submit();
		
	}
	
}












