window.onload = function () {
		genererLiensExternes();
		loadProduct();
	};

//fonction pour la navigation en ajax
function continuer(strPage)
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById("capsule").innerHTML = xmlHttp.responseText;
			var myDiv=document.getElementById("divlisteproduits");
			if(myDiv!=null&&myDiv.scrollUpdate) myDiv.scrollUpdate(); 
		}
	}
	xmlHttp.open("GET","intro/" + strPage,true);
	xmlHttp.send(null);
	
	return false;
}

//tracking de la capsule
function tracker(page, categorie, sexe, type)
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	try
	{
		xmlHttp.open("GET","intro/tracker.jsp?page=" + page + "&categorie=" + categorie + "&sexe=" + sexe + "&type=" + type,true);
		xmlHttp.send(null);
	}
	catch(e)
	{ }

	//return false;
}

function passageFlashHtml(strMarqueur)
{
	strPage = trouverPageProgres(strMarqueur);
	objCapsuleFlash = document.getElementById("capsuleflash");
	objParent = objCapsuleFlash.parentNode;
	
	var newDiv = document.createElement("div");
	newDiv.id = "capsule";
	objParent.replaceChild(newDiv, objCapsuleFlash);
	creerCookie("flash_less", 1, 365);
	continuer(strPage);
}

function creerCookie(c_name,value,expiredays)
{
	var exdate = new Date()
	exdate.setDate(exdate.getDate() + expiredays)
	document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires=" + exdate.toGMTString() + ";path=/")
}

function passageHtmlFlash(strProvince, strPage, langue)
{
	if ( validerPlugiciel("Shockwave Flash", 8) )
	{
		var objCapsuleHtml = document.getElementById("capsule");
		objParent = objCapsuleHtml.parentNode;
	
		var capsuleFlash = document.createElement("div");
		capsuleFlash.id = "capsuleflash";
		
		creerCookie("flash_less", "0", 365);
		creerCookie("etat", "-1", 365);
	
		objParent.replaceChild(capsuleFlash, objCapsuleHtml);
	
		var flashID = "presentation_accueil";
		//var flashObject = new SWFObject("../media/commun/axa.swf?lang=" + langue + "&prov=" + strProvince + "&page=" + strPage, flashID, "530", "221", "8", "#FFF");
		var flashObject = new SWFObject("../media/commun/axa.swf?lang=" + langue + "&prov=" + strProvince, flashID, "530", "221", "8", "#FFF");
		flashObject.addParam("allowscriptaccess", "always");
		flashObject.addParam("wmode", "transparent");
		flashObject.write("capsuleflash");
	
		var eObject = document.getElementById(flashID);
	}
	else
	{
		continuer("choix.jsp");
	}

	return false;
}

function trouverPageProgres(strMarqueur)
{
	strPage = "intro.jsp";
	if(strMarqueur == "intro") { strPage = "intro.jsp"; }
	else if(strMarqueur == "types") { strPage = "produits_types.jsp"; }
	else if(strMarqueur == "age") { strPage = "produits_types.jsp"; }
	else if(strMarqueur == "sexe") { strPage = "produits_types.jsp"; }
	else if(strMarqueur == "categories") { strPage = "produits_categories.jsp?from=flash"; }
	else if(strMarqueur == "liste") { strPage = "produits_categories.jsp?from=flash"; }
	return strPage;
}

//fonction pour resetter les cookies de la capsule d'intro quand on navigue avec le menu déroulant
function resetCookiesCapsule()
{
	creerCookie("etat", 0, 365);
	creerCookie("axa_cType", "", 365);
}

//fonction pour le sondage en page d'accueil
function soumettreSondage(valeurSondage, idSondage)
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById("zoneSondage").innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","resultats.jsp?idSondage=1&action=reponse&reponsesSondage=" + valeurSondage,true);
	xmlHttp.send(null);
	
	return false;
}

//fonction pour le sondage en page d'accueil
function soumettreSondage1(valeurSondage, idSondage)
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById("zoneSondage").innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","resultats1.jsp?idSondage=" + idSondage + "&action=reponse&reponsesSondage=" + valeurSondage,true);
	xmlHttp.send(null);
	
	return false;
}

