/*
Title:      BRP Javascript Framework
Content:
            Base namespace setup BRP
                Events
                Language Selection
                Other Products
                Cookie Manager
                QueryUrl
            Menu
            Sea-Doo : Init + PopUp
                Base namespace setup SeaDoo 
                Initialize Share Options Pop up page
                Initialize Payment Calculator Pop up page
                Initialize Promotions Pop up page
                Initialize Send to a Friend Pop up page
                Initialize Send Brochure Pop up page
                Initialize Popup features
            Main Navigation for IE/Win
            Generic Popup Window
            Showroom : Model Selector
            Showroom : Tool Tip
            Showroom /Overview - Videos Images Slider
*/

window.BRP = window.BRP || {};

BRP = {
	// Main function call (page init)
	Init : function() {	
		document.body.className += " hasJS";
		
		if(typeof MCMSConsoleInit == "function") {
			AdvancedHTMLToolsLoad = false;
			MCMSConsoleInit();
			}
		if(typeof initAdvancedHTMLTools == "function") 
		{
			if (AdvancedHTMLToolsLoad)	initAdvancedHTMLTools();		
		}
	}
		
};

YAHOO.util.Event.addListener(window, "load", BRP.Init, BRP, true);


// ------[ Events ]------------------------------------------------- //	
BRP.Events = {
	id : null,
	table : null,
	tr : null,
	
	Init : function() {
		this.table = document.getElementById(this.id);
		var tbody = this.table.getElementsByTagName("tbody")[0];	
		var tr = tbody.getElementsByTagName("tr");
		
		for(x=0; x<tr.length; x++) {
			var event = tr[x+1].getElementsByTagName("a")[0];
			tr[x].id = "event_" + x;
			tr[x].detail = tr[x+1];
			tr[x+1].bt = tr[x];
			tr[x].isVisible = false;
			tr[x].detail.getElementsByTagName("td")[0].innerHTML = "";
			tr[x].event = event.href;
			tr[x].onclick = BRP.Events.Show;
			tr[x].onmouseover = function() { 
				YAHOO.util.Dom.addClass(this, 'over');		
			}
			tr[x].onmouseout = function() { 
				YAHOO.util.Dom.removeClass(this, 'over');		
			}			
			YAHOO.util.Dom.addClass(tr[x], 'link');						
			x++;		
		}
	},
	
	Close : function(obj) {
		YAHOO.util.Dom.setStyle(obj.parentNode, 'display', 'none');	
		obj.innerHTML = "";	
		obj.parentNode.bt.isVisible = false;
	},
	
	Show : function() {
		if(this.isVisible) {			
			YAHOO.util.Dom.setStyle(this.detail, 'display', 'none');	
			this.detail.getElementsByTagName("td")[0].innerHTML = "";			
			this.isVisible = false;
		} else {		
			document.location = "#" + this.id;
			var iFrame = document.createElement('iframe');
			var td = this.detail.getElementsByTagName("td")[0];
			iFrame.scrolling = 'no';
			iFrame.setAttribute('src',this.event);
			iFrame = td.appendChild(iFrame);			
			YAHOO.util.Dom.setStyle(iFrame, 'width', '100%');
			YAHOO.util.Dom.setStyle(iFrame, 'border', '0');
			YAHOO.util.Dom.setStyle(iFrame, 'height', '540px');	
			YAHOO.util.Dom.setStyle(this.detail, 'display', '');	
			YAHOO.util.Dom.setStyle(td, 'padding', '0px');
			YAHOO.util.Dom.setStyle(td, 'margin', '0px');
			this.isVisible = true;
		}
	}
	
	
};


// ------[ Language Selection ]---------------------------------- //	
BRP.Language = {
	lang : null,
	
	Set : function(lang) {
		BRP.Cookie.Save('SeaDooLanguage', lang, true);
		this.lang = lang;
	},
	
 	Get : function() {	
	 	this.lang = BRP.Cookie.Load("SeaDooLanguage");
		if(this.lang) { 				
			return this.lang;
		} else {			
			return null;		
		}  	 	 	 				 		 	  
 	},
	
	Check : function(path) {
		this.Get();
		
		if((BRP.QueryUrl.Get('reset') != 'true') && (this.lang != null))
		{
		    document.location = path.replace("{lang}", this.lang).replace("{root}", TRYSPYDER.globals.RootDirectory);	
		}
	}
};

