var MCMSConsoleLoad = false;
var NavTopLoad = false;
var ProdBrowserDHTMLLoad = false;
var GalleryBrowserLoad = false;
var PageLoad = false;
var NavTopSelected = false;
var ProductsDHTMLLoad = false;
var InPageGBLoad = false;
var InBriefDHtmlLoad = false;
var NavMapLoad = false;
var CssHTMLToolsLoad = false;
var BannerAd = false;

// Main function, Call in every page.
function main()	{
    try { initlayers(); } catch (e) { }
	if(MCMSConsoleLoad) MCMSConsoleInit();
	if(NavTopLoad) navTopInit();
	if(ProdBrowserDHTMLLoad) ProdBrowserDHTMLInit();
	if(GalleryBrowserLoad) GalleryBrowserInit();
	if(ProductsDHTMLLoad) ProductsDHTMLInit();
	if(InPageGBLoad) InPageGBInit();
	///if(InBriefDHtmlLoad) InBriefDHtmlInit();
	if(NavMapLoad) NavMapInit();
	if(CssHTMLToolsLoad) initCssHTMLTools();
	if(BannerAd) BannerAdInit();
	PageLoad = true;
	}

function lang(culture) {
	if(culture.indexOf("en-CA") != -1) var lang = "fr-CA";
	else var lang = "en-CA";
	var url = document.location + "";
	var urlBegin = url.substring(0,url.indexOf(culture));
	var urlEnd = url.substring(url.indexOf(culture)+culture.length,url.length);
	document.location = urlBegin + lang + urlEnd;
	}

function UrlUpdate() {
	popCount = ReadCookie("UrlUpdateCount");
	if((!popCount) || (popCount < 3)) popWin(webSiteUrl + "/_Static/UrlUpdate.htm",300,300,0,0,'urlupdate',1)
	}

function UrlUpdateCookieWrite() {
	popCount = ReadCookie("UrlUpdateCount");
	if(!popCount) popCount = 1;
	else popCount = eval(popCount)+1;
	WriteCookie("UrlUpdateCount", popCount)
	}

// Section Roll Over 
function SwapImage(id,state) {
	state = (state) ? "_On" : "_Off";
	document.images[id].src = webSiteUrl + "/_Static/" + cultureID + "/Images/" + id + state + ".gif";
	}	

function navLeftRoll(id,state) {
	state = (state) ? "/_Static/neutral/Images/NavLeft_Fle.gif" : "/_Static/neutral/Images/spc.gif";
	document.images[id].src = webSiteUrl + state;
	}		
	
// Generic Popup window Function
// Set URL, Window Name, ...
function popWin(url,w,h,scroll,tools,name,center,baseUrl) {
	var str = "height=" + h + ",innerHeight=" + h;
	str += ",width=" + w + ",innerWidth=" + w;
	if(baseUrl) url = webSiteCMSUrl + url;
	if(!center) var center = true;
	if(!scroll) scroll = 0;
	if(!tools) tools = 0;
	if(!name) name = "pop";

	if((window.screen) && (center)) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - w) / 2;
		var yc = (ah - h) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		}
		
	pop = window.open(url,name,'toolbar=' + tools + ',location=0,directories=0,status=0,menubar=0,scrollbars=' + scroll + ',resizable=0,' + str).focus();
	}
// Some page use this code.. (popUp window)
function PopUpArchives(url, nom, top, left, width, height){		
	windowReference = window.open(webSiteUrl + "/_Static" + url,nom,"width="+width+",height="+height+",top="+top+",left="+left+",scrollbars=no");
	if (!windowReference.opener) windowReference.opener = self;
	}	

// Fix the the DHTML page after a Resize
function fix() { 
	bVer=''; 
	bName = navigator.appName.toLowerCase(); 
	bVer = navigator.appVersion.substring(0,3); 
	// alert(bName+"\n"+bVer);
	if(bName == "netscape" && bVer< '4.08') { 
		return false; 
	} else { 
		document.location = document.location; 
		}
	}	
	
// JavaScript Cooking Handle
var now = new Date();
var expires = now.getTime() + 365 * 24 * 60 * 60 * 1000;
var expires = new Date(expires)
function WriteCookie(name, value) {
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString();
	}

function ReadCookie(Name) {   
	var search = Name + "="   
	if (document.cookie.length > 0) { 					// if there are any cookies      
		offset = document.cookie.indexOf(search)       
		if (offset != -1) { 							// if cookie exists          
			offset += search.length  					// set index of beginning of value         
			end = document.cookie.indexOf(";", offset)	// set index of end of cookie value         
			if (end == -1) end = document.cookie.length         
			return unescape(document.cookie.substring(offset, end))      
			}    
		}
	}	
	/*
function popLargeImage(url) {
	popL = window.open('','LargeImage','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=10,height=10');	
	popL.document.write("<html><head><title>Bombardier Recreational Products</title></head>");
	popL.document.write("<body bgcolor='#ffffff' topmargin='0' marginheight='0' leftmargin='0' marginwidth='0'>");
	popL.document.write("<img src='"+url+"' border='0'>");
	popL.document.write("</body></html>");
	popL.document.close();
	self.name="main";
	popL.resizeTo(popL.document.images[0].width+9,popL.document.images[0].height+29);
	popL.focus();
	}
*/