/*------Site Catalyst Variables----------------------------------------------------------------------------*/
    
	 	  var products_add_to_cart ="";
	 	  var products_accessory="";
	 	  var products_overview="";
  	
/*-------End Site Catalyst Variables ----------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Product Controller
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 6/6/2008
** description: Adds Event Listners to DOM Elements. Delegates events to the approriate command function. 
***/

ProductController = {

		/* Constants */

		CONTENT_CONTAINER:"",  // Reference to the content container element
		SHOWCASE_CONTAINER:"", // Reference to the showcase container element
		ADDTOCART_CONTAINER:"", // Reference to the addtocart container element

        byPassNavExtend:false, // Bypasses navExtend functions when True

		/* Methods */

		init: function() {

			/* Set Constants */

			try {
				ProductController.CONTENT_CONTAINER = document.getElementById('content');
				ProductController.SHOWCASE_CONTAINER = document.getElementById('product_showcase');
				ProductController.ADDTOCART_CONTAINER = document.getElementById('addtocart');
			}
			catch(e) {/*handles error when there is no div defined on the page*/}

			/* Global Event Listeners */

			/* CONTENT_CONTAINER */

			/* Delegate onclick events */
			ProductController.CONTENT_CONTAINER.onclick = function(e) {
				ProductCommands.clickEvent(e);
			}
			

			/* Delegate onmouseover events */
			ProductController.CONTENT_CONTAINER.onmouseover = function(e) {
				ProductCommands.mouseOverEvent(e);
			}

			/* Delegate onmouseout events */
			ProductController.CONTENT_CONTAINER.onmouseout = function(e) {
				ProductCommands.mouseOutEvent(e);
			}


			/* SHOWCASE_CONTAINER */
			
			try {
				ProductController.SHOWCASE_CONTAINER.onmouseover = function(e) {
					ProductCommands.mouseOverEvent(e);
				}
				
	
				/* Delegate onmouseout events */
				ProductController.SHOWCASE_CONTAINER.onmouseout = function(e) {
					ProductCommands.mouseOutEvent(e);
				}
	
				/* Delegate click events */
				
				ProductController.SHOWCASE_CONTAINER.onclick = function(e) {
					ProductCommands.clickEvent(e);
				}
			}
			catch(e) {}
			
			/* ADDTOCART_CONTAINER */
			
			try {
				/* Delegate onmouseover events */
				ProductController.ADDTOCART_CONTAINER.onmouseover = function(e) {
					ProductCommands.mouseOverEvent(e);
				}

				/* Delegate onmouseout events */
				ProductController.ADDTOCART_CONTAINER.onmouseout = function(e) {
					ProductCommands.mouseOutEvent(e);
				}

				/* Delegate click events */
				ProductController.ADDTOCART_CONTAINER.onclick = function(e) {
					ProductCommands.clickEvent(e);
				}

				/* Delegate onchange events */
				ProductController.ADDTOCART_CONTAINER.onchange = function(e) {
					ProductCommands.onChangeEvent(e);
				}
			}
			catch(e) {}
		},
		/* Disable all handlers. Presently used by media showcase to improve perfomance */
		disable: function() {
			ProductController.CONTENT_CONTAINER.onclick = null;
			ProductController.CONTENT_CONTAINER.onmouseover = null;
			ProductController.CONTENT_CONTAINER.onmouseout = null;
			ProductController.CONTENT_CONTAINER.onmousemove = null;
			ProductController.SHOWCASE_CONTAINER.onmouseover = null;
			ProductController.SHOWCASE_CONTAINER.onmouseout = null;
			ProductController.SHOWCASE_CONTAINER.onclick = null;
			ProductController.ADDTOCART_CONTAINER.onclick = null;
			ProductController.ADDTOCART_CONTAINER.onmouseout = null;
		}
}


/*--------------------------------------------------------------------------------------------------------*/

/***
** title: ProductCommands
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 6/6/2008
** description: Object contains commands that will execute functions depending upon the class or id of the element that 
** dispatched the event. Called from the FrontController.
***/

ProductCommands = {

		/* Execute onclick commands */
		clickEvent: function(e) {
			var t = getEventTarget(e);
			Element.extend(t); // Add prototype methods

			/* Execute View More */
			if (t.hasClassName('view_more')) {
				showFeatures(t);
			}

			/* Execute Accordion List */
			if (t.hasClassName('al_open')) {
				AccordionList.toggleList(t);
			}

			/* Execute Media Showcase */
			if (t.hasClassName('showcase')) {
				MediaShowcase.open(t,e);
			}

			/* Execute product tab switch */
			if (t.up().hasClassName('tab')) {
				ProductTabs.onSwitchTab(t,e);
				FSR.run()
			}
			
			// Change the product hero when user changes the product color from the select input
			if(t.id == ('color')) {
				addToCartForm.changeHeroColor(t);
			}
			
			/* Execute Accessory Box */
			if(t.hasClassName('accessory_details')) {
				AccessoryRollover.showBox(t);
			}
			if(t.hasClassName('close')) {
				AccessoryRollover.closeBox(t);
			}
			
			/* Execute Product Color Change */
			if(t.hasClassName('colorchip')) {
				ProductColorChange.changeColor(t);
			}
			
		},

		/* Execute onmouseover commands */
		mouseOverEvent: function(e) {
			var t = getEventTarget(e);
			Element.extend(t);
			
			/* Show the media showcase rollover tip */
			if(t.hasClassName('showcase')) {
				ShowcaseRollover.onRollover(t);
			}
			
			if(t.hasClassName('accessory_details')) {
				RollOverImageSwap.rollover(t);
			}
		},

		/* Execute onmouseout commands */
		mouseOutEvent: function(e) {
			var t = getEventTarget(e);
			Element.extend(t);
			if(t.hasClassName('colorchip')) {
				//addToCartForm.changeHeroColor(t);
				//ProductColorChange.resetRollover(t);
			}

			/* Hide the media showcase rollover tip */
			if(t.hasClassName('showcase'))
			{
				ShowcaseRollover.onRollout(t);
				
			}	
				
			// Change the product hero when user changes the product color from the select input
			if(t.id == ('color'))
			{
				addToCartForm.changeHeroColor(t);
			}
			
			if(t.hasClassName('accessory_details'))
			{
				RollOverImageSwap.rollout(t);
			}

		},

		/* Execute onmchange commands */
		onChangeEvent: function(e)
		{
			var t = getEventTarget(e);
			Element.extend(t);	
			
			// Change the product hero when user changes the product color from the select input
			if(t.id == ('color'))
			{
				addToCartForm.changeHeroColor(t);
			}

		}
}


