/*
 * canalvie.js
 *  2007 canalvie.com
 */


// Browser detect
var browser;
var isIE4 = (document.all) ? true:false;
if (isIE4) {
  if (navigator.userAgent.indexOf('MSIE 6') > 0) {
    browser = 'IE6';
	} else if (navigator.userAgent.indexOf('MSIE 5') > 0) {
    browser = 'IE5';
  } else {
    browser = 'IE4';
  }
} else {
	if (navigator.userAgent.indexOf('Firefox') > 0) {
    browser = 'FFX';
	} else if (navigator.userAgent.indexOf('Netscape/7') > 0) {
    browser = 'NN7';
  } else if (navigator.userAgent.indexOf('Netscape6/6') > 0) {
    browser = 'NN6';
  } else {
    browser = 'NN4';
  }
}


// OS detect
var OS;
if (navigator.appVersion.indexOf("Mac") != -1) {
  OS = 'mac';
} else {
  OS = 'win';
}


// Menu Flash
function printMenu(activeSection)
{
	// On definit les variables du menu
	var menuParams = {
		activeSection: activeSection
	};

	// On definit les paramtres du flash du menu
	var menuSWFParams = {
		bgColor: "#000000",
		quality: "high",
		wmode: "transparent",
		swliveconnect: "true",
		allowScriptAccess: "always",
		allowFullScreen: true
	};

	// On definit les attributs de l'objet html du flash du menu
	var menuHtmlAttributes = {
		id: "HeaderMenu"
	};

	// On print le flash
	swfobject.embedSWF("/_img/Menu.swf", "header_menu", "1000", "34", "9.0.115", "/_img/expressinstall.swf", menuParams, menuSWFParams, menuHtmlAttributes);
}

function printSousMenu(activeSubSection)
{
	$('#deco_sousmenu').flash(
		{ src: '/decoration/_img/SousMenu.swf', width:1000, height: 28, bgcolor: '#ffffff', quality: 'high', menu: false, wmode: 'transparent', swliveconnect: 'true', allowScriptAccess: 'always', allowFullScreen: true, flashvars: {
				activeSection: activeSubSection
			}
		},
		{ version: '9.0.115' }
	);
}

// DHTML popups for members
// MUST include jquery.js
function closeAllMemberPopups() {
 $(document).ready(function(){
    $(".membre_dhtml").css("visibility","hidden");
  });
	/*
	var cv_allDivs = document.getElementsByTagName("div");
	if (cv_allDivs) {
		var cv_memberPopups = new Array();
		var j = 0;
		for (i=0; i<cv_allDivs.length; i++) {
			if (cv_allDivs[i].className == "membre_dhtml") {
				cv_memberPopups[j] = cv_allDivs[i];
				j++;
			}
		}
		if (cv_memberPopups) {
			for (i = 0; i<cv_memberPopups.length; i++) {
				if (cv_memberPopups[i].style) {
					cv_memberPopups[i].style.visibility = "hidden";
				}
			}
		}
	}
	*/
}


// Banner adds
var si_site_name = 'sri.canalvie';
var si_ord = Math.round(Math.random()*100000000000);
function SIWriteAdvert(si_zone, si_tile_id, si_size) {
  try {
    var dcopt_val = '';
    if (si_tile_id == 1) {
      dcopt_val='dcopt=ist;'
    }
    document.write("<sc"+"ript type=\"text/jav"+"ascript\" src=\"http://ad.double"+"click.net/adj/"+si_site_name+"/"+si_zone+";"+dcopt_val+"tile="+si_tile_id+";sz="+si_size+";ord="+si_ord+"?\"></scr"+"ipt>");
  } catch (e) {
    // alert('error');
    return;
  }
}

function SIWriteAdvertBottom(si_zone, si_tile_id, si_size) {
  try {
    var dcopt_val = '';
    if (si_tile_id == 1) {
      dcopt_val='dcopt=ist;'
    }
    document.write("<sc"+"ript type=\"text/jav"+"ascript\" src=\"http://ad.double"+"click.net/adj/"+si_site_name+"/"+si_zone+";"+dcopt_val+"tile="+si_tile_id+";sz="+si_size+";pos=bottom;ord="+si_ord+"?\"></scr"+"ipt>");
  } catch (e) {
    // alert('error');
    return;
  }
}

function SIWriteAdvertTop(si_zone, si_tile_id, si_size) {
  try {
    var dcopt_val = '';
    if (si_tile_id == 1) {
      dcopt_val='dcopt=ist;'
    }
    document.write("<sc"+"ript type=\"text/jav"+"ascript\" src=\"http://ad.double"+"click.net/adj/"+si_site_name+"/"+si_zone+";"+dcopt_val+"tile="+si_tile_id+";sz="+si_size+";pos=top;ord="+si_ord+"?\"></scr"+"ipt>");
  } catch (e) {
    // alert('error');
    return;
  }
}

// Fireworks rollovers
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



// Layers
function MM_showHideLayers() { // v3.0
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i = 0; i<(args.length - 2); i += 3) if ((obj=MM_findObj(args[i]))!=null) {
		v = args[i+2];
		if (obj.style) {
			obj = obj.style;
			v = (v == 'show') ? 'visible' : (v='hide') ? 'hidden' : v;
		}
	obj.visibility = v;
	}
}


// Centered popups
function popup(page, name, w, h, t, l, d, s, m, sc, r) {
	var newleft = (screen.width - w) / 2;
	var newtop = (screen.height - h) / 2;
	var prop1 = "toolbar=" + t + ",location=" + l + ",directories=" + d + ",status=" + s + ",menubar=" + m + ",scrollbars=" + sc + ",resizable=" + r +",";
	var prop2 = "width=" + w + ",height=" + h + ",top=" + newtop + ",left=" + newleft;
	window.open(page, name, prop1 + prop2);
}


// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header

function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}


// Random
function getRandom(maxValue) {
	var randomNumber = Math.floor(Math.random()*(maxValue+1));
	if ((randomNumber > maxValue) || (randomNumber == 0)) {
		return getRandom((maxValue));
	} else {
		return randomNumber;
	}
}


