/*
Initialisation des variables global.
*/
var boolExpandTree      = false; 
var gstrThemeCourante   = new String("");
var gstrNoPlateforme    = new String("");
var gstrNoLangue        = new String("");
var gstrRegion          = new String("");
var gstrExpertise       = new String("");
var gstrLangue          = new String("");
var gstrIdMembre        = new String("0");
var gstrCodeMembre      = new String("0");
var gstrPayeur          = new String("0");
var gstrNomMembre       = new String("");
var gstrNoThemeCourante = new String("");
var gstrCatParent       = new String("");
var gstrCatEnfant       = new String("");

var oImgBtnMIN_on = new Image();
oImgBtnMIN_on.src = "/_SITE/FIQ/RECHERCHE/rech_bt_minON.jpg";

var oImgBtnMAX = new Image();
oImgBtnMAX.src = "/_SITE/FIQ/RECHERCHE/rech_bt_max.jpg";

var oImgBtnMIN = new Image();
oImgBtnMIN.src = "/_SITE/FIQ/RECHERCHE/rech_bt_min.jpg";

var oImgBtnMAX_on = new Image();
oImgBtnMAX_on.src = "/_SITE/FIQ/RECHERCHE/rech_bt_maxON.jpg";

var oImgCarrePlus = new Image();
oImgCarrePlus.src = "/_site/FIQ/recherche/rech_ticarreplus.gif";

var oImgCarreMoin = new Image();
oImgCarreMoin.src = "/_site/FIQ/recherche/rech_ticarreminus.gif";

var oImgOngletOn = new Image();
oImgOngletOn.src = "/_site/FIQ/RECHERCHE/rech_ongletON.jpg";

var oImgOngletOff = new Image();  
oImgOngletOff.src = "/_site/FIQ/RECHERCHE/rech_ongletOFF.jpg";

var oImgFichePlus = new Image();  
oImgFichePlus.src = "/_SITE/FIQ/template/images/bt_ouvert.gif";

var oImgFicheMoin = new Image();  
oImgFicheMoin.src = "/_SITE/FIQ/template/images/bt_ferme.gif";


var whichlink = 0;
var whichimage = 0;
var pixeldelay = 0; //(ie55)? document.images.slide.filters[0].duration*1000 : 0

//specify interval between slide (in mili seconds)
var slidespeed = 12000;
//specify images

var imageholder = new Array();
var linkholder = new Array();
var ie55 = window.createPopup;


var slideimages = new Array();
//specify corresponding links
//var slidelinks = new Array();

function openWiz(url, redirect)
{
	var oLink = {href: "",name: "",title: null,target: null,className: null,style: null};
	width = 700;
	height = 575;
	//alert("wbservice");
	if (url.indexOf("http:") == -1)
	{
		url = "http://" + url;
	}

	if (redirect == "true")
	{
		location.href = url;	
	} else {
		str = window.showModalDialog(url + "&WebbyzzLoggedIn=6144","", "status:no; center:yes; help:no; minimize:no; maximize:no; scroll:auto; border:thin; statusbar:no; dialogWidth:" + width + "px; dialogHeight:" + height + "px");
//	alert(oLink.href)
		if (str != "" && str != undefined)
			{
			location.href = str;
			}
		}
	
}

function slideit(plage)
{
	//try{
		//reloadImages()
		cpt = 0;
		for (i=0;i<slideimages.length;i++)
			{
			//alert(slideimages[i][2])
			
			if (plage == slideimages[i][2])
				{
				imageholder[cpt]=new Image()
				imageholder[cpt].src=slideimages[i][0]
				linkholder[cpt]=new Object;
				linkholder[cpt].href=slideimages[i][1];
				cpt=cpt+1
				}
			}

		if (!document.images) return
		//if (ie55) document.images.slide.filters[0].apply()
		//alert(eval("document.images." + plage + ".src"))
		var docImg = eval("document.images." + plage)
		var docLink = document.getElementById(plage + "_link")
		docImg.src=imageholder[whichimage].src
		docLink.href=linkholder[whichimage].href
		docLink.target='_blank'
		//if (ie55) document.images.slide.filters[0].play()
		whichlink=whichimage
		whichimage=(whichimage<imageholder.length-1)? whichimage+1 : 0
		setTimeout("slideit('"+plage+"')",slidespeed+pixeldelay)
	//}catch(e){}
}

function validateKey(pevent, pstrLangue, pstrAction)
{
	var charCode = pevent.keyCode;

	if (charCode == 13) //Touche enter
	{
		if(pstrAction == "search")
		{
			findResult(gstrNoThemeCourante, pstrLangue, gstrThemeCourante, gstrCatParent, gstrCatEnfant); 
			return;
		}
		if(pstrAction == "login")
		{
			validerLogin();
			return;
		}
	}
}

function ValiderLogin(pUser, pPwd)
{
	var strMessage = "";
	//alert(pUser + " " + pPwd);
	if (pUser != "") {
		if (document.getElementById("xcodeuser").value == "") {
			strMessage = strMessage + "Vous devez entrer un nom d'usager\n";
		}
	}
	
	if (pPwd != "") {
		if (document.getElementById("xpassword").value == "") {
			strMessage = strMessage + "Vous devez entrer un mot de passe\n";
		}
	}

	if (strMessage != "") {
		alert(strMessage);
		return false;
	}

	return true;
}

function CancelAction(obj)
{
	window.event.cancelBubble = true;
	window.event.returnValue  = false;
	obj.focus();

	return false;
}

function refreshTimer()
{
	document.getElementById("img_wait").src = "/_SITE/FIQ/TEMPLATE/IMAGES/timer60_1sc.gif";
}

function boiteMessage(pstrNomDiv)
{
	var intOffsetTop = 0;
	var intOffsetWidth = 0;

	intOffsetTop = document.body.scrollTop;
	intOffsetWidth = document.body.scrollLeft;
try
{
	document.getElementById(pstrNomDiv).style.top = window.event.y + intOffsetTop;
	document.getElementById(pstrNomDiv).style.left = window.event.x + intOffsetWidth;
}
catch (e)
{
document.getElementById(pstrNomDiv).style.top = 200+ intOffsetTop;
	document.getElementById(pstrNomDiv).style.left = 200+ intOffsetWidth;
}
	
	
	if(document.getElementById(pstrNomDiv).style.display == "none")
	{
		document.getElementById(pstrNomDiv).style.display = "inline";
		setTimeout("refreshTimer()",100)
		return;
	}

	if(document.getElementById(pstrNomDiv).style.display == "inline")
	{
		document.getElementById(pstrNomDiv).style.display = "none";
		return;
	}
	
}

function validerLogin()
{
	var strCodeUser = new String(document.getElementById("txtUser").value);
	var strPassword = new String(document.getElementById("txtPassword").value);
	var strUrl = new String("");
	
	var boolSearch;
	boolSearch = false;

	if(strCodeUser == "")
	{
		boiteMessage("div_message");
		return;
	}

	if(strPassword == "")
	{
		boiteMessage("div_message");
		return;
	}

	var objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");

	strUrl = "xcodeuser=" + strCodeUser + "&xpassword=" + strPassword;

	objXMLHttp.open("GET", "/_system/FIQ/LOGIN/valider-login.asp?" + strUrl, false);
	objXMLHttp.setRequestHeader("MethodName", "enterOrder");
	objXMLHttp.setRequestHeader("MessageType", "Call");
	objXMLHttp.setRequestHeader("Content-Type", "text/xml-SOAP");

	objXMLHttp.send();

	strMessage = objXMLHttp.responseText;

	strSearch = /,/i;

	boolSearch = strMessage.search(strSearch);
	
	if (boolSearch != -1)
	{
		tabMembre = strMessage.split(",");
		gstrIdMembre      = tabMembre[0];
		gstrCodeMembre    = tabMembre[1];
		gstrNomMembre     = tabMembre[2];
		gstrPayeur        = tabMembre[3];
		if(gstrPayeur != "1")
		{
			gstrPayeur = "0";
		}
		affiche_console(1, '');
		document.getElementById("login").innerText = gstrNomMembre;
		boiteMessage("div_message_bienvenue");
		return;
	}
	else
	{
		boiteMessage("div_message");
		return;
	}

	delete objXMLHttp;
}


function changeBTN(pstrStatut)
{
	objImgMIN = document.getElementById("imgMIN")
	objImgMAX = document.getElementById("imgMAX")

	if(pstrStatut == 'min')
	{
		objImgMIN.src = oImgBtnMIN_on.src;			
		objImgMAX.src = oImgBtnMAX.src;

		boolExpandTree = false;
		objImgMIN.style.cursor = "default";
		objImgMAX.style.cursor = "hand";

		return;
	}
	else
	{
		objImgMIN.src = oImgBtnMIN.src;
		objImgMAX.src = oImgBtnMAX_on.src;

		boolExpandTree = true;
		objImgMIN.style.cursor = "hand";
		objImgMAX.style.cursor = "default";

		return;
	}
}

/*Naviguation ds le menu de Gauche Produits/Services
  Initialiser une variable pour la fonctionnalité du min et max.
  Ensuite se servir de cette variable pour soit laisser l'arbre toujours ouvert(Bouton Max)
  lors de l'action ou bien le fermé à chaque action si le (Bouton Min) est activé
	
  Par défaut l'arbre se referme toujours.
*/
function clicklevel(pstrTheme, pstrLevel, pstrTemp)
{
	if(pstrTheme == 0)
	{
		strSearchDiv = /div_menu0_3_/i;
		strSearchImg = /img0_3_/i;
	}
	else
	{
		strSearchDiv = /div_menu1_3_/i;
		strSearchImg = /img1_3_/i;
	}

	if (boolExpandTree == false)
	{
		var divArray = document.all.tags("div");
		for (var intCpt = 0; intCpt < divArray.length; intCpt++)
		{
		  strDivId = divArray[intCpt].id;
		  if(strDivId != "div_menu"+pstrTheme+"_"+pstrLevel+"_"+pstrTemp)
		  {
			  intResult = strDivId.search(strSearchDiv);
			  if (intResult != -1)
			   {
				divArray[intCpt].style.display = "none";
			   }
		  }
		}

		var imgArray = document.all.tags("IMG");
		for (var intCpt = 0; intCpt < imgArray.length; intCpt++)
		{
		  strImgId = imgArray[intCpt].id;
		  
		  intResult = strImgId.search(strSearchImg);
		  if (intResult != -1)
		   {
			imgArray[intCpt].src = oImgCarrePlus.src;
		   }
		}
	}
	

	if(document.getElementById("div_menu"+pstrTheme+"_"+pstrLevel+"_"+pstrTemp).style.display == "inline")
	{
		document.getElementById("div_menu"+pstrTheme+"_"+pstrLevel+"_"+pstrTemp).style.display = "none";

		if(pstrTheme == 0 && pstrLevel == 2 && pstrTemp == 0)
		{
			document.getElementById("img0_1_0").src = oImgCarrePlus.src;
		}
		else
		{
			document.getElementById("img"+pstrTheme+"_"+pstrLevel+"_"+pstrTemp).src = oImgCarrePlus.src;
		}
		
	}
	else
	{
		document.getElementById("div_menu"+pstrTheme+"_"+pstrLevel+"_"+pstrTemp).style.display = "inline";
		
		if(pstrTheme == 0 && pstrLevel == 2 && pstrTemp == 0)
		{
			document.getElementById("img0_1_0").src = oImgCarreMoin.src;	
		}
		else
		{
			document.getElementById("img"+pstrTheme+"_"+pstrLevel+"_"+pstrTemp).src = oImgCarreMoin.src;
		}
	}
	//alert(document.getElementById("div_menu"+pstrTheme+"_"+pstrLevel+"_"+pstrTemp).style.display);
	
}