//Verifie que l'usager a selectionne une reponse pour soumettre le sondage
function verifierSelection(objForm)
{
	var valide = false;
	var valeurSondage = 0;
	fichierXml = objForm.fichierXml.value;
	for(i = 0; i < objForm.reponsesSondage.length; i++)
	{
		if(objForm.reponsesSondage[i].checked)
		{
			valide = true;
			valeurSondage = objForm.reponsesSondage[i].value;
		}
	}
	if(valide)
	{
		soumettreSondage(valeurSondage, fichierXml);
	}
}

//Verifie que l'usager a selectionne une reponse pour soumettre le sondage
function verifierSelection1(objForm)
{
	var valide = false;
	var valeurSondage = 0;
	idSondage = objForm.idSondage.value;
	for(i = 0; i < objForm.reponsesSondage.length; i++)
	{
		if(objForm.reponsesSondage[i].checked)
		{
			valide = true;
			valeurSondage = objForm.reponsesSondage[i].value;
		}
	}
	if(valide)
	{
		soumettreSondage1(valeurSondage, idSondage);
	}
}

/*function qui affiche le sous menu dpendemment de la page*/
function shMenu(objLien)
{
	//if(document.getElementById("contenuPage"))
	//{
		if(document.getElementById("ul" + objLien.id))
		{
			if(document.getElementById("ul" + objLien.id).style.display == "none")
			{
				document.getElementById("ul" + objLien.id).style.display = "block";
			}
			else
			{
				document.getElementById("ul" + objLien.id).style.display = "none";
			}
		}
	//}
	return false;
}

/*cache/affiche la liste des produits sous la capsule*/
function showHideBlocProducts(strIdObj)
{
	if(document.getElementById(strIdObj) != null)
	{
		if(document.getElementById(strIdObj).style.display == 'block')
		{
			document.getElementById(strIdObj).style.display = 'none';
		}
		else
		{
			document.getElementById(strIdObj).style.display = 'block';
		}
	}
	return false;
}

/*gere et affiche le bloc de contenu selectionne*/
var idContentActif = "ap1";
var idCatContentActif = "";
function showhide(objLien)
{
	if(document.getElementById("divp0"))
	{
		document.getElementById("divp0").style.display = "none";
	}
	lienActif = document.getElementById(idContentActif);
	lienActif.parentNode.className = "";
	var idDivContent = idContentActif.replace(/a/, "div");
	document.getElementById(idDivContent).style.display = "none";
	var idDivToShow = objLien.id.replace(/a/, "div");
	objLien.parentNode.className = "actif";
	document.getElementById(idDivToShow).style.display = "block";
	idContentActif = objLien.id;
	return false;
}

function showhideFAQ(objLien)
{
	var idDivContent = idContentActif.replace(/a/, "div");
	var idDivToShow = objLien.id.replace(/a/, "div");
	if(document.getElementById(idDivToShow).style.display == "block")
	{
		document.getElementById(idDivToShow).style.display = "none";
	}
	else
	{
		document.getElementById(idDivContent).style.display = "none";
		document.getElementById(idDivToShow).style.display = "block";
		idContentActif = objLien.id;
	}
	return false;
}

function showhideCatFAQ(strIdShowHide)
{
	if(document.getElementById(strIdShowHide))
	{
		if(document.getElementById(strIdShowHide).style.display == "block")
		{
			document.getElementById(strIdShowHide).style.display = "none";
			idCatContentActif = "";
		}
		else
		{
			if(document.getElementById(idContentActif.replace(/a/, "div"))) { document.getElementById(idContentActif.replace(/a/, "div")).style.display = "none"; }
			if(document.getElementById(idCatContentActif)) { document.getElementById(idCatContentActif).style.display = "none"; }
			document.getElementById(strIdShowHide).style.display = "block";
			idCatContentActif = strIdShowHide;
		}
	}
	return false;
}