/****** The following function checks to see what the default tab is, checks a variable on the page to see if the whole content div for that area is loaded, and then calls a function to display the content area. ******/

// When a page is loaded, if querystring object is undefined, set the overview tab to show. Otherwise use the querystring to determine which tab to show.

var tabLoaded = new Array();

tabLoaded["content_products"] = false;
tabLoaded["overview_content"] = false;
tabLoaded["inthebox_content"] = false;
tabLoaded["details_manuals_content"] = false;
tabLoaded["accessories_content"] = false;
tabLoaded["reviews_content"] = false;
tabLoaded["content_products"] = false;

ProductTabs = {
	
	sDisplayTab: "",
	sDefaultTab: "",
	
	/* These variables are used to adjust height of left nav and content area when FAQ expands DAC 5/24/2011 */
        contentDivHeight0:0,    // initial height of content div
        contentDivHeight1:0,    // height of content div when FAQ is expanded
        leftNavDivHeight0:0,    // intial height of left nav div
        leftNavDivHeight1:0,    // height of left nav div when FAQ is expanded
	faqListHeight0:0,       // initial unexpanded height of FAQ list
	faqListHeight1:0,       // current expanded FAQ list height
	faqListDeltaHeight:0,   // difference between the unexpanded and expanded FAQ list height- this gets tacked onto the left nav and the content div
        /* These variables are used to adjust height of left nav and content area when FAQ expands DAC 5/24/2011 */	
	
	getDefaultTab: function() {
		ProductTabs.sDefaultTab = window.location.querystring['tab']; // Get the querystring data

		if(ProductTabs.sDefaultTab == undefined) {
			ProductTabs.sDefaultTab = 'overview_content';
		}
	},
	
	onDefaultTabLoaded: function(tabName) {
		if(tabName == ProductTabs.sDefaultTab) {
			$(ProductTabs.sDefaultTab).className = 'show';
			var sImageClass = $(ProductTabs.sDefaultTab).id.gsub('content','img');
			var sImageName = $(ProductTabs.sDefaultTab).id.gsub('_content','');
			$(sImageClass).src = 'http://francais.bose.ca/enfr/assets/images/navigation/product_tabs/tab_' + sImageName + '_over.gif';
			$(sImageClass).className = 'show';
			navExtend(ProductTabs.sDefaultTab);
		}
		if(tabLoaded[ProductTabs.sDefaultTab] == true) {
			for(var item in tabLoaded) {
				if((tabLoaded[item] == true) && (item != ProductTabs.sDefaultTab)) {
					var sImageClass = $(item).id.gsub('content','img');
					var sImageName = $(item).id.gsub('_content','');
					$(sImageClass).src = 'http://francais.bose.ca/enfr/assets/images/navigation/product_tabs/tab_' + sImageName + '.gif';
					$(sImageClass).className = 'show';
				}
			}
		}
		
		// Fire SiteCatalyst event
		var sDefaultTab = window.location.querystring['tab'] == undefined ? "overview" : window.location.querystring['tab'];
		var tPageId = sPageID.replace(':Index','');
		
		if(s.pageName != tPageId + ':' + sDefaultTab) {
			s.pageName=tPageId + ':' + sDefaultTab.capitalize();
			
			if(products_add_to_cart!='') {
				s.products = products_add_to_cart;
			}
			 
			if(products_accessory!='' && sDefaultTab=='accessories') {
				s.products = s.products +','+ products_accessory;
			}
			 
			if(products_overview!='' && sDefaultTab=='overview') {
				s.products = s.products + ',' + products_overview;
			}
			
			s.products = s.products.split(sPageID).join(s.pageName);
			s.events="prodView,event11";
		 }
	},
	
	onSwitchTab: function(t,e) {
		// Define image elements respresenting tabs
            var sTabImage = t;
		// Loop through and set all tab images to non-clicked state
		for(var item in tabLoaded) {
			if(tabLoaded[item] == true) {
				var sImageClass = $(item).id.gsub('content','img');
				var sImageName = $(item).id.gsub('_content','');
				$(sImageClass).src = 'http://francais.bose.ca/enfr/assets/images/navigation/product_tabs/tab_' + sImageName + '.gif';
				$(sImageClass).className = 'show';
			}
		}
		        
        // Change the tab that was clicked to be selected
        if(sTabImage.src.include('_over.gif') == false) {                    
            sTabImage.src = sTabImage.src.sub('.gif','') + '_over.gif';
        }
        
        // Define divs containing tab content
        var aTabName = t.up().id;  
        var aSections = $('content_products').childElements();
        
        // Loop through and hide all divs
        for(n=0; n<aSections.length; n++) {
            $(aSections[n]).className = 'hide';
        }
        
        // Display the tabbed content that was clicked on
        for(n=0; n<aSections.length; n++) {
            if(aSections[n].id.include(aTabName) == true) {
                $(aSections[n]).className = 'show';
                navExtend(aSections[n].id); // Since the height of the content may change, need to re-run the navExtend() function.
                break;
            }
        }
		
		// Run the SiteCatalyst page view code - on load of the tab	
		var tPageId = sPageID.replace(':Index','');

		if(s.pageName != tPageId + ':' + aTabName){
			s.pageName=tPageId + ':' + aTabName.capitalize();

			if(products_add_to_cart!=''){
				s.products = products_add_to_cart;
			}

			if(products_accessory!='' && aTabName=='accessories'){
				s.products = s.products +','+ products_accessory;
			}

			if(products_overview!='' && aTabName=='overview'){
				s.products = s.products + ',' + products_overview;
			}

			s.products = s.products.split(sPageID).join(s.pageName);
			s.events="prodView,event11";

			s.doPlugins=s_doPlugins;
			var s_code=s.t();
		}
		// Live Person block - sends aTabName to Live Person using sendData() function in echat.js DAC 6/24/2009
                if (typeof(eChatSendData.sendData) === 'function') // Make sure that eChat.js is loaded
                {
                  eChatSendData.sendData('session','ClickAction',aTabName);
                }
                // End of Live Person block		

/* Start FAQ list height adjustment code block. Author DAC 05/04/2011
1. When the Details/Manuals tab is clicked the unexpanded heights of #al_list2 (FAQ), #leftnav and #content are stored in variables 
2. When an FAQ list item icon is clicked Prototype functions in the AccordionList object are fired. The toggle function is used to open FAQ items when no other
item is open. It is also used to close an open item when it is clicked. The BlindDown function is called by the function BlindUp to open a clicked FAQ item when 
another FAQ is open. BlindUp, BlindDown and toggle run asynchronously with .2s delays. See the AccordionList object for details.
3. The AccordionList object uses the prototype functions BlindUp, BlindDown and toggle to open and close the FAQ list. These run asynchronously with 
a .2s delay. Therefore we take height measurements .25s after they have been invoked. This should be enough time for them to complete modifying the DOM and allow
more height measurments to be taken and the delta height to be calcuated.
4. When the change (delta) in the height of the FAQ list is known, we add it to the height of the content div and the left nav.
*/

// When the Details/Manuals tab is clicked we want to record the unexpanded heights of #al_list2 (FAQ), #leftnav and #content
          if (aTabName == 'details_manuals') 
          {
            if ((ProductTabs.faqListHeight0 == 0) && (ProductTabs.faqListHeight1 == 0))  
            { // if the base list height has not been set, set it to the unexpanded height and set the base #content height
              ProductTabs.getBaseHeights();
            }
          }
	},

        // getBaseHeights() finds the unexpanded height of #al_list2 (FAQ), #leftnav and #content containers
	getBaseHeights:function() 
	{
          ProductTabs.leftNavDivHeight0 = jQuery("#leftnav").innerHeight(); // get #leftnav div height
          ProductTabs.contentDivHeight0 = jQuery("#content").innerHeight(); // get #content div height
          ProductTabs.faqListHeight0 = jQuery("#al_list2").innerHeight();   // get prodct page FAQ list height
	},
        // getFAQHeight() - After expanding/collapsing the FAQ list, calculate the delta from the original height
        // Check for the existence of product page details/manuals tab div id (#details_manuals_content) and
        // the existence of the FAQ accordian list id (#al_list2) - if they both exist call setContentHeight()
        // to adjust #leftnav and #content container heights
	getFAQHeight:function()
	{
          ProductTabs.faqListHeight1 = jQuery("#al_list2").innerHeight();
          ProductTabs.faqListDeltaHeight = ProductTabs.faqListHeight1 - ProductTabs.faqListHeight0;
          if ((jQuery("#al_list2").innerHeight() > 0) && (jQuery("#details_manuals_content").innerHeight() > 0) )
          {
             ProductTabs.setContentHeight();          
          }
	},
        setContentHeight:function()
        {
          ProductTabs.contentDivHeight1 = ProductTabs.contentDivHeight0 + ProductTabs.faqListDeltaHeight;
          jQuery("#content").css('height', ProductTabs.contentDivHeight1);   // set #content div height
          ProductTabs.leftNavDivHeight1 = ProductTabs.leftNavDivHeight0 + ProductTabs.faqListDeltaHeight;
          jQuery("#leftnav").css('height', ProductTabs.leftNavDivHeight1);   // set #leftnav div height
        } // End of height adjustment code DAC        
}