// ------[ Other Products ]------------------------------------------------- //	
BRP.OtherProducts = {
	IsShow : false,
	Timer : null,
	DivElement : null,
	strCrossContentHref : null,
	strCrossContentPage : null,
	
	Init : function() {		
		this.DivElement = document.getElementById("other-brp-products");
		if(this.DivElement) {
			this.DivElement.onmouseover = this.Show;
			this.DivElement.onmouseout = this.Hide;
			}
		//Keep the div "other-brp-products" open in the cross-content web page
			strCrossContentHref = window.location.href;
			strCrossContentPage = strCrossContentHref.indexOf("cross-content.htm");			
			if(strCrossContentPage >= 0) {
				BRP.OtherProducts.DivElement.style.display = "block";
			}
		},
	
	Show : function() {
		clearTimeout(BRP.OtherProducts.Timer);
		BRP.OtherProducts.Timer = false;
		BRP.OtherProducts.DivElement.style.display = "block";
		BRP.OtherProducts.IsShow = true;
		window.scrollTo(0,10000000);		
		},
		
	Hide : function() {
			if(strCrossContentPage <= 0) { 
				//console.log("Function Hide strCrossContentPage = " + strCrossContentPage);
				BRP.OtherProducts.Timer = setTimeout('BRP.OtherProducts.HideTimer()',500);
			}
		},

	HideTimer : function() {
		BRP.OtherProducts.Timer = false;
		BRP.OtherProducts.DivElement.style.display = "none";
		BRP.OtherProducts.IsShow = false;			
		},
	
	Display : function() {
		if(this.DivElement) {
			if(!this.IsShow) {
				this.Show();
				//this.Timer = setTimeout('BRP.OtherProducts.HideTimer()',1500);
				}
			else this.Hide();
			}
		}
};
YAHOO.util.Event.addListener(window, "load", BRP.OtherProducts.Init, BRP.OtherProducts, true);


// ------[ Cookie Manager ]---------------------------------- //	
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=/";
	}			


};


// ------[ QueryUrl ]---------------------------------- //
BRP.QueryUrl = {
	
	Search : function(q) {
		if(q.length > 1) this.q = q.substring(1, q.length);
		else this.q = null;
		this.keyValuePairs = new Array();
		
		if(q) {
			for(var i=0; i < this.q.split("&").length; i++) {
				this.keyValuePairs[i] = this.q.split("&")[i];
				}
			}
		
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function(s) {
			for(var j=0; j < this.keyValuePairs.length; j++) {
				if(this.keyValuePairs[j].split("=")[0] == s) return this.keyValuePairs[j].split("=")[1];
				}
			return;
			}
		
		this.getParameters = function() {
			var a = new Array(this.getLength());
			for(var j=0; j < this.keyValuePairs.length; j++) {
				a[j] = this.keyValuePairs[j].split("=")[0];
				}
			return a;
			}
		
		this.getLength = function() { return this.keyValuePairs.length; }		
		},
	
	Get : function(key) {
		var page = new this.Search(window.location.search);
		return unescape(page.getValue(key));		
		}
};

// ------[ Menu ]------------------------------------------------- //
YAHOO.util.Event.onContentReady("main-nav", function () {  

	/**
	* Initialize the Menu
	* Ul Navigation: Display 'block' to show nav after Loading
	*/

	function MenuInit(){
		var UlNavObject = document.getElementById("main-nav-container");
		YAHOO.util.Dom.setStyle(UlNavObject, "display", "block");				
	};
	
	MenuInit();
	
});

// ------[ Sea-Doo : Init + PopUp ]------------------------------------------------- //

/**
 * Base namespace setup
 */
var SeaDoo = {
    globals: {
		labels: {}
	},
    pages: {
        all: {},
        modelOverview: {}        
    },
    widgets: {}
}

/**
 * Init for all pages
 */ 