/* fonction qui ferme toutes les catégories de la faq et les questions/réponses après le pageload */
function closeAllFAQ()
{
	var counter = 1;
	var endfound = false;
	while(!endfound)
	{
		if(document.getElementById("ul_cat_faq_" + counter))
		{
			document.getElementById("ul_cat_faq_" + counter).style.display = "none";
		}
		else
		{
			endfound = true;
		}
		counter++;
	}

	counter = 1;
	endfound = false;
	while(!endfound)
	{
		if(document.getElementById("divp" + counter))
		{
			document.getElementById("divp" + counter).style.display = "none";
		}
		else
		{
			endfound = true;
		}
		counter++;
	}
}

/*Fonctions et variable pour gérer l'affichage des conseils pratiques*/
var idTipActif = "tip1";

function showhideTips(idTip)
{
	if(document.getElementById(idTip).style.display == "block" || document.getElementById(idTip).style.display == "")
	{
		document.getElementById(idTip).style.display = "none";
	}
	else
	{
		document.getElementById(idTipActif).style.display = "none";
		document.getElementById(idTip).style.display = "block";
		idTipActif = idTip;
	}
	return false;
}

function hideTips()
{
	i = 1;
	while(document.getElementById("tip" + i))
	{
		document.getElementById("tip" + i).style.display = "none";
		i++;
	}
}

function showhideConditions(idCondition)
{
	if(document.getElementById(idCondition).style.display == "block")
	{
		document.getElementById(idCondition).style.display = "none";
	}
	else
	{
		document.getElementById(idCondition).style.display = "block";
	}
	return false;
}

/*active le lien de la page en cours dans le menu*/
/*function activerLien(){
	var adresse = location.pathname;
	var positionDernierSlash = adresse.lastIndexOf("s/");
	var page = adresse.substring(positionDernierSlash);
	var aLiens = document.links;
	for(var i = 0; i < aLiens.length; i++)
	{
		if(aLiens[i].href.indexOf(page) != -1 && aLiens[i].href.indexOf("#") == -1)
		{
			aLiens[i].className += " actif";
		}
	}
	initialiserMenu(adresse);
}*/

function activerLien(){
	var adresse = location.pathname;
	var positionDernierSlash = adresse.lastIndexOf("s/");
	var page = adresse.substring(positionDernierSlash);
	var aLiens = document.links;
	for(var i = 0; i < aLiens.length; i++)
	{
		if((aLiens[i].href.indexOf(page) != -1 && aLiens[i].href.indexOf("#") == -1) || (page.indexOf("/automobile/") != -1 && (aLiens[i].href.indexOf("automobile-particulier.jsp") != -1 || aLiens[i].href.indexOf("automobile-personal.jsp") != -1)))
		{
			aLiens[i].className += " actif";
		}
	}
	initialiserMenu(adresse);
}

function initialiserMenu(strUri)
{
	//if(document.getElementById("contenuPage"))
	//{
		var i = 1;
		var aListeLettres = new Array("a", "b", "x", "y", "z");
		for(index = 0; index < aListeLettres.length; index++)
		{
			while(i != -1)
			{
				if(document.getElementById(aListeLettres[index] + i))
				{
					if(document.getElementById("ul" + aListeLettres[index] + i))
					{
						if(!trouverParent(document.getElementById("ul" + aListeLettres[index] + i), "contenuPage")) // si !trouve == menu
							document.getElementById("ul" + aListeLettres[index] + i).style.display = "none";
					}
					i++;
				}
				else
				{
					i = -1;
				}
			}
			i = 1;
		}
		//check pour une page de proprit
		if((strUri.indexOf("Produits") != -1 && strUri.indexOf("/automobile/") == -1)
		    || (strUri.indexOf("Products") != -1 && strUri.indexOf("/automobile/") == -1)
		    || strUri.indexOf("/assurance-auto") == (strUri.length - "/assurance-auto".length)
			|| strUri.indexOf("/auto-insurance") == (strUri.length - "/auto-insurance".length))
		{
			document.getElementById("ula1").style.display = "block";
			i = 1;
			while(i != -1)
			{
				if(document.getElementById("x" + i))
				{
					if(document.getElementById("ulx" + i))
					{
						k = 1;
						while(k != -1)
						{
							if(document.getElementById("x" + i + "a" + k))
							{
								objLien = document.getElementById("x" + i + "a" + k);
								positionDernierSlashUri = strUri.lastIndexOf("s/");
								pageEnCours = strUri.substring(positionDernierSlashUri);
								if(objLien.href.indexOf(pageEnCours) != -1)
								{
								    document.getElementById("ulx" + i).style.display = "block";
								}
								k++;
							}
							else
							{
								k = -1;	
							}
						}
					}
					i++;
				}
				else
				{
					i = -1;
				}
			}
		}
		else if(strUri.indexOf("Notre-entreprise") != -1 || strUri.indexOf("Our-company") != -1)
		{
			if(document.getElementById("ula4") != null) { document.getElementById("ula4").style.display = "block"; }
			//else if(document.getElementById("ula4") != null) { document.getElementById("ula4").style.display = "block"; }
		}
		else if(strUri.indexOf("Salle-de-presse") != -1 || strUri.indexOf("Nous-joindre/info-media") != -1 || strUri.indexOf("Press-room") != -1 || strUri.indexOf("Join-Us/media-info.jsp") != -1)
		{
			document.getElementById("ulb3").style.display = "block";
		}
		else if(strUri.indexOf("/Droits/") != -1 || strUri.indexOf("/Rights/") != -1)
		{
			if(document.getElementById("ula3") != null) { document.getElementById("ula3").style.display = "block"; }
		}
	//}
}