// Form validation
function checkIfNumeric(input) {
	var isNumeric = false;
	var NUMERIC = "0123456789";
	input = input.toUpperCase();
	for(var i=0; i<input.length; i++) {
		var CHAR = input.charAt(i);
		if((NUMERIC.indexOf(CHAR) >= 0) && !isNumeric) {
			isNumeric = true;
		}
	}
	return isNumeric;
}

function getCheckRadioValue(radios) {
	var checkedValue = -1;
	for (i=0; i<radios.length; i++) {
		if (radios[i].checked) {
			checkedValue = radios[i].value;
		}
	}
	return checkedValue;
}

function checkIfValidUploadFile(file) {
	var isValid = true;
	var indexExe = file.indexOf('.exe');
	var indexJs = file.indexOf('.js');
	if ((indexExe > -1) || (indexJs > -1)) {
		isValid = false;
	}
	return isValid;
}

function checkIfValidImageFile(file) {
	var isValid = true;
	var indexJpeg = file.toLowerCase().lastIndexOf('.jpeg');
	var indexJpg = file.toLowerCase().lastIndexOf('.jpg');
	var indexGif = file.toLowerCase().lastIndexOf('.gif');
	if ((indexJpeg == -1) && (indexJpg == -1) && (indexGif == -1)) {
		isValid = false;
	}
	return isValid;
}

function checkIfMail(address) {
	var filterRegExp =/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;
	return filterRegExp.test(address)
}

function checkRecr(recrForm) {
	var errorContainer;
	if (document.getElementById) {
		// Level 1 DOM code
		errorContainer = document.getElementById("errorContainer");
	} else if (document.all) {
    	// Microsoft DOM code
		errorContainer = document.all['errorContainer'];
	}
	var errorMsg = "<b>Erreur : </b><br/>";
	for (var i=0; i<recrForm.length; i++) {
		var element = recrForm.elements[i];
		if ((element.type != "hidden") && (element.type != "submit")) {
			// Text
			if (element.type == "text") {
				if ((element.name.indexOf("optionnel") == -1) && (element.value == "")) {
					errorMsg += "Veuillez remplir le champ \"" + element.name + "\".<br/>";
				/*} else if (element.name == "Courriel") {*/
				} else if (element.name.indexOf("Courriel") != -1) {
					if (!checkIfMail(element.value)) {
						errorMsg += "Votre adresse de courriel ne semble pas valide.<br/>";
					}
				}
			}
			// Textarea
			if (element.type == "textarea") {
				if ((element.name.indexOf("optionnel") == -1) && element.value == "") {
					errorMsg += "Veuillez remplir le champ \"" + element.name + "\".<br/>";
				}
			}
			// Radio
			if (element.type == "radio") {
				if (element.name.indexOf("optionnel") == -1) {
					if (getCheckRadioValue(recrForm.elements[element.name]) == -1) {
						if (errorMsg.indexOf(element.name) == -1) {
							errorMsg += "Veuillez faire votre choix pour \"" + element.name + "\".<br/>";
						}
					}
				}
			}
			// Checkbox
			/* (release - voir www.canalvie.com/emission/monenfant_monheros/recrutement2.jsp) */
			if (element.type == "checkbox" && element.name == "Release" && element.checked == false) {
				errorMsg += "\nVeuillez cocher la case \"" + element.value + "\".\nEn soumettant votre tmoignage, vous devez accepter que \nLes Chanes Tl Astral puissent publier votre texte, \nune partie de celui-ci ou encore toute photo \nque vous aurez jointe  votre tmoignage.<br/>";
			} else if (element.type == "checkbox") {
				if (element.name.indexOf("optionnel") == -1) {
					if (element.checked == false) {
						errorMsg += "Veuillez cocher la case \"" + element.name + "\".\n<br/>";
					}
				}
			}
			// File
			if (element.type == "file") {
				if (element.name.indexOf("optionnel") == -1) {
					if (element.value == "") {
						errorMsg += "Veuillez slectionner un fichier pour le champ \"" + element.name + "\".<br/>";
					} else {
						if (element.name.indexOf("Photo") > -1) {
							if (!checkIfValidImageFile(element.value)) {
								errorMsg += "Les seuls fichiers accepts sont \".gif\", \".jpg\" ou \".jpeg\".<br/>";
							}
						} else if (!checkIfValidUploadFile(element.value)) {
							errorMsg += "Les seuls fichiers accepts sont \".gif\", \".jpg\" ou \".jpeg\".<br/>";
						}
					}
				}
			}

			// Drop-down box
			if (element.type == "select-one") {
				if (element.name.indexOf("optionnel") == -1) {
					if (element.selectedIndex == 0) {
						errorMsg += "Veuillez slectionner un lment du menu droulant \"" + element.name + "\".<br/>";
					}
				}
			}
		}
	}
	if (errorMsg != "<b>Erreur : </b><br/>") {
		errorContainer.innerHTML = "" + errorMsg + "";
		errorContainer.style.display = "block";
		return false;
	} else {
		return true;
	}
}


// Print section - decore
var gAutoPrint = true; // Tells whether to automatically call the print function