SeaDoo.pages.all.init = function () {
	
	/**
	* Initialize Share Options Pop up page
	*/
	SeaDoo.globals.shareOptions = new YAHOO.widget.Panel(
		"shareoptions",
		{ 
			width: "260px",
			height: "120px",
			context:["linkShare","bl","tr"],
			constraintoviewport: false,
			close:true,
			visible:false,
			draggable:false,
			zIndex: 5
		}
	);
	//Render the panel for screen
	SeaDoo.globals.shareOptions.render(document.body);

	//Create an array with all anchor with the classname "shareoptions"
     var el = YAHOO.util.Dom.getElementsByClassName('shareoptions','a');

     for (var i=0; el[i]; i++) {
		el[i].onclick = function() { 
			var pnl = SeaDoo.globals.shareOptions;
			pnl.setBody("<iframe allowtransparency='true' width='260' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' height='120' src='" + this.href + "'></iframe>");
			pnl.render();
			pnl.show();
	        return false;
			}
		el[i].style.visibility = "visible";
      }
      
	/**
	* Initialize Payment Calculator Pop up page
	*/
	SeaDoo.globals.calculator = new YAHOO.widget.Panel(
		"calculatepayment",
		{ 
			width: "255px",
			height: "345px",
			constraintoviewport: true,  
			underlay:"shadow",  
			close:true,  
			visible:false,  
			fixedcenter: true,  
			draggable:false,
			zIndex: 5,
			modal: true //Window bkg
		}
	);
	//Render the panel for screen
	SeaDoo.globals.calculator.render(document.body);

	//Create an array with all anchor with the classname "calculatepayment"
     var el = YAHOO.util.Dom.getElementsByClassName('calculatepayment','a');

     for (var i=0; el[i]; i++) {
		el[i].onclick = function() { 
			var pnl = SeaDoo.globals.calculator;
			pnl.setBody("<iframe allowtransparency='true' width='255' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' height='345' src='" + this.href + "'></iframe>");
			pnl.render();
			pnl.show();
	        return false;
			}
		el[i].style.visibility = "visible";
      }
	
	/**
	* Initialize Promotions Pop up page
	*/
	SeaDoo.globals.promotions = new YAHOO.widget.Panel(
		"popupPromotions",
		{ 
			width: "470px",
			height: "670px",
			constraintoviewport: true,  
			underlay:"shadow",  
			close:true,  
			visible:false,  
			fixedcenter: false,
			draggable:false,
			zIndex: 5,
			modal: true //Window bkg
		}
	);
	//Render the panel for screen
	SeaDoo.globals.promotions.render(document.body);

	//Create an array with all anchor with the classname "popupPromotions"
     var el = YAHOO.util.Dom.getElementsByClassName('popupPromotions','a');

     for (var i=0; el[i]; i++) {
		el[i].onclick = function() { 
			var pnl = SeaDoo.globals.promotions;
			pnl.setBody("<iframe allowtransparency='true' width='470' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' height='670' src='" + this.href + "'></iframe>");
			pnl.render();
			pnl.center();
			pnl.show();
	        return false;
			}
		el[i].style.visibility = "visible";
      }
	
	//Redirection du bouton "Get a Quote" dans la popup "popupPromotions"
     var btn = YAHOO.util.Dom.getElementsByClassName('rightButton','a');
     for (var i=0; btn[i]; i++) {
	    btn[i].onclick = function() {
	    	parent.SeaDoo.globals.promotions.hide();
		    parent.window.location = btn[i].href;
		    return false;
		    }
	    btn[i].style.visibility = "visible";
      }
	
	
	/**
	* Initialize Send to a Friend Pop up page
	*/
	SeaDoo.globals.sendEmail = new YAHOO.widget.Panel(
		"sendtofriend",
		{ 
			width: "655px",
			height: "315px",
			constraintoviewport: true,  
			underlay:"shadow",  
			close:true,  
			visible:false,  
			fixedcenter: true,  
			draggable:false,
			zIndex: 5,
			modal: true //Window bkg
		}
	);
	//Render the panel for screen
	SeaDoo.globals.sendEmail.render(document.body);

	//Create an array with all anchor with the classname "sendfriend"
     var el = YAHOO.util.Dom.getElementsByClassName('sendfriend','a');
     var el2 = YAHOO.util.Dom.getElementsByClassName('shareoptions','a');

     for (var i=0; el[i]; i++) {
		el[i].onclick = function() { 
			var pnl = parent.SeaDoo.globals.sendEmail;
		    parent.SeaDoo.globals.shareOptions.hide();
			pnl.setBody("<iframe allowtransparency='true' width='655' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' height='315' src='" + this.href + "'></iframe>");
			pnl.render();
			pnl.show();
	        return false;
		    }
		el[i].style.visibility = "visible";
      }
      
	/**
	* Initialize Send Brochure Pop up page
	*/
	SeaDoo.globals.brochure = new YAHOO.widget.Panel(
		"sendBrochure",
		{ 
			width: "665px",
			height: "335px",
			constraintoviewport: true,  
			underlay:"shadow",  
			close:true,  
			visible:false,  
			fixedcenter: true,  
			draggable:false,
			zIndex: 5,
			modal: true //Window bkg
		}
	);
	//Render the panel for screen
	SeaDoo.globals.brochure.render(document.body);

	//Create an array with all anchor with the classname "sendBrochure"
     var el = YAHOO.util.Dom.getElementsByClassName('sendBrochure','a');

     for (var i=0; el[i]; i++) {
		el[i].onclick = function() { 
			var pnl = SeaDoo.globals.brochure;
			pnl.setBody("<iframe allowtransparency='true' width='665' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' height='335' src='" + this.href + "'></iframe>");
			pnl.render();
			pnl.show();
	        return false;
			}
		el[i].style.visibility = "visible";
      }
      
	/**
	* Initialize Popup features
	*/
	SeaDoo.globals.featuresH = new YAHOO.widget.Panel(
		"popupFeatures",
		{ 
			width: "577px",
			height: "265px",
			constraintoviewport: true,  
			underlay:"shadow",  
			close:true,  
			visible:false,  
			fixedcenter: true,  
			draggable:false,
			zIndex: 5,
			modal: true //Window bkg
		}
	);
	
	SeaDoo.globals.featuresV = new YAHOO.widget.Panel(
		"popupFeatures",
		{ 
			width: "527px",
			height: "341px",
			constraintoviewport: true,  
			underlay:"shadow",  
			close:true,  
			visible:false,  
			fixedcenter: true,  
			draggable:false,
			zIndex: 5,
			modal: true //Window bkg
		}
	);
	//Render the panel for screen
	SeaDoo.globals.featuresH.render(document.body);
	SeaDoo.globals.featuresV.render(document.body);

	//Create an array with all anchor with the classname "popupFeatures"
     var el = YAHOO.util.Dom.getElementsByClassName('popupFeatures','a');

     for (var i=0; el[i]; i++) {
		el[i].onclick = function() { 
		    var style = new BRP.QueryUrl.Search(this.href).getValue("Style");
		    
		    var pnl, width, height;
		    if(style.toLowerCase() == "h"){
		        pnl = SeaDoo.globals.featuresH;
		        width = 577;
		        height = 265;
		    }
		    else{
		        pnl = SeaDoo.globals.featuresV;
		        width = 527;
		        height = 341;
		    }
		    
			pnl.setBody("<iframe allowtransparency='true' width='"+width+"' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' height='"+height+"' src='" + this.href + "'></iframe>");
			pnl.render();
			pnl.show();
	        return false;
			}
		el[i].style.visibility = "visible";
      }
      
      
      SeaDoo.globals.overviewVideo = new YAHOO.widget.Panel(
		"overview-video",
		{ 
			width: "555px",
			height: "350px",
			constraintoviewport: true,  
			underlay:"shadow",  
			close:true,  
			visible:false,  
			fixedcenter: true,  
			draggable:false,
			zIndex: 5,
			modal: true //Window bkg
		}
	);
      SeaDoo.globals.overviewVideoLarge = new YAHOO.widget.Panel(
		"overview-video",
		{ 
			width: "730px",
			height: "530px",
			constraintoviewport: true,  
			underlay:"shadow",  
			close:true,  
			visible:false,  
			fixedcenter: true,  
			draggable:false,
			zIndex: 5,
			modal: true //Window bkg
		}
	);
	//Render the panel for screen
	SeaDoo.globals.overviewVideo.render(document.body);
	SeaDoo.globals.overviewVideoLarge.render(document.body);

	//Create an array with all anchor with the classname "overview-video"
     var el = YAHOO.util.Dom.getElementsByClassName('overview-video','a');

     for (var i=0; el[i]; i++) {
		el[i].onclick = function() { 
		    var style = new BRP.QueryUrl.Search(this.href).getValue("Style");
		    
		    if(!style) {
		        style = "";
		    }
		    
		    var pnl, width, height;
		    if(style.toLowerCase() == "large"){
		        pnl = SeaDoo.globals.overviewVideoLarge;
		        width = 730;
		        height = 530;
		    }
		    else {
		        pnl = SeaDoo.globals.overviewVideo;
		        width = 555;
		        height = 350;
		    }
		    
			pnl.setBody("<iframe allowtransparency='true' width='"+width+"' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' height='"+height+"' src='" + this.href + "&Style="+style+"'></iframe>");
			pnl.render();
			pnl.subscribe("hide", function(){
			    this.setBody("");
			});
			
			pnl.show();
	        return false;
			}
		el[i].style.visibility = "visible";
      }
      
      
      //IE6 Only patch Navigation : onmouseover level
      MainNavigationInit();
 };

 // ------[ Main Navigation for IE/Win ]------------------------------------------------- //
 function MainNavigationInit() {
     if (document.all && document.getElementById) {
         navRoot = document.getElementById("main-nav-container");
         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() {
     if (this.level.toString() == "2") {
         if (this.className != "") {
             this.className = this.className.replace("selectedNode", "");
             this.className += "selectedNode navOver";
         }
         else {
             this.className += "navOver";
         }
     }
     else {
         this.className += "navOver";
     }

 }
 function MainOut() {
     if (this.level.toString() == "2") {
         if (this.className == "selectedNode navOver") {
             this.className = this.className.replace("selectedNode navOver", "selectedNode");
         }
         else {
             this.className = this.className.replace("navOver", "");
         }
     }
     else {
         this.className = this.className.replace("navOver", "");
     }
 }
// ------[ 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();
}

// ------[ Model Selector ]--------------------------------------------- //



BRP.ModelSelector = {

	FiltersContainerId : "",
	ModelsContainerId : "",	
	modelselectorTracker : null, 

	Create: function(modelContainerId,filterContainerId,channelName)
	{
		this.ModelsContainerId = modelContainerId;
		this.FiltersContainerId = filterContainerId;
		YAHOO.util.Event.on(this.FiltersContainerId,'click',this.FilterClicked);		
		if (channelName.toLowerCase() == "watercraft")
		{
		    modelselectorTracker = pageTracker._createEventTracker('Model%20Selector%20PWC');
		}
		else
		{
		    modelselectorTracker = pageTracker._createEventTracker('Model%20Selector%20SB');
		}		
	},

	FilterClicked: function(e, params)
	{
		var elTarget = YAHOO.util.Event.getTarget(e);
		var optionClicked = false;
		while(elTarget.id != this.FiltersContainerId)
		{
			if(elTarget.nodeName.toUpperCase() == "INPUT")
			{
				optionClicked = true;
				break;
			}
			else
			{
				elTarget = elTarget.parentNode;
			}
		}

		if (optionClicked)
		{
			BRP.ModelSelector.RefreshModels();
			if(elTarget.nodeName.toUpperCase() == "INPUT" && elTarget.attributes["type"].value.toLowerCase() == "checkbox")
			{
			    if (elTarget.checked)
			    {
			        modelselectorTracker._trackEvent('check', elTarget.attributes["id"].value);
			    }
			    else
			    {
			        modelselectorTracker._trackEvent('uncheck', elTarget.attributes["id"].value);
			    }
			}
	    }
	},	

	RefreshModels: function()
	{
		var inclusionArray = new Array();
		var filterCategories = YAHOO.util.Dom.getElementsByClassName('filterCategory',null,this.FiltersContainerId);
		var filterCategoriesLength = filterCategories.length;
		for(var i=0;i<filterCategoriesLength;i++)
		{
			var finalCategoryInclusion = "";
			var filters = YAHOO.util.Dom.getElementsByClassName('filter',null,filterCategories[i]);
			var filtersLength = filters.length;
			for(var j=0;j<filtersLength;j++)
			{
				if (filters[j].checked)
				{
					finalCategoryInclusion += filters[j].value + ";";
				}
			}
			inclusionArray.push(finalCategoryInclusion);
		}

		//set visibility to elements accordingly
		var modelElements = YAHOO.util.Dom.getElementsByClassName("models-seadoo",null,this.ModelsContainerId);
		var modelElementsLength = modelElements.length;
		var inclusionArrayLenth = inclusionArray.length;
		
		for(var k=0;k<modelElementsLength;k++)
		{
			var modelElementId = modelElements[k].id;
			//console.log("modelElementId = " + modelElementId);
			var modelIsVisible = true;			

			for(var l=0;l<inclusionArrayLenth;l++)
			{
				if (inclusionArray[l].indexOf(modelElementId + ";") == -1)
				{
					modelIsVisible = false;
				}
			}

			if (modelIsVisible)
			{
				 YAHOO.util.Dom.removeClass(modelElementId,"models-off");
				 YAHOO.util.Dom.addClass(modelElementId,"models-on");
			}
			else
			{
				 YAHOO.util.Dom.removeClass(modelElementId,"models-on");
				 YAHOO.util.Dom.addClass(modelElementId,"models-off");
			}
		}
	}
};

// ------[ Showroom : Tool Tip ]--------------------------------------------- //

BRP.ModelToolTip = {
	Create: function(modelContainerId, toolContainerId)
	{
		//Show only the Main Div Element
		YAHOO.util.Dom.setStyle("models-tooltip", "display", "block")
		this.ModelsContainerId = modelContainerId;
		this.ToolContainerId = toolContainerId;
		BRP.ModelToolTip.ActionModelsHover(this.ModelsContainerId,this.ToolContainerId);
	},	

	ActionModelsHover: function(elAllModels, elModelsSeaDoo)
	{
		var containerModels = YAHOO.util.Dom.get(elAllModels);
		var modelsSeaDooElement = elModelsSeaDoo;	

		if(containerModels && modelsSeaDooElement) {
			/* aArray == All a Element */
			var aArray = containerModels.getElementsByTagName('a');	
			var aCount = aArray.length;
			/* toolArray == Parent Element */
			var toolArray = YAHOO.util.Dom.getElementsByClassName(modelsSeaDooElement,null,containerModels);		

			for (i=0; i < aCount; i++) {
				//Create all "SeaDoo Info Tool" ID
				var toolId = toolArray[i].id+"Info";			

				//Hide all SeaDoo Info Tool
				//YAHOO.util.Dom.setStyle(toolId, "display", "none");
				//Moves "tool tip" element to the xy position of "a" element
				var xPosition = YAHOO.util.Dom.getX(aArray[i]);
				var yPosition = YAHOO.util.Dom.getY(aArray[i]);
				var aElementWidth = aArray[i].offsetWidth;
				//round = Arrondit à l'entier le plus proche la valeur donnée.
				var maxWidth = Math.round((107 - aElementWidth) / 2);
				//floor = Retourne le plus grand entier inférieur ou égal à la valeur donnée en paramètre.
				xPosition = Math.floor(xPosition + aElementWidth + maxWidth - 10);
				yPosition = Math.floor(yPosition - 80);

				//Set the "tool tip" element position
				YAHOO.util.Dom.setX(toolId, xPosition);
				YAHOO.util.Dom.setY(toolId, yPosition);

				//Create Fade in Tool element
				BRP.ModelToolTip.SEADOOID =  
					new YAHOO.widget.Overlay(toolId,
						{
						    visible: false,
						    zIndex: 6,
						    effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25}
						}
				);			

				/* Call Action on Element */
				
				YAHOO.util.Event.addListener(toolArray[i], "mouseover", BRP.ModelToolTip.SEADOOID.show, BRP.ModelToolTip.SEADOOID, true);
				YAHOO.util.Event.addListener(toolArray[i], "mouseout", function () {
					var container = toolArray[i];
					return function (e) {
						e = e || event;
						relatedTarget = YAHOO.util.Event.getRelatedTarget(e);
						if (typeof relatedTarget === "undefined") 
						{/*If Outside ViewPort*/
							this.hide();
						}
						else 
						{
							/*Look if we are inside the Parent Element*/
							var isInside = YAHOO.util.Dom.getAncestorBy(relatedTarget, function (el) {
									if (el.id === container.id) 
									{
										return true;
									}
									return false;
							});
							if (!isInside) 
							{
								this.hide();
							}
						}
					}
				}(), BRP.ModelToolTip.SEADOOID, true);

				//Create href on Parent DIV element 
				var alinks = function(e, params) {
					var url = params.links || event;
					YAHOO.util.Event.preventDefault(e);
					
					//Check to see if we clicked on an DIV element
					//console.log("params.caller.tagName = " + params.caller.tagName);
					if (params.caller && params.caller.tagName && (params.caller.tagName.toLowerCase() == 'div'))
					{
						window.location = url;
					}
				}
				
				YAHOO.util.Event.addListener(toolArray[i], 'click', alinks, {caller:toolArray[i], links:aArray[i]});
			}
		}
	}
};