//ProductTabs.getDefaultTab();

/*--------------------------------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Showcase Rollover
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 7/1/2008
** description: Displays showcase text on rollover, hides text on rollout
***/

ShowcaseRollover = {

	showcaseRolloverOffsetX:0,
	showcaseRolloverOffsetY:0,
	showcaseCompensateRollovers:false,
	showcaseCompensateOffsetX:0,

	onRollover: function(t)

	{
		$('rollover_content').childElements().each(function(el){
			if (el.hasClassName(t.className.substr(t.className.lastIndexOf(" ")+1)))
			{
				if (ShowcaseRollover.showcaseCompensateRollovers == true)
				{
					//alert(getElementPosition(t).left+","+getElementPosition(t).top);
					switch (t.className.substr(t.className.lastIndexOf(" ")))
					{
						case " s360":
						{
							el.childElements()[0].className = "img_head_s360";
							ShowcaseRollover.showcaseCompensateOffsetX = -10;
							break;
						}
						case " sPhotos":
						{
							el.childElements()[0].className = "img_head_sPhotos";
							ShowcaseRollover.showcaseCompensateOffsetX = -65;
							break;
						}
						case " sVideos":
						{
							el.childElements()[0].className = "img_head_sVideos";
							ShowcaseRollover.showcaseCompensateOffsetX = -129;
							break;
						}
					}
				}
				var pos = getElementPosition(t);
				el.style.top = (pos.top + 20 + ShowcaseRollover.showcaseRolloverOffsetY) + "px";
				el.style.left = (pos.left - 7 + ShowcaseRollover.showcaseRolloverOffsetX + ShowcaseRollover.showcaseCompensateOffsetX) + "px";
				el.style.visibility = 'visible';
			}
		});
		//alert(getElementPosition(t).top + " " + getElementPosition(t).left);
		//alert(t.className.substr(t.className.lastIndexOf(" ")));
	},
	onRollout: function(t)
	{
	$('rollover_content').childElements().each(function(el){
			el.style.visibility = 'hidden';
		});
	}

}


/*--------------------------------------------------------------------------------------------------------*/

/***
** title: getSelectedTabName
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0, tabLoaded Array
** last updated: 11/10/2008
** description: Return the name of the selected tab as a string. Used for tracking
***/


function getSelectedTabName()
{
	for(var item in tabLoaded)
	{
		if(tabLoaded[item] == true) {
			var sImageID = $(item).id.replace('content','img');
			var chkImage = $(sImageID);
			if(chkImage.src.indexOf('_over.')>0)
			{
				return sImageID.replace("_img","");
			}
		}
	}
}

/*--------------------------------------------------------------------------------------------------------*/


/***
** title: initCapUnderscoreToSpace
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0, tabLoaded Array
** last updated: 11/11/2008
** description: takes a string as an argument and returns the string with initial caps and underscores replaced with spaces.
** used in the SC tracking request sent on open of the media showcase app.
***/

function initCapUnderscoreToSpace(newStr)
{
	newStr = String(newStr);
	var myArraySplit = newStr.split("_");
	newStr = "";
	for (i = 0; i<myArraySplit.length; i++)
	{	 
		// init cap only if lowercase alphabet char
		if ( myArraySplit[i].charCodeAt(0) > 96 && myArraySplit[i].charCodeAt(0) < 123 )
		{
			newStr += (String.fromCharCode(myArraySplit[i].charCodeAt(0)-32)+myArraySplit[i].slice(1))+" ";
		} 
		else
		{
			newStr += myArraySplit[i]+" ";
		}
	}
	return newStr.slice(0,newStr.length-1);
}


/*--------------------------------------------------------------------------------------------------------*/

/***
** title: MediaShowcase
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 9/11/2008
** description: Open Lightwindow with media showcase
***/

/* add required support files */

	document.write('<script src="http://francais.bose.ca/enfr/js/swfobject.js" language="javascript"></script>');	


