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 CssHTMLToolsLoad = false;
var VideoBrowserLoad = false;
var LangageSelectorLoad = false;
var ProductSpecLoad = false;
var DHTMLImgProductLoad = false;
var ChangeImageInit = false;
var BannerAd = false;
var MainWindowName = window.name;

// Main function, Call in every page.
function main()	{
	initlayers();
	if(LangageSelectorLoad) LangageSelectorInit();
	if(MCMSConsoleLoad) MCMSConsoleInit();
	if(NavTopLoad) navTopInit();
	if(ProdBrowserDHTMLLoad) ProdBrowserDHTMLInit();
	if(GalleryBrowserLoad) GalleryBrowserInit();
	if(VideoBrowserLoad) VideoBrowserInit();
	if(NavTopSelected) {
		nTRollBt('navTop_'+NavTopSelected,"On");
		NavTopSelected = 'navTop_'+NavTopSelected;
		}
	if(ProductsDHTMLLoad) ProductsDHTMLInit();
	if(InPageGBLoad) InPageGBInit();
	if(CssHTMLToolsLoad) initCssHTMLTools();
	if(ProductSpecLoad) ProductSpecInit();
	if(DHTMLImgProductLoad) DHTMLImgProductInit();
	if(BannerAd) BannerAdInit();
	PageLoad = true;
	//window.name = "main";
	}

function ShowProducts() {
	var panel = document.getElementById("other-brp-products");
	
	if (panel.style.display = "none") {
		panel.style.display = "block";		
	}
}	
	
// Section Roll Over 
function SwapImage(id,state) {
	state = (state) ? "_on" : "_off";
	document.images[id].src = webSiteUrl + "/_Static/" + cultureID + "/Images/" + id + state + ".jpg";
	}	

function SwapGifImage(state,id) {
	state = (state) ? "_on" : "_off";
	document.images[id].src = webSiteUrl + "/_Static/" + cultureID + "/Images/" + id + state + ".gif";
	}	


function SwapImageNeutral(id,state,lang) {
	state = (state) ? "_On" : "_Off";
	document.images[id].src = webSiteUrl + "/_Static/Neutral/ETec/Images/" + id + state + ".gif";
	}		
	
function navRoll(id,state) {
	state = (state) ? "/_Static/neutral/Images/FleNav.gif" : "/_Static/neutral/Images/Spc.gif";
	document.images[id].src = webSiteUrl + state;
	}		

function navRollTest(id,state) {
//	alert(id);
	modele = /_categoryLink/i;
	id2 = id.replace(modele,"");
//	alert(id2);

	state = (state) ? "/_Static/neutral/Images/FleNav.gif" : "/_Static/neutral/Images/Spc.gif";
//	alert(webSiteUrl + state);
	document.images[id2].src = webSiteUrl + state;
	//alert(webSiteUrl + state);
	}		
function navRollTest2(id,state) {
//	alert(id);
	modele = /_categoryLink2/i;
	id2 = id.replace(modele,"");
//	alert(id2);

	state = (state) ? "/_Static/neutral/Images/BulNav_On.gif" : "/_Static/neutral/Images/BulNav_Off.gif";
//	alert(webSiteUrl + state);
	document.images[id2].src = webSiteUrl + state;
	//alert(webSiteUrl + state);
	}		
	
function navRollSub(id,state) {
	state = (state) ? "/_Static/neutral/Images/BulNav_On.gif" : "/_Static/neutral/Images/BulNav_Off.gif";
	document.images[id].src = webSiteUrl + state;
	}		
	