function formatFiche(pstrIdDivProd, pstrIdDivEntreprise, pstrIdDivFiche, pstrIdImgFiche)
{
	var oDivProd;
	var oDivEntreprise;
	var oDivFiche;
	var oImgFiche;

	try
	{
		window.event.cancelBubble = true;
	}
	catch(e)
	{
	}

	
	oDivProd = document.getElementById(pstrIdDivProd);
	oDivEntreprise = document.getElementById(pstrIdDivEntreprise);
	oDivFiche = document.getElementById(pstrIdDivFiche);
	oImgFiche = eval("document.frm_result." + pstrIdImgFiche);
	
	if(oDivFiche.style.display == "inline" || oDivFiche.style.display == "block")// || oDivEntreprise.style.display == "inline")
	{
		oImgFiche.src = oImgFichePlus.src;
		//document.getElementById(pstrIdDivFiche).style.display = "none";

		if (oDivEntreprise != null && oDivEntreprise != "")
		{
			oDivEntreprise.style.visibility = "hidden";
			oDivEntreprise.style.display = "none";
			oDivEntreprise.style.visibility = "visible";
			//oDivEntreprise.style.visibility = "hidden";

		}
		
		if (oDivProd != null && oDivProd != "")
		{
			oDivProd.style.visibility = "hidden";
			oDivProd.style.display = "none";
			oDivProd.style.visibility = "visible";
		}
		oDivFiche.style.visibility = "hidden";
		oDivFiche.style.display = "none";
		

		return;
	}
	else
	{
		oImgFiche.src = oImgFicheMoin.src;
		//document.getElementById(pstrIdDivFiche).style.display = "block";
		//oDivFiche.style.display = "none";
		if (oDivEntreprise != null && oDivEntreprise != "")
		{
			oDivEntreprise.style.visibility = "visible";
			oDivEntreprise.style.display = "block";
			//oDivEntreprise.style.visibility = "visible";
		}
		
		if (oDivProd != null && oDivProd != "")
		{
			oDivProd.style.visibility = "visible";
			oDivProd.style.display = "block";
			//oDivProd.style.visibility = "visible";
		}
		oDivFiche.style.visibility = "visible";
		oDivFiche.style.display = "block";
		//oDivFiche.style.visibility = "visible";
		
		return;
	}
}


function findResult(pstrNoTheme, pstrLangue, pstrArbre, pstrCatParent, pstrCatEnfant)
{
	//document.getElementById("divDefault").style.cursor = 'wait';
	
	var strUrl       = new String("");
	var strNoFiltre1 = new String("");
	var strNoFiltre2 = new String("");
	var strNoFiltre3 = new String("");
	var intStart     = 1;
	var intQty;
	var strGabarit   = new String("recherche.xsl");
	var strMotCle    = new String("");
	var boolFicheOpen;
	var boolEntreprise;
	var boolProduitsServices;
	var strReg = "/";

	document.getElementById("filAriane").innerText = "";
	
	
	if(pstrCatParent != "")
	{
		pstrCatParent = pstrCatParent.replace(strReg, "'");
		document.getElementById("filAriane").innerText = document.getElementById("filAriane").innerText + pstrCatParent;
		gstrCatParent = pstrCatParent;
	}
	else
	{
		gstrCatParent = "";
	}

	if(pstrCatEnfant != "")
	{
		pstrCatEnfant = pstrCatEnfant.replace(strReg, "'");
		document.getElementById("filAriane").innerText = document.getElementById("filAriane").innerText + pstrCatEnfant;
		gstrCatEnfant = pstrCatEnfant;
	}
	else
	{
		gstrCatEnfant = "";
	}
	
	gstrNoThemeCourante = pstrNoTheme;
 
	//code = pstrNoTheme

	if(pstrArbre == "produits")
	{
		strNoFiltre1 = document.getElementById("plateforme").options[document.getElementById("plateforme").selectedIndex].value;
		strNoFiltre2 = document.getElementById("langueProduits").options[document.getElementById("langueProduits").selectedIndex].value;
		strNoFiltre3 = document.getElementById("clienteleProduits").options[document.getElementById("clienteleProduits").selectedIndex].value;
		
		
		if(pstrLangue == 1)
		{
			document.getElementById("filAriane").innerText = "Vous êtes ici: Produits" +  document.getElementById("filAriane").innerText;
		}
		else
		{
			document.getElementById("filAriane").innerText = "You are here: Products" +  document.getElementById("filAriane").innerText;
		}
	}
	if(pstrArbre == "services")
	{
		strNoFiltre1 = document.getElementById("region").options[document.getElementById("region").selectedIndex].value;
		strNoFiltre2 = document.getElementById("langueServices").options[document.getElementById("langueServices").selectedIndex].value;
		strNoFiltre3 = document.getElementById("clienteleServices").options[document.getElementById("clienteleServices").selectedIndex].value;
		
		//document.getElementById("filAriane").innerText = "Services" +  document.getElementById("filAriane").innerText;
		if(pstrLangue == 1)
		{
			document.getElementById("filAriane").innerText = "Vous êtes ici: Services" +  document.getElementById("filAriane").innerText;
		}
		else
		{
			document.getElementById("filAriane").innerText = "You are here: Services" +  document.getElementById("filAriane").innerText;
		}
	}

	intQty = document.getElementById("fichespage").options[document.getElementById("fichespage").selectedIndex].value;
	strMotCle = document.getElementById("motclefs").value;
	for(intCpt = 0; intCpt < document.all.fiches.length; intCpt++)
	{
		if(document.all.fiches[intCpt].checked == true)
		{
			boolFicheOpen = document.all.fiches[intCpt].value;
		}
	}		
		
	boolEntreprise = document.getElementById("Entreprise").checked;
	boolProduitsServices = document.getElementById("prod_serv").checked;

	strUrl = "params=" + intStart + "," + intQty + "," + pstrLangue + "," + pstrArbre + "," + pstrNoTheme + "," + strNoFiltre1 + "," + strNoFiltre2 + "," + strNoFiltre3 + "," + boolFicheOpen + ",recherche.xsl," + boolEntreprise + "," + boolProduitsServices + "," + strMotCle;
	
	//alert("Url recherche: " + strUrl);
	//return;

	//document.location.href = "/_system/FIQ/recherche/recherche.asp?" + strUrl;
	//return;
	
	var objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
	objXMLHttp.open("GET", "/_system/FIQ/recherche/recherche.asp?" + strUrl, false);
	objXMLHttp.setRequestHeader("MethodName", "enterOrder");
	objXMLHttp.setRequestHeader("MessageType", "Call");
	objXMLHttp.setRequestHeader("Content-Type", "text/xml-SOAP");

	objXMLHttp.send();

	strMessage = objXMLHttp.responseText;

	document.getElementById("div_result").innerHTML = strMessage;
	//document.getElmentById("divDefault").style.cursor = 'default';
	document.location.href = "#top";

	delete objXMLHttp;
}
	
function validerInfo()
{
	var strCourriel = new String("");

	if(document.all.xnom.value == "")
	{
		alert("Vous devez entrer votre nom.");
		return false;
	}
	if(document.all.xprenom.value == "")
	{
		alert("Vous devez entrer votre prénom.");
		return false;
	}
	if(document.all.xcourriel.value == "")
	{
		alert("Vous devez entrer votre courriel.");
		return false;
	}
	else
	{
		strCourriel = document.all.xcourriel.value;
		if(isEmail(strCourriel))
		{
			return true;
		}
		else
		{
			alert("Vous courriel est invalide.");
			return false;
		}
	}
	return true;
}

function NextPage(pstrNoPage, totalLiens, pageDecalage, pageQty, pageFin, pageGabarit, paramPagination, rechLangue)
	{
		//alert(pstrNoPage);

		var strUrl;
		var strMessage;
		var oMsg;
		
		oMsg = false;

		try {
			oMsg = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				oMsg = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				oMsg = false;
			}
		}

		if (!oMsg && typeof XMLHttpRequest!='undefined') {
			oMsg = new XMLHttpRequest();
		}

		strUrl = location.href.substring(location.href.lastIndexOf('?') + 1, location.href.length);

		strUrl = strUrl + "&pagination=1&pageCourante=" + pstrNoPage + "&totalLiens=" + totalLiens + "&pageDecalage=" + pageDecalage + "&pageQty=" + pageQty + "&pageFin=" + pageFin + "&pageGabarit=" + pageGabarit + "&paramPagination=" + paramPagination + "&rechLangue=" + rechLangue 

		if (strUrl != 0){	
		
			//alert(strUrl);
			oMsg.open("GET", "/_system/APFF/recherche/recherche.asp?" + strUrl, false)
			oMsg.setRequestHeader("MethodName", "enterOrder")
			oMsg.setRequestHeader("MessageType", "Call")
			oMsg.setRequestHeader("Content-Type", "text/xml-SOAP")

			oMsg.send(null)

			strMessage = oMsg.responseText
			//alert('StrMEssage:' + strMessage)
			if (strMessage.length > 10)
			{
				document.getElementById("wb_contenu_in").innerHTML = strMessage
			}

			document.getElementById("SEARCH").value = document.getElementById("C_SEARCH").value
		}
		delete oMsg;
	}


	function init()
	{
		var strUrl;
		var strMessage;
		var intPosPI;
		var oMsg;
		
		oMsg = false;

		try {
			oMsg = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				oMsg = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				oMsg = false;
			}
		}

		if (!oMsg && typeof XMLHttpRequest!='undefined') {
			oMsg = new XMLHttpRequest();
		}

		strUrl = location.href.substring(location.href.lastIndexOf('?') + 1, location.href.length);

		if (strUrl != 0){		
			strUrl = "/_system/APFF/recherche/recherche.asp?" + strUrl;
			oMsg.open("GET", strUrl, false);
			oMsg.setRequestHeader("MethodName", "enterOrder");
			oMsg.setRequestHeader("MessageType", "Call");
			oMsg.setRequestHeader("Content-Type", "text/xml-SOAP");
			
			oMsg.send(null);

			strMessage = oMsg.responseText;
			if (strMessage.length > 10)
			{
				document.getElementById("wb_contenu_in").innerHTML = strMessage
			}

			document.getElementById("SEARCH").value = document.getElementById("C_SEARCH").value
		}
		delete oMsg;
	}

/*function NextPage(pstrNoPage, totalLiens, pageDecalage, pageQty, pageFin, pageGabarit, paramPagination, rechLangue, pstrCode, pstrFiltre1, pstrFiltre2, pstrFiltre3, pstrAffFiche, pstrAffEntreprise, pstrAffProduitsServices, pstrMot, pstrTheme)
{
	//document.getElementById("divDefault").style.cursor = 'wait';
	
	var strUrl;
	var strMessage;
	var oMsg = new ActiveXObject("Microsoft.XMLHTTP");
	 
	strUrl = "";

	strUrl = "pagination=1&pageCourante=" + pstrNoPage + "&totalLiens=" + totalLiens + "&pageDecalage=" + pageDecalage + "&pageQty=" + pageQty + "&pageFin=" + pageFin + "&pageGabarit=" + pageGabarit + "&paramPagination=" + paramPagination + "&rechLangue=" + rechLangue + "&notheme=" + pstrCode + "&filtre1=" + pstrFiltre1 + "&filtre2=" + pstrFiltre2 + "&filtre3=" + pstrFiltre3 + "&affFiche=" + pstrAffFiche + "&affEntreprise=" + pstrAffEntreprise + "&affProduitsServices=" + pstrAffProduitsServices + "&mot=" + pstrMot + "&theme=" + pstrTheme;

	if (strUrl != ""){	
	
		strUrl = "/_system/FIQ/recherche/recherche.asp?" + strUrl
		//alert(strUrl);
		oMsg.open("GET", strUrl, false)
		oMsg.setRequestHeader("MethodName", "enterOrder")
		oMsg.setRequestHeader("MessageType", "Call")
		oMsg.setRequestHeader("Content-Type", "text/xml-SOAP")

		oMsg.send()

		strMessage = oMsg.responseText
		//alert('StrMEssage:' + strMessage)
		if (strMessage.length > 10)
		{
			document.getElementById("div_result").innerHTML = strMessage
		}
	}
	delete oMsg;

	document.location.href = "#top";
	//document.getElementById("divDefault").style.cursor = 'default';
}
*/
	