MediaShowcase = {

	windowWidth: "",
	windowHeight: "",
	contentWidth: 927,
	contentHeight: 609,
	margin: 10,
    lang: "",
	defaultLang: "en-us",
    	// Set default value of Live Person variable FlashDemoActive status to false. 
    	// Value of FlashDemo Active is reset in the open()/close() functions.	
        lpFlashDemoActive:false,
	init: function()
	{
		// Detect language Cookie
		MediaShowcase.lang = getCookie("langsel")

		// Map to 4 char lang code. Default to en-us if undefined. 
		switch(MediaShowcase.lang)
		{
			case "FR":
			MediaShowcase.lang = "fr-ca";
			break;
			case "FR-CA":
			MediaShowcase.lang = "fr-ca";
			break;
			case "fr-ca":
			MediaShowcase.lang = "fr-ca";
			break;
			case "EN":
			MediaShowcase.lang = "en-us";
			break;
			case "EN-US":
			MediaShowcase.lang = "en-us";
			break;
			case "en-us":
			MediaShowcase.lang = "en-us";
			break;
			default: 
			MediaShowcase.lang = MediaShowcase.defaultLang;
			break;
		}

		// Show the showcase buttons /
		$$('img.showcase').each(function(s) {   s.style.visibility = 'visible' }); 
	},

	open: function(t,e)
	{
		/* Added try to handle errors if content has not loaded */
		try{
		if($('mediaShowCase'))
			{
			var path = "";
			var msType = "";
			if (t.hasClassName('s360'))
			{
					path = media360_url;
					msType = "360";

			} else if (t.hasClassName('sPhotos'))
			{

					path = photos_url;
					msType = "Photos";

			}else if (t.hasClassName('sVideos'))
			{
					path = video_url;
					msType = "Videos";
			}

			
			if (ProductController.byPassNavExtend == false)
			{
				if (ProductLabel)
				{
					// Send a SiteCatalyst image request with the new page view
					s.pageName = "MS:"+initCapUnderscoreToSpace(ProductLabel)+":"+msType+":"+initCapUnderscoreToSpace(getSelectedTabName())+":Index";
					s.doPlugins=s_doPlugins;
					var s_code=s.t();
				}
			}


		
			// Kill the event listners to improve performance.
			ProductController.disable();
			GlobalController.disable();

			// get the window dimensions
			MediaShowcase.windowWidth = getWindowDimensions().w;
			MediaShowcase.windowHeight = getWindowDimensions().h
			
			// get the body element
			var msBody = $(document.body);


			// Calculate Page Height
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = document.body.scrollWidth;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ 
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { 
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}

			var oHeight = msBody.clientHeight;

			var oHeight = yScroll;
			var oWidth = xScroll;

			if (xScroll < screen.availWidth)
			{
				oWidth = screen.availWidth;
			}
			if (yScroll < msBody.clientHeight)
			{
				oHeight = msBody.clientHeight
			}

			// Position the window
			
			var msTop = MediaShowcase.margin;
			var msLeft = MediaShowcase.margin; 
			if (MediaShowcase.windowWidth > (MediaShowcase.contentWidth+(MediaShowcase.margin*2)))
			{
				msLeft = (MediaShowcase.windowWidth - MediaShowcase.contentWidth)*0.5;
			}

			if (MediaShowcase.windowHeight > (MediaShowcase.contentHeight+(MediaShowcase.margin*2)))
			{
				msTop = (MediaShowcase.windowHeight - MediaShowcase.contentHeight)*0.5;
			}

			// hide all the selects so they don't overlap the overlay
			var selects = document.getElementsByTagName('select');

			for(var i = 0; i < selects.length; i++) {
				selects[i].style.visibility = 'hidden';
			}

			// get the new elements
			var msOverlay = $('msOpacityOverlay');
			var msShowcase = $('mediaShowCase');

			// Show the overlay
			msOverlay.style.width = oWidth+'px';
			msOverlay.style.height = oHeight+'px';
			msOverlay.style.visibility = 'visible';
			
			// Show the flash content
			msShowcase.style.top = msTop+'px';
			msShowcase.style.left = msLeft+'px';
			msShowcase.style.visibility = 'visible';

			// Load the Flash 
			var flashContent = {};    

			// substring(1) to remove the '?'   
			var pairs = path.substring(1).split("&");   
			var splitPair;   
		  
			// Load the key/values of the return collection   
			for (var i = 0; i < pairs.length; i++) {   
				splitPair = pairs[i].split("=");   
				flashContent[splitPair[0]] = splitPair[1];   
			}
			// Swap the default language extension with the detected cookie language

			flashContent["source"] = flashContent["source"].replace(MediaShowcase.defaultLang,MediaShowcase.lang);
			// Used to test app on Mozilla browsers in the teamsite environment. Leave blank at all other times.
			var hostLocation = ""; //"http://"+window.location.host+window.location.pathname+"?url=";
		
			var checkFlashPlayer = new deconcept.SWFObjectUtil.getPlayerVersion();
			var requiredFlashPlayer = new deconcept.PlayerVersion([9,0,103]); // Enter required version of flash here. Use array format [major,minor,revision].
			if (checkFlashPlayer.versionIsValid(requiredFlashPlayer)){
			
					var so = new SWFObject("http://www.bose.ca/assets/flash/media_showcase/mediaShowcase.swf", "mainflash", MediaShowcase.contentWidth, MediaShowcase.contentHeight, "9,0,124");
					so.addParam("quality", "high");
					so.addParam("align", "middle");
					so.addParam("salign", "");
					so.addParam("loop", "false");
					so.addParam("scale", "showall");
					so.addParam("devicefont", "false");
					so.addParam("menu", "true");
					so.addParam("allowFullScreen", "false");
					so.addParam("allowScriptAccess","always");
					so.addParam("FlashVars", "initView="+flashContent["action"]+"&appXML=./assets/flash/media_showcase/data/media_showcase_app_"+MediaShowcase.lang+".xml&productXML=."+flashContent["source"]+"&hostLoc="+hostLocation+"&trackingSuite="+s.fun+"&trackingHost=metrics.bose.com");
					so.write("mediaShowCase");
				}
				else
				{
					var altHTML = '<div id="altContent" style="position:relative;text-align:center"><p>You need the latest Flash Player to view this content. <a href="http://www.adobe.com/go/getflash/" target="_blank">Install Adobe Flash Player</a>.</p><p><a style="text-decoration:none;" href="javascript:MediaShowcase.close()">Close &raquo;</a></p></div>';

					var cAlt = $("mediaShowCase");

					cAlt.style.background = "#000000";
				
					cAlt.innerHTML = altHTML;

					var altContent = cAlt.down(0);

					altContent.style.top = '300px';

				}
				
                        // Send FlashDemoActive status to Live Person using sendData() function in echat.js 
                        // FlashDemoActive is set to true here.	DAC 6/24/2009
                        MediaShowcase.lpFlashDemoActive = true;
                        if (typeof(eChatSendData.sendData) === 'function') // Make sure that eChat.js is loaded
                        {
                          eChatSendData.sendData('session','FlashDemoActive',MediaShowcase.lpFlashDemoActive);              
                        }				

			// Add listener to close the Media showcase if the user clicks outside the showcase area

			$('msInnerWrap').onclick = function(e)
			{
				MediaShowcase.close();
			}

			// Hide any rollover

			$('rollover_content').childElements().each(function(el){
				el.style.visibility = 'hidden';
			});
			} // end conditional
	} catch(e){
	
		//alert(e.message);
	};

	},
	close: function()
	{
		// remove the elements
		var msOverlay = $('msOpacityOverlay').style.visibility = 'hidden';
		var msShowcase = $('mediaShowCase');
		msShowcase.style.visibility = 'hidden';
		msShowcase.innerHTML = "";

		// show all the selects that were hidden
		var selects = document.getElementsByTagName('select');
		for(var i = 0; i < selects.length; i++) {
			selects[i].style.visibility = 'visible';
		}

		/* Enable the page listeners */
		ProductController.init();
		GlobalController.init();
		//myLightWindow.deactivate();

                // Send FlashDemoActive status to Live Person using sendData() function in echat.js 
                // FlashDemoActive is set to false here. DAC 6/24/2009
                MediaShowcase.lpFlashDemoActive = false;          
                if (typeof(eChatSendData.sendData) === 'function') // Make sure that eChat.js is loaded
                {
                  eChatSendData.sendData('session','FlashDemoActive',MediaShowcase.lpFlashDemoActive);              
                }		
	}

}

