

// AUTO-TRACKING OMNITURE

document.write("<script type='text/javascript' src='http://www.muchmusic.com/GlobalPageTracking.js'></script>")

// INITIATE isPageLoaded
var dblClickTimestamp = Math.random()*10000000;
var isPageLoaded = false;
var _BASE_URL = '';

// GET CURRENT PAGE + STRIP OUT APPLICATION LOCATION
var currURI = ""+document.location;
//currURI = currURI.replace("cgi-bin/Identification","");


// GESTIONNAIRE POPUP
function popUp(url,vwidth,vheight,scroll,menu) {	
	
var w = vwidth;
var h = vheight;
var x = (screen.width - w)/2;
var y = (screen.height - h)/2;			
var s = "yes";
var m = menu;

if ((s == 0) || (s == "") || (s == null)) {
	s = "no"
}
else {
	s = "yes"
}

if ((m == 0) || (m == "") || (m == null)) {
	m = "no"
}
else {
	m = "yes"
}
		
popupWin = window.open(url, 'popup',  'menubar='+m+',toolbar=no,location=no,directories=no,status=no,scrollbars='+s+',resizable=no,width='+w+',height='+h+',left='+x+',top='+y+'')
}	



// GESTIONNAIRE POPUP
function popUpSondage(url,vwidth,vheight,scroll,menu,id) {	
	
var w = vwidth;
var h = vheight;
var x = (screen.width - w)/2;
var y = (screen.height - h)/2;			
var s = scroll;
var m = menu;

if ((s == 0) || (s == "") || (s == null)) {
	s = "no"
}
else {
	s = "yes"
}

if ((m == 0) || (m == "") || (m == null)) {
	m = "no"
}
else {
	m = "yes"
}
		
popupWin = window.open(url, id,  'menubar='+m+',toolbar=no,location=no,directories=no,status=no,scrollbars='+s+',resizable=no,width='+w+',height='+h+',left='+x+',top='+y+'')
}	



function popUp1(url,vwidth,vheight,scroll,menu) {	
	
var w = vwidth;
var h = vheight;
var x = (screen.width - w)/2;
var y = (screen.height - h)/2;			
var s = scroll;
var m = menu;

if ((s == 0) || (s == "") || (s == null)) {
	s = "no"
}
else {
	s = "yes"
}

if ((m == 0) || (m == "") || (m == null)) {
	m = "no"
}
else {
	m = "yes"
}
		
popupWin = window.open(url, 'popup1',  'menubar='+m+',toolbar=no,location=no,directories=no,status=no,scrollbars='+s+',resizable=no,width='+w+',height='+h+',left='+x+',top='+y+'')
}	



// GESTIONNAIRE COOKIES
// Mode d'utilisation :
// Créer un cookie		===> 	createCookie(name,value,expire)  ===> remplace les variables avec les vraies valeurs (expire = nombres de jours)
// Lire un cookie		===> 	readCookie(name) ===> retour la valeur de la cookie
// Effacer un cookie	===>	deleteCookie(name)

Cookies = {
	save : function(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = ""
		document.cookie = name+"="+value+expires+"; path=/";
	},
	read : function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i<ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
			return null;
	},
	erase : function(name) {
		Cookies.save(name,"",-1);
	}
	
}

// CREER UN COOKIE
function createCookie(name,value,expire){
	Cookies.erase(name);
	Cookies.save(name,value,expire);
}

// LIRE LA VALEUR D'UN COOKIE
function readCookie(name) {
	var cookieVal = Cookies.read(name);
	return cookieVal;
}

// EFFACER UN COOKIE
function deleteCookie(name) {
	Cookies.erase(name);
}

// PLACE UNIQUE TRACKING COOKIE FOR ALL USERS
// Generate random number
var trackingID = Math.floor(Math.random()*99999999999999999999);
// Check for cookie
if (!readCookie("uniqueID")) {
	createCookie("uniqueID",trackingID,730)	
}

// BOUTIQUE RDS
function showBoutique (boutiqueVal) {

	if (boutiqueVal == "1") {
		document.getElementById('boutiqueLien1').className = 'boutiqueLienOn';
		document.getElementById('boutiqueLien2').className = 'boutiqueLienOff';
		document.getElementById('boutiqueLien3').className = 'boutiqueLienOff';		
		document.getElementById('boutiqueInfo1').style.display = 'block';
		document.getElementById('boutiqueInfo2').style.display = 'none';
		document.getElementById('boutiqueInfo3').style.display = 'none';
	}
	
	else if (boutiqueVal == "2") {
		document.getElementById('boutiqueLien1').className = 'boutiqueLienOff';
		document.getElementById('boutiqueLien2').className = 'boutiqueLienOn';
		document.getElementById('boutiqueLien3').className = 'boutiqueLienOff';
		document.getElementById('boutiqueInfo1').style.display = 'none';
		document.getElementById('boutiqueInfo2').style.display = 'block';
		document.getElementById('boutiqueInfo3').style.display = 'none';				
	}
	
	else if (boutiqueVal == "3") {
		document.getElementById('boutiqueLien1').className = 'boutiqueLienOff';
		document.getElementById('boutiqueLien2').className = 'boutiqueLienOff';
		document.getElementById('boutiqueLien3').className = 'boutiqueLienOn';
		document.getElementById('boutiqueInfo1').style.display = 'none';
		document.getElementById('boutiqueInfo2').style.display = 'none';
		document.getElementById('boutiqueInfo3').style.display = 'block';				
	}		
	
}