function printSpecialDecore() {
	if (document.getElementById != null) {
		var html = '';
		html += '<HTML>\n\r';
		html += '<HEAD>\n\r';
		html += '<style type="text/css">\n\r';
		html += '@import url(/_css/canalvie_print.css);\n\r';
		html += '</style>\n\r';
		html += '</HEAD>\n\r';
		html += '<BODY>\n\r';
		html += '<IMG SRC="http://www.canalvie.com/emission/decore_tavie/_img/entete_print.jpg"><BR><BR>\n\r';
		var printReadyElem = document.getElementById("printReady");
		if (printReadyElem != null) {
			html += printReadyElem.innerHTML;
		} else {
			// alert("Fonction printReady introuvable.");
			return;
		}
		html += '</BODY>\n\r';
		html += '</HTML>';
		var printWin = window.open("","printSpecial","menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)	printWin.print();
	} else {
		// alert("Votre fureteur ne supporte pas cette fonction. Veuillez le mettre  jour.");
	}
}


// Print section
function printSpecial() {
	if (document.getElementById != null) {
		var html = '<HTML>\n<HEAD>\n';
		if (document.getElementsByTagName != null) {
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0) {
				html += headTags[0].innerHTML;
			}
		}
		html += '\n</HEAD>\n<BODY>\n';
		var printReadyElem = document.getElementById("printReady");
		if (printReadyElem != null) {
			html += printReadyElem.innerHTML;
		} else {
			// alert("Fonction printReady introuvable.");
			return;
		}
		html += '\n</BODY>\n</HTML>';
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint) {
			printWin.print();
		}
	} else {
		// alert("Votre fureteur ne supporte pas cette fonction. Veuillez le mettre  jour.");
	}
}


// Cookies
function getCookie(cookieName) {
	var results = document.cookie.match (cookieName + '=(.*?)(;|$)');
	if (results) {
		return (unescape(results[1]));
	} else {
		return null;
	}
}

function setCookie(cookieName, cookieValue, cookieDays) {
	if (cookieDays) {
		var date = new Date();
		date.setTime(date.getTime() + (cookieDays*24*60*60*1000));
		var cookieExpires = "; expires=" + date.toGMTString();
	} else {
		var cookieExpires = "";
	}
	document.cookie = cookieName + "=" + cookieValue + cookieExpires + "; path=/";
}


// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
/*function correctPNG() {
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}
if (isIE4) {
	window.attachEvent("onload", correctPNG);
}
*/



// CheckBoxes
function alterCheckBoxes(idCSVList, state) {
	// Ids must be unique in page.
	var idArray = new Array();
	idArray = idCSVList.split(", ");
	for (i = 0; i < idArray.length; i++) {
		document.getElementsByName(idArray[i])[0].checked = state;
	}
}