/* Call function rather then method to fix Flex External Interface Error when calling a js object method */

function closeMediaShowcase()
{
	var t=setTimeout('MediaShowcase.close()',250);
}

/* Return Tracking Suite Data to the showcase*/

function getTrackingSuite()
{
	return s.fun;
}

function getTrackingServer()
{
	return s.trackingServer;
}


/*--------------------------------------------------------------------------------------------------------*/


/***
** title: Product Color Change
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 9/17/2008
** description: Change the product color when the user rolls over a color chip.
***/


var ProductColorChange =
{

	// Vars
	colorChips:"",
	productHero:"",
	productColors: new Array(),
	targetColor:"",

	productHeroImgEnd:"_lg.jpg",

	// Methods
	init: function()
	{
		try {
			if(document.getElementById('multiple_product_color_chips')) {
				var mainContainer = document.getElementById('multiple_product_color_chips');
				var colorChipContainers = mainContainer.getElementsByTagName('ul');
				var containerArray = new Array();
				for (cc=0;cc<colorChipContainers.length;cc++) {
					containerArray.push(ProductLabel + "_colors" == colorChipContainers[cc].getAttribute("id"));
				}
				for (ca=0;ca<containerArray.length;ca++) {
					if(containerArray[ca] == false) {
						colorChipContainers[ca].className = 'colors hidden_color_chip_container';
						} else {
						colorChipContainers[ca].className = 'colors';
						ProductColorChange.colorChips = colorChipContainers[ca].getElementsByTagName('li');
						}
				}
				//ProductColorChange.changeColor(t);
				// Select UL based on multiProductToggleArrayNum
				// Then select color chip based on interaction or radio btn
				// Then set ATP msg in id='color' element
			} else {
				ProductColorChange.colorChips = $('colors').childElements();
			}

			/* if ProductLabel matches UL id then set color chips */
    		ProductColorChange.productHero = $('product_hero');
			var ipath;
			if(document.getElementById('multiple_product_color_chips')) {
				if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
					ipath = ProductColorChange.colorChips.item(0).childNodes(0).id;
				} else {
					ipath = ProductColorChange.colorChips.item(0).childNodes[1].id;
				}
				ProductColorChange.targetColor = ipath.slice(ipath.lastIndexOf('_'));
			} else {
				ipath = ProductColorChange.colorChips[0].down(0).src;
				ProductColorChange.targetColor = ipath.slice(ipath.lastIndexOf('_'),ipath.lastIndexOf('.'));
			}
    		

    		//Pre Load the different product colors
    		if(document.getElementById('multiple_product_color_chips')) {
				for(i=0;i<ProductColorChange.colorChips.length;i++) {
					ProductColorChange.productColors[i] = new Image();
					var path;
					if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
						path = ProductColorChange.colorChips.item(i).childNodes(0).id;
						} else {
						path = ProductColorChange.colorChips.item(i).childNodes[1].id;
					}
					var color = path.slice(path.lastIndexOf('_'));
					ProductColorChange.productColors[i].src = 'http://francais.bose.ca/enfr/assets/images/shop_online/' + ProductLabel + '/' + ProductLabel + color + ProductColorChange.productHeroImgEnd;
				}
				} else {
					for(i=0;i<ProductColorChange.colorChips.length-1;i++) {
						ProductColorChange.productColors[i] = new Image();
						var path = ProductColorChange.colorChips[i].down(0).src;
						var color = path.slice(path.lastIndexOf('_'),path.lastIndexOf('.'));
						ProductColorChange.productColors[i].src = 'http://francais.bose.ca/enfr/assets/images/shop_online/' + ProductLabel + '/' + ProductLabel + color + ProductColorChange.productHeroImgEnd;
					}
				}

			// First, set all colorchips on the page to their default state
			if(document.getElementById('multiple_product_color_chips')) {
				for(i=0;i<ProductColorChange.colorChips.length;i++) {
					var cImg;
					if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
						cImg = ProductColorChange.colorChips.item(i).childNodes(0);
						ProductColorChange.colorChips.item(i).childNodes(1).className = "multi_product_color_description_hidden";
						} else {
						cImg = ProductColorChange.colorChips.item(i).childNodes[1];
						ProductColorChange.colorChips.item(i).childNodes[2].className = "multi_product_color_description_hidden";
					}
					cImg.src = cImg.src.sub('_over.','.');
				}
			}			

			// Then set the first chip as selected
			if(document.getElementById('multiple_product_color_chips')) {
				var cImg;
				if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
					cImg = ProductColorChange.colorChips.item(0).childNodes(0);
					ProductColorChange.colorChips.item(0).childNodes(1).className = "multi_product_color_description";
					} else {
					cImg = ProductColorChange.colorChips.item(0).childNodes[1];
					ProductColorChange.colorChips.item(0).childNodes[2].className = "multi_product_color_description";
				}
				sExt = getFileExt(cImg);
				if(cImg.src.indexOf('_over') == -1) {
					cImg.src = cImg.src.sub('.' + sExt,'_over.' + sExt);
				}
			} else {
				var cImg = ProductColorChange.colorChips[0].down(0);
				sExt = getFileExt(cImg);
				cImg.src = cImg.src.sub('.' + sExt,'_over.' + sExt);
			}
        } catch(e){/*handles error when there is no color change on a product*/}
	},

	changeColor: function(t)
	{
		var colorChipContainer;
		if(document.getElementById('multiple_product_color_chips')) {
			for(i=0;i<document.getElementsByClassName('colors').length;i++) {
				if(t.parentNode.parentNode == document.getElementsByClassName('colors')[i]) {
				 colorChipContainer = i;
				 }
			}
		}
		
		
		// First, set all colorchips on the page to their default state
		if(document.getElementById('multiple_product_color_chips')) {
			for(i=0;i<ProductColorChange.colorChips.length;i++) {
				var cImg;
				if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
					cImg = ProductColorChange.colorChips.item(i).childNodes(0);
					ProductColorChange.colorChips.item(i).childNodes(1).className = "multi_product_color_description_hidden";
					} else {
					cImg = ProductColorChange.colorChips.item(i).childNodes[1];
					ProductColorChange.colorChips.item(i).childNodes[2].className = "multi_product_color_description_hidden";
					}
				cImg.src = cImg.src.sub('_over.','.');
			}
		} else {
			for(i=0;i<ProductColorChange.colorChips.length-1;i++) {
				var cImg = ProductColorChange.colorChips[i].down(0);
				cImg.src = cImg.src.sub('_over.','.');
			}
		}

		// Now, flip the colorchip that is currently being moused over to its selected state
		sExt = getFileExt(t);
		if(document.getElementById('multiple_product_color_chips')) {
				for(i=0;i<ProductColorChange.colorChips.length;i++) {
						if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
								if(t == ProductColorChange.colorChips.item(i).childNodes(0)) {
									ProductColorChange.colorChips.item(i).childNodes(1).className = "multi_product_color_description";
									multiProductToggle(colorChipContainer,i);
								}
							} else {
								if(t == ProductColorChange.colorChips.item(i).childNodes[1]) {
									ProductColorChange.colorChips.item(i).childNodes[2].className = "multi_product_color_description";
									multiProductToggle(colorChipContainer,i);
								}
						}
				}
				if(t.src.indexOf('_over') == -1) {
					t.src = t.src.sub('.' + sExt,'_over.' + sExt);
				}
			} else {
				t.src = t.src.sub('.' + sExt,'_over.' + sExt);
			}
		

		// Swap in the new hero image
		var path = t.src.sub(t.src.slice(t.src.lastIndexOf('_'),t.src.lastIndexOf('.')),'');
		var color = path.slice(path.lastIndexOf('_'),path.lastIndexOf('.'));
		ProductColorChange.productHero.src = 'http://francais.bose.ca/enfr/assets/images/shop_online/' + ProductLabel + '/' + ProductLabel + color + ProductColorChange.productHeroImgEnd;
		ProductColorChange.targetColor = color;	
		
		// Keep the color change in syc with the dropdown
			var dropdownColor = $('color');
			for (i=0;i<dropdownColor.options.length;i++){
				if('_'+dropdownColor.options[i].value==color){
					dropdownColor.options.selectedIndex=i;
					if(document.getElementById('multiple_product_color_chips')) {
					 if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 8) {
						var colorvariant = document.getElementById('colorvariant');
						colorvariant.value = color.replace('_','');
						}
					} else {
						dropdownColor.onchange();
					}
				}
			}
			
	},

	resetRollover: function(t)
	{

		// First, set all colorchips on the page to their default state
		if(document.getElementById('multiple_product_color_chips')) {
			for(i=0;i<ProductColorChange.colorChips.length;i++) {
				var cImg;
					if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
						cImg = ProductColorChange.colorChips.item(i).childNodes(0);
						ProductColorChange.colorChips.item(i).childNodes(1).className = "multi_product_color_description_hidden";
						} else {
						cImg = ProductColorChange.colorChips.item(i).childNodes[1];
						ProductColorChange.colorChips.item(i).childNodes[2].className = "multi_product_color_description_hidden";
					}
				cImg.src = cImg.src.sub('_over.','.');
			}
		} else {
				for(i=0;i<ProductColorChange.colorChips.length-1;i++) {
					var cImg = ProductColorChange.colorChips[i].down(0);
					cImg.src = cImg.src.sub('_over.','.');
				}
			}

		// get the selected color
		var dropdownColor = $('color').value;

		// reset the color chip to the selected color
		if(document.getElementById('multiple_product_color_chips')) {
			for(i=0;i<ProductColorChange.colorChips.length;i++) {
				var cImg;
					if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
						cImg = ProductColorChange.colorChips.item(i).childNodes(0);
						ProductColorChange.colorChips.item(i).childNodes(1).className = "multi_product_color_description";
						} else {
						cImg = ProductColorChange.colorChips.item(i).childNodes[1];
						ProductColorChange.colorChips.item(i).childNodes[2].className = "multi_product_color_description";
					}
					if (cImg.src.search("_"+dropdownColor+".")!= -1)
					{
						sExt = getFileExt(cImg);
						cImg.src = cImg.src.sub('.' + sExt,'_over.' + sExt);
					}				
				} 
			} else {
				for(i=0;i<ProductColorChange.colorChips.length-1;i++) {
					var cImg = ProductColorChange.colorChips[i].down(0);
					if (cImg.src.search("_"+dropdownColor+".")!= -1)
					{
						sExt = getFileExt(cImg);
						cImg.src = cImg.src.sub('.' + sExt,'_over.' + sExt);
					}
				}
			}
	}

}