// ------[ Showroom /Overview - Videos Images Slider ]------------------------------------------------- /

SeaDoo.pages.modelOverview.init = function(e, CatalogModelYear) {
    // Initialize video images slideshow
    this.catalogModelYear = CatalogModelYear;
    SeaDoo.globals.slideShow = new SeaDoo.widgets.Slideshow(this.catalogModelYear);
};
/**
* Creates a slideshow with previous/next buttons and slides in between representing
* the current slide among the total number of slides in the show
*/
SeaDoo.widgets.Slideshow = function(CatalogModelYear) {
    //Catalog Model Year
    this.catalogModelYear = CatalogModelYear;
    // Video Player Element
    this.slidesEl = YAHOO.util.Dom.get("video-player");
    // Slider Controls Element
    this.controlBarEl = YAHOO.util.Dom.get("pics-indicator");
    if (!this.slidesEl || !this.controlBarEl) return;

    // Find all THUMBNAILS Slider Images
    this.slides = this.controlBarEl.getElementsByTagName("div");

    this.slidesPtr = 0;
    this.currentSlide = function() { return this.slidesPtr + 1 }

    /*
    *   Initial States :
    *       Show the Slider details box
    *       Allow to view all the elements after the content is load
    */
    var elProductsDetailsContent = YAHOO.util.Dom.get("products-images");
    elProductsDetailsContent.style.display = "block";

    /*
    * Only create slideshow if there is more than 0 slide
    */
    if (this.slides.length > 0) {
        /*
        *  Set all THUMBNAILS Slider Images for the CLICK action
        */
        for (var i = 0; i < this.slides.length; i++) {
            YAHOO.util.Event.addListener(this.slides[i], 'click', function(that, num, catalogModelYear) {
                return function(e) {
                    YAHOO.util.Event.preventDefault(e);
                    //If the current slide click == to same click, do nothing
                    if (that.slidesPtr != num) {
                        that.slidesPtr = num;
                        that.setCurrentEl();
                        //Set the video
                        SeaDoo.widgets.Slideshow.StartVideo(this.attributes["videoUrl"].nodeValue, this.attributes["productid"].nodeValue, this.attributes["applicationPath"].nodeValue, catalogModelYear);
                    }
                }
            } (this, i, this.catalogModelYear));
        }
        /*
        * Set the Current Thumbnails Class
        */
        this.setCurrentEl = function() {
            if (this.controlBarEl) {
                for (var i = 0; this.slides[i]; i++) {
                    if ((i + 1) === this.currentSlide()) {
                        this.slides[i].className = "current";
                    } else {
                        this.slides[i].className = "";
                    }
                }
            }
        }
        /*
        *  Initialize the first Current slide
        */
        this.setCurrentEl();
        /*
        *  Initialize the SlideShow Selector
        */
        this.ImageSelectorScroll.Init();
    }
}          //init