/*fonction pour initialiser le menu pour le plan du site*/
function preparerPlan()
{
	compteur = 75;
	for(i = 0; i < document.links.length; i++)
	{
		if(trouverParent(document.links[i], "contenuPage") && document.links[i].href.indexOf("#") != -1)
		{
			//document.links[i].setAttribute("class", "titreSectionInactif");
			document.links[i].className = document.links[i].className + " titreSectionInactif";
			document.links[i].setAttribute("onclick", "return false;");
			if(!trouverParent(document.links[i], "filAriane"))
			{
				//verifier pour un sous-menu pour enlever l'id
				for(j = 0; j < document.links[i].parentNode.childNodes.length; j++)
				{
					if(document.links[i].parentNode.childNodes[j].nodeName == "UL")
					{
						document.links[i].parentNode.childNodes[j].id = "";
						//document.links[i].parentNode.childNodes[j].style.display = "block";
					}
				}
			}
		}
	}
}

/*initialise la liste des produits pour afficher dans l'accueil*/
function preparerListeProduits(strType)
{
	for(i = 0; i < document.links.length; i++)
	{
		if(trouverParent(document.links[i], "blocProduits") && document.links[i].href.indexOf("#") != -1)
		{
			document.links[i].className = document.links[i].className + " titreSectionInactif";
			document.links[i].setAttribute("onclick", "return false;");
			if(!trouverParent(document.links[i], "filAriane"))
			{
				//verifier pour un sous-menu pour enlever l'id
				for(j = 0; j < document.links[i].parentNode.childNodes.length; j++)
				{
					if(document.links[i].parentNode.childNodes[j].nodeName == "UL")
					{
						if(document.links[i].parentNode.childNodes[j].id == "ula1")
						{
							document.links[i].parentNode.childNodes[j].id = "ulproducts";
						}
						else
						{
							document.links[i].parentNode.childNodes[j].id = "";
						}
					}
				}
			}
		}
	}
	for(i = 0; i < document.links.length; i++)
	{
		if(document.links[i].id == "a1")
		{
			if(trouverParent(document.links[i], "blocProduits"))
			{
				document.links[i].innerHTML += " - " + strType;
				document.links[i].parentNode.innerHTML = insererOnClick(document.links[i].parentNode.innerHTML, "showHideBlocProducts('ulproducts')");
				
				for(k = 0; k < document.links[i].parentNode.childNodes.length; k++)
				{
					if(document.links[i].parentNode.childNodes[k].id == "ulproducts")
					{
						document.links[i].parentNode.childNodes[k].style.display = "none";
						k = document.links[i].parentNode.childNodes.length;
					}
				}
			}
		}
	}
}