/*--------------------------------------------------------------------------------------------------------*/


/***
** title: Product Hero Image and Add to Cart color dropdown synch
** author: Dan DeRose
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 9/17/2008
** description: Changes the color on the Product Hero image to match whatever is selected in the Add to Cart color dropdown
***/

addToCartForm = {

	changeHeroColor: function(t)

	{
		var dropdownColor = $('color');
		//alert(dropdownColor.value);
		$('product_hero').src = $('product_hero').src.substr(0, $('product_hero').src.length-9) + dropdownColor.value + ProductColorChange.productHeroImgEnd;

		// First, set all colorchips on the page to their default state
		if(document.getElementById('multiple_product_color_chips')) {
			for(i=0;i<ProductColorChange.colorChips.length;i++) {
				var cImg;
					if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
						cImg = ProductColorChange.colorChips.item(i).childNodes(0);
						ProductColorChange.colorChips.item(i).childNodes(1).className = "multi_product_color_description_hidden";
						} else {
						cImg = ProductColorChange.colorChips.item(i).childNodes[1];
						ProductColorChange.colorChips.item(i).childNodes[2].className = "multi_product_color_description_hidden";
					}
					cImg.src = cImg.src.sub('_over.','.');
				} 
		} else {
				for(i=0;i<ProductColorChange.colorChips.length-1;i++) {
					var cImg = ProductColorChange.colorChips[i].down(0);
					cImg.src = cImg.src.sub('_over.','.');
				}
			}

		// get the selected color
		var dropdownColor = $('color').value;

		// reset the color chip to the selected color
			if(document.getElementById('multiple_product_color_chips')) {
				for(i=0;i<ProductColorChange.colorChips.length;i++) {
				var cImg;
					if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) < 9) {
						cImg = ProductColorChange.colorChips.item(i).childNodes(0);
						ProductColorChange.colorChips.item(i).childNodes(1).className = "multi_product_color_description";
						} else {
						cImg = ProductColorChange.colorChips.item(i).childNodes[1];
						ProductColorChange.colorChips.item(i).childNodes[2].className = "multi_product_color_description";
					}
					if (cImg.src.search("_"+dropdownColor+".")!= -1)
					{
						sExt = getFileExt(cImg);
						cImg.src = cImg.src.sub('.' + sExt,'_over.' + sExt);
					}	
				}
			} else {
				for(i=0;i<ProductColorChange.colorChips.length-1;i++) {
					var cImg = ProductColorChange.colorChips[i].down(0);
					if (cImg.src.search("_"+dropdownColor+".")!= -1)
					{
						sExt = getFileExt(cImg);
						cImg.src = cImg.src.sub('.' + sExt,'_over.' + sExt);
					}
				}
			}
	}
}

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: View More Script
** author: Dan DeRose
** company: Bose Corporation
** requires: scriptaculous 1.7.0, Prototype 1.5.0
** last updated: 5/26/2008
** description: Cycles through all images with a class of view_more and shows/hides the content in a div places directly under the image in the html
***/


