var PageLoad = false;
var MCMSConsoleLoad = false;
var AdvancedHTMLToolsLoad = false;
var InPageGBLoad = false;
var BannerAd = false;

// ------[ Main function call (page init) ]------------------------------------------------- //
function main()	{
	if(MCMSConsoleLoad) MCMSConsoleInit();
	if(AdvancedHTMLToolsLoad) initAdvancedHTMLTools();
	if(InPageGBLoad) InPageGBInit();
	MainNavigationInit();
	if(BannerAd) BannerAdInit();
	PageLoad = true;
	}

// ------[ Generic Popup Window ]------------------------------------------------- //
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 = false;
	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=1,' + str).focus();
	}
	
// ------[ Cookie 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))      
			}    
		}
	}	

// ------[ Main Navigation for IE/Win ]------------------------------------------------- //
function MainNavigationInit() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("main-nav-level1");
		if(navRoot) MainNavigationLoop(navRoot, 2)
		}
	}
	
function MainNavigationLoop(obj, level) {
	for (var i=0; i<obj.childNodes.length; i++) {
		node = obj.childNodes[i];
		if(node.nodeName=="LI") {
			node.level = level;
			node.onmouseover=MainNavOver;
			node.onmouseout=MainOut;
			}

		if(node.childNodes.length > 2) {
			node2 = node.childNodes[2];
			MainNavigationLoop(node2, level+1)
			}
		}
	}

function MainNavOver() {
	this.className+=" navOver" + this.level.toString();
	}
	
function MainOut() {
	this.className=this.className.replace(" navOver" + this.level.toString(), "");
	}	

// ------[ resize Popup image ]------------------------------------------------- //

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>');
popL.document.write('<scr'+'ipt language="JavaScript">');
popL.document.write('function resizeWin() { window.resizeTo(document.images[0].width+9,document.images[0].height+29); self.focus(); }');
popL.document.write('</scr'+'ipt>');
popL.document.write('</head>');
popL.document.write('<body onblur="self.close();" onload="resizeWin();" 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();
}