/*Modifie le code html recu pour placer un appel à la fonction passée en paramètre dans le onclick de la première balise recontrée*/
function insererOnClick(strHtml, strCallFonction)
{
	position = strHtml.indexOf(">");
	if(position != -1)
	{
		//recherche d'un onclick déjà présent
		positionAction = strHtml.substring(0, position).indexOf("onclick=");
		if(positionAction != -1)
		{
			//recherche des délimiteurs de la valeur de onclick (apostrophes)
			strDelimiter = strHtml.charAt(positionAction + 8);
			if(strDelimiter != '"' && strDelimiter != "'")
			{
				strDelimiter = "";
			}
			else
			{
				longueurAction = strHtml.substring(positionAction + 8, strHtml.indexOf(strDelimiter, positionAction + 9) + 1).length;
				strHtml = strHtml.substring(0, positionAction) + " onclick=\"return " + strCallFonction + "\"" + strHtml.substring(positionAction + 8 + longueurAction);
			}
		}
		else
		{
			strHtml = strHtml.substring(0, position) + " onclick=\"return " + strCallFonction + "\"" + strHtml.substring(position);
		}
	}
	return strHtml;
}

/*recherche l'item strIdParent dans les parents d'un element, jusqu'au body*/
function trouverParent(objEnCours, strIdParent)
{
	trouve = false;
	parentCourant = objEnCours.parentNode;
	while(!trouve && parentCourant.nodeName != "BODY")
	{
		if(parentCourant.id == strIdParent)
		{
			trouve = true;
		}
		else
		{
			parentCourant = parentCourant.parentNode;
		}
	}
	return trouve;
}


//fonction qui affiche les coords de la ville et mets le lien  l'etat actif
function afficherCoord(refLien, refCoordVille){
	
	var conteneurCoor = document.getElementById("coordVille");
	var div_array = conteneurCoor.getElementsByTagName("div");
	//effacer les coords
	for ( var cDiv = 0; cDiv < div_array.length; cDiv++ ) {
		var nodeDiv = div_array[cDiv];
		nodeDiv.style.display = "none";
		}
	var conteneurVille = document.getElementById("villes");
	var a_array = conteneurVille.getElementsByTagName("a");
	for ( var cA = 0; cA < a_array.length; cA++ ) {
		var nodeA = a_array[cA];
		nodeA.className = "nonactif";	
		}
	
	//mettre le lien actif
	refLien.className = "actif";
	var lesCoord = document.getElementById(refCoordVille);
	lesCoord.style.display = "block";
	}
	
//fonction qui affiche les villes et mets le lien  l'etat actif
function afficherVille(refLien, refLesVilles, refCoord){
	var conteneurVille = document.getElementById("villes");
	var div_array = conteneurVille.getElementsByTagName("div");
	//effacer les villes
	for ( var cDiv = 0; cDiv < div_array.length; cDiv++ ) {
		var nodeDiv = div_array[cDiv];
		nodeDiv.style.display = "none";
		}
	//affiche les bonnes villes
	var lesVillesAfficher = document.getElementById(refLesVilles);
	lesVillesAfficher.style.display = "block";
	//mets tous les liens  inactif
	var lienVille_array = lesVillesAfficher.getElementsByTagName("a");
	for ( var cA = 0; cA < lienVille_array.length; cA++ ) {
		var nodeLienVille = lienVille_array[cA];
		nodeLienVille.className = "nonactif";	
		}
	//mets le premier lien actif
	var lepremierLien = lesVillesAfficher.getElementsByTagName("a")[0];
	lepremierLien.className = "actif";
	//mets tous les lien inactif
	var conteneurSecteur =  document.getElementById("secteurs");
	var a_array = conteneurSecteur.getElementsByTagName("a");
	for ( var cA = 0; cA < a_array.length; cA++ ) {
		var nodeA = a_array[cA];
		nodeA.className = "nonactif";	
		}
	
	//mets le lien actif
	refLien.className = "actif";
	
	//efface tous les coords
	var conteneurCoor = document.getElementById("coordVille");
	var div_array = conteneurCoor.getElementsByTagName("div");
	//effacer les coords
	for ( var cDiv = 0; cDiv < div_array.length; cDiv++ ) {
		var nodeDiv = div_array[cDiv];
		nodeDiv.style.display = "none";
		}
	//affiche le bon coord
	
	var leContenu = document.getElementById(refCoord);
	leContenu.style.display = "block";
	}


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Génére l'ouverture des liens externes dans une nouvelle fenêtre */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function genererLiensExternes() {
	
	var aAncres = document.getElementsByTagName("a");
	var eAncre;
	
	// Parcourt chacune des ancres de la page
	for ( var cAncres = 0; cAncres < aAncres.length; cAncres++ ) {
		eAncre = aAncres[cAncres];
		
		
		// L'URI de l'ancre ne comporte pas le domaine actuel (et n'est pas un lien de courriel), on l'ouvre donc dans une nouvelle page
		if ( eAncre.href ) {
			if ( eAncre.href.indexOf(document.domain) == -1 && eAncre.href.indexOf("javascript:") == -1 && eAncre.href.indexOf("mailto:") != 0 && !eAncre.onclick)
				eAncre.onclick = function () { window.open(this.href); return false; };
		}
	}
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Ouvrir feneter avec grandeur fixe Événement dans le onClick
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