function showFeatures(t) {
    var name = t.up(1).previousSiblings()
    
    if(t.src.include('button_view_more.gif') == true) {
        t.src = 'http://francais.bose.ca/img/bose/button_view_less.gif';
		t.alt = 'Minimiser';
        name[0].style.display = 'block';
		if (ProductController.byPassNavExtend == false) navExtend(t.up(2).id);
		
		// Fire SiteCatalyst event
		var tempPageName = s.pageName;
		s.prop13 = tempPageName;
		var aString = tempPageName.split(':');
		var iLength = aString.length;
		s.tl(this,'o','view more:' + aString[iLength-2]);
    }
    else {
        t.src = 'http://francais.bose.ca/img/bose/button_view_more.gif';
		t.alt = 'Voir plus';
        name[0].style.display = 'none';
		
		if (ProductController.byPassNavExtend == false) navExtend(t.up(2).id);
		
		// Fire SiteCatalyst event
		var tempPageName = s.pageName;
		s.prop14 = tempPageName;
		var aString = tempPageName.split(':');
		var iLength = aString.length;
		s.tl(this,'o','minimize:' + aString[iLength-2]);
    }
}

/*--------------------------------------------------------------------------------------------------------*/

/*
title: BeKK Accordion List
author: Isaac Chellin, modified for PEP by Dan DeRose
company: Bose Corporation
requires: scriptaculous 1.7.0, 1.5.0
last updated: 8/29/2007
*/

var AccordionList = {
	
	//vars
	
	toOpen: "",
	toClose: "",
	i: 1,
        FAQHeightTimer:"", /* Used for SetTimeout() calls for page height adjustments DAC 5/24/2011 */
	// methods

	init: function() {
	
		document.getElementsByClassName('accordion_list').each(function(al) { 
			al.id = 'al_list'+AccordionList.i; // assign a unique id to each element
			AccordionList.i++;
			document.getElementsByClassName('al_body',al).each(function(ab){ ab.hide(); });
			al.setStyle({ visibility: 'visible' }); 
		});
	},

	toggleList: function(target) {
          var ah = target.up();
          var ap = ah.up(0);
          var ab = ah.next();
          var pb = AccordionList.toClose;
          AccordionList.toOpen = ab;
            
			if (pb && (ab != pb)) {
                                ah.down().addClassName('open');
                                pb.previous().down().removeClassName('open');
                                pb.previous().down().next().show();
                                ap.style.background = '#ffffff';
                                pb.up().style.background = '#f8f8f8';
                                
				if (pb.visible()) {
                                  AccordionList.toggleImage(pb.previous());
				}
                                /* Close the open FAQ then open the FAQ that was clicked */				
				Effect.BlindUp(pb, {duration:0.2, afterFinish: AccordionList.onBlindFinish } );
			}
			else 
			{
				if (ah.down().hasClassName('open')) {
                                  ah.down().removeClassName('open');
                                  ah.down().next().show();
                                  pb.up().style.background = '#f8f8f8';
                                }
				else {
                                  ah.down().addClassName('open');
                                  ap.style.background = '#ffffff';
				}
				Effect.toggle(ab,'blind',{duration:0.2});
                                /* 
                                toggle is used on the first click to open an element or to close an open element if it is clicked. 
                                toggle is running asynchrounously so we need a timed delay before we can take a height measurment. DAC 5/3/2011 
                                */
                                FAQHeightTimer = setTimeout("ProductTabs.getFAQHeight()",250); // Take an FAQ height measurement
                                			
			}
			AccordionList.toClose = ab;
			AccordionList.toggleImage(ah);
	},
	
	toggleImage: function(ah){
		if(ah.down().src.include('plus') == true) {
                  ah.down().src = 'http://www.bose.ca/assets/images/global/icon_faq_minus.gif';
                }
		else {
			ah.down().src = 'http://www.bose.ca/assets/images/global/icon_faq_plus.gif';
			// Fire SiteCatalyst event - Only when a FAQ is selected; not when one is closed
			/*var tempPageName = s.pageName;
			s.prop15 = tempPageName;
			s.tl(this,'o','view more');
			s.pageName = tempPageName;*/
		}
	},
	
	onBlindFinish: function(obj) 
	{
          Effect.BlindDown(AccordionList.toOpen,{duration:0.2});  /* Open the FAQ that was clicked */
          /* BlindDown is running asynchrounously so we need a timed delay before we can take a height measurment. DAC 5/3/2011 */
          FAQHeightTimer = setTimeout("ProductTabs.getFAQHeight()",250);
	}

}

/***
** title: Accessory Rollover
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 09/23/08
** description: Add details rollover for all divs with the class product_accessory
***/