/**
 * SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
	if (!document.createElement || !document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall);
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', useExpressInstall);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}


/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			for (var i=3; axo!=null; i++) {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				PlayerVersion = new deconcept.PlayerVersion([i,0,0]);
			}
		}catch(e){}
		if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; // version is ok, skip minor detection
		// this only does the minor rev lookup if the user's major version
		// is not 6 or we are checking for a specific minor or revision number
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
			try{
				PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
			}catch(e){}
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = parseInt(arrVersion[0]) != null ? parseInt(arrVersion[0]) : 0;
	this.minor = parseInt(arrVersion[1]) || 0;
	this.rev = parseInt(arrVersion[2]) || 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param){
		var q = document.location.search || document.location.hash;
		if(q){
			var startIndex = q.indexOf(param +"=");
			var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
			if (q.length > 1 && startIndex > -1) {
				return q.substring(q.indexOf("=", startIndex)+1, endIndex);
			}
		}
		return "";
	}
}


/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;


// Fonction qui switch le contenu d'un div
function switchDivContent(htmlToInsert, divId){
	if (document.getElementById) {
		obj = document.getElementById(divId);
		obj.innerHTML = htmlToInsert;
	} else if (document.all) {
		obj = document.all[divId]
		obj.innerHTML = htmlToInsert;
	}
}

// Ajouter aux favoris
function favoris(pageName, pageUrl) {
	if ( navigator.appName != 'Microsoft Internet Explorer' ){
		window.sidebar.addPanel(pageName,pageUrl,"");
	} else {
		window.external.AddFavorite(pageUrl, pageName);
	}
}

// Menu droulant
function jumpBox(list) {location.href =list.options[list.selectedIndex].value}

function jumpBoxBlank(list) {
	url = list.options[list.selectedIndex].value;
	if (url != '') {
		window.open(url);
	}
}

// Function used to include js files. Script must "end" before included script can be active.
function jsInclude(jsFile) {
	document.write('<' + 'script');
	document.write(' language="JavaScript"');
	document.write(' type="text/javascript"');
	document.write(' src="' + jsFile + '">');
	document.write('</' + 'script' + '>');
}

// Format for url
function formatForUrlStrict(input) {
	var output = input.toLowerCase();

	output = output.replace(/&quot;/g,'"'); // 34 22
	output = output.replace(/&amp;/g,'&'); // 38 26
	output = output.replace(/&#39;/g,"'"); // 39 27
	output = output.replace(/&lt;/g,'<'); // 60 3C
	output = output.replace(/&gt;/g,'>'); // 62 3E
	output = output.replace(/&circ;/g,'^'); // 94 5E
	output = output.replace(/&lsquo;/g,''); // 145 91
	output = output.replace(/&rsquo;/g,''); // 146 92
	output = output.replace(/&ldquo;/g,''); // 147 93
	output = output.replace(/&rdquo;/g,''); // 148 94
	output = output.replace(/&bull;/g,''); // 149 95
	output = output.replace(/&ndash;/g,''); // 150 96
	output = output.replace(/&mdash;/g,''); // 151 97
	output = output.replace(/&tilde;/g,''); // 152 98
	output = output.replace(/&trade;/g,''); // 153 99
	output = output.replace(/&scaron;/g,''); // 154 9A
	output = output.replace(/&rsaquo;/g,''); // 155 9B
	output = output.replace(/&oelig;/g,''); // 156 9C
	output = output.replace(/&#357;/g,''); // 157 9D
	output = output.replace(/&#382;/g,''); // 158 9E
	output = output.replace(/&Yuml;/g,''); // 159 9F
	output = output.replace(/&nbsp;/g,' '); // 160 A0
	output = output.replace(/&iexcl;/g,''); // 161 A1
	output = output.replace(/&cent;/g,''); // 162 A2
	output = output.replace(/&pound;/g,''); // 163 A3
	output = output.replace(/&curren;/g,' '); // 164 A4
	output = output.replace(/&yen;/g,''); // 165 A5
	output = output.replace(/&brvbar;/g,''); // 166 A6
	output = output.replace(/&sect;/g,''); // 167 A7
	output = output.replace(/&uml;/g,''); // 168 A8
	output = output.replace(/&copy;/g,''); // 169 A9
	output = output.replace(/&ordf;/g,''); // 170 AA
	output = output.replace(/&laquo;/g,''); // 171 AB
	output = output.replace(/&not;/g,''); // 172 AC
	output = output.replace(/&shy;/g,''); // 173 AD
	output = output.replace(/&reg;/g,''); // 174 AE
	output = output.replace(/&macr;/g,''); // 175 AF
	output = output.replace(/&deg;/g,''); // 176 B0
	output = output.replace(/&plusmn;/g,''); // 177 B1
	output = output.replace(/&sup2;/g,''); // 178 B2
	output = output.replace(/&sup3;/g,''); // 179 B3
	output = output.replace(/&acute;/g,''); // 180 B4
	output = output.replace(/&micro;/g,''); // 181 B5
	output = output.replace(/&para/g,''); // 182 B6
	output = output.replace(/&middot;/g,''); // 183 B7
	output = output.replace(/&cedil;/g,''); // 184 B8
	output = output.replace(/&sup1;/g,''); // 185 B9
	output = output.replace(/&ordm;/g,''); // 186 BA
	output = output.replace(/&raquo;/g,''); // 187 BB
	output = output.replace(/&frac14;/g,''); // 188 BC
	output = output.replace(/&frac12;/g,''); // 189 BD
	output = output.replace(/&frac34;/g,''); // 190 BE
	output = output.replace(/&iquest;/g,''); // 191 BF
	output = output.replace(/&Agrave;/g,''); // 192 C0
	output = output.replace(/&Aacute;/g,''); // 193 C1
	output = output.replace(/&Acirc;/g,''); // 194 C2
	output = output.replace(/&Atilde;/g,''); // 195 C3
	output = output.replace(/&Auml;/g,''); // 196 C4
	output = output.replace(/&Aring;/g,''); // 197 C5
	output = output.replace(/&AElig;/g,''); // 198 C6
	output = output.replace(/&Ccedil;/g,''); // 199 C7
	output = output.replace(/&Egrave;/g,''); // 200 C8
	output = output.replace(/&Eacute;/g,''); // 201 C9
	output = output.replace(/&Ecirc;/g,''); // 202 CA
	output = output.replace(/&Euml;/g,''); // 203 CB
	output = output.replace(/&Igrave;/g,''); // 204 CC
	output = output.replace(/&Iacute;/g,''); // 205 CD
	output = output.replace(/&Icirc;/g,''); // 206 CE
	output = output.replace(/&Iuml;/g,''); // 207 CF
	output = output.replace(/&ETH;/g,''); // 208 D0
	output = output.replace(/&Ntilde;/g,''); // 209 D1
	output = output.replace(/&Ograve;/g,''); // 210 D2
	output = output.replace(/&Oacute;/g,''); // 211 D3
	output = output.replace(/&Ocirc;/g,''); // 212 D4
	output = output.replace(/&Otilde;/g,''); // 213 D5
	output = output.replace(/&Ouml;/g,''); // 214 D6
	output = output.replace(/&times;/g,''); // 215 D7
	output = output.replace(/&Oslash;/g,''); // 216 D8
	output = output.replace(/&Ugrave;/g,''); // 217 D9
	output = output.replace(/&Uacute;/g,''); // 218 DA
	output = output.replace(/&Ucirc;/g,''); // 219 DB
	output = output.replace(/&Uuml;/g,''); // 220 DC
	output = output.replace(/&Yacute;/g,''); // 221 DD
	output = output.replace(/&THORN;/g,''); // 222 DE
	output = output.replace(/&szlig;/g,''); // 223 DF
	output = output.replace(/&agrave;/g,''); // 224 E0
	output = output.replace(/&aacute;/g,''); // 225 E1
	output = output.replace(/&acirc;/g,''); // 226 E2
	output = output.replace(/&atilde;/g,''); // 227 E3
	output = output.replace(/&auml;/g,''); // 228 E4
	output = output.replace(/&aring;/g,''); // 229 E5
	output = output.replace(/&aelig;/g,''); // 230 E6
	output = output.replace(/&ccedil;/g,''); // 231 E7
	output = output.replace(/&egrave;/g,''); // 232 E8
	output = output.replace(/&eacute;/g,''); // 233 E9
	output = output.replace(/&ecirc;/g,''); // 234 EA
	output = output.replace(/&euml;/g,''); // 235 EB
	output = output.replace(/&igrave;/g,''); // 236 EC
	output = output.replace(/&iacute;/g,''); // 237 ED
	output = output.replace(/&icirc;/g,''); // 238 EE
	output = output.replace(/&iuml;/g,''); // 239 EF
	output = output.replace(/&eth;/g,''); // 240 F0
	output = output.replace(/&ntilde;/g,''); // 241 F1
	output = output.replace(/&ograve;/g,''); // 242 F2
	output = output.replace(/&oacute;/g,''); // 243 F3
	output = output.replace(/&ocirc;/g,''); // 244 F4
	output = output.replace(/&otilde;/g,''); // 245 F5
	output = output.replace(/&ouml;/g,''); // 246 F6
	output = output.replace(/&divide;/g,''); // 247 F7
	output = output.replace(/&oslash;/g,''); // 248 F8
	output = output.replace(/&ugrave;/g,''); // 249 F9
	output = output.replace(/&uacute;/g,''); // 250 FA
	output = output.replace(/&ucirc;/g,''); // 251 FB
	output = output.replace(/&uuml;/g,''); // 252 FC
	output = output.replace(/&yacute;/g,''); // 253 FD
	output = output.replace(/&thorn;/g,''); // 254 FE
	output = output.replace(/&yuml;/g,''); // 255 FF

	output = stripAccents(output);

	// Whitelist character verification
	var allowedCharacters = "a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9";
	var outputWithOnlyAllowedChars = "";

	for (var i=0; i<output.length; i++) {
		if (allowedCharacters.indexOf(output.charAt(i)) != -1) {
			outputWithOnlyAllowedChars += output.charAt(i);
		} else {
			outputWithOnlyAllowedChars += " ";
		}
	}

	// White space removal and replacement
	while (outputWithOnlyAllowedChars.indexOf("  ") != -1) {
		outputWithOnlyAllowedChars = outputWithOnlyAllowedChars.replace(/  /g, " ");
	}

	outputWithOnlyAllowedChars = outputWithOnlyAllowedChars.replace(/ /g, "-");

	return outputWithOnlyAllowedChars;
}

function stripAccents(input) {
	var output = input.replace(/[]/gi,"a");
	output = output.replace(/[]/gi,"e");
	output = output.replace(/[]/gi,"i");
	output = output.replace(/[]/gi,"o");
	output = output.replace(/[]/gi,"u");
	output = output.replace(/[]/gi,"c");
	return output;
}

function convertHTMLEntitiesToANSI(input) {

	var output = input;

	output = output.replace(/&quot;/g,'"'); // 34 22
	output = output.replace(/&amp;/g,'&'); // 38 26
	output = output.replace(/&#39;/g,"'"); // 39 27
	output = output.replace(/&lt;/g,'<'); // 60 3C
	output = output.replace(/&gt;/g,'>'); // 62 3E
	output = output.replace(/&circ;/g,'^'); // 94 5E
	output = output.replace(/&lsquo;/g,''); // 145 91
	output = output.replace(/&rsquo;/g,''); // 146 92
	output = output.replace(/&ldquo;/g,''); // 147 93
	output = output.replace(/&rdquo;/g,''); // 148 94
	output = output.replace(/&bull;/g,''); // 149 95
	output = output.replace(/&ndash;/g,''); // 150 96
	output = output.replace(/&mdash;/g,''); // 151 97
	output = output.replace(/&tilde;/g,''); // 152 98
	output = output.replace(/&trade;/g,''); // 153 99
	output = output.replace(/&scaron;/g,''); // 154 9A
	output = output.replace(/&rsaquo;/g,''); // 155 9B
	output = output.replace(/&oelig;/g,''); // 156 9C
	output = output.replace(/&#357;/g,''); // 157 9D
	output = output.replace(/&#382;/g,''); // 158 9E
	output = output.replace(/&Yuml;/g,''); // 159 9F
	output = output.replace(/&nbsp;/g,' '); // 160 A0
	output = output.replace(/&iexcl;/g,''); // 161 A1
	output = output.replace(/&cent;/g,''); // 162 A2
	output = output.replace(/&pound;/g,''); // 163 A3
	output = output.replace(/&curren;/g,' '); // 164 A4
	output = output.replace(/&yen;/g,''); // 165 A5
	output = output.replace(/&brvbar;/g,''); // 166 A6
	output = output.replace(/&sect;/g,''); // 167 A7
	output = output.replace(/&uml;/g,''); // 168 A8
	output = output.replace(/&copy;/g,''); // 169 A9
	output = output.replace(/&ordf;/g,''); // 170 AA
	output = output.replace(/&laquo;/g,''); // 171 AB
	output = output.replace(/&not;/g,''); // 172 AC
	output = output.replace(/&shy;/g,''); // 173 AD
	output = output.replace(/&reg;/g,''); // 174 AE
	output = output.replace(/&macr;/g,''); // 175 AF
	output = output.replace(/&deg;/g,''); // 176 B0
	output = output.replace(/&plusmn;/g,''); // 177 B1
	output = output.replace(/&sup2;/g,''); // 178 B2
	output = output.replace(/&sup3;/g,''); // 179 B3
	output = output.replace(/&acute;/g,''); // 180 B4
	output = output.replace(/&micro;/g,''); // 181 B5
	output = output.replace(/&para/g,''); // 182 B6
	output = output.replace(/&middot;/g,''); // 183 B7
	output = output.replace(/&cedil;/g,''); // 184 B8
	output = output.replace(/&sup1;/g,''); // 185 B9
	output = output.replace(/&ordm;/g,''); // 186 BA
	output = output.replace(/&raquo;/g,''); // 187 BB
	output = output.replace(/&frac14;/g,''); // 188 BC
	output = output.replace(/&frac12;/g,''); // 189 BD
	output = output.replace(/&frac34;/g,''); // 190 BE
	output = output.replace(/&iquest;/g,''); // 191 BF
	output = output.replace(/&Agrave;/g,''); // 192 C0
	output = output.replace(/&Aacute;/g,''); // 193 C1
	output = output.replace(/&Acirc;/g,''); // 194 C2
	output = output.replace(/&Atilde;/g,''); // 195 C3
	output = output.replace(/&Auml;/g,''); // 196 C4
	output = output.replace(/&Aring;/g,''); // 197 C5
	output = output.replace(/&AElig;/g,''); // 198 C6
	output = output.replace(/&Ccedil;/g,''); // 199 C7
	output = output.replace(/&Egrave;/g,''); // 200 C8
	output = output.replace(/&Eacute;/g,''); // 201 C9
	output = output.replace(/&Ecirc;/g,''); // 202 CA
	output = output.replace(/&Euml;/g,''); // 203 CB
	output = output.replace(/&Igrave;/g,''); // 204 CC
	output = output.replace(/&Iacute;/g,''); // 205 CD
	output = output.replace(/&Icirc;/g,''); // 206 CE
	output = output.replace(/&Iuml;/g,''); // 207 CF
	output = output.replace(/&ETH;/g,''); // 208 D0
	output = output.replace(/&Ntilde;/g,''); // 209 D1
	output = output.replace(/&Ograve;/g,''); // 210 D2
	output = output.replace(/&Oacute;/g,''); // 211 D3
	output = output.replace(/&Ocirc;/g,''); // 212 D4
	output = output.replace(/&Otilde;/g,''); // 213 D5
	output = output.replace(/&Ouml;/g,''); // 214 D6
	output = output.replace(/&times;/g,''); // 215 D7
	output = output.replace(/&Oslash;/g,''); // 216 D8
	output = output.replace(/&Ugrave;/g,''); // 217 D9
	output = output.replace(/&Uacute;/g,''); // 218 DA
	output = output.replace(/&Ucirc;/g,''); // 219 DB
	output = output.replace(/&Uuml;/g,''); // 220 DC
	output = output.replace(/&Yacute;/g,''); // 221 DD
	output = output.replace(/&THORN;/g,''); // 222 DE
	output = output.replace(/&szlig;/g,''); // 223 DF
	output = output.replace(/&agrave;/g,''); // 224 E0
	output = output.replace(/&aacute;/g,''); // 225 E1
	output = output.replace(/&acirc;/g,''); // 226 E2
	output = output.replace(/&atilde;/g,''); // 227 E3
	output = output.replace(/&auml;/g,''); // 228 E4
	output = output.replace(/&aring;/g,''); // 229 E5
	output = output.replace(/&aelig;/g,''); // 230 E6
	output = output.replace(/&ccedil;/g,''); // 231 E7
	output = output.replace(/&egrave;/g,''); // 232 E8
	output = output.replace(/&eacute;/g,''); // 233 E9
	output = output.replace(/&ecirc;/g,''); // 234 EA
	output = output.replace(/&euml;/g,''); // 235 EB
	output = output.replace(/&igrave;/g,''); // 236 EC
	output = output.replace(/&iacute;/g,''); // 237 ED
	output = output.replace(/&icirc;/g,''); // 238 EE
	output = output.replace(/&iuml;/g,''); // 239 EF
	output = output.replace(/&eth;/g,''); // 240 F0
	output = output.replace(/&ntilde;/g,''); // 241 F1
	output = output.replace(/&ograve;/g,''); // 242 F2
	output = output.replace(/&oacute;/g,''); // 243 F3
	output = output.replace(/&ocirc;/g,''); // 244 F4
	output = output.replace(/&otilde;/g,''); // 245 F5
	output = output.replace(/&ouml;/g,''); // 246 F6
	output = output.replace(/&divide;/g,''); // 247 F7
	output = output.replace(/&oslash;/g,''); // 248 F8
	output = output.replace(/&ugrave;/g,''); // 249 F9
	output = output.replace(/&uacute;/g,''); // 250 FA
	output = output.replace(/&ucirc;/g,''); // 251 FB
	output = output.replace(/&uuml;/g,''); // 252 FC
	output = output.replace(/&yacute;/g,''); // 253 FD
	output = output.replace(/&thorn;/g,''); // 254 FE
	output = output.replace(/&yuml;/g,''); // 255 FF

	return output;
}


/* Added by Seb */
var generalMemberLogged = false;
var generalMemberId = 0;
var generalMemberUsername = "";