SeaDoo.widgets.Slideshow.StartVideo = function(videoUrl, productId, applicationPath, catalogModelYear) {
    var params = {};
    params.wmode = "transparent";
    params.quality = "high";
    params.scale = "noscale";
    params.allowfullscreen = "true";

    var attributes = {};
    attributes.id = "inner-video";
    attributes.name = "inner-video";

    videoFlashvars.videoName = videoUrl;
    videoFlashvars.productId = productId;

    swfobject.embedSWF(applicationPath + "/_Static/neutral/flash/"+catalogModelYear+"/mainLoader.swf", "inner-video", "438", "285", "9.0.0", applicationPath + "/_Static/Neutral/Flash/expressInstall.swf", videoFlashvars, params, attributes);
};

SeaDoo.widgets.Slideshow.prototype.ImageSelectorScroll = {
    picActualPosition: 0,
    listId: 'main-indicator',
    itemsList: 'pics-indicator',
    scrollPrevious: 'pics-left',
    scrollNext: 'pics-right'
};

SeaDoo.widgets.Slideshow.prototype.ImageSelectorScroll.Init = function() {
    // Find ID element
    this.scrollableListContainer = document.getElementById(this.listId);
    this.scrollableList = document.getElementById(this.itemsList);
    this.lnkPrevious = document.getElementById(this.scrollPrevious);
    this.lnkNext = document.getElementById(this.scrollNext);

    this.picsArray = this.scrollableList.getElementsByTagName('div');
    this.picsWidth = this.picsArray[0].offsetWidth;
    this.picsCount = this.picsArray.length;

    // Set the correct "width" for the list : ignoring the scrollableListContainer width
    this.scrollableList.style.width = this.picsWidth * this.picsCount + "px";
    this.ViewablePics = parseInt(this.scrollableListContainer.offsetWidth / this.picsWidth);

    YAHOO.util.Event.addListener(this.lnkPrevious, 'click', this.Scrolling, { caller: this, direction: -1 });
    YAHOO.util.Event.addListener(this.lnkNext, 'click', this.Scrolling, { caller: this, direction: 1, pics: this.ViewablePics, count: this.picsCount });

    //Show the Slider Scroll button if 4 products and more
    if (this.picsCount > "3") {
        YAHOO.util.Dom.setStyle(this.lnkPrevious, 'display', 'block');
        YAHOO.util.Dom.setStyle(this.lnkNext, 'display', 'block');
        this.RefreshNavigation();
    }
};