AccessoryRollover = {
		showBox: function(t)
		{
			var sAccessoryDiv = t.up(1).previous(1);

			// Get all divs with the accessory_rollover class and put them in an array
			var aAccessoryBoxes = $$('div.accessory_rollover'); 
			
			// Now, loop through all accessory moduels and make sure the details content is hidden and the containers (product_accessory) all have position:relative
			for(i=0;i<aAccessoryBoxes.length;i++) {
				aAccessoryBoxes[i].hide();
				aAccessoryBoxes[i].up().style.position = 'relative';
			}
			
			try {
				t.up(2).next().style.position = 'static'; // Sets the next product_accessory div to static to avoid IE bug with z-index
				t.up(2).next(3).style.position = 'static'; // If this is the last accssory in a section, this will target the next product_accessory div, skipping over a couple other for the section divider
				} catch(e) {}
				sAccessoryDiv.style.visibility = 'hidden';
				sAccessoryDiv.style.display = 'block';
			
			// Ie6 hack to deal with select elements and z-index problems
			 var is_ie6 = document.all && (navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1);
			 if (is_ie6)
			{
				// Finally, open the selected accessory box and set the div underneath to static so there are no z-index issues in IE; it will be reset to relative every time another details link is clicked on
				try {
					t.up(2).next().style.position = 'static'; // Sets the next product_accessory div to static to avoid IE bug with z-index
					t.up(2).next(3).style.position = 'static'; // If this is the last accssory in a section, this will target the next product_accessory div, skipping over a couple other for the section divider
				} catch(e) {}
				sAccessoryDiv.style.visibility = 'hidden';
				sAccessoryDiv.style.display = 'block';
				// Add iframe to hide the select
			    var html =
				"<iframe style=\"position: absolute; display: block; " +
				"z-index: -1; width: "+sAccessoryDiv.offsetWidth+"px; height: "+sAccessoryDiv.offsetHeight+"px; top: 0; left: 0;" +
				"filter: mask(); background-color: #FFFFFF; \"></iframe>";
				if (sAccessoryDiv) sAccessoryDiv.innerHTML += html;
				// force refresh of div
				var olddisplay = sAccessoryDiv.style.display;
				sAccessoryDiv.style.display = 'none';
				sAccessoryDiv.style.display = olddisplay;
				// show the div
			};
			sAccessoryDiv.style.visibility = 'visible';
			
			/*for(i=0;i<aAccessoryBoxes.length;i++) {
				aAccessoryBoxes[i].up().style.position = 'static';
			}
			t.up(2).style.position = 'relative';*/
			
			/* Fire SiteCatalyst event. This one is a little tricky because the requirement is not just to track the event, but to also track which accessory rollover box was revealed (by accessory name). To do this, I navigated up to the parent div containing that accessory, then navigate down to the acccessory_info div inside, which always starts with the Web Display name of the accessory. Since the structure of the html is very controlled and doesn't change, I can do this. So, I navigate down to the H4 tag containing the Web Display Name, grab the content inside the H4 tag using innerHTML and then strip any html tags that may be still inside. Lastly, I replace all non alpha-numeric characters with a space to get rid of things like trademark or registered symbols. EDIT 09/01/08 - They no longer want the Web Display Name, but I'm leaving the code in just in case they change their minds. */
			/* var tempPageName = s.pageName;
			var sWebDisplayName = t.up(2).childElements();
			sWebDisplayName = sWebDisplayName[0].down(1).innerHTML.stripTags().replace(/\W+/g," ");
			s.prop14 = tempPageName;
			s.tl(this,'o','Accessory Detail Rollover');
			s.pageName = tempPageName;*/
		},
		
		closeBox: function(t)
		{
			// Hide the div
			t.up().style.visibility = 'hidden';
		}
};

/***
** title: setAccessoryATPMessage
** author: Clark Bilawchuk
** company: Bose Corporation
** requires: 
** last updated: 09-23-08
** description: used for all add to cart modules and accessory xsl module, on product page and accessory hub
***/
function setAccessoryATPMessage(form, message, allocdiv, add_to_cart_button){

	var messageElements = message.split('|') ;

	if(message==''){
		messageElements="|||".split('|') ;
	}
	var element;
	var productName;

	for (var i=0; i < form.elements.length; i++) {
	  element = form.elements[i];
	  if (element.id=='colorvariant'){
		element.value=messageElements[2];
	   }
	   if (element.id=='product'){
		productName=element.value ;
	   }
	  
	}

	element = document.getElementById(allocdiv)
	element.innerHTML=messageElements[0];

	element = document.getElementById(add_to_cart_button);

	if(messageElements[3]!='' && messageElements[3]!='undefined' && messageElements[3]=='X'){
		element.disabled=true;
		element.src="http://francais.bose.ca/img/bose/FR_10157.gif";

	}else{
		element.disabled=false;
		element.src="http://francais.bose.ca/img/bose/FR_4829.gif";
	}
}
/***
** title: submitAccessoryForm
** author: Clark Bilawchuk
** company: Bose Corporation
** requires: 
** last updated: 09-23-08
** description: used for all add to cart modules and accessory xsl module, on product page and accessory hub
***/
function submitAccessoryForm(formObject){
	formObject.submit;
}

new PeriodicalExecuter( function(products_pe) {  
	try{
	if ($(ProductTabs.sDefaultTab)){		
		products_pe.stop();
		ProductController.init();
		ProductColorChange.init();
		AccordionList.init();
		MediaShowcase.init();
    }
	else if($('footer')) {
		products_pe.stop();
		ProductController.init();
		ProductColorChange.init();
		accessoryColorChange();
		AccordionList.init();
		navExtend(sContentArea); //sContentArea is set inline in the accessory product and accessory hub pages
	}

	}catch(e){};
}, .1);


function accessoryColorChange() {
	if(window.location.querystring['color']) {
		jQuery("#color").val(window.location.querystring['color']);
		jQuery("#colorvariant").val(window.location.querystring['color']);

		jQuery('.colorchip').each(function() {
			sExt = this.src.substr(this.src.length-3);

			if(this.src.indexOf('_over.' + sExt) !== -1) {
				this.src = this.src.replace('_over.' + sExt,'.' + sExt);
			}
		});
		
		jQuery('.colorchip').each(function() {
			sExt = this.src.substr(this.src.length-3);

			if(this.src.indexOf("_" + window.location.querystring['color']) !== -1) {
				this.src = this.src.replace('.' + sExt,'_over.' + sExt);
			}
		});
		
		jQuery('#product_hero').each(function() {
			sExt = this.src.substr(this.src.length-3);
			this.src = 'http://francais.bose.ca/enfr/assets/images/shop_online/' + ProductLabel + '/' + ProductLabel + '_' + window.location.querystring['color'].toLowerCase() + '_lg.' + sExt;
		});
	}
}


