function afficherLCEN()
{
	document.getElementById("changementMail").value="true";
	document.getElementById("ouverture").submit();    
}
function cacher(element){
	document.getElementById(element).style.display="none";
}
function montrer(element){
	document.getElementById(element).style.display="block";
}
function activerLien(element){
	document.getElementById("lien"+element).className="active";
}
function desactiverLien(element){
	document.getElementById("lien"+element).className=null;
}
function changerImageSource(vElement,vChemin){
	document.getElementById(vElement).src=vChemin;
}
function montrerSurLaSourie(element){
	document.getElementById(element).style.display="block";
/*	alert(positionSouriY);*/	
	document.getElementById(element).style.top=parseInt(positionSouriY-20)+"px";
	document.getElementById(element).style.left=parseInt(positionSouriX-30)+"px";
}

function detecterFlash(){
	var flashinstalled = 0;
	var flashversion = 0;
	MSDetect = "false";
	if (navigator.plugins && navigator.plugins.length)
	{
		x = navigator.plugins["Shockwave Flash"];
		if (x)
		{
			flashinstalled = 2;
			if (x.description)
			{
				y = x.description;
				flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
		else
			flashinstalled = 1;
		if (navigator.plugins["Shockwave Flash 2.0"])
		{
			flashinstalled = 2;
			flashversion = 2;
		}
	}
	else if (navigator.mimeTypes && navigator.mimeTypes.length)
	{
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin)
			flashinstalled = 2;
		else
			flashinstalled = 1;
	}
	else
		MSDetect = "true";
	if (MSDetect == "true")
	{
		for(var i=10; i>2; i--){		
			try{
				var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
				flashVersion = i;
				flashinstalled = 2
				break;
			}
			catch(e){
			}
		}
	}
	return flashinstalled;
}

/***********************    Onglet assistance   *******************************/
function selectionOngletAssistance(element){
	document.getElementById('onglet-contact').className="onglet-contact";
	document.getElementById('onglet-assistant').className="onglet-assistant";
	document.getElementById(element).className=element+"-active";
	if(element=="onglet-contact"){
		cacher("assistant");
		montrer("contact");
	}
	if(element=="onglet-assistant"){
		cacher("contact");
		montrer("assistant");			
	}
}

/***********************    Nos solutions       *******************************/
function initialiserNosSolutionsEnUnCoupOeil(){
	masquerNosSolutionsEnUnCoupOeil();
	activerLien("reservecredit");
	montrer("reservecredit");
}
function masquerNosSolutionsEnUnCoupOeil() {
	cacher("reservecredit");
	cacher("pretpersonnel");
	cacher("rachatcredit");
	cacher("cartes");
	cacher("assurances");
	cacher("epargne");	
	desactiverLien("reservecredit");
	desactiverLien("pretpersonnel");
	desactiverLien("rachatcredit");
	desactiverLien("cartes");
	desactiverLien("assurances");
	desactiverLien("epargne");
}
function afficherResumeNosSolutionsEnUnCoupOeil(element){
	masquerNosSolutionsEnUnCoupOeil();
	activerLien(element);
	montrer(element);
}

/***********************    Page macro          *******************************/
function afficherPageMacro(element1, element2, nb, numero){
	masquerPageMacro(element1, element2, nb);
	document.getElementById(element1+numero).className="ouvert";		
	montrer(element2+numero);
}
function masquerPageMacro(element1, element2, nb){
	for(i=1;i<=nb;i++){
		cacher(element2+i);
		document.getElementById(element1+i).className="fermer";		
	}
}

/***********************  Page réseau   **********************************/
function afficheResume(velement,caseH,caseV){
	if((positionSouriX>(positionXCaseHautGauche+(124*caseV)))&&(positionSouriX<(positionXCaseHautGauche+(124*(caseV+1))))){
		if(document.getElementById(velement).style.top = parseInt(-5000)+"px"){
			effacerReseau();
				document.getElementById(velement).style.top=parseInt((positionYCaseHautGauche+(66*caseH))-8)+"px";
			if(caseV>3){
				document.getElementById(velement).style.left=((positionXCaseHautGauche+(124*caseV))-233)+"px";			
			}else{
				document.getElementById(velement).style.left=((positionXCaseHautGauche+(124*caseV))-8)+"px";			
			}			
		}
	}
}
function position(e) {
	positionSouriX = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x/*+document.body.scrollLeft*/;
	positionSouriY = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y/*+document.body.scrollTop*/;
	/*Position X et y de la premiere case haut gauche*/
	if(detecterFlash()){
	positionYCaseHautGauche=430;/*on ajoute 124 par case */
	}else{
		positionYCaseHautGauche=320;/*on ajoute 124 par case */
	}
	positionXCaseHautGauche=250;/*on ajoute 66 par case*/
	/*Position X et y de la derniere case bas droite*/
	//positionYCaseBasDroite=722;/*on ajoute 124 par case */
	//positionXCaseBasDroite=996;/*on ajoute 66 par case*/
	/*Position X et y de la premiere case haut gauche pour les cartes*/
	//positionYCaseHautColonne1Carte=503;/*on ajoute 63 par case */
	positionXCaseHautColonne1Carte=382;/*on ajoute 118 par case*/
	//positionYCaseHautColonne2Carte=503;/*on ajoute 63 par case */
	positionXCaseHautColonne2Carte=757;/*on ajoute 118 par case*/
	positionSouriXnoScroll = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
	positionSouriYnoScroll = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
}
function afficheResume2(velement,zone){
	//alert("X = "+positionSouriX+" Y ="+positionSouriY+" scroll="+window.scrollTop  );
}
/***********************    Partenaires    ************************************/
function preparationDonneesSimulationPPR(p, montant) {
	return preparationDonneesSimulationLPR(p, montant);
}

function trouverBaremeLPRpourMontant(p, montant) {
	var nbmontant = p.length;
	for (i=0; i<nbmontant; i++) {
		if (p[i][0]>=montant)
			return p[i][0];
	}
	return p[5][0];
}

function preparationDonneesSimulationLPR(p, montant) {

	var chaineret = "";
	var nbmontant = p.length;
	chaineret += "&m="+montant;
	chaineret += "&nbmo="+nbmontant;
	
	for (i=0; i<nbmontant; i++) {
		chaineret += "&mo_"+i+"="+p[i][0];
		if (p[i][1] != null)
			nbmens = p[i][1].length;
		else
			nbmens = p[i][7].length;
		
		chaineret += "&nbme_"+i+"="+nbmens;
		for (j=0; j<nbmens; j++) {
			if (p[i][1] != null)
				chaineret += "&d_"+i+"_"+j+"="+(p[i][1])[j];
			else
				chaineret += "&d_"+i+"_"+j+"=-";
			
			
			if (p[i][2] != null)
				chaineret += "&t_"+i+"_"+j+"="+(p[i][2])[j];
			else
				chaineret += "&t_"+i+"_"+j+"=-";
				
			if (p[i][7] != null)
				chaineret += "&m_"+i+"_"+j+"="+(p[i][7])[j];
			else
				chaineret += "&m_"+i+"_"+j+"=-";
				
			if (p[i][10] != null)
				chaineret += "&f_"+i+"_"+j+"="+(p[i][10])[j];
			else
				chaineret += "&f_"+i+"_"+j+"=-";
				
			if (p[i][9] != null)
				chaineret += "&c_"+i+"_"+j+"="+(p[i][9])[j];
			else
				chaineret += "&c_"+i+"_"+j+"=-";
		}
	}

	return chaineret;
}

function preparationDonneesSimulationRAC(p, montant,mens) {
	var chaineret = "";
	var nbmontant = p.length;
	chaineret += "&imprimerActif=N";
	chaineret += "&emailActif=N";
	chaineret += "&m="+montant;
	chaineret += "&mens="+mens;
	chaineret += "&nbmo="+nbmontant;
	for (i=0; i<nbmontant; i++) {
		chaineret += "&mo_"+i+"="+p[i][0];
		if (p[i][1] != null)
			nbmens = p[i][1].length;
		else
			nbmens = p[i][7].length;
		
		chaineret += "&nbme_"+i+"="+nbmens;
		for (j=0; j<nbmens; j++) {
			if (p[i][1] != null)
				chaineret += "&d_"+i+"_"+j+"="+(p[i][1])[j];
			else
				chaineret += "&d_"+i+"_"+j+"=-";
			
			
			if (p[i][2] != null)
				chaineret += "&t_"+i+"_"+j+"="+(p[i][2])[j];
			else
				chaineret += "&t_"+i+"_"+j+"=-";
				
			if (p[i][7] != null)
				chaineret += "&m_"+i+"_"+j+"="+(p[i][7])[j];
			else
				chaineret += "&m_"+i+"_"+j+"=-";
				
			if (p[i][10] != null)
				chaineret += "&f_"+i+"_"+j+"="+(p[i][10])[j];
			else
				chaineret += "&f_"+i+"_"+j+"=-";
				
			if (p[i][9] != null)
				chaineret += "&c_"+i+"_"+j+"="+(p[i][9])[j];
			else
				chaineret += "&c_"+i+"_"+j+"=-";
		}
	}


	return chaineret;
}

/***********************    Flashs (methodes standards)   **********************/
function flashNavigation(action) {
	if (action == "formulaire-rac-info") {
		xt_med('C','1','P SIMU SHP','N');
		if (typeof racFMP != "undefined"){
			window.open('../../../pages/en-savoir-plus-rac.html','Sondage', 'menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=250,top=100,width=800,height=400');
		} else {
			window.document.location = "../../../ba/rachat-credit/rachat-de-credits.html";	
		}		
	} else if (action == "rac-exemple-utilisation") {
		xt_med('C','1','P SIMU SHP','N');
		if (typeof racFMP != "undefined"){
			window.open('../../../pages/en-savoir-plus-rac.html','Sondage', 'menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=250,top=100,width=800,height=400');
		} else {
			window.document.location = "../../../ba/rachat-credit/rachat-de-credits.html#example";
		}		
	} else	if (action == "formulaire-rac-info-public") {
		window.document.location = "../rachat-credit/rachat-de-credits.html";
	} else	if (action == "rac-exemple-utilisation-public") {
		window.document.location = "../rachat-credit/rachat-de-credits.html#example";
	} else	if (action == "push_pperso") {
		window.document.location = "../pret-personnel/pret-personnel.html";
	} else	if (action == "rac-exemple-utilisation-2") {
		window.document.location = "../../ba/rachat-credit/rachat-de-credits.html#example";
	}else if (action == "AssuAutoEte") {
		window.document.location = "../assurance/assurance-auto.html";
	} else if (action == "reseau") {
		window.document.location = "../reseau/reseau.html";
	} else if (action == "dossier_du_mois") {
		window.document.location = "../nos-conseils/article-0053.html";
	} else if (action == "article1") {
		window.document.location = "../nos-conseils/article-0074.html";
	} else if (action == "article2") {
		window.document.location = "../nos-conseils/article-0075.html";
	} else if (action == "article3") {
		window.document.location = "../nos-conseils/article-0076.html";
	} else if (action == "AssSanté") {
		window.document.location = "../assurance/complementaire-sante.html";
	} else if (action == "accueil-rachat-demande-simu") {
		xt_med('C','1','P SIMU HP','N');
		window.document.location = "../../p/ba/rachat-credit/identification.html";
	} else if (action == "RAC") {
		xt_med('C','1','P HP RAC','N');
		window.document.location = "../../p/ba/rachat-credit/identification.html";
	} else if (action == "rac-tableau") {
		window.document.location = "#racTable";
	} else if (action == "Avenir") {
		xt_med('C','1','bahp203aa50%','N');
		window.document.location = "../epargne/assurance-vie.html";
	} else if (action == "4profils") {
		xt_med('C','1','baShp202aa410','N');
		window.document.location = "../epargne/assurance-vie-profil-investissement.html#4profils";
	}  else if (action == "Pret") {
		window.document.location = "../pret-personnel/pret-personnel.html";
	} else if (action == 'accordlibre' || action=='financer-projets-accueil-reserve-credit' || action == 'Alibre') {
		window.document.location = "../reserve-credit/reserve-argent.html";
	} else if (action == 'ALIbre') {
		window.document.location = "../reserve-credit/reserve-argent.html";
	} else if (action == "AssHab") {
		xt_med('C','1','P SHP ASS Flash HAB','N');
		window.document.location = "../assurance/assurance-habitation.html";
	} else if (action == "AssSecu") {
		xt_med('C','1','P SHP ASS Flash SECU','N');
		window.document.location = "../assurance/assurance-securite.html";
	} else if (action == "AssAuto") {
		xt_med('C','1','P SHP ASS Flash AUTO','N');
		window.document.location = "../assurance/assurance-auto.html";
	} else if (action == "AssurancesCallback") {
		xt_med('C','1','C CALLBACK','N');
		windowOptions = 'menubar=no,toolbar=noresizable=yes,width='+550+',height='+350;
		windowOptions += ',scrollbars=no';
		window.open('http://www3.nexx.fr/WCB/index.asp?val=3','Callback', windowOptions);
	} else if (action == "imprimeReduction-evt") {
		window.open('http://www.jimprimemesreductions.com');	
	}else if (action == "Ventes") {
		window.document.location = "../../p/ba/ventesflash/ventesflash.html";
	} else if (action == "Home") {
		window.document.location = "../accueil/accueil.html?evt=no";
	} else if (action == "DemandeAccord") {
		window.document.location = "../../p/ba/accordavenir/documentation.html";
	} else if (action == 'Accordlibre') {
		window.document.location = "../reserve-credit/reserve-argent.html";
	} else if (action == "Sante") {
		xt_med('C','1','P HP SANTE','N');
		window.document.location = "../assurance/complementaire-sante.html";
	} else if (action == "pperso") {
		window.document.location = "../pret-personnel/pret-personnel.html";
	} else if (action == "cbvisa") {
		window.document.location = "../cartes/carte-visa-premier.html";
	} else if (action == "habitation") {
		xt_med('C','1','P SIMU SHP','N');
		window.document.location = "../assurance/assurance-habitation.html";
	} else if (action == "auto") {
		xt_med('C','1','P SIMU SHP','N');
		window.document.location = "../assurance/assurance-auto.html";
	} else if (action == "alibre") {
		window.document.location = "../reserve-credit/reserve-argent.html";
	} else if (action == "home") {
		window.document.location = "../accueil/accueil.html?evt=no";
	} else if (action == "voeux") {
		window.document.location = "../voeux/voeux-2009.html";
	} else if (action == "DmdeAA") {
		window.document.location = "../../p/ba/accordavenir/documentation.html";
	} else if (action == "ETUDE_RAC_BPC") {
		window.document.location = "../../p/ba/bons-plans-credits/rachat-credit.html";
	} else if (action == "BPC_budget") {
		xt_med('C','1','P HP BPC Flash PPR','N');
	} else if (action == "BPC_projet") {
		xt_med('C','1','P HP BPC Flash LPR','N');
	} else if (action == "BPC_RAC") {
		xt_med('C','1','P HP BPC Flash RAC','N');
	} else if (action == "sondage_webzine") {
		window.open('http://netetudes.com/Questionnaires/etude1285/index.php','Sondage', 'menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=250,top=100,width=1030,height=670');
	} else if (action == "Assurances") {
		window.document.location = "../../ba/assurance/assurance.html";
	} else if (action == "push_e_releve_2") {
		try {
			xt_med('C','1','P HP1','N', adresseAbonnementEReleve);
		} catch(e) { }
	} else if (action == "erdcthonHP1") {
		try {
			xt_med('C','1','P HP1','N', adresseAbonnementEReleve);
		} catch(e) { }
	} else if (action == "erdcthonSimuHP") {
		try {
			xt_med('C','1','P SIMU HP','N', adresseAbonnementEReleve);
		} catch(e) { }
	} else if (action == "accueil-virement-demande") {
		try {
			xt_med('C','1','P HP1','N', adresseDemandeVirementPlus);
		} catch(e) { }
	} else if (action == "AA") {
		try {
			if (destFlash!=null && destFlash=='demandeDoc') {
				window.document.location = "../../p/ba/accordavenir/documentation.html";
			}
		} catch (e) {
			window.document.location = "../../ba/epargne/assurance-vie.html";
		}
	} else if (action == 'recompensesAccordAvenir') {
		window.document.location = "../../ba/epargne/assurance-vie-recompense.html";
	} else if (action == "accueil-service-client-2009") {
		xt_med('C','1','P HP Service client 2009 Flash','N');
		window.document.location = "../../ba/qui-sommes-nous/service-client.html";
	} else if (action == "accueil-qui-sommes-nous-video") {
		xt_med('C','1','P Page Service client 2009 Flash','N');
		window.document.location = "../../ba/qui-sommes-nous/video.html";
	} else if (action == 'accueil-vnf-demande-tg') {
		try {
			//alert(adresseDemandeVirementNFois);
			xt_med('C','1','P OFFRE VNF ACC','N', adresseDemandeVirementNFois);
		} catch(e) { }
	}  else if (action == 'accueil-assurance-auto-habitation') {
		xt_med('C','1','P HP1','N','../assurance/assurance.html');
	} else if (action == 'hp-event-jeu-concours-avril-2009') {
		xt_med('C','1','P HP Event','N');
		try {
			window.document.location = adresseJeuConcoursClient ;
		} catch(e) { }
	} else if (action == 'home-hp2-jeu-concours-avril-2009') {
		xt_med('C','1','P HP1','N');
		try {
			window.document.location = adresseJeuConcoursClient ;
		} catch(e) { }
	} else if (action == 'changements_carte_auchan_contact'){
		xt_med('C','1','P Contact Faq Carte Auchan','N','../../p/ba/contact/formulaire.html');
	}  else if (action == 'changements_carte_auchan_contact_tel'){
		xt_med('C','1','P Contact Faq Carte Auchan Tel','N','../contact/contact-par-tel.html');
	} else if (action == 'home-hp2-assurance-vie') {
		xt_med('C','1','P HP2_AAP_0110','N');
		window.document.location = '../../ba/epargne/assurance-vie.html' ;
	} else if (action == 'home-shp-assurance-vie') {
		xt_med('C','1','SHP_AA_0110','N');
		window.document.location = '../../ba/epargne/assurance-vie.html' ;
	} 
	else if (action == "carte_auchan_mastercard") {
		window.document.location = "../cartes/carte-mastercard.html";
	} else if (action == "carte_auchan_visa") {
		window.document.location = "../cartes/carte-visa.html";
	} else if (action == "carte_auchan_visa_premier") {
		window.document.location = "../cartes/carte-visa-premier.html";
	} else if (action == "carte_auchan") {
		window.document.location = "../cartes/carte-auchan.html";
	} else if (action == "carte_auchan_fidelite") {
		window.document.location = "../cartes/changementsfidelite.html";
	} else if (action == "hp_event_carte_auchan") {
		window.document.location = "../cartes/cartes-auchan.html";
	} else if (action == "home-hp2-carte-auchan") {
		window.document.location = "../cartes/cartes-auchan.html";
	} else if (action == "vente-flash-home-evt") {
		xt_med('C','1','P HP EVENT VFPP','N');
		window.document.location = "../../p/ba/ventesflash/ventesflash.html";
	} else if (action == "vente-flash-home") {
		xt_med('C','1','P HP VFPP','N');
		window.document.location = "../../p/ba/ventesflash/ventesflash.html";
	} else if (action == "vente-flash-en-cours") {
		xt_med('C','1','P HP NAV VFPP on','N');
		document.forms['ouvertureVE'].submit();
	} else if (action == "vente-flash-terminee") {
		xt_med('C','1','P HP NAV VFPP off','N');
		window.document.location = "../../../ba/pret-personnel/pret-personnel.html";
	} else if (action == "racpphp2pret"){
		window.document.location = "../../ba/pret-personnel/pret-personnel.html"
	} else if (action == "racpphp2rac"){
		xt_med('C','1','P HP HP2RAC61','N');
		window.document.location = "../../ba/rachat-credit/rachat-de-credits.html"
	} else if (action == "hp2_ass_securite"){
		xt_med('C','1','GMP_HP2P','N');
		window.document.location = "../assurance/assurance-securite.html";
	} else if (action == "simu_ass_securite"){
		xt_med('C','1','GMP_simuHP','N');
		window.document.location = "../assurance/assurance-securite.html";
	} else if (action == "jmreduction-hp2") {
		xt_med('C','1','P HP2','N');
		window.open('http://www.jimprimemesreductions.com','JMR', 'menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=250,top=100,width=1024,height=620');
	} else if (action == "elu2010") {
		xt_med('C','1','P elu2010','N');
		window.open('../../ressources/commun/html/avis.html','Je_donne_mon_avis', 'menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=250,top=100,width=680,height=640');
	} else if (action == "hp_promo_pret_perso") {
		xt_med('C','1','SimuHP_PP_SOLDES','N');
		window.document.location = "../pret-personnel/pret-personnel.html";
	} else if(action == 'e-releves_2') {
		xt_med('C','1','P HP ERDC','N');
		try{
			window.document.location = contexteClientSecu + "s/ba/releveabonnement/formulaireclassique.html";
		} catch (e){
		}
	} else if(action == 'vente-privilege-HPE') {
		xt_med('C','1','P HP EVT VENTE PRIVILEGE','N');
		window.document.location = "../../p/ba/ventesflash/ventesflash.html";
	} else if(action == 'hp-no-evt') {
		xt_med('C','1','P HP EVT NO EVT','N');
		window.document.location = "accueil.html?evt=no";
	} else if(action == 'jeu-concours-evt') {
		xt_med('C', '1', 'P HP EVT JEU CONCOURS', 'N');
		try{
			window.document.location = contexteClientSecu + "s/ba/releveabonnement/formulaireclassique.html";
		} catch (e){
		}
	}else {
		window.status = action;
	}
}

function flashnavigation(action) {
	if (action == "pretperso") {
		xt_med('C','1','P HP PP','N');
		window.document.location = "../pret-personnel/pret-personnel.html";
	} else if (action == "reglement") {
		window.open('../../ressources/commun/pdf/reglement-jeu-assurance.pdf','reglement', 'menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=800,height=600');
	}
}


function flashSimulateurAction(id, action) {
	if (id == "LPR") {
		if (action == "DEMANDE") {
			xt_med('C','1','P HP SIM PP','N');
			document.forms['ouverture-lpr'].submit();
		} else if (action == "DOCUMENTATION") {
			xt_med('C','1','P HP PP DMD DOC','N');
			document.forms['documentation-lpr'].submit();
		}
	} else if (id == "PPR") {
		if (action == "DEMANDE") {
			xt_med('C','1','P HP SIM AL','N');
			document.forms['ouverture-ppr'].submit();
		} else if (action == "DOCUMENTATION") {
			xt_med('C','1','P HP AL DMD DOC','N');
			document.forms['documentation-ppr'].submit();
		}
	} else if (id == "PPR2") {
		if (action == "DEMANDE") {
			xt_med('C','1','P SIMU SHP','N');
			document.forms['ouverture-ppr'].submit();
		} else if (action == "DOCUMENTATION") {
			xt_med('C','1','P SHP AL DMD DOC','N');
			document.forms['documentation-ppr'].submit();
		}
	} else if (id == "LPR2") {
		if (action == "DEMANDE") {
			xt_med('C','1','SimuSHP_PP_SOLDES','N');
			document.forms['ouverture-lpr'].submit();
		} else if (action == "DOCUMENTATION") {
			xt_med('C','1','P SHP PP DMD DOC','N');
			document.forms['documentation-lpr'].submit();
		}
		} else if (id == "PPR3") {
		if (action == "DEMANDE") {
			xt_med('C','1','P BPC SIM AL','N');
			document.forms['ouverture-ppr'].submit();
		} else if (action == "DOCUMENTATION") {
			xt_med('C','1','P BPC AL DMD DOC','N');
			document.forms['documentation-ppr'].submit();
		}
	} else if (id == "LPR3") {
		if (action == "DEMANDE") {
			xt_med('C','1','P SIMU SHP','N');
			document.forms['ouverture-lpr'].submit();
		} else if (action == "EMAIL") {
			document.forms['ouverture-rac'].submit();
		} else if (action == "IMPRIMER") {
			window.print();
		}
	} else if (id=='GEN3') {
		try {
			xt_med('C','1','P SimuHPPret','N');
			if (accueilBA) {
				if (document.forms['ouverture-fmp'].elements['codeProjet'].value=='RAC') {
					window.document.location = "../../p/ba/rachat-credit/identification.html";
				} else { 
					document.forms['ouverture-fmp'].action='../pret-personnel/pret-personnel.html'
					document.forms['ouverture-fmp'].submit();
				}
			} else {
				document.forms['ouverture-fmp'].submit();
			}
		} catch(e) {
			document.forms['ouverture-fmp'].submit();
		}
	} else if (id=='RAC2') {
		if (action == "DEMANDE") {
			xt_med('C','1','P RAC2 SIM PP','N');
			document.forms['ouverture-rac'].submit();
		} else if (action == "EMAIL") {
			xt_med('C','1','P RAC2 PP AMI','N');
			document.forms['ouverture-rac'].submit();
		} else if (action == "IMPRIMER") {
			xt_med('C','1','P RAC2 PP IMP','N');
			window.print();
		}
	} else {
		// alert("flashSimulateurAction2 : " + id + "/" + action);
	}
}

function flashSimulateurSimulation(id, montant, mensualite) {
	if (id == "LPR" || id == "LPR2" || id == "LPR3") {
		document.forms['ouverture-lpr'].elements['montant'].value = montant;
		document.forms['ouverture-lpr'].elements['mensualite'].value = mensualite;
		document.forms['documentation-lpr'].elements['montant'].value = montant;
		document.forms['documentation-lpr'].elements['mensualite'].value = mensualite;
	} else if (id == "PPR" || id == "PPR2" || id == "PPR3") {
		document.forms['ouverture-ppr'].elements['montant'].value = montant;
		document.forms['ouverture-ppr'].elements['mensualite'].value = mensualite;
		document.forms['documentation-ppr'].elements['montantCredit'].value = montant;
		document.forms['documentation-ppr'].elements['montantMensualite'].value = mensualite;
	} else {/*
		alert("flashSimulateurSimulation3 : " + id + "/" + montant + "/" + mensualite);
		*/
	}
}

function flashSimulateurProjet(action,valeur)
{
	if (action=='GEN3')
		document.forms['ouverture-fmp'].elements['codeProjet'].value = valeur;
	/*else
		alert("flashSimulateurProjet : " + action + "/" + valeur );
	*/	
}

function flashSimulateurMontant(action,valeur)
{
	if (action=='GEN3')
		document.forms['ouverture-fmp'].elements['montant'].value = valeur;
	/*else
		alert("flashSimulateurMontant : " + action + "/" + valeur );
		*/
}


/************************    Moteur de recherche    ************************/

/*
 * affecte le texte contenu dans span d'index 'spanNum' au champ texte 'mot'
 */
function setResult(div, spanNum, hideBlock){

	// recup du span et affectation du texte 
	var spans = div.getElementsByTagName("div");
	document.getElementById("motClef").value = spans[spanNum].getElementsByTagName("span")[0].innerHTML;
	if (hideBlock && hideBlock == "true") {
		// disparition de la liste d'aide
		div.style.display = "none";
	}
	// postionnement du curseur sur le champ texte
	document.getElementById("motClef").focus();
	
}

/*
 * met le div/span dont l'index est 'spanNum' en surbrillance (dans la zone d'aide de saisie)
 */
function setSelectedSpan (div, spanNum) {
	var count = -1;
	var thisSpan;
	var spans = div.getElementsByTagName("div");
	if (spans) {
		// on parcours les entrees dans la liste d'aide
		for (var i = 0; i < spans.length; i++) {
			if (++count == spanNum) {
			 	// on change simplement la classe de style pour mettre en surbrillance (cf. style)
				spans[i].className = "highlight";
		        thisSpan = spans[i];
			} else {
				spans[i].className = "";
			}
		}
	}
	return thisSpan;
}

/*
 * retourne le numéro du div/span qui est en surbrillance (dans la zone d'aide de saisie)
 */
function getSelectedSpanNum(div) {
	var count = -1;
	var spans = div.getElementsByTagName("div");
	if (spans) {
		// on parcours les entrees dans la liste d'aide
		for (var i = 0; i < spans.length; i++) {
			count++;
			// on reconnait le div/span selectionne au nom de la classe de style
			if (spans[i].className == "highlight") {
				return count;
			}
		}
	}
	return -1;
}

/*
 * 
 */
function keypressHandler(evt, prefixeURL) {

	var div = document.getElementById("autocomplete");
	var nbSpan = div.getElementsByTagName("div").length;
	var key;

	var KEYUP = 38;
	var KEYDOWN = 40;
	var KEYENTER = 13;
	var MAXLENGTH = 3;
	

	if (evt && evt.which) {
		evt = evt;
		key = evt.which;
	} else {
		 evt = event;
		 key = evt.keyCode;
	}

	// 1er cas : touche haut, bas ou entree et presence de l'aide a la saisie
	if ((key == KEYUP || key == KEYDOWN || key == KEYENTER) && (div.style.display == "block")) {
		// dans ce cas on se "promene" dans les differents reponses proposees
		// on commence par recuperer le span qui est actuellement selectionne
		var indexSpan = getSelectedSpanNum(div);
		
		if (key == KEYUP) { // on "monte" dans la liste des resultat
			if (indexSpan > 0) {
				setSelectedSpan(div, indexSpan - 1);
				setResult(div, indexSpan - 1, "false");
			}
		} else if (key == KEYDOWN) { // on "descent" dans la liste des resultat
			if (indexSpan < nbSpan - 1) {
				setSelectedSpan(div, indexSpan + 1);
				setResult(div, indexSpan + 1, "false");
			} else {
				setSelectedSpan(div, indexSpan);
				setResult(div, indexSpan, "false");
			}
		} else if (key == KEYENTER) { // on affecte la valeur selectionnee au champ texte 'motClef'
			if (indexSpan >= 0) {
				setResult(div, indexSpan, "true");
			}
			/*document.forms['form-rechercher'].submit();*/
		}
	} else if (key == KEYENTER){ // la zone d'aide a la saisie n'est pas visible, cela correspond
	    // a une validation de formulaire
		/*document.forms['form-rechercher'].submit();*/
	} else { // on fait l'appel serveur pour mettre a jour la liste d'aide a la saisie
		// celui-ci n'est fait que si le mot fait 3 caracteres
		var curLength = document.getElementById("motClef").value.length;
		if (curLength <= MAXLENGTH && curLength > 0) {
			getMots(prefixeURL);
		} else if (curLength == 0) {
			div.style.display = "none";
		}
	}
}

/*
 * execute l'appel serveur pour recuperer la liste des mots apparente au champ texte associe
 */
function getMots(prefixeURL) {
	var motClef = document.getElementById("motClef").value;
	// creation de l'objet xmlHttpRequest
	var req = newXMLHttpRequest();
	if (!req) { // ajax non supporte par le navigateur
		return;
	}
	// lancement du thread qui va attendre la reponse a la requete ci-apres.
	// une fois la reponse recue, la fonction javascript de callback "popupResult" sera appelee
	req.onreadystatechange = getReadyStateHandler(req, popupResult);
	// preparation et envoi de la requete avec les parametres qui vont bieng
 	req.open("POST", prefixeURL + "../p/ba/recherche/autocompletion.html", true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send("prefixe=" + motClef);
}

/*
 * Fonction de callback qui met a jour de l'etat du bloc (html) suite au traitement cote serveur
 */
function popupResult(resultXML) {

	// recuperation du flux xml genere cote serveur
	var htmlContent = "";
	var nbMots = resultXML.getElementsByTagName("mot").length;
	if (nbMots > 0) {
		// on va creer le contenu du bloc d'aide en html a l'aide de balise <div>
		for (var i = 0; i < nbMots; i++) {
			htmlContent += "<div><span>" + resultXML.getElementsByTagName("mot")[i].firstChild.nodeValue + "</span></div>";
		}
		// une fois que le code html est genere, on remplit le block avec le code que l'on
		// vient de generer...
		remplir(htmlContent);
		// ...et on affiche le block
    	document.getElementById("autocomplete").style.display = "block";
   	} else { // aucun mot trouve, on cache le bloc d'aide
	   	document.getElementById("autocomplete").style.display = "none";
   	}
}

/*
 * rempli le bloc avec du code html
 */
function remplir(sHTML){

	document.getElementById("autocomplete").innerHTML = sHTML;
	var nodes = document.getElementById("autocomplete").childNodes;
	// on en profite pour gerer les evenements "souris"
	for(var i = 0; i < nodes.length; i++){
		// sur le onmouseover, on met le <div> en surbrillance
		nodes[i].onmouseover = function(){ this.className = "highlight"; }
		// sur le onmouseout, on ne fait rien
		nodes[i].onmouseout = function(){ this.className = ""; }
		// sur le onclick, on affecte le texte courant au champ texte et on cache la zone d'aide
		nodes[i].onclick = function(){
			document.getElementById("motClef").value = this.getElementsByTagName("span")[0].innerHTML;
			document.getElementById("motClef").focus();
			document.getElementById("autocomplete").style.display = "none";
		}
	}
}

/**
 * Affiche le contrat dans une popup
 */
var hrefContrat;
function ouvrirPopupContrat(lienId){
	//alert('ouvrirPopup');
	lien = document.getElementById(lienId);
	href = lien.getAttributeNode('href');
	valHref = href.nodeValue;
	if (valHref != 'javascript:void(0)'){
		hrefContrat = valHref;
	} else {
		valHref = hrefContrat;
	}
	lien.removeAttributeNode(href);
		
	href = document.createAttribute('href');
	href.nodeValue='javascript:void(0)';
	lien.setAttributeNode(href);
	
	target = lien.getAttributeNode('target');
	if (target){
		lien.removeAttributeNode(target);
	}
	
	window.open(valHref,'contratpdf', 'menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=660,height=570');
	
}

function prepareAutocomplete(champId) {
	champ = document.getElementById(champId);
	if (champ) {
		autocompl = champ.getAttributeNode('autocomplete');
		if (autocompl){
			champ.removeAttributeNode(autocompl);
		}
		autocompl = document.createAttribute('autocomplete');
		autocompl.nodeValue = 'off';
		champ.setAttributeNode(autocompl);
	}
}
function goDevis() {
	var newWindow = window.open("bamdocs/http/html/assuranceauto.html","AssuranceAuto", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=650,height=450");
}
var hrefDevis;
function ouvrirPopupDevis(lienId,titrefenetre,hauteur,largeur,scroll){
	//alert('ouvrirPopup');
	lien = document.getElementById(lienId);
	href = lien.getAttributeNode('href');
	valHref = href.nodeValue;
	if (valHref != 'javascript:void(0)'){
		hrefDevis = valHref;
	} else {
		valHref = hrefDevis;
	}
	lien.removeAttributeNode(href);
		
	href = document.createAttribute('href');
	href.nodeValue='javascript:void(0)';
	lien.setAttributeNode(href);
	
	target = lien.getAttributeNode('target');
	if (target){
		lien.removeAttributeNode(target);
	}
	windowOptions = 'menubar=no,toolbar=noresizable=yes,width='+largeur+',height='+hauteur;
	if (scroll){
		windowOptions += ',scrollbars='+scroll;
	} else {
		windowOptions += ',scrollbars=yes';
	}
	window.open(valHref,'Devis', windowOptions);
	
}
var hrefPopup = new Array();
function ouvrirPopup(lienId,titrefenetre,hauteur,largeur){
	//alert('ouvrirPopup');
	lien = document.getElementById(lienId);
	href = lien.getAttributeNode('href');
	valHref = href.nodeValue;
	if (valHref != 'javascript:void(0)'){
		var lienExiste = false;
    for (i=0;i<hrefPopup.length;i++){
      if ((hrefPopup[i])[0]==lienId){
        lienExiste = true;
      }
    }
    //alert('lienExiste ? '+lienExiste);
    if (!lienExiste){
      hrefPopup.push(new Array(lienId,valHref));
      //alert(hrefPopup.join());
    }
	} else {
		for (i=0;i<hrefPopup.length;i++){
      if ((hrefPopup[i])[0]==lienId){
        valHref = (hrefPopup[i])[1];
      }
    }
    //alert('valHref = '+valHref);
	}
	lien.removeAttributeNode(href);
		
	href = document.createAttribute('href');
	href.nodeValue='javascript:void(0)';
	lien.setAttributeNode(href);
	
	target = lien.getAttributeNode('target');
	if (target){
		lien.removeAttributeNode(target);
	}
	
	window.open(valHref,'Devis', 'menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=250,top=100,width='+largeur+',height='+hauteur);
	
}

/***********************  Demande doc AccordAvenir  *******************************/
function afficherNumeroCarte(ligneId, blocId, champId, lignePrecId){
	
	bloc = document.getElementById(blocId);
	var ligneNumCarte = document.getElementById(ligneId);
	
	if (!ligneNumCarte){
		ligne = document.createElement('p');
		idLigne = document.createAttribute('id');
		idLigne.nodeValue = ligneId;
		ligne.setAttributeNode(idLigne);
	
		label = document.createElement('label');
		forLabel = document.createAttribute('for');
		forLabel.nodeValue = champId;
		textLabel = document.createTextNode('Numéro de carte ');
		label.setAttributeNode(forLabel);
		label.appendChild(textLabel);
		
		input = document.createElement('input');
		typeInput = document.createAttribute('type');
		typeInput.nodeValue = 'text';
		idInput = document.createAttribute('id');
		idInput.nodeValue = champId;
		nameInput = document.createAttribute('name');
		nameInput.nodeValue = champId;
		valueInput = document.createAttribute('value');
		valueInput.nodeValue = '';
		mxlInput = document.createAttribute('maxlength');
		mxlInput.nodeValue='50';
		sizeInput = document.createAttribute('size');
		sizeInput.nodeValue='40';
	
		input.setAttributeNode(typeInput);
		input.setAttributeNode(idInput);
		input.setAttributeNode(nameInput);
		input.setAttributeNode(valueInput);
		input.setAttributeNode(mxlInput);
		input.setAttributeNode(sizeInput);
		
		ligne.appendChild(label);
		ligne.appendChild(input);
		
		lignePrec = document.getElementById(lignePrecId);
		bloc.insertBefore(ligne,lignePrec.nextSibling);
	}
	
}

function masquerNumeroCarte(idLigne, idBloc){
	bloc = document.getElementById(idBloc);
	var ligneNumCarte = document.getElementById(idLigne);
	
	if (ligneNumCarte){
		bloc.removeChild(ligneNumCarte);
	}
}

function visibilite(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
//--></script>