// GESTION DES ONGLETS
function showLayer(layerVal,layerName,layerNum) {	

	// layerVal = valeur du layer a afficher
	// layerName = nom de la groupe de layers (sans la valeur individuel)
	// layerNum = nombre de layers totale dans la groupe
	
	if (document.getElementById) {
		
		// turn off all laters
		for (x = 1; x < layerNum + 1; x++) {
			document.getElementById(layerName + x).style.display = "none";
		}
		
		// display requested layer
		document.getElementById(layerName + layerVal).style.display = "block";
	}	
}



// GESTION DES SOUS MENU POPUPS
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}


function getObj(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers) {
		if (document.layers[name]) {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		}
		else {
			this.obj = document.layers.testP.layers[name];
			this.style = document.layers.testP.layers[name];
		}
	}
}


// INCLUDE gestionnaire_cookies.js
document.write("<scr" + "ipt language='javascript' type='text/javascript' src='/js/gestionnaire_cookies.js'><\/scr" + "ipt>");


// GESTION DES TAILLES DE FONT
var fontSize = readCookie("cookieFontSize");

//alert(fontSize)

// Check for stored font value and set custom stylesheet
if (fontSize) {
	document.write("<link rel='stylesheet' href='/css/font" + fontSize + ".css' type='text/css' />");
}
// If no stored font value set default stylesheet and create cookie
else {
	document.write("<link rel='stylesheet' href='/css/font08em.css' type='text/css' />");
	createCookie("cookieFontSize",'07em',365);
}

// Create custom font stylesheet array
var fontArr = new Array ("05em","06em","07em","08em","09em","10em","11em","12em","13em","14em","15em");

function increaseFont() {
	for (x=0; x < fontArr.length; x++) {
		if ((fontArr[x] == fontSize) && (x != (fontArr.length - 1))) {
			createCookie("cookieFontSize",fontArr[x+1],365);
			document.location = currURI;			
		}
	}
}

function decreaseFont() {
	for (x=0; x < fontArr.length; x++) {
		if ((fontArr[x] == fontSize) && (x != 0)) {
			createCookie("cookieFontSize",fontArr[x-1],365);
			document.location = currURI;			
		}
	}
}

function resetFont (newFont) {
	createCookie("cookieFontSize",'07em',365);
	document.location = currURI;
}


// FERMER SESSION
function fermerSession(session) {
	deleteCookie(session);
	//document.location = currURI;
    //On retourne a la page d'accueil
//	document.location = "/index.html";
}


// SLI ADTAG

function printAdTag ( strPrg, strArg, strWidth, strHeight )
{

  var strLink = "/"+strPrg+"/"+strArg+";p="+strArg+";sz="+strWidth+"x"+strHeight+";\"" ;
  document.write ( "<a href=\"http://ad.doubleclick.net/jump" + strLink + " target=\"blank\">" ) ;
  document.write ( "<img src=\"http://ad.doubleclick.net/ad" + strLink + "width=\""+ strWidth 
                     + "\" height=\""+ strHeight + "\" border=\"0\"></a>" ) ;



}

 function deSecuriserPage() {

	for (i=0 ; i<document.links.length ; i++)
	{
		if (document.links[i].protocol=='https:')
		{
			if (document.links[i].href.indexOf('GestionProfil') == -1){
			document.links[i].protocol='http:';
			document.links[i].port=80 ;
			}
		}
	}
}

function showobj() {
	document.getElementById('hummerBAS').style.display = "block" ;
}
function hideobj() {
	document.getElementById('hummerBAS').style.display = "none"
}
function timeOutHide() {
	setTimeout("hideobj('hummerBAS')", 6000) ;
}


//concours jetprivé (JS de la page concours...rds.vdl2.ca/concours/)
function loadContest() {

	GetCookie ("pkprofil");
	
	if (oCurrentCookie.sessionkey == 'na' || oCurrentCookie.sessionkey == 'deleted' ){
		//alert ('redirect url = http://www.jetprivesuperbowl.com/');
		document.location.href = 'http://ad.doubleclick.net/clk;166344276;14995588;b?http://www.jetprivesuperbowl.com/';
	}
	
	else {
		//alert ('redirect url = http://www.jetprivesuperbowl.com/?pk_profil=' + oC);
	
		if (oCurrentCookie.sessionkey == 'na' || oCurrentCookie.sessionkey == 'deleted' ){
			//alert ('redirect url = http://www.jetprivesuperbowl.com/');
			document.location.href = 'http://ad.doubleclick.net/clk;166344276;14995588;b?http://www.jetprivesuperbowl.com/';
		}
		
		else {
			//alert ('redirect url = http://www.jetprivesuperbowl.com/?pk_profil=' + oCurrentCookie.sessionkey);
			document.location.href = 'http://ad.doubleclick.net/clk;166344276;14995588;b?http://www.jetprivesuperbowl.com/?pk_profil=' + oCurrentCookie.pkprofil;
		}
	}
}


function SetCookieRDSCA (name, value ) {
	var argv = SetCookieRDSCA.arguments;
	var argc = SetCookieRDSCA.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=http://rds.ca")) +
	((secure == true) ? "; secure" : "");
}


/* Nouvelle function pour la gestion du coukie du login de rds */

function deleteMySessionkeyCookie(name, path, domain) {
	if (readCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
	fermerSession(name);
	document.location = "/index.html";
}


function Vdl2isOnline() {
	if (document.location.href.indexOf('.vdl2.ca') > -1){
		_BASE_URL = 'rds.vdl2.ca';
		return false;
	}
	else {
		return true;
	}
}

if (Vdl2isOnline()) {
	_BASE_URL = 'rds.ca';
}
else {
	_BASE_URL = 'rds.vdl2.ca';
}

/* Si l'image n'existe pas affiche le default */
RescueImage = function (obj) {obj.src = '/images/avatar_default_medium.gif'; }