SeaDoo.widgets.Slideshow.prototype.ImageSelectorScroll.RefreshNavigation = function() {
    if (this.picActualPosition > 0) {
        YAHOO.util.Dom.setStyle(this.lnkPrevious, 'opacity', 1);
    }
    else {
        YAHOO.util.Dom.setStyle(this.lnkPrevious, 'opacity', 0.2);
    }

    if ((this.picActualPosition + this.ViewablePics) < this.picsCount) {
        YAHOO.util.Dom.setStyle(this.lnkNext, 'opacity', 1);
    }
    else {
        YAHOO.util.Dom.setStyle(this.lnkNext, 'opacity', 0.2);
    }
};

SeaDoo.widgets.Slideshow.prototype.ImageSelectorScroll.Scrolling = function(e, params) {

    if (params.direction == "1") {
        // Next
        if ((params.caller.picActualPosition + params.pics) >= params.count) {
            //Stop the Click Event if we are in maximum in RIGHT position
            return false;
        } else {
            // Set the new position counter
            params.caller.picActualPosition += params.direction;
        }
    } else {
        // Previous
        if (params.caller.picActualPosition <= 0) {
            //Stop the Click Event if we are in maximum in LEFT position
            return false;
        } else {
            // Set the new position counter
            params.caller.picActualPosition += params.direction;
        }
    }

    // Get the actual XY position of the scroller DIV;
    var originalXY = YAHOO.util.Dom.getXY(params.caller.scrollableList);

    // Calculate the new coordinates
    var elContainerXY = YAHOO.util.Dom.getXY(params.caller.scrollableListContainer);
    var newXY = [elContainerXY[0] + ((params.caller.picActualPosition * -1) * params.caller.picsWidth), originalXY[1]];

    /* 
    * Anim subclass for moving elements along a path
    * Defined by the "opacity" and "points" member of "attributes"
    * Set the Duration (0.5) and Method (EaseOut) for the animation
    */
    var animSlide = new YAHOO.util.Motion(params.caller.scrollableList, { opacity: { from: 0.3, to: 1 }, points: { to: newXY} }, 0.5, YAHOO.util.Easing.EaseOut);
    animSlide.animate();

    // Set Style of Navigation button 
    params.caller.RefreshNavigation();
}
