////////////////////////////////////////////////////////////////////
//  Global Variables 
var LoadLineup = new function() {};



function frLangSwap() { // Switch to French from English
	var FrSite = '/francais/';
	YouWereHere = location.href;
	if (YouWereHere.indexOf('results') < 0) {
		YouAreHere = YouWereHere.replace(/\/english\//g, FrSite);
	} else {
		YouAreHere = "/canada/homepage/francais/index.jsp";
	}
	window.location = YouAreHere;
}

function enLangSwap() { // Switch to English from French
	var EnSite = '/english/';
	YouWereHere = location.href;
	
	if (YouWereHere.indexOf('results') < 0) {
		YouAreHere = YouWereHere.replace(/\/francais\//g, EnSite);
	} else {
		YouAreHere = "/canada/homepage/english/index.jsp";
	}	
	window.location = YouAreHere;
}


/////////////////////////////////////////////////////////////////////
//                                                                 //           
//   DOM onLoad with Event Stacker                                 //
//   ------------------------------------------------------------  //
//                                                                 //      
//                                                                 //      	
/////////////////////////////////////////////////////////////////////

function init() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;
    if (_timer) clearInterval(_timer);
		LoadLineup();
};

// MOZILLA & OPERA 9 //////////////////////////////////////////////////////////////////////////
if (document.addEventListener) { document.addEventListener("DOMContentLoaded", init, false); }

// IEXPLORER //////////////////////////////////////////////////////////////////////////////////
/*@cc_on @*/ // CONDITIONAL COMMENT
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() { if (this.readyState == "complete") { init(); } };
/*@end @*/

// SAFARI /////////////////////////////////////////////////////////////////////////////////////
if (/WebKit/i.test(navigator.userAgent)) { var _timer = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { init(); }  }, 10); }

// OTHER //////////////////////////////////////////////////////////////////////////////////////
window.onload = init;

///////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////
//                                                                 //           
//   addLoadEvent Function                                         //
//   ------------------------------------------------------------  //
//                                                                 //           
//                                                                 //
/////////////////////////////////////////////////////////////////////



function addLoadEvent(func) {
  var oldLineup = LoadLineup;
  if (typeof LoadLineup != 'function') {
    LoadLineup = func;
  } else {
    LoadLineup = function() { if (oldLineup) {
        oldLineup();
      }
      func(); 
    }
  }
}

function DontDeleteMe() { return true; }
addLoadEvent(DontDeleteMe);

function checkSearch(english, field) {
	if (field.value == "") {
		if (english) { field.value = "Enter your search terms"; }
		else {field.value = "Rechercher les termes"; }
	} else if ((field.value == "Enter your search terms") || (field.value == "Rechercher les termes")) {
		field.value = "";
	}
}

function citi_pop(URL,facename,w,h,scroll,t,l,s,m,r,d){
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;

	settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar='+t+',location='+l+',status='+l+',menubar='+l+',resizable='+l+',dependent='+l;

	win = window.open(URL,facename,settings);

	if(parseInt(navigator.appVersion) >= 4){
		win.window.focus();
		}
}

function doFlash(id,flashfile,width,height,transparent,flashvars) {
	var output = "";
	
	var ImageLocation = flashfile.split("/");
	ImageLocation = ImageLocation[1] + "/" + ImageLocation[2] + "/" + ImageLocation[3] + "/img/" + ImageLocation[5];
	
	var wmode = (transparent) ? "transparent" : "opaque";
	output += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' style='width:" + width + "px;height:" + height + "px;vertical-align:top;'>\n";
	output += "<param name='allowScriptAccess' value='sameDomain' />\n";
	output += "<param name='movie' value='" + flashfile + ".swf' />\n";
	output += "<param name='quality' value='high' />\n";
	output += "<param name='flashvars' value='" + flashvars + "' />\n";
	output += "<param name='wmode' value='" + wmode + "' />\n";
	output += "<param name='menu' value='false' />\n";
	output += "<embed src='" + flashfile + ".swf' quality='high' style='width:" + width + "px;height:" + height + "px;vertical-align:top;' id='" + id + "-FL' wmode='" + wmode + "' menu='false' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' flashvars='" + flashvars + "'></embed>\n";
	output += "<img src='" + ImageLocation + ".gif' quality='high' style='width:0" + width + "px;height:" + height + "px;display:none;' id='" + id + "-IMG' />\n";
	output += "</object>";
	document.getElementById(id).innerHTML = output;
}

function navigateDropDown(obj) {
	var loc = obj.split(" | ")[0];
	var tgt = obj.split(" | ")[1];
	if (obj.value !== "") {
		citi_pop(loc,tgt,0,800,500,'yes','yes','yes','yes','yes','yes')
	} else {
		return false;
	}
}


function jumpto(myurl) {
	window.location.href = myurl;
}

function toggleVisible(identity) {
	if (document.getElementById('HidingRange')) {
		   var navigate = document.getElementById( 'HidingRange' );
		   var names = navigate.getElementsByTagName( 'div' );
		   for( var i=0; i < names.length; i++ ){
			  if (names[i].id.substr(0,2) == 'hm') { 
				document.getElementById(names[i].id).style.display = "none";
			  }
		}
		document.getElementById(identity).style.display = "block";
	} else {
		var x = document.getElementById(identity).style; var isVisible = false;
		if (x.widows.toString() == "1") { isVisible = true;	x.widows = "2";	} else { x.widows = "1"; }
		x.display = (isVisible) ? "none" : "block"; return false;
	}
}



function MMSI() { //v3.0
  var i,j=0,x,a=MMSI.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MMFO(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MMRI() { //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 MMFO(n, d) { //v4.0
  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=MMFO(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}