function navRolls(id,state) {
	state = (state) ? "/_Static/neutral/Etec/Images/NavLeft_sBul_on.gif" : "/_Static/neutral/Etec/Images/NavLeft_sBul_off.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(!center) var center = true;
	if(!scroll) scroll = 0;
	if(!tools) tools = 0;
	if(!name) name = "pop";
	if(baseUrl) url = webSiteCMSUrl + url;
	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 ObjImgRoll(obj,img) {
	obj.src = webSiteUrl + "/_Static/" + cultureID  + "/Images/" + img;
	}	
	
function CSRoll(id,state) {
	state = (state) ? "_on" : "_off";
	document.images[id].src = webSiteUrl + "/_Static/neutral/Images/" + id + state + ".gif";
	}
	
// Pull-down menu Faq Template
function setFaqCategory (newAddress) {
	if(newAddress!="") {
		window.top.location.href=newAddress;
		}
	}
// pour images homepage

function rand(number) {
        return Math.ceil(rnd()*number);
}

function aleatoire() {
	var truc = rand(6);
	str = '<img src="'+NonSecureSiteUrl+'/images/home'+truc+'.gif" width="250" height="315" alt="" border="0">';
	c1.html(str);
	setTimeout('aleatoire()',5000)
	}
	
	/*
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();
	}
*/

// fonction pour webcast appele dans le posting ... (en attente)

function fncOpenWindow0690407051511() {
var winPub = window.open("http://www.webcastgroup.com/webcast/auth_test/fs_FliveAhead.asp?WebcastID=1511", "winPub1511", "width=666,height=521,toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0")
winPub.focus()
return false
}
// fin fonction pour webcast appele dans le posting ... (en attente)

// Showroom - affichage photos selon le moteur
function ChangeImage(id){	
	document.getElementById('ContentPhoto').src = id;
}

// Evinrude Specs - affichage des tabs selon le Variant
var selected = null;
function DisplayVariantInfo(variant)
{    
	 var color = document.getElementById(variant + 'Color').innerHTML;
     var length = document.getElementById(variant + 'Length').innerHTML;
     var weight = document.getElementById(variant + 'Weight').innerHTML;
     document.getElementById('ColorValue').innerHTML = color;
     document.getElementById('LengthValue').innerHTML = length;
     document.getElementById('WeightValue').innerHTML = weight;
    
    //Remet la class normale aux autres span
	if(selected) {
		selected.className = "variant";
		}
		
	//Ajoute la class selected	
    document.getElementById(variant + "VariantName").className = "variant-selected";
    selected = document.getElementById(variant + "VariantName");
}

/**
 * Base namespace setup
 */
BRP = {
	// Main function call (page init)
	Init : function() {
		document.body.className += " hasJS";
		},
	globals: {},
	widgets: {}
};

YAHOO.util.Event.addListener(window, "load", BRP.Init, BRP, true);

// ------[ Expand ]------------------------------------------------- //	
BRP.Expand = function(el) {
	if (el) {
		this.Root = el;
		YAHOO.util.Event.addListener(window, "load", this.Init, this, true);
	}
};

BRP.Expand.prototype = {
	
	Root : null,

	Init : function() {
		div = document.getElementById(this.Root);
		if(div) {
			dl = div.getElementsByTagName("dl");	

			for (var j=0; j<dl.length; j++) {
				var dt = dl[j].getElementsByTagName('dt');
				dt[0].dl = dl[j];
				dl[j].className += ' closed';
				dt[0].onclick = function() { 
					state = (this.dl.className.indexOf("opened") != -1 ) ? false : true;
					if(state) {
						this.dl.className = this.dl.className.replace('closed','opened');
					} else {
						this.dl.className = this.dl.className.replace('opened','closed');
					}
				};
			}
		}	
	}
};

// ------[ Direct Mail Contest : Rules & Regulations ]------------------------------------------------- //	

BRP.directMailContest = {
	Init : function() {

		/**
		* Initialize Rules & Regulations Pop up page
		*/
		BRP.globals.seeRules = new YAHOO.widget.Panel(
			"rulesregulations",
			{ 
				width: "700px",
				height: "400px",
				constraintoviewport: true,  
				underlay:"shadow",  
				close:true,  
				visible:false,  
				fixedcenter: true,  
				draggable:false,
				zIndex: 5,
				modal: true //Window bkg
			}
		);
		//Render the panel for screen
		BRP.globals.seeRules.render(document.body);

		//Create an array with all anchor with the classname "rules-regulations"
		var el = YAHOO.util.Dom.getElementsByClassName('rules-regulations','a');

		for (var i=0; el[i]; i++) {
		el[i].onclick = function() {
			var pnl = BRP.globals.seeRules;
			pnl.setBody("<iframe width='700' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' height='400' src='" + this.href + "'></iframe>");
			pnl.render();
			pnl.show();
			return false;
			}
		el[i].style.visibility = "visible";
		}
    }
}

BRP.Cookie = {

	Load: function (id) {
		var search = id + "=";  
		var cookie = null;
		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;
				cookie = unescape(document.cookie.substring(offset, end));   
				}    
			}	
		return cookie;	
	},

	Save: function (id, data, session) {
		if(session) {
			var now = new Date();
			var expires = now.getTime() + 365 * 24 * 60 * 60 * 1000;
			var expires = new Date(expires);
			session = "; expires=" + expires.toGMTString();
		} else session = "";

		document.cookie = id + "=" + escape(data) + session + "; path=/";
	}			


};

var promotionBannerLoaded = false;

function rotatePromotionBanner()
{
	if (window == window.top && !promotionBannerLoaded)
	{
		var cookieName = 'promoBannerCookie';
		var cookie = BRP.Cookie.Load(cookieName);

		var promoBanner1 = window.top.document.getElementById('promoBanner1');
		var promoBanner3 = window.top.document.getElementById('promoBanner3');


		var splitResult;
		if (cookie) {
			
			var splitResult = cookie.split('|');
			if (parseInt(splitResult[0]) == "nan")
			{
				splitResult[0] = -1;
			}
			
			if (parseInt(splitResult[1]) =="nan")
			{
				splitResult[1] = -1;
			}
		}
		else {
			splitResult = new Array(2);
			splitResult[0] = -1;
			splitResult[1] = -1;
		}
		
		splitResult[0]++;
		splitResult[1]++;
		
		if (promoBanner1 != null) {
			if (splitResult[0] >= promoBanner1.childNodes.length) {
				splitResult[0] = 0;
			}
			for (var i = 0; i < promoBanner1.childNodes.length; i++) {
				if (splitResult[0] == i) {
				promoBanner1.childNodes[i].style.display = 'inline';
				  
				// Track impression
				if (promoBanner1.childNodes[i].attributes['trackimpression']) {
					eval(promoBanner1.childNodes[i].attributes['trackimpression'].value);
				}
				}
				else {
					promoBanner1.childNodes[i].style.display = 'none';
				}
			}
		}
		
		if (promoBanner3 != null) {
			if (splitResult[1] >= promoBanner3.childNodes.length) {
				splitResult[1] = 0;
			}
			for (var i = 0; i < promoBanner3.childNodes.length; i++) {
				if (splitResult[1] == i) {
				promoBanner3.childNodes[i].style.display = 'inline';
				  
				// Track impression
				if (promoBanner3.childNodes[i].attributes['trackimpression']) {
					eval(promoBanner3.childNodes[i].attributes['trackimpression'].value);
				}
				}
				else {
					promoBanner3.childNodes[i].style.display = 'none';
				}
			}
		}
		
		BRP.Cookie.Save(cookieName, splitResult[0] + '|' + splitResult[1], false);
		promotionBannerLoaded = true;
	}
}

YAHOO.util.Event.addListener(window, "load", rotatePromotionBanner);