rnd.today=new Date();
rnd.seed=rnd.today.getTime();

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:no; border:thin; statusbar:no; dialogWidth:" + width + "px; dialogHeight:" + height + "px");
//	alert(oLink.href)
		if (str != "" && str != undefined)
			{
			location.href = str;
			}
		}
	
}

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://tourismecantons.qc.ca/_system/baniere/adclick2.asp?adresse='+slidelinks[whichlink],'stat')
}

function WBGoLien(intNoLien, intNoType, strUrl) {
//********************************************************
// Modifie le lien selon son type
//********************************************************	

// Variable du no de site pour les statistiques
//page interne
	if((intNoType==11) && (intNoLien==0)){
		if (!(strUrl.indexOf("ttp://") > 0))
		{
				strUrl = "http://" + strUrl;
		}
		location.href = strUrl
		//parent.location.href = "http://director.marigny.com/d-click.php?aid="+strIDSite+"&url="+strUrl;

	
	}else{
//page externe
		if ((intNoType==13) || (intNoType==12)){
			//WBLogUrlRequest(strUrl)
			if (!((strUrl.indexOf("ttp://") > 0) || (strUrl.indexOf("ww.") > 0))){
					strUrl = "http://iqfa.webbyzz.com" + 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{
//image						
			if ((intNoType==10) && (strUrl.indexOf(".htm") > 0))
			{
				strUrl = "http://iqfa.webbyzz.com" + 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=637,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=630,height=740,left=0,top=0')
}

function ChangeClass(pNo, pStrOn, pIsHighlight) {
	if (pIsHighlight) {
		document.getElementById("id_" + pNo).className = 'Txt_SMenu' + pStrOn;
	} else {
		document.getElementById("id_" + pNo).className = 'Txt_SMenu';
	}
}

function ChangeClassTop(pNo, pStrOn, pIsHighlight) {
	if (pIsHighlight) {
		document.getElementById("top_" + pNo).className = 'Txt_Menu' + pStrOn;
	} else {
		document.getElementById("top_" + pNo).className = 'Txt_Menu';
	}
}

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/IQFA/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/IQFA/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 rnd() {
	rnd.seed = (rnd.seed*9301+49297) % 233280;
	return rnd.seed/(233280.0);
}

function rand(number) {
		return Math.ceil(rnd()*number);
}

function NewImageSet() {
	document.getElementById("imgSet").src = "/_site/IQFA/template/images/set_photos_" + rand(8) + ".jpg";
}

function refreshTimer()	{
	document.getElementById("img_wait").src = "/_SITE/IQFA/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 isEmail(opt) {
	if (opt == "" || opt.length < 6)	//' Check if empty or invalid length 
		return false

	temp = /\s+/g;										//' Check for spaces (illegal characters)
	if (temp.test(opt))
		return false;
	

	temp = /^(\w|[^_]\.|[\-])+((\@){1}([^_]))(([a-z]|[\d]|[\-]|\.)+|([^_]\.[^_])*)+\.[a-z]{2,6}$/i;
	if (!temp.test(opt))
		return false;
			
	temp =/\.(a[c-gil-oq-uwz]|b[a-bd-jm-or-tvwyz]|c[acdf-ik-orsuvx-z]|d[ejkmoz]|e[ceghr-u]|f[i-kmorx]|g[abd-ilmnp-uwy]|h[kmnrtu]|i[delm-oq-t]|j[emop]|k[eg-imnprwyz]|l[a-cikr-vy]|m[acdghk-z]|n[ace-giloprtuz]|om|p[ae-hk-nrtwy]|qa|r[eouw]|s[a-eg-ort-vyz]|t[cdf-hjkm-prtvwz]|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[admrw]|com|edu|net|org|mil|gov|biz|pro|aero|coop|info|name|museum)$/i;
	
	if (!temp.test(opt))								//' Validate domains part of the email
		return false;
	
	temp = /\.\./										//' Validate ././ problem
	if (temp.test(opt))
		return false;
	
														//'  Validate @@ problem
	temp = /\@\@/
	if(temp.test(opt))
		return false;

	return true;
}

function ValidateSendToFriend() {
	var strMessage = "";
	var emailDest = document.getElementById("emailDest").value;
	if (emailDest == "") {
		strMessage = strMessage + "Le courriel du destinataire est obligatoire.\n";
	} else {
		if (emailDest.indexOf(",") != -1) {
			var arrEmail = emailDest.split(",")
			for (var i = 0; i < arrEmail.length; i++) {
				if (!(isEmail(arrEmail[i]))) {
					strMessage = strMessage + "Le courriel du destinataire «" + arrEmail[i] + "» ne possède pas un format valide.\n"
				}
			}
		} else {
			if (!(isEmail(emailDest))) {
				strMessage = strMessage + "Le courriel du destinataire ne possède pas un format valide.\n"
			}
		}
	}
	
	if (document.getElementById("nomSender").value == "") {
		strMessage = strMessage + "Votre nom est obligatoire.\n"
	}

	if (document.getElementById("emailSender").value != "") {
		if (!(isEmail(document.getElementById("emailSender").value))) {
			strMessage = strMessage + "Votre courriel ne possède pas un format valide.\n"
		}
	}

	if (strMessage != "") {
		document.getElementById("div_attente").style.display = "none";
		alert(strMessage);
		return false;
	}

	return true;
}

function validerInfo() {
	var strCourriel = new String("");
	var strMessage = "";

	if(document.getElementById("nom").value == "") {
		strMessage = strMessage + "Vous devez entrer votre nom.\n";
	}
	if(document.getElementById("prenom").value == "")
	{
		strMessage = strMessage + "Vous devez entrer votre prénom.\n";
	}
	if(document.getElementById("courriel").value == "")
	{
		strMessage = strMessage + "Vous devez entrer votre courriel.\n";
	}
	else
	{
		strCourriel = document.getElementById("courriel").value;
		if(!isEmail(strCourriel)) {
			strMessage = strMessage + "Vous courriel est invalide.\n";
		}
	}

	if (strMessage != "") {
		alert(strMessage);
		return false;
	}


	return true;
}