function checkLoginGeneral() {
	var ieRant = Math.floor(Math.random()*1000001); // Generate random so that this f***ing IE browser does not cache xml response
	$.ajax({
		type: "GET",
		url: "/_dyn/checkLoginXML.jsp",
		data: "ieRant=" + ieRant,
		dataType: "xml",
		success: function(xml) {
			generalMemberLogged = ($(xml).find("logged").text() == "true");
			if (generalMemberLogged) {
				generalMemberId = Number($(xml).find("id").text());
				generalMemberUsername = $(xml).find("username").text();
			}
			if (typeof(initMembershipSpecifics) == "function") {
				initMembershipSpecifics();
			}
		}
	});
}

function checkLogin() {
	var ieRant = Math.floor(Math.random()*1000001); // Generate random so that this f***ing IE browser does not cache xml response
	$.ajax({
		type: "GET",
		url: "/_dyn/checkLogin.jsp",
		data: "ieRant=" + ieRant,
		dataType: "xml",
		success: function(xml) {
			generalMemberLogged = ($(xml).find("logged").text() == "true");
			if (generalMemberLogged) {
				generalMemberId = Number($(xml).find("id").text());
				generalMemberUsername = $(xml).find("username").text();
			}
		}
	});
}

// On incrmente le compteur de nouvelles
function incNewsCount(newsId) {
	var ieRant = Math.floor(Math.random()*1000001); // Generate random so that this f***ing IE browser does not cache xml response
	$.ajax({
		type: "GET",
		url: "/_dyn/incNewsCount.jsp",
		data: "newsId=" + newsId + "&ieRant=" + ieRant,
		dataType: "xml",
		success: function(xml) {
			// Do nothing
		}
	});
}