function resizeWind(pWindow)
{
	if(pWindow == "Formulaire_entreprise_produits")
	{
		
		window.moveTo(0,0);
		window.resizeTo(660,600);
		return;
	}
	if(pWindow == "login")
	{
		window.moveTo(0,0);
		window.resizeTo(655,500);
		return;
	}
}
/*function init(pstrOngletActif, pstrLangue) 
{
	gstrThemeCourante = pstrOngletActif;
	gstrLangue        = pstrLangue
	if(pstrLangue == "1")
	{
		switch (pstrOngletActif)
		{
		case "produits":
			document.getElementById("lblTheme").innerText = "Produits";
			document.getElementById("filAriane").innerText = "Vous êtes ici: Produits";
			break;
		case "services":
			document.getElementById("lblTheme").innerText = "Services";
			document.getElementById("filAriane").innerText = "Vous êtes ici: Services";
			break;
		}
		return;
	}
	if(pstrLangue == "2")
	{
		switch (pstrOngletActif)
		{
		case "produits":
			document.getElementById("lblTheme").innerText = "Products";
			document.getElementById("filAriane").innerText = "You are here: Products";
			break;
		case "services":
			document.getElementById("lblTheme").innerText = "Services";
		document.getElementById("filAriane").innerText = "You are here: Services";
			break;
		}
		return;
	}

	//alert(document.getElementById("plateforme").options[document.getElementById("plateforme").selectedIndex].value);
}
*/
function affiche_console(no, pstrVisite) {
  document.getElementById("div_login0").style.display="none";
  document.getElementById("div_login1").style.display="none";
  document.getElementById("div_login"+no).style.display="inline";

  if(no == 0)
 {
	document.getElementById("txtUser").value = "";
	document.getElementById("txtPassword").value = "";
	gstrIdMembre = "0";
	gstrCodeMembre = "0";
	gstrPayeur = "0";

	document.getElementById("login").innerText = "";
	boiteMessage("div_message_sessionEnd");
 }
  
  if(pstrVisite == "new")
  {
	document.getElementById("div_action_login").style.display = "none";
	boiteMessage("div_message_newUser");
	return;
  }
  else
  {
	document.getElementById("div_action_login").style.display = "inline";
	return;
  }
}
function select_plateforme(objet) {
 //alert (objet.selectedIndex)
}
function select_langue(objet) {
 //alert (objet.selectedIndex)
}
function select_region(objet) {
 //alert (objet.selectedIndex)
}
function select_expertise(objet) {
 //alert (objet.selectedIndex)
}

function select_motclef(objet) {
 var motclefs = document.getElementById('motclefs')
 motclefs.value += ' ' + objet.options[objet.selectedIndex].innerText
}

function input_go(pstrLangue) 
{
	findResult(gstrNoThemeCourante, pstrLangue, gstrThemeCourante, gstrCatParent, gstrCatEnfant); 
}

function affiche_aide(pstrNomDiv)
{
	if(document.getElementById(pstrNomDiv).style.display == "none")
	{
		document.getElementById(pstrNomDiv).style.display = "inline";
		return;
	}

	if(document.getElementById(pstrNomDiv).style.display == "inline")
	{
		document.getElementById(pstrNomDiv).style.display = "none";
		return;
	}
	
	
}

function rad_fiches(objet,ouvert) {
 //alert (objet.checked + " " + ouvert)
}
function chk_fiches(no,objet) {
 //alert (no + " " + objet.checked)
}

function select_fichespage(objet) {
 //alert (objet.options[objet.selectedIndex].value)
}

function affiche_catalogue(no) {
  //document.getElementById('cell_cat0').style.backgroundColor="transparent";
  //document.getElementById('cell_cat1').style.backgroundColor="transparent"; 
  //document.getElementById('cell_cat'+no).style.backgroundColor="blue";
  
  gstrCatParent = "";
  gstrCatEnfant = "";

  if(no == 0)
  {
	document.getElementById("cell_cat0").style.backgroundImage = "url("+oImgOngletOn.src+")";
	document.getElementById("cell_cat1").style.backgroundImage = "url("+oImgOngletOff.src+")";
	gstrThemeCourante = "produits";
	switch (gstrLangue)
	{
	case "1":
		document.getElementById("lblTheme").innerText = "Produits";
		document.getElementById("filAriane").innerText = "Vous êtes ici: Produits";
		findResult('', '1', 'produits', gstrCatParent, gstrCatEnfant);
		break;
	case "2":
		document.getElementById("lblTheme").innerText = "Products";
		document.getElementById("filAriane").innerText = "You are here: Products";
		findResult('', '2', 'produits', gstrCatParent, gstrCatEnfant);
		break;
	}
  }
  else
  {
	document.getElementById("cell_cat0").style.backgroundImage = "url("+oImgOngletOff.src+")";
	document.getElementById("cell_cat1").style.backgroundImage = "url("+oImgOngletOn.src+")";
	gstrThemeCourante = "services";
	switch (gstrLangue)
	{
	case "1":
		document.getElementById("lblTheme").innerText = "Services";
		document.getElementById("filAriane").innerText = "Vous êtes ici: Services";
		findResult('', '1', 'services', gstrCatParent, gstrCatEnfant);
		break;
	case "2":
		document.getElementById("lblTheme").innerText = "Services";
		document.getElementById("filAriane").innerText = "You are here: Services";
		findResult('', '2', 'services', gstrCatParent, gstrCatEnfant);
		break;
	}
  }
  
  document.getElementById("div_cat0").style.display="none";
  document.getElementById("div_cat1").style.display="none";
  document.getElementById("div_cat"+no).style.display="inline";

  document.getElementById("div_menu0").style.display="none";
  document.getElementById("div_menu1").style.display="none";
  document.getElementById("div_menu"+no).style.display="inline";

  document.getElementById("div_mot0").style.display="none"; //Mot cle produits
  document.getElementById("div_mot1").style.display="none";//Mot cle services
  document.getElementById("div_mot"+no).style.display="inline";
 
  
  //alert(document.getElementById("div_menu"+no).style.display);
}