// onclick="javascript:OpenNewWindow('src', 'coord', 400, 330, 0);return false;"

// Parameter(s):
//   - winPath    (string)
//   - winName    (string)
//   - winWidth   (int)
//   - winHeight  (int)
//   - Scrollable (int)

function OpenNewWindow(winPath, winName, winWidth, winHeight, winScrollable){
  var winLeft = (screen.width - winWidth) / 2;
  var winTop = (screen.height - winHeight ) / 2;
  var theWindow = window.open(winPath, winName, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+winScrollable+',resizable=0,width='+winWidth+',height='+winHeight+',screenX='+winLeft+',screenY='+winTop+',left='+winLeft+',top='+winTop+'');
  theWindow.opener = self;
  theWindow.focus();
  return theWindow;
}

function OpenNewWindowBrokers(swinLanguage){
	var swinPath = "";
	if (swinLanguage == "fr" )
	{
		swinPath = "http://www1.axa.ca/axainternetwebapp/client/brokerSearch/fr/a5_1.jsp" ;

	}else{

		swinPath = "http://www1.axa.ca/axainternetwebapp/client/brokerSearch/en/a5_1.jsp" ;
	}
	
	return OpenNewWindow(swinPath, 'Broker', 600, 500, 1);

}


function ouvrirContactCourtier( uri ) {
	var largeur = 550;
	var hauteur = 500;
	
	var posX = (screen.availWidth / 2) - (largeur / 2);
	var posY = (screen.availHeight / 2) - (hauteur / 2);
	
	window.open( uri, "ContactCourtier", "left=" + posX + ",top=" + posY + ",width=" + largeur + ",height=" + hauteur + ",resizable=yes,scrollbars=yes" );
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Valide si le fureteur possede le plugiciel requis     */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function validerPlugiciel( sPlugiciel, iVersion ) {
	if ( navigator.appName.indexOf("Explorer") == -1 ) {
		if ( navigator.plugins ) {
			if ( oPlugiciel = navigator.plugins[sPlugiciel] ) {
				oPlugiciel.version = parseInt( oPlugiciel.description.replace( /^[^\d]*/, '' ) );
				
				if ( oPlugiciel.version >= iVersion )
					return true;
				else
					return false;
			}
		}
	} else {
		var reqVer = parseFloat(iVersion + "." + 0);
		for ( var compteur = 25; compteur > 0; compteur--) {	
			var versionStr = detecterFlashIeWin(compteur);
			
			if ( versionStr == -1 ) { 
				return false;
			} else if ( versionStr != 0 ) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				

				versionMajor      = versionArray[0];
				versionMinor      = versionArray[1];
				versionRevision   = versionArray[2];
				
				versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
				versionNum        = parseFloat(versionString);
				
				if ( (versionMajor > iVersion) && (versionNum >= reqVer) ) {
					return true;
				} else {
					return ((versionNum >= reqVer && versionMinor >= 0) ? true : false );	
				}
			}
		}	
		return (reqVer ? false : 0.0);
	}	
}

/* Vérifie si on doit afficher un produit en particulier passé en paramètre */
function loadProduct()
{
    if(location.hash)
    {
        if(document.getElementById(location.hash.substr(1)))
        {
            showhide(document.getElementById(location.hash.substr(1)));
        }
    }
}