// On incrmente le compteur de bannire concours
function clickThroughDraw(drawId, imageId, statZone) {
	var ieRant = Math.floor(Math.random()*1000001); // Generate random so that this f***ing IE browser does not cache xml response
	$.ajax({
		type: "GET",
		url: "/_dyn/incDrawCount.jsp",
		data: "drawId=" + drawId + "&imageId=" + imageId + "&statZone=" + statZone + "&ieRant=" + ieRant,
		dataType: "xml",
		success: function(xml) {
			var opResult = $(xml).find("opResult").text();
			var opMessage = $(xml).find("opMessage").text();
			var linkUrl = $(xml).find("linkUrl").text();
			if (opResult == 'ok') {
				self.location.href = linkUrl;
			} else {
				alert(opMessage);
			}
		}
	});
}

// Endswith
function endsWith(str, endStr) {

	// http://preprod.canalvie.com/ decoration/ : 39
	// decoration/ : 11
	var originalStringWithEndStrInserted = str.substring(0, str.length - endStr.length) + endStr;

	//alert("str.substring(str.length - endStr.length) + endStr : " + str.substring(0, str.length - endStr.length) + endStr);
	//alert("originalStringWithEndStrInserted : " + originalStringWithEndStrInserted);

	if (str == originalStringWithEndStrInserted) {
		return true;
	} else {
		return false;
	}
}