function affiche_formulaire(pstrLangue, pstrAction)
{
	var strUrl = new String("");
	var strTheme = new String("");

	for(intCpt = 0; intCpt < document.all.rad_console.length; intCpt++)
	{
		if(document.all.rad_console[intCpt].checked == true)
		{
			strTheme = document.all.rad_console[intCpt].value
		}
	}

	if(strTheme == "publicites")
	{
		strUrl = "/_SITE/FIQ/PUBLICITE/pub-fr.htm"
		window.open(strUrl,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=600,height=600,left=200,top=50');	
	}
	else
	{
		strUrl = "/FRANCAIS/formulaire.asp?xtype="+strTheme+"&xlangue="+pstrLangue+"&xaction="+pstrAction+"&xpayeur=" + gstrPayeur + "&xid=" + gstrIdMembre;
		window.open(strUrl,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=620,height=600,left=200,top=50');
	}
}

function select_autresite(objet) 
{
	var strRefSite =  new String(objet.options[objet.selectedIndex].value);
	strRefSite = strRefSite.replace("javascript:", "");
	eval(strRefSite);
}

function WBPrint() {
	window.focus();
	if(window.print)
		window.print();

}

function WBLogUrlRequest(strUrl) {
	window.open('/_system/services/logUrlRequest.asp?page='+strUrl,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=1,height=1,left=0,top=0')	
}

function golien(intNoLien) {
	window.open("/lien/lien-redirect.asp?xnolien="+intNoLien);
}

function gotoshow(){
	window.open('http://www.apff.org/_system/baniere/adclick2.asp?adresse='+slidelinks[whichlink],'stat')
}

function WBGoLien(intNoLien, intNoType, strUrl) {
	strIDSite = "d000572"
	if((intNoType==11) && (intNoLien==0)){
		if (!(strUrl.indexOf("ttp://") > 0))
		{
			if (strUrl.indexOf("ttps://") > 0 )
			{
//				strUrl = "http://" + strUrl;
			} else {
				strUrl = "http://" + strUrl;
			}			
		}
		location.href = strUrl
		//parent.location.href = "http://director.marigny.com/d-click.php?aid="+strIDSite+"&url="+strUrl;
	}else{
		if ((intNoType==13) || (intNoType==12)){
			//WBLogUrlRequest(strUrl)
			if (!((strUrl.indexOf("ttp://") > 0) || (strUrl.indexOf("ttps://") > 0) || (strUrl.indexOf("ww.") > 0))){
					strUrl = "http://www.apff.org" + strUrl;
			}
			if (intNoType==13) 
			{
				window.open(strUrl);
			}
			else
			{
				location.href = strUrl;
			}
			//window.open("http://director.marigny.com/d-click.php?aid="+strIDSite+"&url="+strUrl);
		}else{
			if ((intNoType==10) && (strUrl.indexOf(".htm") > 0))
			{
				strUrl = "http://www.apff.org" + strUrl
				//window.open("http://director.marigny.com/d-click.php?aid="+strIDSite+"&url="+strUrl);
				location.href = strUrl
			}else{
				window.open(strUrl);
			}
		}
	}
}

function WBSendPage() {
	window.open('/_system/services/sendpage.asp?page='+location.pathname,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=650,height=440,left=0,top=0')	
}


function WBPrintPage() {
	window.open('/_system/services/printpage.asp?page='+location.pathname,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=620,height=740,left=0,top=0')
}

function WBPrintPageTheme() {
	window.open('/_system/services/printpage.asp?theme='+document.all.xthemecourant.value,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=620,height=740,left=0,top=0')
}


/*

Fonction pour le moteur de recherche

*/
function initDiv()
{
	if (document.recherche.xtoussecteurs.checked == false)
	{
		for (var i = 0; i < document.all.xsecteurs.length; i++)
		{
			if (document.all.xsecteurs[i].checked)
			{
				document.all['div_' + document.all.xsecteurs[i].value].style.display = 'block';
			}
		}
	}
	if (document.recherche.r_adv_value.value=="avance")
	{
		document.getElementById("r_adv_on").style.display = "none";
		document.getElementById("r_adv_off").style.display = "block";
		document.getElementById("r_adv_block").style.display = "block";
		document.getElementById("r_adv_produit_block").style.display = "block";
	}
}

function showDiv(valeur,coche)
{
	if (coche == true) {
		document.all['div_' + valeur].style.display = 'block';
		if (document.all.xtoussecteurs.checked) {
			document.all.xtoussecteurs.checked = false;
		}
	} else {
		try{
			document.all['div_' + valeur].style.display = 'none'
			var idObj = 'xcodes' + valeur
			for (var intCpt = 1; intCpt < eval('document.all.' + idObj).length; intCpt++) {
				eval('document.all.' + idObj)[intCpt].checked = false;
			}
			eval('document.all.' + idObj)[0].checked = true;
		}catch(e){}
	}
} 

function hideAllDiv(valeur,coche)
{
	if (coche == true) {
		for (var intCpt = 0; intCpt < document.all.xsecteurs.length; intCpt++) {
			document.all.xsecteurs[intCpt].checked = false
		}
		strSearch = /div_/i;
		var divArray = document.all.tags('div');
		for (var intCpt = 0; intCpt < divArray.length; intCpt++)
		{   
			strDivId = '';
			oName='';
			strDivId = divArray[intCpt].id;
			oName = document.all[strDivId];
			intResult = strDivId.search(strSearch);
			if (intResult != -1)
				{
					try{
						var idObj = 'xcodes' + strDivId.substr(4,strDivId.length-4)
						for (var intCptCode = 1; intCptCode < eval('document.all.' + idObj).length; intCptCode++) {
							eval('document.all.' + idObj)[intCptCode].checked = false;
						}
						eval('document.all.' + idObj)[0].checked = true;
						oName.style.display = 'block';
						oName.style.display = 'none';
					}catch(e){}
					
				}
		}
	 }
 }

function uncheckAllService(valeur,coche)
{
	if (coche == true) {
		try
		{
			for (var intCpt = 0; intCpt < document.all.xsecteurs.length; intCpt++) {
				document.all.xsecteurs[intCpt].checked = false
			}	
		}
		catch (e) {}
	 }
 }

function checkService(valeur,coche)
{
	if (coche == true) {
		if (document.all.xtoussecteurs.checked) {
			document.all.xtoussecteurs.checked = false;
		}
	} 
} 


 function checkCodes(valeur,coche,noId)
 {
	 var idObj = 'xcodes' + noId;
	 intResult = valeur.indexOf('all_');
	 if (intResult != -1) {
		if (coche == true) {
			try{
				for (var intCpt = 1; intCpt < eval('document.all.' + idObj).length; intCpt++) {
					eval('document.all.' + idObj)[intCpt].checked = false;
				}
			}catch(e){}
		}
	 } else {
		eval('document.all.' + idObj)[0].checked = false;
	 }
 }


 function rechercheAvance(valeur){
	
	
	if (valeur == true)
	{
		document.getElementById("r_adv_on").style.display = "none";
		document.getElementById("r_adv_off").style.display = "block";
		document.getElementById("r_adv_block").style.display = "block";
		document.getElementById("r_adv_produit_block").style.display = "block";
		document.recherche.r_adv_value.value="avance";
	}else{
		document.getElementById("r_adv_on").style.display = "block";
		document.getElementById("r_adv_off").style.display = "none";		
		document.getElementById("r_adv_block").style.display = "none";
		document.getElementById("r_adv_produit_block").style.display = "none";
		document.recherche.r_adv_value.value="simple";
	}
 
 }

 function raffinerRecherche(intNbrPage){
	history.go(intNbrPage);
 }

 function wb_print_fiche(pDiv, pstrLangue)
{
	if (pstrLangue == "1")
	{
			window.open("printDiv.asp?xdiv="+pDiv+"&xmodel=/FRANCAIS/print/fiche_recherche.html&xlangue=" + pstrLangue,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=642,height=740,left=0,top=0');  
			return;
	}
	if (pstrLangue == "2")
	{
			window.open("printDiv.asp?xdiv="+pDiv+"&xmodel=/ANGLAIS/print/fiche_recherche.html&xlangue=" + pstrLangue,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=642,height=740,left=0,top=0');  
			return;
	}
 }

 function wb_print_page(pstrLangue)
 {
	if (pstrLangue == "1")
	{
			window.open("printDiv.asp?xdiv=all_fiches&xmodel=/FRANCAIS/print/resultat_recherche.html&xlangue=" + pstrLangue,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=642,height=740,left=0,top=0');  
			return;
	}	
	if (pstrLangue == "2")
	{
			window.open("printDiv.asp?xdiv=all_fiches&xmodel=/ANGLAIS/print/resultat_recherche.html&xlangue=" + pstrLangue,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=642,height=740,left=0,top=0');  
			return;
	}	
 }

 function rech_fiche_detail(pstrNoFiche, pstrLangue)
 {
	if (pstrLangue == "1")
	{
		window.open("../services/detail-Entreprise.asp?xid="+pstrNoFiche+"&xurlretour=/FRANCAIS/al_rl/fiche_detail_entreprise.html" + "&xlangue=" + pstrLangue,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=642,height=740,left=0,top=0'); 
		return;
	}
	if (pstrLangue == "2")
	{
		window.open("../services/detail-Entreprise.asp?xid="+pstrNoFiche+"&xurlretour=/ANGLAIS/al_rl/fiche_detail_entreprise.html" + "&xlangue=" + pstrLangue,'','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=642,height=740,left=0,top=0'); 
		return;
	}
 }

function wb_printCurrentPage(){

	window.event.cancelBubble = true;
	window.print();
}

function hidePages(){
	try{
		document.all.div_pagination_top.style.display = 'none';
		document.all.div_pagination_bottom.style.display = 'none';
	}catch(e){}
}

function loadData(pDiv) {
	var str;
	str = String(window.opener.document.getElementById(pDiv).innerHTML);
	if (str.indexOf("<FORM") != -1)
	{
	str = str.substr(str.indexOf("<TABLE"), str.length - 8 - str.indexOf("<TABLE")+1);
	}
	
	document.getElementById("Div_Data").innerHTML = str;
	setTimeout("hidePages()", 100);
	setTimeout("print()", 100);
}

function fnoaction(){
	//var ev = document.handleEvent()

	alert("Cette fenêtre est pour impression seulement, la navigation dans cette fenêtre est déconseillée.");
	//ev.stopPropagation()
	window.event.cancelBubble = true;
	window.event.returnValue = false;
	//return false;
}




function go_recherche()
{

	var ie4up = (document.all) ? 1 : 0;

	if (navigator.userAgent.indexOf('Netscape/7') != -1  || ie4up == 1)     
	{
		
		if (document.recherche.xtoussecteurs.checked == true)
		{
			if (document.recherche.mot.value!='')
			{
				
				boiteMessage("div_attente");
				
				return true;
			}else{
				alert("Vous devez être plus spécifique dans votre recherche.");
				return false;
			}
		}
		if (document.recherche.xtoussecteurs.checked == false && document.recherche.mot.value == '')
		{
			try
			{
				for (var intCpt = 0; intCpt < document.recherche.xsecteurs.length; intCpt++) {
						if (document.recherche.xsecteurs[intCpt].checked == true)
						{
							
							boiteMessage("div_attente");
							
							return true;
						}
				}
			}catch(e){
				alert("Vous devez être plus spécifique dans votre recherche.2");
				return false;
			}
			alert("Vous devez être plus spécifique dans votre recherche.");
			return false;
			
		}else{
			boiteMessage("div_attente");
			
			return true;	
		}
	}
	else
	{
		strUrl = "/FRANCAIS/aide/Navigateurs.html";
		myWindow = window.open(strUrl,'incompatible','toolbar=no,status=no,titlebar=no,menubar=no,resizable=yes,scrollbars=yes,width=572,height=500,left=0,top=0');
		myWindow.focus();
		return;
	}
}


function  doMath() {
	if (document.getElementById('montant').value != "") {
		var one = eval(document.getElementById('montant').value)
	} else {
		var one = 0;
	}

	if (document.getElementById('ipa').value != "") {
		var onea = eval(document.getElementById('ipa').value)
	} else {
		var onea = 0;
	}

	
	var two = eval(document.getElementById('tax').value)
	var tot = one + onea
	var prod = tot  *   two
	document.getElementById('TotalAFacturer').value=custRound(prod,2);
	document.getElementById('Total_somm').value = tot;
} 

function custRound(x,places) {
	return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
}

function CalculerTaxes(TVQincluse, TPSincluse, prix) {
	var temp1 = prix;
	if (!(TVQincluse) && !(TPSincluse)) {
		if (0+prix > 0)	{
			document.getElementById("prixAvantTaxe").value = prix;
			document.getElementById("montantTPS").value = 0 + prix * 0.07;
			document.getElementById("montantTVQ").value = 0 + (prix + parseFloat(document.getElementById("montantTPS").value)) * 0.075;
		} else {
			document.getElementById("prixAvantTaxe").value = 0;
			document.getElementById("montantTPS").value = 0;
			document.getElementById("montantTVQ").value = 0;
		}
		
	}

	if (TVQincluse && TPSincluse) {
		if (0+prix > 0)	{
			document.getElementById("montantTVQ").value = temp1 - (temp1 / 1.075);
			temp1 = temp1 - document.getElementById("montantTVQ").value;
			document.getElementById("montantTPS").value = temp1 - (temp1 / 1.07);
			document.getElementById("prixAvantTaxe").value = temp1 - parseFloat(document.getElementById("montantTPS").value);
		} else {
			document.getElementById("prixAvantTaxe").value = 0;
			document.getElementById("montantTPS").value = 0;
			document.getElementById("montantTVQ").value = 0;
		}
	}

	if (!(TVQincluse) && TPSincluse) {
		if (0+prix > 0)	{
			document.getElementById("montantTPS").value = temp1 - (temp1 / 1.07);
			document.getElementById("montantTVQ").value = 0 + temp1 * 0.075;
			document.getElementById("prixAvantTaxe").value = temp1 - parseFloat(document.getElementById("montantTPS").value);
		} else {
			document.getElementById("prixAvantTaxe").value = 0;
			document.getElementById("montantTPS").value = 0;
			document.getElementById("montantTVQ").value = 0;
		}
	}

	if (0+prix == 0) {
		document.getElementById("paiement").style.display = 'none';
	} else {
		document.getElementById("paiement").style.display = 'block';
	}
}

function CalculerTaxeQte(pNo, isOctas) {
	document.getElementById("totalLigne" + pNo).value = custRound(document.getElementById("qteBillet" + pNo).options[document.getElementById("qteBillet" + pNo).selectedIndex].value * document.getElementById("prix" + pNo).value, 2);

	if ((document.getElementById("totalLigne" + pNo).value).indexOf('.') == -1) {
		document.getElementById("totalLigne" + pNo).value = document.getElementById("totalLigne" + pNo).value + '.00';
	}

	if ((document.getElementById("totalLigne" + pNo).value).indexOf('.') == (document.getElementById("totalLigne" + pNo).value).length - 2) {
		document.getElementById("totalLigne" + pNo).value = document.getElementById("totalLigne" + pNo).value + '0';
	}
	
	if (isOctas) {
		document.getElementById("montantTPS" + pNo).value = (document.getElementById("qteBillet" + pNo).options[document.getElementById("qteBillet" + pNo).selectedIndex].value * document.getElementById("prix" + pNo).value) * 0.07;
		document.getElementById("montantTVQ" + pNo).value = (parseFloat(document.getElementById("qteBillet" + pNo).options[document.getElementById("qteBillet" + pNo).selectedIndex].value * document.getElementById("prix" + pNo).value) + parseFloat(document.getElementById("montantTPS" + pNo).value)) * 0.075;
	} else {
		CalculerTaxeLigne(pNo, document.getElementById("TPS" + pNo).value, document.getElementById("TVQ" + pNo).value);
	}

	CalculerAllLines();
	
	CalculerGrandTotal(isOctas);	
}

function CalculerAllLines() {
	var total = 0;

	if (document.getElementById("totalLigne1") != null) {
		total = parseFloat(total) + parseFloat(document.getElementById("totalLigne1").value); 
	}

	if (document.getElementById("totalLigne2") != null) {
		total = parseFloat(total) + parseFloat(document.getElementById("totalLigne2").value); 
	}

	if (document.getElementById("totalLigne3") != null) {
		total = parseFloat(total) + parseFloat(document.getElementById("totalLigne3").value); 
	}

	if (document.getElementById("totalLigne4") != null) {
		total = parseFloat(total) + parseFloat(document.getElementById("totalLigne4").value); 
	}

	if (document.getElementById("totalLigne5") != null) {
		total = parseFloat(total) + parseFloat(document.getElementById("totalLigne5").value); 
	}

	if (document.getElementById("totalLigne6") != null) {
		total = parseFloat(total) + parseFloat(document.getElementById("totalLigne6").value); 
	}

	document.getElementById("prixAvantTaxeQte").value = custRound(parseFloat(total), 2);
	
	if ((document.getElementById("prixAvantTaxeQte").value).indexOf('.') == -1) {
		document.getElementById("prixAvantTaxeQte").value = document.getElementById("prixAvantTaxeQte").value + '.00';
	}
	
	if ((document.getElementById("prixAvantTaxeQte").value).indexOf('.') == ((document.getElementById("prixAvantTaxeQte").value).length - 2)) {
		document.getElementById("prixAvantTaxeQte").value = document.getElementById("prixAvantTaxeQte").value + '0';
	}
}

function CalculerTaxeLigne(pNo, pTPS, pTVQ) {
	var temp = document.getElementById("totalLigne" + pNo).value;
	if (pTPS == 'true' && pTVQ == 'true') {
		document.getElementById("montantTVQ" + pNo).value = temp - (temp / 1.075);
		temp = temp - document.getElementById("montantTVQ" + pNo).value
		document.getElementById("montantTPS" + pNo).value = temp - (temp / 1.07);
		document.getElementById("totalLigne" + pNo).value = temp - parseFloat(document.getElementById("montantTPS" + pNo).value);
	}

	if (pTPS == 'false' && pTVQ == 'false') {
		document.getElementById("totalLigne" + pNo).value = temp;
		document.getElementById("montantTPS" + pNo).value = temp * 0.07;
		document.getElementById("montantTVQ" + pNo).value = (parseFloat(temp) + parseFloat(document.getElementById("montantTPS" + pNo).value)) * 0.075;
	}
 
	document.getElementById("totalLigne" + pNo).value = custRound(document.getElementById("totalLigne" + pNo).value,2)

	if ((document.getElementById("totalLigne" + pNo).value).indexOf('.') == -1) {
		document.getElementById("totalLigne" + pNo).value = document.getElementById("totalLigne" + pNo).value + '.00';
	}
	
	if ((document.getElementById("totalLigne" + pNo).value).indexOf('.') == ((document.getElementById("totalLigne" + pNo).value).length - 2)) {
		document.getElementById("totalLigne" + pNo).value = document.getElementById("totalLigne" + pNo).value + '0';
	}
	
}

function CalculerGrandTotal(isOctas) {
	
	var pTypeTaxe;
	if (isOctas) {
		pTypeTaxe = document.getElementById("TPSTVQOCTAS").options[document.getElementById("TPSTVQOCTAS").selectedIndex].value;
	} else {
		pTypeTaxe = '5';
	}

	var totalTPS = 0;
	var totalTVQ = 0;

	if (document.getElementById("totalLigne1") != null) {
		totalTPS = totalTPS + parseFloat(document.getElementById("montantTPS1").value); 
		totalTVQ = totalTVQ + parseFloat(document.getElementById("montantTVQ1").value); 
	}

	if (document.getElementById("totalLigne2") != null) {
		totalTPS = totalTPS + parseFloat(document.getElementById("montantTPS2").value); 
		totalTVQ = totalTVQ + parseFloat(document.getElementById("montantTVQ2").value); 
	}

	if (document.getElementById("totalLigne3") != null) {
		totalTPS = totalTPS + parseFloat(document.getElementById("montantTPS3").value); 
		totalTVQ = totalTVQ + parseFloat(document.getElementById("montantTVQ3").value); 
	}

	if (document.getElementById("totalLigne4") != null) {
		totalTPS = totalTPS + parseFloat(document.getElementById("montantTPS4").value); 
		totalTVQ = totalTVQ + parseFloat(document.getElementById("montantTVQ4").value); 
	}

	if (document.getElementById("totalLigne5") != null) {
		totalTPS = totalTPS + parseFloat(document.getElementById("montantTPS5").value); 
		totalTVQ = totalTVQ + parseFloat(document.getElementById("montantTVQ5").value); 
	}

	if (document.getElementById("totalLigne6") != null) {
		totalTPS = totalTPS + parseFloat(document.getElementById("montantTPS6").value); 
		totalTVQ = totalTVQ + parseFloat(document.getElementById("montantTVQ6").value); 
	}

	switch (pTypeTaxe) {
		case "1" :
			document.getElementById("Total_somm").value = custRound(parseFloat(document.getElementById("prixAvantTaxeQte").value) + totalTPS + totalTVQ, 2);
			break;
		case "2" :
			document.getElementById("Total_somm").value = custRound(parseFloat(document.getElementById("prixAvantTaxeQte").value) + totalTPS, 2);
			break;
		case "3" :
			document.getElementById("Total_somm").value = custRound(parseFloat(document.getElementById("prixAvantTaxeQte").value), 2);
			break;
		case "5" :
			document.getElementById("Total_somm").value = custRound(parseFloat(document.getElementById("prixAvantTaxeQte").value) + totalTPS + totalTVQ, 2);
			break;
	}

	if ((document.getElementById("Total_somm").value).indexOf('.') == -1) {
		document.getElementById("Total_somm").value = document.getElementById("Total_somm").value + '.00';
	}

	if ((document.getElementById("Total_somm").value).indexOf('.') == ((document.getElementById("Total_somm").value).length - 2)) {
		document.getElementById("Total_somm").value = document.getElementById("Total_somm").value + '0';
	}
}

function CalculerTaxes2Tarif(TVQincluse1, TPSincluse1, TVQincluse2, TPSincluse2, prix1, prix2) {
	var temp1 = prix1;
	document.getElementById("montantTPS").value = 0
	document.getElementById("montantTVQ").value = 0
	document.getElementById("prixAvantTaxe").value = 0

	document.getElementById("montantTPS1").value = 0
	document.getElementById("montantTVQ1").value = 0
	document.getElementById("prixAvantTaxe1").value = 0

		//alert(TVQincluse1 + ' ' + TPSincluse1 + ' ' + TVQincluse2 + ' ' + TPSincluse2 + ' ' + prix1 + ' ' + prix2)

	if (TVQincluse1 == 'false' && TPSincluse1 == 'false') {
		if (0+prix1 > 0)	{
			document.getElementById("prixAvantTaxe1").value = prix1;
			document.getElementById("montantTPS1").value = 0 + prix1 * 0.07;
			document.getElementById("montantTVQ1").value = 0 + (prix1 + document.getElementById("montantTPS1").value) * 0.075;
		} else {
			document.getElementById("prixAvantTaxe1").value = 0;
			document.getElementById("montantTPS1").value = 0;
			document.getElementById("montantTVQ1").value = 0;
		}
		
	}

	if (TVQincluse1 == 'true' && TPSincluse1 == 'true') {
		if (0+prix1 > 0)	{
			document.getElementById("montantTVQ1").value = temp1 - (temp1 / 1.075);
			temp1 = temp1 - document.getElementById("montantTVQ1").value;
			document.getElementById("montantTPS1").value = temp1 - (temp1 / 1.07);
			document.getElementById("prixAvantTaxe1").value = temp1 - document.getElementById("montantTPS1").value;
		} else {
			document.getElementById("prixAvantTaxe1").value = 0;
			document.getElementById("montantTPS1").value = 0;
			document.getElementById("montantTVQ1").value = 0;
		}
	}

	if (TVQincluse1 == 'false' && TPSincluse1 == 'true') {
		if (0+prix1 > 0)	{
			document.getElementById("montantTPS1").value = temp1 - (temp1 / 1.07);
			document.getElementById("montantTVQ1").value = 0 + temp1 * 0.075;
			document.getElementById("prixAvantTaxe1").value = temp1 - document.getElementById("montantTPS1").value;
		} else {
			document.getElementById("prixAvantTaxe1").value = 0;
			document.getElementById("montantTPS1").value = 0;
			document.getElementById("montantTVQ1").value = 0;
		}
	}
	
	var temp2 = prix2;
	tempTPS = document.getElementById("montantTPS1").value;
	tempTVQ = document.getElementById("montantTVQ1").value;
	tempAvantTaxe = document.getElementById("prixAvantTaxe1").value;

	document.getElementById("montantTPS2").value = 0;
	document.getElementById("montantTVQ2").value = 0;
	document.getElementById("prixAvantTaxe2").value = 0;
//alert(TVQincluse2+ ' ' +TPSincluse2)

	if (TVQincluse2 == 'false' && TPSincluse2 == 'false') {
		//alert("here")
		if (0+prix2 > 0)	{
			document.getElementById("prixAvantTaxe2").value = prix2;
			document.getElementById("montantTPS2").value = 0 + prix2 * 0.07;
			document.getElementById("montantTVQ2").value = (0 + parseFloat(prix2) + parseFloat(document.getElementById("montantTPS2").value)) * 0.075;
			//alert(prix2 + ' ' + document.getElementById("montantTVQ2").value)
		} else {
			document.getElementById("prixAvantTaxe2").value = 0;
			document.getElementById("montantTPS2").value = 0;
			document.getElementById("montantTVQ2").value = 0;
		}
		
	}

	if (TVQincluse2 == 'true' && TPSincluse2 == 'true') {
		if (0+prix2 > 0)	{
			document.getElementById("montantTVQ2").value = temp2 - (temp2 / 1.075);
			temp2 = temp2 - document.getElementById("montantTVQ2").value;
			document.getElementById("montantTPS2").value = temp2 - (temp2 / 1.07);
			document.getElementById("prixAvantTaxe2").value = temp2 - document.getElementById("montantTPS2").value;
		} else {
			document.getElementById("prixAvantTaxe2").value = 0;
			document.getElementById("montantTPS2").value = 0;
			document.getElementById("montantTVQ2").value = 0;
		}
	}

	if (TVQincluse2 == 'false' && TPSincluse2 == 'true') {
		if (0+prix2 > 0)	{
			document.getElementById("montantTPS2").value = temp2 - (temp2 / 1.07);
			document.getElementById("montantTVQ2").value = 0 + temp2 * 0.075;
			document.getElementById("prixAvantTaxe2").value = temp2 - document.getElementById("montantTPS2").value;
		} else {
			document.getElementById("prixAvantTaxe2").value = 0;
			document.getElementById("montantTPS2").value = 0;
			document.getElementById("montantTVQ2").value = 0;
		}
	}
	
	//alert(document.getElementById("prixAvantTaxe").value+ ' ' +document.getElementById("montantTPS").value+ ' ' +document.getElementById("montantTVQ").value)
	document.getElementById("montantTPS").value = parseFloat(document.getElementById("montantTPS2").value) + parseFloat(tempTPS);
	document.getElementById("montantTVQ").value = parseFloat(document.getElementById("montantTVQ2").value) + parseFloat(tempTVQ);
	document.getElementById("prixAvantTaxe").value = parseFloat(document.getElementById("prixAvantTaxe2").value) + parseFloat(tempAvantTaxe);
	
	//alert(document.getElementById("prixAvantTaxe").value+ ' ' +document.getElementById("montantTPS").value+ ' ' +document.getElementById("montantTVQ").value)

	if (0+prix2+prix1 == 0) {
		document.getElementById("paiement").style.display = 'none';
	} else {
		document.getElementById("paiement").style.display = 'block';
	}
}

function ValiderNBCarac() {
	return true;
}

function ShowDivTarif(pNom, pNoTarif) {
	for (var intCpt = 1; intCpt <= 6; intCpt++) {
		if (document.getElementById("tarif"+intCpt) != null) {
			document.getElementById("tarif"+intCpt).style.display = "none";
		}
	}

	if (document.getElementById("tarif"+pNom) != null) {
		document.getElementById("tarif"+pNom).style.display = "block";
		document.getElementById("nomtarif_"+ pNoTarif +"_1").value = document.getElementById("NOM").value;
		document.getElementById("prenomtarif_"+ pNoTarif +"_1").value = document.getElementById("PRENOM").value;
		document.getElementById("compagnietarif_"+ pNoTarif +"_1").value = document.getElementById("Nom_Entreprise").value;
		document.getElementById("fonctiontarif_"+ pNoTarif +"_1").value = document.getElementById("FONCTION").value;
		document.getElementById("nomtarif_"+ pNoTarif +"_1").readOnly = true;
		document.getElementById("prenomtarif_"+ pNoTarif +"_1").readOnly = true;
		document.getElementById("compagnietarif_"+ pNoTarif +"_1").readOnly = true;
		document.getElementById("fonctiontarif_"+ pNoTarif +"_1").readOnly = true;
	}
}

function RetirerIdent(pNoGroupe, pNoLigne) {
	var str = "Êtes-vous certain(e) de vouloir retirer " + document.getElementById("prenom_" + pNoGroupe + "_" + pNoLigne).value + " " + document.getElementById("nom_" + pNoGroupe + "_" + pNoLigne).value + " ?";
	if (confirm(str)) {
		document.getElementById("nom_" + pNoGroupe + "_" + pNoLigne).value = "";
		document.getElementById("prenom_" + pNoGroupe + "_" + pNoLigne).value = "";
		document.getElementById("courriel_" + pNoGroupe + "_" + pNoLigne).value = "";
		document.getElementById("compagnie_" + pNoGroupe + "_" + pNoLigne).value = "";
		document.getElementById("fonction_" + pNoGroupe + "_" + pNoLigne).value = "";
		document.getElementById("tel_" + pNoGroupe + "_" + pNoLigne).value = "";
		document.getElementById("id_" + pNoGroupe + "_" + pNoLigne).value = "";
		var type = document.getElementById("type_" + pNoGroupe + "_" + pNoLigne).value;
		document.getElementById("type_" + pNoGroupe + "_" + pNoLigne).value = "";
		
		document.getElementById("nom_" + pNoGroupe + "_" + pNoLigne).readOnly = true;
		document.getElementById("prenom_" + pNoGroupe + "_" + pNoLigne).readOnly = true;
		document.getElementById("courriel_" + pNoGroupe + "_" + pNoLigne).readOnly = true;
		document.getElementById("compagnie_" + pNoGroupe + "_" + pNoLigne).readOnly = true;
		document.getElementById("fonction_" + pNoGroupe + "_" + pNoLigne).readOnly = true;
		document.getElementById("tel_" + pNoGroupe + "_" + pNoLigne).readOnly = true;
		
		document.getElementById("add_" + pNoGroupe + "_" + pNoLigne).style.display = 'block';
		document.getElementById("ret_" + pNoGroupe + "_" + pNoLigne).style.display = 'none';

		if (document.getElementById("groupe_liste") == null) {
			RecalculerMnM();
		} else {
			RecalculerGroupe();
		}
	}
}

function UpdateTotal(pNo) {
	if (document.getElementById("groupe_liste") == null) {
		RecalculerMnM();
	} else {
		RecalculerGroupe();	
	}
}

function RecalculerGroupe() {
	var notEmpty;
	var totalGroupe = 0;
	
	for (var noGroupe = 1; noGroupe <= parseInt(document.getElementById("nbGroupe").value); noGroupe++) {
		notEmpty = false;
		for (var noLigne = 1; noLigne <= parseInt(document.getElementById("nbLigne").value) && !notEmpty; noLigne++) {
			if (document.getElementById("type_" + noGroupe + "_" + noLigne).value != "") {
				notEmpty = true;
				totalGroupe += 1;
			}
		}
	}

	if (totalGroupe == 0) {
		document.getElementById("qtyMembre3").value = 1;
	} else {
		document.getElementById("qtyMembre3").value = totalGroupe;
	}

	document.getElementById("totalMembre3").value = parseInt(document.getElementById("qtyMembre3").value) * document.getElementById("prix3").value;
	CalculerTaxes(document.getElementById("TVQ3").value, document.getElementById("TPS3").value, document.getElementById("totalMembre3").value);
	document.getElementById("Total_somm").value = custRound(parseFloat(eval(document.getElementById("prixAvantTaxe").value)) + parseFloat(eval(document.getElementById("montantTVQ").value)) + parseFloat(eval(document.getElementById("montantTPS").value)), 2);
}

function RecalculerMnM() {
	document.getElementById("qtyMembre1").value = 0;
	document.getElementById("qtyMembre2").value = 0;	

	for (var noGroupe = 1; noGroupe <= parseInt(document.getElementById("nbGroupe").value); noGroupe++) {
		for (var noLigne = 1; noLigne <= parseInt(document.getElementById("nbLigne").value); noLigne++) {
			if (document.getElementById("type_" + noGroupe + "_" + noLigne).value == "M") {
				document.getElementById("qtyMembre1").value = parseInt(document.getElementById("qtyMembre1").value) + 1;
			}
			
			if (document.getElementById("type_" + noGroupe + "_" + noLigne).value == "NM") {
				document.getElementById("qtyMembre2").value = parseInt(document.getElementById("qtyMembre2").value) + 1;
			}
		}
	}

	document.getElementById("totalMembre1").value = custRound(parseInt(document.getElementById("qtyMembre1").value) * document.getElementById("prix1").value, 2);
	document.getElementById("totalMembre2").value = custRound(parseInt(document.getElementById("qtyMembre2").value) * document.getElementById("prix2").value, 2);
	
	if ((document.getElementById("totalMembre1").value).indexOf('.') == -1) {
		document.getElementById("totalMembre1").value = document.getElementById("totalMembre1").value + '.00';
	}

	if ((document.getElementById("totalMembre1").value).indexOf('.') == ((document.getElementById("totalMembre1").value).length - 2)) {
		document.getElementById("totalMembre1").value = document.getElementById("totalMembre1").value + '0';
	}
	
	if ((document.getElementById("totalMembre2").value).indexOf('.') == -1) {
		document.getElementById("totalMembre2").value = document.getElementById("totalMembre2").value + '.00';
	}

	if ((document.getElementById("totalMembre2").value).indexOf('.') == ((document.getElementById("Total_somm").value).length - 2)) {
		document.getElementById("totalMembre2").value = document.getElementById("totalMembre2").value + '0';
	}

	CalculerTaxes2Tarif(document.getElementById("TVQ1").value, document.getElementById("TPS1").value, document.getElementById("TVQ2").value, document.getElementById("TPS2").value, document.getElementById("totalMembre1").value, document.getElementById("totalMembre2").value);

	document.getElementById("Total_somm").value = custRound(parseFloat(document.getElementById("prixAvantTaxe").value) + parseFloat(document.getElementById("montantTVQ").value) + parseFloat(document.getElementById("montantTPS").value), 2);

	if ((document.getElementById("Total_somm").value).indexOf('.') == -1) {
		document.getElementById("Total_somm").value = document.getElementById("Total_somm").value + '.00';
	}

	if ((document.getElementById("Total_somm").value).indexOf('.') == ((document.getElementById("Total_somm").value).length - 2)) {
		document.getElementById("Total_somm").value = document.getElementById("Total_somm").value + '0';
	}
}

function IdentificationMNM(pNoGroupe, pNoLigne) {
	var strUrl = "/_system/fiq/login/login_ident.asp?xnogroupe=" + pNoGroupe + "&xnoligne=" + pNoLigne;
	window.open(strUrl, "", "width=310px, height=280px, top=200px, left=150px");	
}

function UpdateSousTot(pQtyField, pPrix, pTotalField) {
	document.getElementById(pTotalField).value = custRound(document.getElementById(pQtyField).value * pPrix, 2);
}

function ShowDivReferer(pValue) {
	if (document.getElementById("div_referer") != null) {
		if (pValue == 'MEMBRE') {
			document.getElementById("div_referer").style.display = 'block';
		} else {
			document.getElementById("div_referer").style.display = 'none';
		}

	}
}

function MettreReferer() {
	if (document.getElementById("nom_referer") != null) {
		document.getElementById("nom_referer").value = document.getElementById("nom_referer_hid").value
	}
	
	if (document.getElementById("no_referer") != null) {
		document.getElementById("no_referer").value = document.getElementById("no_referer_hid").value
	}
}


	function trim(s) 
		{
		  // Remove leading spaces and carriage returns
		  
		  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
		  {
			s = s.substring(1,s.length);
		  }

		  // Remove trailing spaces and carriage returns

		  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
		  {
			s = s.substring(0,s.length-1);
		  }
		  return s;
		}


	function ValiderLength() {
		if (trim(document.getElementById("xnom").value) == "" && trim(document.getElementById("xprenom").value) == "" && trim(document.getElementById("xentreprise").value) == "") {
			alert("Vous devez emplir au minimum un champs pour faire la recherche.");
			document.getElementById("div_attente").style.display = "none";
			return false;
		}

		if (trim(document.getElementById("xentreprise").value).length > 0 && trim(document.getElementById("xentreprise").value).length < 2) {
			alert("Il doit y avoir au minimum 2 caractères dans le champs entreprise.");
			document.getElementById("div_attente").style.display = "none";
			return false;
		}
	}


function Sarissa(){};
Sarissa.PARSED_OK = "Document contains no parsing errors";
Sarissa.PARSED_EMPTY = "Document is empty";
Sarissa.PARSED_UNKNOWN_ERROR = "Not well-formed or other error";
var _sarissa_iNsCounter = 0;
var _SARISSA_IEPREFIX4XSLPARAM = "";
var _SARISSA_HAS_DOM_IMPLEMENTATION = document.implementation && true;
var _SARISSA_HAS_DOM_CREATE_DOCUMENT = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.createDocument;
var _SARISSA_HAS_DOM_FEATURE = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.hasFeature;
var _SARISSA_IS_MOZ = _SARISSA_HAS_DOM_CREATE_DOCUMENT && _SARISSA_HAS_DOM_FEATURE;
var _SARISSA_IS_SAFARI = (navigator.userAgent && navigator.vendor && (navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1 || navigator.vendor.indexOf("Apple") != -1));
var _SARISSA_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1  && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
if(!window.Node || !Node.ELEMENT_NODE){
    Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5,  ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12};
};

if(typeof XMLDocument == "undefined" && typeof Document !="undefined"){ XMLDocument = Document; } 

// IE initialization
if(_SARISSA_IS_IE){
    // for XSLT parameter names, prefix needed by IE
    _SARISSA_IEPREFIX4XSLPARAM = "xsl:";
    // used to store the most recent ProgID available out of the above
    var _SARISSA_DOM_PROGID = "";
    var _SARISSA_XMLHTTP_PROGID = "";
    var _SARISSA_DOM_XMLWRITER = "";
    /**
     * Called when the Sarissa_xx.js file is parsed, to pick most recent
     * ProgIDs for IE, then gets destroyed.
     * @private
     * @param idList an array of MSXML PROGIDs from which the most recent will be picked for a given object
     * @param enabledList an array of arrays where each array has two items; the index of the PROGID for which a certain feature is enabled
     */
    Sarissa.pickRecentProgID = function (idList){
        // found progID flag
        var bFound = false;
        for(var i=0; i < idList.length && !bFound; i++){
            try{
                var oDoc = new ActiveXObject(idList[i]);
                o2Store = idList[i];
                bFound = true;
            }catch (objException){
                // trap; try next progID
            };
        };
        if (!bFound) {
            throw "Could not retreive a valid progID of Class: " + idList[idList.length-1]+". (original exception: "+e+")";
        };
        idList = null;
        return o2Store;
    };
    // pick best available MSXML progIDs
    _SARISSA_DOM_PROGID = null;
    _SARISSA_THREADEDDOM_PROGID = null;
    _SARISSA_XSLTEMPLATE_PROGID = null;
    _SARISSA_XMLHTTP_PROGID = null;
    if(!window.XMLHttpRequest){
        /**
         * Emulate XMLHttpRequest
         * @constructor
         */
        XMLHttpRequest = function() {
            if(!_SARISSA_XMLHTTP_PROGID){
                _SARISSA_XMLHTTP_PROGID = Sarissa.pickRecentProgID(["Msxml2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]);
            };
            return new ActiveXObject(_SARISSA_XMLHTTP_PROGID);
        };
    };
    // we dont need this anymore
    //============================================
    // Factory methods (IE)
    //============================================
    // see non-IE version
    Sarissa.getDomDocument = function(sUri, sName){
        if(!_SARISSA_DOM_PROGID){
            _SARISSA_DOM_PROGID = Sarissa.pickRecentProgID(["Msxml2.DOMDocument.6.0", "Msxml2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"]);
        };
        var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
        // if a root tag name was provided, we need to load it in the DOM object
        if (sName){
            // create an artifical namespace prefix 
            // or reuse existing prefix if applicable
            var prefix = "";
            if(sUri){
                if(sName.indexOf(":") > 1){
                    prefix = sName.substring(0, sName.indexOf(":"));
                    sName = sName.substring(sName.indexOf(":")+1); 
                }else{
                    prefix = "a" + (_sarissa_iNsCounter++);
                };
            };
            // use namespaces if a namespace URI exists
            if(sUri){
                oDoc.loadXML('<' + prefix+':'+sName + " xmlns:" + prefix + "=\"" + sUri + "\"" + " />");
            } else {
                oDoc.loadXML('<' + sName + " />");
            };
        };
        return oDoc;
    };
    // see non-IE version   
    Sarissa.getParseErrorText = function (oDoc) {
        var parseErrorText = Sarissa.PARSED_OK;
        if(oDoc.parseError.errorCode != 0){
            parseErrorText = "XML Parsing Error: " + oDoc.parseError.reason + 
                "\nLocation: " + oDoc.parseError.url + 
                "\nLine Number " + oDoc.parseError.line + ", Column " + 
                oDoc.parseError.linepos + 
                ":\n" + oDoc.parseError.srcText +
                "\n";
            for(var i = 0;  i < oDoc.parseError.linepos;i++){
                parseErrorText += "-";
            };
            parseErrorText +=  "^\n";
        }
        else if(oDoc.documentElement == null){
            parseErrorText = Sarissa.PARSED_EMPTY;
        };
        return parseErrorText;
    };
    // see non-IE version
    Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
        oDoc.setProperty("SelectionLanguage", "XPath");
        oDoc.setProperty("SelectionNamespaces", sNsSet);
    };   
    /**
     * Basic implementation of Mozilla's XSLTProcessor for IE. 
     * Reuses the same XSLT stylesheet for multiple transforms
     * @constructor
     */
    XSLTProcessor = function(){
        if(!_SARISSA_XSLTEMPLATE_PROGID){
            _SARISSA_XSLTEMPLATE_PROGID = Sarissa.pickRecentProgID(["Msxml2.XSLTemplate.6.0", "MSXML2.XSLTemplate.3.0"]);
        };
        this.template = new ActiveXObject(_SARISSA_XSLTEMPLATE_PROGID);
        this.processor = null;
    };
    /**
     * Imports the given XSLT DOM and compiles it to a reusable transform
     * <b>Note:</b> If the stylesheet was loaded from a URL and contains xsl:import or xsl:include elements,it will be reloaded to resolve those
     * @argument xslDoc The XSLT DOMDocument to import
     */
    XSLTProcessor.prototype.importStylesheet = function(xslDoc){
        if(!_SARISSA_THREADEDDOM_PROGID){
            _SARISSA_THREADEDDOM_PROGID = Sarissa.pickRecentProgID(["MSXML2.FreeThreadedDOMDocument.6.0", "MSXML2.FreeThreadedDOMDocument.3.0"]);
        };
        xslDoc.setProperty("SelectionLanguage", "XPath");
        xslDoc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
        // convert stylesheet to free threaded
        var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID);
        // make included/imported stylesheets work if exist and xsl was originally loaded from url
        if(xslDoc.url && xslDoc.selectSingleNode("//xsl:*[local-name() = 'import' or local-name() = 'include']") != null){
            converted.async = false;
            if (_SARISSA_THREADEDDOM_PROGID == "MSXML2.FreeThreadedDOMDocument.6.0") { 
                converted.setProperty("AllowDocumentFunction", true); 
                converted.resolveExternals = true; 
            }
            converted.load(xslDoc.url);
        } else {
            converted.loadXML(xslDoc.xml);
        };
        converted.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
        var output = converted.selectSingleNode("//xsl:output");
        this.outputMethod = output ? output.getAttribute("method") : "html";
        this.template.stylesheet = converted;
        this.processor = this.template.createProcessor();
        // for getParameter and clearParameters
        this.paramsSet = new Array();
    };

    /**
     * Transform the given XML DOM and return the transformation result as a new DOM document
     * @argument sourceDoc The XML DOMDocument to transform
     * @return The transformation result as a DOM Document
     */
    XSLTProcessor.prototype.transformToDocument = function(sourceDoc){
        // fix for bug 1549749
        if(_SARISSA_THREADEDDOM_PROGID){
            this.processor.input=sourceDoc;
            var outDoc=new ActiveXObject(_SARISSA_DOM_PROGID);
            this.processor.output=outDoc;
            this.processor.transform();
            return outDoc;
        }
        else{
            if(!_SARISSA_DOM_XMLWRITER){
                _SARISSA_DOM_XMLWRITER = Sarissa.pickRecentProgID(["Msxml2.MXXMLWriter.6.0", "Msxml2.MXXMLWriter.3.0", "MSXML2.MXXMLWriter", "MSXML.MXXMLWriter", "Microsoft.XMLDOM"]);
            };
            this.processor.input = sourceDoc;
            var outDoc = new ActiveXObject(_SARISSA_DOM_XMLWRITER);
            this.processor.output = outDoc; 
            this.processor.transform();
            var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
            oDoc.loadXML(outDoc.output+"");
            return oDoc;
        };
    };
    
    /**
     * Transform the given XML DOM and return the transformation result as a new DOM fragment.
     * <b>Note</b>: The xsl:output method must match the nature of the owner document (XML/HTML).
     * @argument sourceDoc The XML DOMDocument to transform
     * @argument ownerDoc The owner of the result fragment
     * @return The transformation result as a DOM Document
     */
    XSLTProcessor.prototype.transformToFragment = function (sourceDoc, ownerDoc) {
        this.processor.input = sourceDoc;
        this.processor.transform();
        var s = this.processor.output;
        var f = ownerDoc.createDocumentFragment();
        if (this.outputMethod == 'text') {
            f.appendChild(ownerDoc.createTextNode(s));
        } else if (ownerDoc.body && ownerDoc.body.innerHTML) {
            var container = ownerDoc.createElement('div');
            container.innerHTML = s;
            while (container.hasChildNodes()) {
                f.appendChild(container.firstChild);
            }
        }
        else {
            var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
            if (s.substring(0, 5) == '<?xml') {
                s = s.substring(s.indexOf('?>') + 2);
            }
            var xml = ''.concat('<my>', s, '</my>');
            oDoc.loadXML(xml);
            var container = oDoc.documentElement;
            while (container.hasChildNodes()) {
                f.appendChild(container.firstChild);
            }
        }
        return f;
    };
    
    /**
     * Set global XSLT parameter of the imported stylesheet
     * @argument nsURI The parameter namespace URI
     * @argument name The parameter base name
     * @argument value The new parameter value
     */
    XSLTProcessor.prototype.setParameter = function(nsURI, name, value){
        // nsURI is optional but cannot be null 
        if(nsURI){
            this.processor.addParameter(name, value, nsURI);
        }else{
            this.processor.addParameter(name, value);
        };
        // update updated params for getParameter 
        if(!this.paramsSet[""+nsURI]){
            this.paramsSet[""+nsURI] = new Array();
        };
        this.paramsSet[""+nsURI][name] = value;
    };
    /**
     * Gets a parameter if previously set by setParameter. Returns null
     * otherwise
     * @argument name The parameter base name
     * @argument value The new parameter value
     * @return The parameter value if reviously set by setParameter, null otherwise
     */
    XSLTProcessor.prototype.getParameter = function(nsURI, name){
        nsURI = nsURI || "";
        if(this.paramsSet[nsURI] && this.paramsSet[nsURI][name]){
            return this.paramsSet[nsURI][name];
        }else{
            return null;
        };
    };
    /**
     * Clear parameters (set them to default values as defined in the stylesheet itself)
     */
    XSLTProcessor.prototype.clearParameters = function(){
        for(var nsURI in this.paramsSet){
            for(var name in this.paramsSet[nsURI]){
                if(nsURI){
                    this.processor.addParameter(name, null, nsURI);
                }else{
                    this.processor.addParameter(name, null);
                };
            };
        };
        this.paramsSet = new Array();
    };
}else{ /* end IE initialization, try to deal with real browsers now ;-) */
    if(_SARISSA_HAS_DOM_CREATE_DOCUMENT){
        /**
         * <p>Ensures the document was loaded correctly, otherwise sets the
         * parseError to -1 to indicate something went wrong. Internal use</p>
         * @private
         */
        Sarissa.__handleLoad__ = function(oDoc){
            Sarissa.__setReadyState__(oDoc, 4);
        };
        /**
        * <p>Attached by an event handler to the load event. Internal use.</p>
        * @private
        */
        _sarissa_XMLDocument_onload = function(){
            Sarissa.__handleLoad__(this);
        };
        /**
         * <p>Sets the readyState property of the given DOM Document object.
         * Internal use.</p>
         * @private
         * @argument oDoc the DOM Document object to fire the
         *          readystatechange event
         * @argument iReadyState the number to change the readystate property to
         */
        Sarissa.__setReadyState__ = function(oDoc, iReadyState){
            oDoc.readyState = iReadyState;
            oDoc.readystate = iReadyState;
            if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function")
                oDoc.onreadystatechange();
        };
        Sarissa.getDomDocument = function(sUri, sName){
            var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
            if(!oDoc.onreadystatechange){
            
                /**
                * <p>Emulate IE's onreadystatechange attribute</p>
                */
                oDoc.onreadystatechange = null;
            };
            if(!oDoc.readyState){
                /**
                * <p>Emulates IE's readyState property, which always gives an integer from 0 to 4:</p>
                * <ul><li>1 == LOADING,</li>
                * <li>2 == LOADED,</li>
                * <li>3 == INTERACTIVE,</li>
                * <li>4 == COMPLETED</li></ul>
                */
                oDoc.readyState = 0;
            };
            oDoc.addEventListener("load", _sarissa_XMLDocument_onload, false);
            return oDoc;
        };
        if(window.XMLDocument){
            // do nothing
        }// TODO: check if the new document has content before trying to copynodes, check  for error handling in DOM 3 LS
        else if(_SARISSA_HAS_DOM_FEATURE && window.Document && !Document.prototype.load && document.implementation.hasFeature('LS', '3.0')){
            //Opera 9 may get the XPath branch which gives creates XMLDocument, therefore it doesn't reach here which is good
            /**
            * <p>Factory method to obtain a new DOM Document object</p>
            * @argument sUri the namespace of the root node (if any)
            * @argument sUri the local name of the root node (if any)
            * @returns a new DOM Document
            */
            Sarissa.getDomDocument = function(sUri, sName){
                var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
                return oDoc;
            };
        }
        else {
            Sarissa.getDomDocument = function(sUri, sName){
                var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
                // looks like safari does not create the root element for some unknown reason
                if(oDoc && (sUri || sName) && !oDoc.documentElement){
                    oDoc.appendChild(oDoc.createElementNS(sUri, sName));
                };
                return oDoc;
            };
        };
    };//if(_SARISSA_HAS_DOM_CREATE_DOCUMENT)
};
//==========================================
// Common stuff
//==========================================
if(!window.DOMParser){
    if(_SARISSA_IS_SAFARI){
        /*
         * DOMParser is a utility class, used to construct DOMDocuments from XML strings
         * @constructor
         */
        DOMParser = function() { };
        /** 
        * Construct a new DOM Document from the given XMLstring
        * @param sXml the given XML string
        * @param contentType the content type of the document the given string represents (one of text/xml, application/xml, application/xhtml+xml). 
        * @return a new DOM Document from the given XML string
        */
        DOMParser.prototype.parseFromString = function(sXml, contentType){
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(sXml), false);
            xmlhttp.send(null);
            return xmlhttp.responseXML;
        };
    }else if(Sarissa.getDomDocument && Sarissa.getDomDocument() && Sarissa.getDomDocument(null, "bar").xml){
        DOMParser = function() { };
        DOMParser.prototype.parseFromString = function(sXml, contentType){
            var doc = Sarissa.getDomDocument();
            doc.loadXML(sXml);
            return doc;
        };
    };
};

if((typeof(document.importNode) == "undefined") && _SARISSA_IS_IE){
    try{
        /**
        * Implementation of importNode for the context window document in IE
        * @param oNode the Node to import
        * @param bChildren whether to include the children of oNode
        * @returns the imported node for further use
        */
        document.importNode = function(oNode, bChildren){
            var tmp;
            if(oNode.nodeName == "tbody" || oNode.nodeName == "tr"){
                tmp = document.createElement("table");
            }
            else if(oNode.nodeName == "td"){
                tmp = document.createElement("tr");
            }
            else if(oNode.nodeName == "option"){
                tmp = document.createElement("select");
            }
            else{
                tmp = document.createElement("div");
            };
            if(bChildren){
                tmp.innerHTML = oNode.xml ? oNode.xml : oNode.outerHTML;
            }else{
                tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).outerHTML;
            };
            return tmp.getElementsByTagName("*")[0];
        };
    }catch(e){ };
};
if(!Sarissa.getParseErrorText){
    /**
     * <p>Returns a human readable description of the parsing error. Usefull
     * for debugging. Tip: append the returned error string in a &lt;pre&gt;
     * element if you want to render it.</p>
     * <p>Many thanks to Christian Stocker for the initial patch.</p>
     * @argument oDoc The target DOM document
     * @returns The parsing error description of the target Document in
     *          human readable form (preformated text)
     */
    Sarissa.getParseErrorText = function (oDoc){
        var parseErrorText = Sarissa.PARSED_OK;
        if(!oDoc.documentElement){
            parseErrorText = Sarissa.PARSED_EMPTY;
        } else if(oDoc.documentElement.tagName == "parsererror"){
            parseErrorText = oDoc.documentElement.firstChild.data;
            parseErrorText += "\n" +  oDoc.documentElement.firstChild.nextSibling.firstChild.data;
        } else if(oDoc.getElementsByTagName("parsererror").length > 0){
            var parsererror = oDoc.getElementsByTagName("parsererror")[0];
            parseErrorText = Sarissa.getText(parsererror, true)+"\n";
        } else if(oDoc.parseError && oDoc.parseError.errorCode != 0){
            parseErrorText = Sarissa.PARSED_UNKNOWN_ERROR;
        };
        return parseErrorText;
    };
};
Sarissa.getText = function(oNode, deep){
    var s = "";
    var nodes = oNode.childNodes;
    for(var i=0; i < nodes.length; i++){
        var node = nodes[i];
        var nodeType = node.nodeType;
        if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){
            s += node.data;
        } else if(deep == true
                    && (nodeType == Node.ELEMENT_NODE
                        || nodeType == Node.DOCUMENT_NODE
                        || nodeType == Node.DOCUMENT_FRAGMENT_NODE)){
            s += Sarissa.getText(node, true);
        };
    };
    return s;
};
if(!window.XMLSerializer 
    && Sarissa.getDomDocument 
    && Sarissa.getDomDocument("","foo", null).xml){
    /**
     * Utility class to serialize DOM Node objects to XML strings
     * @constructor
     */
    XMLSerializer = function(){};
    /**
     * Serialize the given DOM Node to an XML string
     * @param oNode the DOM Node to serialize
     */
    XMLSerializer.prototype.serializeToString = function(oNode) {
        return oNode.xml;
    };
};

/**
 * strips tags from a markup string
 */
Sarissa.stripTags = function (s) {
    return s.replace(/<[^>]+>/g,"");
};
/**
 * <p>Deletes all child nodes of the given node</p>
 * @argument oNode the Node to empty
 */
Sarissa.clearChildNodes = function(oNode) {
    // need to check for firstChild due to opera 8 bug with hasChildNodes
    while(oNode.firstChild) {
        oNode.removeChild(oNode.firstChild);
    };
};
/**
 * <p> Copies the childNodes of nodeFrom to nodeTo</p>
 * <p> <b>Note:</b> The second object's original content is deleted before 
 * the copy operation, unless you supply a true third parameter</p>
 * @argument nodeFrom the Node to copy the childNodes from
 * @argument nodeTo the Node to copy the childNodes to
 * @argument bPreserveExisting whether to preserve the original content of nodeTo, default is false
 */
Sarissa.copyChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
    if((!nodeFrom) || (!nodeTo)){
        throw "Both source and destination nodes must be provided";
    };
    if(!bPreserveExisting){
        Sarissa.clearChildNodes(nodeTo);
    };
    var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
    var nodes = nodeFrom.childNodes;
    if(typeof(ownerDoc.importNode) != "undefined")  {
        for(var i=0;i < nodes.length;i++) {
            nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
        };
    } else {
        for(var i=0;i < nodes.length;i++) {
            nodeTo.appendChild(nodes[i].cloneNode(true));
        };
    };
};

/**
 * <p> Moves the childNodes of nodeFrom to nodeTo</p>
 * <p> <b>Note:</b> The second object's original content is deleted before 
 * the move operation, unless you supply a true third parameter</p>
 * @argument nodeFrom the Node to copy the childNodes from
 * @argument nodeTo the Node to copy the childNodes to
 * @argument bPreserveExisting whether to preserve the original content of nodeTo, default is
 */ 
Sarissa.moveChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
    if((!nodeFrom) || (!nodeTo)){
        throw "Both source and destination nodes must be provided";
    };
    if(!bPreserveExisting){
        Sarissa.clearChildNodes(nodeTo);
    };
    var nodes = nodeFrom.childNodes;
    // if within the same doc, just move, else copy and delete
    if(nodeFrom.ownerDocument == nodeTo.ownerDocument){
        while(nodeFrom.firstChild){
            nodeTo.appendChild(nodeFrom.firstChild);
        };
    } else {
        var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
        if(typeof(ownerDoc.importNode) != "undefined") {
           for(var i=0;i < nodes.length;i++) {
               nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
           };
        }else{
           for(var i=0;i < nodes.length;i++) {
               nodeTo.appendChild(nodes[i].cloneNode(true));
           };
        };
        Sarissa.clearChildNodes(nodeFrom);
    };
};

/** 
 * <p>Serialize any object to an XML string. All properties are serialized using the property name
 * as the XML element name. Array elements are rendered as <code>array-item</code> elements, 
 * using their index/key as the value of the <code>key</code> attribute.</p>
 * @argument anyObject the object to serialize
 * @argument objectName a name for that object
 * @return the XML serializationj of the given object as a string
 */
Sarissa.xmlize = function(anyObject, objectName, indentSpace){
    indentSpace = indentSpace?indentSpace:'';
    var s = indentSpace  + '<' + objectName + '>';
    var isLeaf = false;
    if(!(anyObject instanceof Object) || anyObject instanceof Number || anyObject instanceof String 
        || anyObject instanceof Boolean || anyObject instanceof Date){
        s += Sarissa.escape(""+anyObject);
        isLeaf = true;
    }else{
        s += "\n";
        var itemKey = '';
        var isArrayItem = anyObject instanceof Array;
        for(var name in anyObject){
            s += Sarissa.xmlize(anyObject[name], (isArrayItem?"array-item key=\""+name+"\"":name), indentSpace + "   ");
        };
        s += indentSpace;
    };
    return s += (objectName.indexOf(' ')!=-1?"</array-item>\n":"</" + objectName + ">\n");
};

/** 
 * Escape the given string chacters that correspond to the five predefined XML entities
 * @param sXml the string to escape
 */
Sarissa.escape = function(sXml){
    return sXml.replace(/&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/>/g, "&gt;")
        .replace(/"/g, "&quot;")
        .replace(/'/g, "&apos;");
};

/** 
 * Unescape the given string. This turns the occurences of the predefined XML 
 * entities to become the characters they represent correspond to the five predefined XML entities
 * @param sXml the string to unescape
 */
Sarissa.unescape = function(sXml){
    return sXml.replace(/&apos;/g,"'")
        .replace(/&quot;/g,"\"")
        .replace(/&gt;/g,">")
        .replace(/&lt;/g,"<")
        .replace(/&amp;/g,"&");
};

if(_SARISSA_HAS_DOM_FEATURE && document.implementation.hasFeature("XPath", "3.0")){
    /**
    * <p>SarissaNodeList behaves as a NodeList but is only used as a result to <code>selectNodes</code>,
    * so it also has some properties IEs proprietery object features.</p>
    * @private
    * @constructor
    * @argument i the (initial) list size
    */
    function SarissaNodeList(i){
        this.length = i;
    };
    /** <p>Set an Array as the prototype object</p> */
    SarissaNodeList.prototype = new Array(0);
    /** <p>Inherit the Array constructor </p> */
    SarissaNodeList.prototype.constructor = Array;
    /**
    * <p>Returns the node at the specified index or null if the given index
    * is greater than the list size or less than zero </p>
    * <p><b>Note</b> that in ECMAScript you can also use the square-bracket
    * array notation instead of calling <code>item</code>
    * @argument i the index of the member to return
    * @returns the member corresponding to the given index
    */
    SarissaNodeList.prototype.item = function(i) {
        return (i < 0 || i >= this.length)?null:this[i];
    };
    /**
    * <p>Emulate IE's expr property
    * (Here the SarissaNodeList object is given as the result of selectNodes).</p>
    * @returns the XPath expression passed to selectNodes that resulted in
    *          this SarissaNodeList
    */
    SarissaNodeList.prototype.expr = "";
    /** dummy, used to accept IE's stuff without throwing errors */
    if(window.XMLDocument && (!XMLDocument.prototype.setProperty)){
        XMLDocument.prototype.setProperty  = function(x,y){};
    };

    Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
        //oDoc._sarissa_setXpathNamespaces(sNsSet);
        oDoc._sarissa_useCustomResolver = true;
        var namespaces = sNsSet.indexOf(" ")>-1?sNsSet.split(" "):new Array(sNsSet);
        oDoc._sarissa_xpathNamespaces = new Array(namespaces.length);
        for(var i=0;i < namespaces.length;i++){
            var ns = namespaces[i];
            var colonPos = ns.indexOf(":");
            var assignPos = ns.indexOf("=");
            if(colonPos > 0 && assignPos > colonPos+1){
                var prefix = ns.substring(colonPos+1, assignPos);
                var uri = ns.substring(assignPos+2, ns.length-1);
                oDoc._sarissa_xpathNamespaces[prefix] = uri;
            }else{
                throw "Bad format on namespace declaration(s) given";
            };
        };
    };
    /**
    * @private Flag to control whether a custom namespace resolver should
    *          be used, set to true by Sarissa.setXpathNamespaces
    */
    XMLDocument.prototype._sarissa_useCustomResolver = false;
    /** @private */
    XMLDocument.prototype._sarissa_xpathNamespaces = new Array();
    /**
    * <p>Extends the XMLDocument to emulate IE's selectNodes.</p>
    * @argument sExpr the XPath expression to use
    * @argument contextNode this is for internal use only by the same
    *           method when called on Elements
    * @returns the result of the XPath search as a SarissaNodeList
    * @throws An error if no namespace URI is found for the given prefix.
    */
    XMLDocument.prototype.selectNodes = function(sExpr, contextNode, returnSingle){
        var nsDoc = this;
        var nsresolver = this._sarissa_useCustomResolver
        ? function(prefix){
            var s = nsDoc._sarissa_xpathNamespaces[prefix];
            if(s)return s;
            else throw "No namespace URI found for prefix: '" + prefix+"'";
            }
        : this.createNSResolver(this.documentElement);
        var result = null;
        if(!returnSingle){
            var oResult = this.evaluate(sExpr,
                (contextNode?contextNode:this),
                nsresolver,
                XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
            var nodeList = new SarissaNodeList(oResult.snapshotLength);
            nodeList.expr = sExpr;
            for(var i=0;i<nodeList.length;i++)
                nodeList[i] = oResult.snapshotItem(i);
            result = nodeList;
        }
        else {
            result = oResult = this.evaluate(sExpr,
                (contextNode?contextNode:this),
                nsresolver,
                XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        };
        return result;      
    };
    /**
    * <p>Extends the Element to emulate IE's selectNodes</p>
    * @argument sExpr the XPath expression to use
    * @returns the result of the XPath search as an (Sarissa)NodeList
    * @throws An
    *             error if invoked on an HTML Element as this is only be
    *             available to XML Elements.
    */
    Element.prototype.selectNodes = function(sExpr){
        var doc = this.ownerDocument;
        if(doc.selectNodes)
            return doc.selectNodes(sExpr, this);
        else
            throw "Method selectNodes is only supported by XML Elements";
    };
    /**
    * <p>Extends the XMLDocument to emulate IE's selectSingleNode.</p>
    * @argument sExpr the XPath expression to use
    * @argument contextNode this is for internal use only by the same
    *           method when called on Elements
    * @returns the result of the XPath search as an (Sarissa)NodeList
    */
    XMLDocument.prototype.selectSingleNode = function(sExpr, contextNode){
        var ctx = contextNode?contextNode:null;
        return this.selectNodes(sExpr, ctx, true);
    };
    /**
    * <p>Extends the Element to emulate IE's selectSingleNode.</p>
    * @argument sExpr the XPath expression to use
    * @returns the result of the XPath search as an (Sarissa)NodeList
    * @throws An error if invoked on an HTML Element as this is only be
    *             available to XML Elements.
    */
    Element.prototype.selectSingleNode = function(sExpr){
        var doc = this.ownerDocument;
        if(doc.selectSingleNode)
            return doc.selectSingleNode(sExpr, this);
        else
            throw "Method selectNodes is only supported by XML Elements";
    };
    Sarissa.IS_ENABLED_SELECT_NODES = true;
};