/* Fonctions pour la recherche avec SES */
function GetOptionFromUrl (optionName)
{
	var str = window.location.href;
	var ind = str.indexOf (optionName + '=');
	if (ind != -1)
	{
		var optEnd = str.indexOf ('&', ind + optionName.length + 1);
		if (optEnd == -1)
		{
			return unescape (str.substr (ind + optionName.length + 1));
		}
		else
		{
			return unescape (str.substring (ind + optionName.length + 1, optEnd));
		}
	}
	return 0;
}

function ReplaceAll (str, src, trg)
{
	var s = str;
	var start = 0;
	while(true)
	{
		var ind = s.indexOf(src, start);
		if (ind == -1)
		{
			break;
		}
		s = s.substring (0, ind) + trg + s.substr (ind + src.length);
		start = ind + trg.length;
	}
	return s;
}

function FindAllFormItems (form)
{
	var els = new Array ();
	if (form)
	{
		var ar = form.elements;
		var i;
		for(i=0;ar && i<ar.length;i++)
		{
			if (ar [i].name)
			{
				els [els.length] = ar [i].name;
			}
		}
	}
	return els;
}

function ConvertUtf8 (input)
{
	var output = '';
	for (var n = 0; n < input.length; n++)
	{
		var c = input.charCodeAt (n);
		if (c < 128) output += String.fromCharCode (c);
		else if ((c > 191) && (c < 224))
		{
			output += String.fromCharCode (((c & 31) << 6) | (input.charCodeAt (n + 1) & 63));
			n++;
		}
		else
		{
			output += String.fromCharCode (((c & 15) << 12) | ((input.charCodeAt (n + 1) & 63) << 6) | (input.charCodeAt (n + 2) & 63));
			n+=2;
		}
	}
	return output;
}

function UrlToFormItems (form)
{
	var els = FindAllFormItems (form);
	var i;
	var bUTF8 = true;
	for (i = 0; els && i < els.length; i++)
	{
		var nm = els [i];
		var val = GetOptionFromUrl (nm);
		if (form)
		{
			if (val)
			{
				if(nm && (nm.substr (0,1) == 'q' || nm.substr (0,2) == 'fq')) val = ReplaceAll (val, '+', ' ');
				else if(nm == 'enc' && val.toLowerCase() == 'iso-8859-1') bUTF8 = false;
				else if(nm == 'ae' && val.charCodeAt(0) == 223) {bUTF8 = false;continue;}
			}
			var el = form.elements [nm];
			if (el && val)
			{
				if (el.type == 'checkbox') el.checked = val;
				else if (el.type == 'select-one')
				{
					for (option = 0; option < el.options.length; option++) if (el.options [option].value == val) el.options [option].selected = 1;
				}
				else if (el.length)
				{
					for (j = 0; j < el.length; j++) if (el [j].value == val) el [j].checked = true;
				}
				else
				{
					if(nm == 'enc') el.value = 'utf-8';
					else el.value = (bUTF8 ? ConvertUtf8 (val) : val);
				}
			}
		}
	}
	document.bAnsi = !bUTF8;
}

function ClearSearchResults (resultsCodePart)
{	
	document.searchResultCode = '';
}

function AddToSearchResults (resultsCodePart)
{
	document.searchResultCode = document.searchResultCode + resultsCodePart;	
}

function ApplySearchResultsCode ()
{
	var resultsDiv = document.getElementById ('SearchResults');

	if (resultsDiv && document.searchResultCode)
	{
		resultsDiv.innerHTML = document.searchResultCode;
	}
}

function emptyDefaultValue(objChamp, strValue)
{
	if(objChamp.value.toLowerCase() == strValue.toLowerCase())
	{
		objChamp.style.color = "#000";
		objChamp.value = "";
		objChamp.maxLength = 3;
	}
}

function checkTransition(objChamp, objNextChamp, strDefaultValueNext)
{
	if(objNextChamp) { if(objChamp.value.length == objChamp.maxLength) { objNextChamp.focus(); emptyDefaultValue(objNextChamp, strDefaultValueNext); } }
}