// Removes white space (leading and trailing)
function trim(toTrim) {
	return toTrim.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

function alphaNumericalOnly(inputStr, replaceOthersWith) {
	var output = inputStr.toLowerCase();

	// Whitelist character verification
	var allowedCharacters = "abcdefghijklmnopqrstuvwxyz0123456789";
	var outputWithOnlyAllowedChars = "";

	for (var i=0; i<output.length; i++) {
		if (allowedCharacters.indexOf(output.charAt(i)) != -1) {
			outputWithOnlyAllowedChars += output.charAt(i);
		} else {
			outputWithOnlyAllowedChars += replaceOthersWith;
		}
	}

	return outputWithOnlyAllowedChars;
}

function numericalOnly(inputStr, replaceOthersWith) {
	var output = inputStr.toLowerCase();

	// Whitelist character verification
	var allowedCharacters = "0123456789";
	var outputWithOnlyAllowedChars = "";

	for (var i=0; i<output.length; i++) {
		if (allowedCharacters.indexOf(output.charAt(i)) != -1) {
			outputWithOnlyAllowedChars += output.charAt(i);
		} else {
			outputWithOnlyAllowedChars += replaceOthersWith;
		}
	}

	return outputWithOnlyAllowedChars;
}

// ***************************************************** Ad tag generation script *****************************************************
var BASE_AD_TAG = "http://ad.doubleclick.net/adj/sri.";
var SUBDOMAINS_TO_IGNORE = "preprod, wc1, wc2, noc, dev, www, concours";
var pageTile=0;
var ord = "ord=" + Math.round(Math.random()*100000000000) + "?";

function printAdTag(adSize, position) {

	// Init vars
	// var pageURL = self.location.href; Is this for iframes?
	var pageUrl = document.location + "";
	var zonename = "";
	var keyvaluepair1 = "";
	var keyvaluepair2 = "";

	// Increment tiles
	pageTile++;

	// Dcopt for use with tile 1
	var dcopt = "";
	if (pageTile == 1) {
		dcopt = "dcopt=ist;";
	}

	// Adjust position for usage (valid values : top, bottom / Defaults to top)
	if (position == null) {
		var position = "top";
	}
	var pos = "pos=" + position + ";";

	// Valid sizes : 728x90, 300x250, 160x600
	if (adSize == undefined || adSize == '') return 0;

	// Remove http://subdomain.
	var pageUrlTransit = pageUrl.substring(pageUrl.indexOf(".")+1);

	// Split url on /
	var urlSplitArray = pageUrlTransit.split("/");

	// Add site to base ad tag
	var baseAdTagWithSite = BASE_AD_TAG + urlSplitArray[0].substring(0, (urlSplitArray[0].length-4)) + "/";

	// Add subdomain to array if it's not blacklisted
	var subdomain = (document.domain + "").substring(0, (document.domain + "").indexOf("."));
	if (SUBDOMAINS_TO_IGNORE.indexOf(subdomain) == -1) {
		urlSplitArray.splice(1, 0, subdomain);
	}

	// Build zonename
	if (urlSplitArray.length >= 2) {
		if (urlSplitArray[1] != "") {
			zonename = alphaNumericalOnly(urlSplitArray[1], "").toLowerCase();
		} else {
			// This is homepage
			zonename = "homepage";
		}
	}

	// Build keyvaluepair1
	if (urlSplitArray.length >= 3) {
		if (urlSplitArray[2] != "") {
			keyvaluepair1 = "ss=" + alphaNumericalOnly(urlSplitArray[2], "").toLowerCase() + ";";
		} else if (zonename != "homepage" && zonename != "") {
			// This is a section's homepage
			keyvaluepair1 = "ss=sectionhome;";
		}
	}

	// Build keyvaluepair2
	if (urlSplitArray.length >= 4) {
		if (urlSplitArray[3] != "") {
			// Don't use value #3, use all the remaining url
			var restOfUrl = pageUrlTransit.substring(pageUrlTransit.indexOf(urlSplitArray[3]));
			keyvaluepair2 = "title=" + numericalOnly(restOfUrl, "").toLowerCase() + ";";
		}
	}

	// Build recipeCategoriesKeyValue from specified recipe categories
	var recipeCategoriesKeyValue = "";
	if (typeof(recipeCategories) == "string") {
		recipeCategoriesKeyValue = recipeCategories;
	}

	// Build recipeshowname key value from specified recipe program title
	var recipeShowNameKeyValue = "";
	if (typeof(recipeshowname) == "string") {
		recipeShowNameKeyValue = "recipeshowname=" + alphaNumericalOnly(recipeshowname, "") + ";";
	}

	// 	} Build ad tag src
	var adTagSrc = baseAdTagWithSite + zonename + ";" + keyvaluepair1 ;
	if ( typeof( window[ 'recipeAdTag' ] ) != "undefined" )  {
		adTagSrc +=  recipeAdTag + ";" ;
    }
    if ( typeof( window[ 'eventAdTag' ] ) != "undefined" )  {
		adTagSrc +=  eventAdTag + ";" ;
    }


	adTagSrc +=  keyvaluepair2 + recipeCategoriesKeyValue + recipeShowNameKeyValue + dcopt + pos + "tile=" + pageTile + ";sz=" + adSize + ";" + ord;

	// Build ad tag to print
	var adTag = "<sc"+"ript type='text/jav"+"ascript' src='" + adTagSrc + "'></scr"+"ipt>";

	// Finally, print it
	document.write(adTag.toLowerCase())

}

// Clear selects
function clearSelect(selectId, previousSelectText) {
	$("#" + selectId).removeOption(/./);
	$("#" + selectId).addOption("0", "Choisissez " + previousSelectText + " avant");
}

// Load country select
function loadCountrySelect(selectedCountryId, selectId) {

	// Max characters for option
	var maxChar = 25;

	var ieRant = Math.floor(Math.random()*1000001); // Generate random so that this f***ing IE browser does not cache xml response
	$.ajax({
		type: "GET",
		url:"/_dyn/getCountries.jsp",
		data: "&ieRant=" + ieRant,
		dataType: "xml",
		success: function(xml){

			// Clear the list
			$("#" + selectId).removeOption(/./);

			$(xml).find("country").each(function(){

				// Get values from XML
				var countryId = $(this).attr("id");
				var countryName = $(this).text();
				var countrySelected = false;
				if (countryId == selectedCountryId) {
					countrySelected = true;
				}

				// Truncate name
				if (countryName.length > maxChar) {
					countryName = countryName.substring(0, maxChar) + "...";
				}

				// Add option to select
				$("#" + selectId).addOption(countryId, countryName, countrySelected);

			});
		}
	});

}

// Load province select
function loadProvinceSelect(countryId, selectedProvinceId, selectId) {

	// Max characters for option
	var maxChar = 25;

	if (countryId == 0) {
		clearSelect(selectId, "un pays");
	} else {

		var ieRant = Math.floor(Math.random()*1000001); // Generate random so that this f***ing IE browser does not cache xml response
		$.ajax({
			type: "GET",
			url:"/_dyn/getProvinces.jsp",
			data: "countryId=" + countryId + "&ieRant=" + ieRant,
			dataType: "xml",
			success: function(xml){

				// Clear the list
				$("#" + selectId).removeOption(/./);

				$(xml).find("province").each(function(){

					// Get values from XML
					var provinceId = $(this).attr("id");
					var provinceName = $(this).text();
					var provinceSelected = false;
					if (provinceId == selectedProvinceId) {
						provinceSelected = true;
					}

					// Truncate name
					if (provinceName.length > maxChar) {
						provinceName = provinceName.substring(0, maxChar) + "...";
					}

					// Add option to select
					$("#" + selectId).addOption(provinceId, provinceName, provinceSelected);

				});
			}
		});

	}

}

// Load region select
function loadRegionSelect(provinceId, selectedRegionId, selectId) {

	// Max characters for option
	var maxChar = 25;

	if (provinceId == 0) {
		clearSelect(selectId, "une province");
	} else {

		var ieRant = Math.floor(Math.random()*1000001); // Generate random so that this f***ing IE browser does not cache xml response
		$.ajax({
			type: "GET",
			url:"/_dyn/getRegions.jsp",
			data: "provinceId=" + provinceId + "&ieRant=" + ieRant,
			dataType: "xml",
			success: function(xml){

				// Clear the list
				$("#" + selectId).removeOption(/./);

				$(xml).find("region").each(function(){

					// Get values from XML
					var regionId = $(this).attr("id");
					var regionName = $(this).text();
					var regionSelected = false;
					if (regionId == selectedRegionId) {
						regionSelected = true;
					}

					// Truncate name
					if (regionName.length > maxChar) {
						regionName = regionName.substring(0, maxChar) + "...";
					}

					// Add option to select
					$("#" + selectId).addOption(regionId, regionName, regionSelected);

				});

			}
		});

	}

}

// Load municipality select
function loadMunicipalitySelect(regionId, selectedMunicipalityId, selectId) {

	// Max characters for option
	var maxChar = 25;

	if (regionId == 0) {
		clearSelect(selectId, "une rgion");
	} else {

		var ieRant = Math.floor(Math.random()*1000001); // Generate random so that this f***ing IE browser does not cache xml response
		$.ajax({
			type: "GET",
			url:"/_dyn/getMunicipalities.jsp",
			data: "regionId=" + regionId + "&ieRant=" + ieRant,
			dataType: "xml",
			success: function(xml){
				// Clear the list
				$("#" + selectId).removeOption(/./);

				$(xml).find("municipality").each(function(){

					// Get values from XML
					var municipalityId = $(this).attr("id");
					var municipalityName = $(this).text();
					var municipalitySelected = false;
					if (municipalityId == selectedMunicipalityId) {
						municipalitySelected = true;
					}

					// Truncate name
					if (municipalityName.length > maxChar) {
						municipalityName = municipalityName.substring(0, maxChar) + "...";
					}

					// Add option to select
					$("#" + selectId).addOption(municipalityId, municipalityName, municipalitySelected);

				});
			}
		});

	}

}

// Load municipality select
function loadBoroughSelect(municipalityId, selectedBoroughId, selectId) {

	// Max characters for option
	var maxChar = 25;

	if (municipalityId == 0) {
		clearSelect(selectId, "une municipalit");
	} else {

		var ieRant = Math.floor(Math.random()*1000001); // Generate random so that this f***ing IE browser does not cache xml response
		$.ajax({
			type: "GET",
			url:"/_dyn/getBoroughs.jsp",
			data: "municipalityId=" + municipalityId + "&ieRant=" + ieRant,
			dataType: "xml",
			success: function(xml){
				// Clear the list
				$("#" + selectId).removeOption(/./);

				$(xml).find("borough").each(function(){

					// Get values from XML
					var boroughId = $(this).attr("id");
					var boroughName = $(this).text();
					var boroughSelected = false;
					if (boroughId == selectedBoroughId) {
						boroughSelected = true;
					}

					// Truncate name
					if (boroughName.length > maxChar) {
						boroughName = boroughName.substring(0, maxChar) + "...";
					}

					// Add option to select
					$("#" + selectId).addOption(boroughId, boroughName, boroughSelected);

				});
			}
		});

	}

}

function displayWallpaper(startDateString, endDateString, src, color, repeat, position, attachment) {
		var startDate=new Date(startDateString);
		var endDate=new Date(endDateString);
		var today = new Date();
		
		if ( (startDate < today) && (today < endDate) ) {
			$('body, html').css('background-image', 'url(' + src + ')');  
			$('body, html').css('background-color', color);  
			$('body, html').css('background-repeat', repeat);  
			$('body, html').css('background-position', position);  
			$('body, html').css('background-attachment', attachment);  
		}
		
}

function displayTuile(startDateString, endDateString, divId) {
		var startDate=new Date(startDateString);
		var endDate=new Date(endDateString);
		var today = new Date();
		var id = divId;
		
		if ( (startDate < today) && (today < endDate) ) {
			$('#' + id).css('display', 'block');  
		}
		
}
