/* Browser information */
var browser = navigator.appName;
var b_version = navigator.appVersion;

/**** A simple function to get and return the file extension on the object passed in ****/

function getFileExt(fileSrc) {
    sExt = fileSrc.src.substr(fileSrc.src.length-3);
    return sExt;
}

/**** Statement to enable image caching for ie6 browsers that have background image caching disabled -- Fixes DHTML Flicker Bug ****/

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Get Event Target
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 6/6/2008
** description: Returns the target of a javascript event. 
***/

function getEventTarget(e){ 
		e = e || window.event;
		return e.target || e.srcElement;
	}



/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Get Element Position
** author: Isaac Chellin
** company: Bose Corporation
** last updated: 7/1/2008
** description: Returns an object with the top and left position of an element. 
***/



function getElementPosition(e)
{
	var pos = {
		top: getElementTop(e),
		left: getElementLeft(e)
	}
	return pos;
}

function getElementLeft(e)
{
	var left = e.offsetLeft;
	var tmp = e.offsetParent;
	while(tmp!=null)
	{
	left += tmp.offsetLeft;
	tmp = tmp.offsetParent;
	}
	return left;
}

function getElementTop(e)
{
	var top = e.offsetTop;
	var tmp = e.offsetParent;
	while(tmp!=null)
	{
	top += tmp.offsetTop;
	tmp = tmp.offsetParent;
	}
	return top;
}

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Get Window Dimensions
** author: Isaac Chellin
** company: Bose Corporation
** last updated: 9/11/2008
** description: Returns the window dimensions as an object 
***/

function getWindowDimensions()
{		
		var dim = {w:0,h:0};
		if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		dim.w = window.innerWidth;
		dim.h = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		dim.w = document.documentElement.clientWidth;
		dim.h = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		dim.w = document.body.clientWidth;
		dim.h = document.body.clientHeight;
	  }
	  return dim;
}



/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Global 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. 
***/

GlobalController = {

		/* Constants */

		CONTAINER:"",  // Reference to the container element

		/* Methods */

		init: function(){

			/* Set Constants */

			GlobalController.CONTAINER = document.getElementById('container');

			/* Global Event Listeners */

			/* Delegate onclick events */
			GlobalController.CONTAINER.onclick = function(e)
			{
				GlobalCommands.clickEvent(e);
			},
			
			/* Delegate onmouseover events */
			GlobalController.CONTAINER.onmouseover = function(e)
			{
				GlobalCommands.mouseOverEvent(e);
			},

			/* Delegate onmouseout events */
			GlobalController.CONTAINER.onmouseout = function(e)
			{
				GlobalCommands.mouseOutEvent(e);
			}
		},
		
		/* Lets you disable the controller to improve performance. Used by Media Showcase. */
		disable: function()
		{
			GlobalController.CONTAINER.onclick = null;
			GlobalController.CONTAINER.onmouseover = null;
			GlobalController.CONTAINER.onmouseout = null;
		}

}

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: GlobalCommands
** 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.
***/

GlobalCommands = {

		/* Execute onclick commands */
		clickEvent: function(e)
		{
			var t = getEventTarget(e);
			Element.extend(t); // Add prototype methods
			
			/* Execute popup */
			// Check if target has a class of popup or is an image with a parent with the a class of popup.
			if (t.hasClassName("popup") || ( t.tagName.match(/(IMG|STRONG|EM|B|I)/) && t.up().hasClassName("popup")))
			{
				if (t.tagName.match(/(IMG|STRONG|EM|B|I)/))
				{
					t = t.up();
				}
				popupWindow(t,e);
			}
			
			if (t.hasClassName("popup_compare"))
			{
				popupCompareWindow(t,e);
			}
			
			
			
			/* Execute email to a friend script */
			if (t.up().hasClassName("email"))
			{
				emailFriend(t,e);
			}
		},

		/* Exectute onmouseover commands */
		mouseOverEvent: function(e)
		{
			var t = getEventTarget(e);
			Element.extend(t);
			/* Execute the roll over image swap */
			if (t.hasClassName("rollover"))
			{
				RollOverImageSwap.rollover(t);
			}
		},

		/* Exectute onmouseout commands */
		mouseOutEvent: function(e)
		{
			var t = getEventTarget(e);
			Element.extend(t);
			/* Execute the roll over image swap */
			if (t.hasClassName("rollover"))
			{
				RollOverImageSwap.rollout(t);
			}
		}

}

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Left Navigation Extension Script
** author: Dan DeRose
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 5/6/2008
** description: Updates the left nav to extend to the same height as the content column
***/
function navExtend(productHeight) {
    // Get the height of both the left nav div and the content div. Also check optional productHeight parameter to see if this is a product page, since the tabs cause an issue for the script and an exception needed to be coded. To do this, the navExtend() function is called whenever a product tab is clicked on since all the content is displayed in separate divs on the product pages but, depending on which tab is selected, the amount shown will be of different heights. See products.js for the rest.
    
    // Get the height of all the tabs and set a variable to hold the height of the tab that was last clicked on
	try {
        var iTabHeight = new Array();
        iTabHeight[0] = $('overview_content');
        iTabHeight[1] = $('inthebox_content');
        iTabHeight[2] = $('details_manuals_content');
        iTabHeight[3] = $('accessories_content');
        iTabHeight[4] = $('reviews_content');
		iTabHeight[5] = $('content_products');
		iTabHeight[6] = $('accessories');
		iTabHeight[7] = $('content_inner');

        for(n=0;n<8;n++) {
            try {
				if(iTabHeight[n].id == productHeight) {
                	var sTab = iTabHeight[n].getHeight();
            	}
        	} catch(e){}
		}

	    var sWrapper = $('content');

	    // If this is a product page set the height of the div containing the tabs to the height of the current tab plus a little extra padding and assign it to a variable. If it is not a product page and therefore has no tabs, just set the height of the content area and assign it to a variable
	    if(productHeight != null) {
			if(productHeight != 'content_inner') {
	        	$('content').style.height = sTab + 96 + 'px';
			}
	        var sWrapperHeight = $('content').getHeight();
	    }
	    else {
	        var sWrapperHeight = $('content').getHeight();
	    }
	    
	    // ID the left nav, set the height to 'auto' to shrink it, then get the resulting height
	    var sNav = $('leftnav');
	    sNav.style.height = 'auto';
	    var sNavHeight = $('leftnav').getHeight();
	
	    // Figure out which column is taller and set the other to match it
	    if (sWrapperHeight > sNavHeight) {
	        sNav.style.height = sWrapperHeight - 17 + 'px';
	    }
	    else {
	        sWrapper.style.height = sNavHeight + 19 + 'px';
	    }
	}
	catch(e) {
		alert(e.description);
	}
}


/*--------------------------------------------------------------------------------------------------------*/

/***
** loacation.querystring[]
** Returns an associative array with the key value pairs parsed from the url search string.
** Example:
** value = window.location.querystring["key"];
** Added by IC - 05/08
***/

location.querystring = (function() {   
    // The return is a collection of key/value pairs   
    var result = {};   
  
    // Gets the query string with a preceeding '?'   
    var querystring = location.search;   
  
    // document.location.search is empty if a query string is absent   
    if (!querystring)   
        return result;   
  
    // substring(1) to remove the '?'   
    var pairs = querystring.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("=");   
        result[splitPair[0]] = splitPair[1];   
    }   
  
    return result;   
})(); 

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Rollover Image Swap
** author: Dan DeRose
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 6/6/2008
** description: Creates a rollover behavior on any image with the class "rollover". The rollover image MUST use the naming convention of [orginal_filename]_over.[ext]
***/

RollOverImageSwap = {

	rollover: function(t)
	{
		if (!t.src.match('_over.'))
		{
			var sExt = getFileExt(t);
			t.src = t.src.sub('.' + sExt,'') + '_over.' + sExt;
		}
	},
	rollout: function(t)
	{
		if (t.src.match('_over.'))
		{
			var sExt = getFileExt(t);
			t.src = t.src.sub('_over.' + sExt,'') + '.' + sExt;
		}
	}

}

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Popup Window Script
** author: Dan DeRose
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 6/6/2008
** description: Creates a popup window that can refer back to its parent. The popup behavior is keyed off the class "popup". If this class is applied to a normal href then it will instantiate the popup behavior. The rel attribute is used to specify the width and height, in that order.
***/


function popupWindow(t,e) {

	// Kill the event and stop the href action
	e = e ||  window.event;
	e.cancelBubble = true;
	e.returnValue = false;
	try
	{
		e.preventDefault();
		e.stopPropagation();
	}
	catch (err){ }

	// Set a default height and width
	var iWidth = '600';
	var iHeight = '600';

	// Check to see if the element has the "rel" attribute. If it does, assign the values to the iWidth and iHeight variables. 
	if((t.getAttribute('rel') != null) && (t.getAttribute('rel') != '')) {
		var sPopupSettings = t.getAttribute('rel');
		var aPopupSettings = sPopupSettings.split(',');
		
		if(aPopupSettings[0] != 'undefined') {
			iWidth = aPopupSettings[0];
		}
		if(aPopupSettings[1] != 'undefined') {
			iHeight = aPopupSettings[1];
		}
	}

	// Set the features for the popup window
	var sPopupFeatures = 'menubar=no,toolbar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=' + iWidth + ',height=' + iHeight;

	// Spawn the popup
	// Detect if this is an email a friend link by reading the class
	if(t.up().hasClassName('email')) {
		emailFriend(t,e,sPopupFeatures);
	}
	// If not email to a friend, simply spawn the popup
	else {
		window.open(t,'childWindow',sPopupFeatures);
	}
}

// Spinoff to handle the compare chart popup from the left nav. The popup behavior is keyed off the class "popup_compare". 
function popupCompareWindow(t,e) {
	// Kill the event and stop the href action
	e = e ||  window.event;
	e.cancelBubble = true;
	e.returnValue = false;
	try
	{
		e.preventDefault();
		e.stopPropagation();
	}
	catch (err){ }
	
	// Set the features for the popup window
	var sPopupFeatures = 'menubar=no,toolbar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=1000,height=600';
	window.open(t,'childWindow',sPopupFeatures);
}


/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Get Mouse Coordinates
** author: Isaac Chellin
** company: Bose Corporation
** last updated: 6/6/2008
** description: Returns and object with the x and y coordinates of the mouse pointer. Requires event object.
***/

function getMouseCoordinates(e) // e is a javascript event object
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	return {x:posx,y:posy};
}


//@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
//      COOKIE UTILITY FUNCTIONS: START
//@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @

function setCookie (name,value,expires,path,domain,secure) {
    //test for params and set if provided
    document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function checkForCookie(strCookieName) {
    var objAllCookies = document.cookie;
    var checkPos = objAllCookies.indexOf(strCookieName);
    if (checkPos != -1) {
        return true;
    }
    return false;
}

function getCookieValue (offset) {
    var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1) {
            endstr = document.cookie.length;
        }
        return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    if((document.cookie == null) || (document.cookie.length == null)) {
        return null;
    }
    var i = 0;
    while (i < clen) {
        var j = i + alen;

        if (document.cookie.substring(i,j) == arg) {
        return getCookieValue(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) {
            break;
        }
    }
    return null;
}

function deleteCookieNow(strName) {
    document.cookie=strName + "=;expires=-1;path=/";
}

function isSurveyShown() {

    var blnSurveyShown = false;

    //new generic survey shown cookie name
    var surveyShownCookieName = "SurveyShown";

    //legacy survey shown cookie names
    var dtcSurveyShownCookieName = "DTCShopSurveyShown";
    var foreseeSurveyShownCookieName = "ForeseeSurveyShown_wkpxs8EF00";

    //all legacy survey shown cookies will expire by this time
    var intLegacySurveyCookieMaxExpireTime = (new Date(2008,2,1)).getTime();
    var intNow = (new Date()).getTime();

    //check for new generic survey shown cookie...

    if(getCookie(surveyShownCookieName) != null) {
        blnSurveyShown = true;
    }

    //check for legacy survey shown cookies...

    if(intNow < intLegacySurveyCookieMaxExpireTime) {

        if(getCookie(dtcSurveyShownCookieName) != null) {
            blnSurveyShown = true;
            processLegacySurveyCookie(dtcSurveyShownCookieName);
        }

        if(getCookie(foreseeSurveyShownCookieName) != null) {
            blnSurveyShown = true;
            processLegacySurveyCookie(foreseeSurveyShownCookieName);
        }
    }

    return blnSurveyShown;
}

/* Call Functions when page has loaded */

new PeriodicalExecuter( function(global_pe) {  
	if ($('footer')){
		global_pe.stop();
        GlobalController.init();
	}
}, .1);


/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Email to a Friend Script
** author: Dan DeRose
** company: Bose Corporation
** last updated: 8/22/2008
** description: Automatically builds the link and querystring for the Email a friend links
***/

function emailFriend(t,e,sPopupFeatures) {
	var sURL = window.location.href;
	var sURLPosition = sURL.indexOf('url=') + 4;
	var sEmailPath = sURL.substring(sURLPosition);
	window.open(t + '&pop_email_url=controller?url=' + sEmailPath,'childWindow',sPopupFeatures);
}

/*--------------------------------------------------------------------------------------------------------*/

//GENERIC DROP DOWN NAVIGATION
function goDropDown(strForm,strElement) {
    var objElement = eval('document.' + strForm + '.' + strElement);
    var objElementValue = objElement[objElement.selectedIndex].value;
    if (objElementValue != "") {
        window.location = objElementValue;
    }
}

/*--------------------------------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: LEGACY - Redirect to US sections
** author: unknown
** company: unknown
** last updated: 8/22/2008
** description: Sends a link to the US version with an alert with a cancel option
***/

//CONFIRM WINDOW GENERIC
//strMessage - the confirmation message to be displayed
function confirmDialogue(strMessage) {
    if (window.confirm(strMessage)) {
        return true;
    }
    return false;
}

// LIST OF JAVSCRIPT STATIC STRINGS
// This string object is also defined/instantiated in scriptlib.js
var objStrings;
objStrings = new Object();
// English version string properties
objStrings.ExitGlobalBoseMessage = "This content can be found on global.Bose.com.  Would you like to view this website in a new window?";
objStrings.ExitBoseUsMessage = "This product information is displayed on the United States Bose website. Pricing and promotions are intended for US residents only. If you live in Canada and would like to order one of these products, please call us toll free at 877-428-2673 for pricing and availability. \n \n Would you like to view the US Bose content in a new window? ";
objStrings.ExitBoseUsLMTGMessage = "This product information is displayed on the United States Bose website. Pricing and promotions are intended for US residents only. If you live in Canada and would like to order one of these products, please call us toll free at 888-592-2073 for pricing and availability. \n \n Would you like to view the US Bose content in a new window? ";
objStrings.ExitBoseUsAHXMessage = "You can learn about Aviation Headset X at Bose.com (USA). To purchase this product, please call 1-508-766-1099. Would you like to view this content in a new window?";

// French version string properties
objStrings.ExitGlobalCABoseMessage = "This content can be found on global.Bose.com.  Would you like to view this website in a new window? Bose.com is an English-language site for the United States";
objStrings.ExitBoseCAMessage = "This product information is displayed in English on the United States Bose website. Pricing and promotions are intended for US residents only. If you live in Canada and would like to order one of these products, please call us toll free at 877-428-2673 for pricing and availability. \n \n Would you like to view the US Bose content in a new window?";
objStrings.ExitBoseCALMTGMessage = "This product information is displayed in English on the United States Bose website. Pricing and promotions are intended for US residents only. If you live in Canada and would like to order one of these products, please call us toll free at 888-592-2073 for pricing and availability. \n \n Would you like to view the US Bose content in a new window?";
objStrings.ExitBoseCAAHXMessage = "You can learn about Aviation Headset X at Bose.com (USA). To purchase this product, please call 1-508-766-1099. Would you like to view this content in a new window? Bose.com is an English-language site for the United States";

var objChildWindow;
function doChildWindow(strURL, objWin, strOptions) {
    //check for open windows and close them
    if (objChildWindow && objChildWindow.closed == false) {
        objChildWindow.close();

        objChildWindow = window.open(strURL, objWin, strOptions);
        objChildWindow.focus();
    }
    else {
        objChildWindow = window.open(strURL, objWin, strOptions);
        objChildWindow.focus();
    }
}

//GLOBAL NEW WINDOW
function openNewWin(strURL, intWidth, intHeight) {
    var strOptions;
    //check for parameters and set defaults
    if ((intWidth == '') || (intHeight == '')) {
        strOptions = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=100,width=615,height=345";
    }
    else {
        intWidth += 45;
        intHeight += 45;
        strOptions = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=100,width=" + intWidth + ",height=" + intHeight;
    }
    doChildWindow(strURL, 'child_window', strOptions);
    objChildWindow.focus();
}

//GENERIC METHOD FOR SETTING/UPDATING SITE CATALYST GLOBAL VARIABLES
//@ author - MPL
//@ param strPropertyName - the string name of the global Site Catalyst variable to be set
//@ param strPropertyValue - the string representation of the value the global Site Catalyst variable is set to
//@ see /jsp/includes/tracking/tracking_values.jsp for a listing of all Site Catalyst variables
function updateSiteCatalystProperty(strPropertyName, strPropertyValue) {

    var strLocalPropName = strPropertyName;
    var strLocalPropValue = strPropertyValue;
        
    if ((strLocalPropName == null || strLocalPropName.length == 0) || (strLocalPropValue == null || strLocalPropValue.length == 0)) {
        //do nothing and leave early - property name or property value is null or empty...
        
        return;
    }
    else {
        //OK to execute...
        
        if (eval(strLocalPropName) == '') {
           //property value has not been set already, so just set it to property value passed in 
           eval(strLocalPropName + ' = "' + strLocalPropValue + '"');
        }
        else {
           //property value has been set already, so must concatenate ";" + property value passed in
           eval(strLocalPropName + ' += ";' + strLocalPropValue + '"');
        }
    }
}

//EMAIL NEWS LETTER EMAIL VALIDATE
	function checkInputEmail(theForm) {
    if ((theForm.enews.value=="") || (theForm.enews.value.indexOf("@") == -1) || (theForm.enews.value.indexOf(".") == -1)) {
        alert("Please enter a valid email address");
        return false;
    }
    return true;
}


/*--------------------------------------------------------------------------------------------------------*/

/***
** title: BoseOverlay
** author: Isaac Chellin
** company: Bose Corporation
** requires: Prototype 1.5.0
** last updated: 4/20/2010 by Josh Sherer
** -- to allow an optional class attribute to be set to #boseOverlayContent and
** -- have the iframe scrolling attribute to be set by CSS.
** description: Open lightwindow like overlay in a custom content wrapper.
** See the CSS in global.css
***/


BoseOverlay = {

	windowWidth: "",
	windowHeight: "",
	contentWidth: 0,
	contentHeight: 0,
	containerWidth: 0,
	containerHeight: 0,
	margin: 10,
    lang: "",
	defaultLang: "en-us",
	title: "",
	learnMoreLink:"",
	overlayClass:"",
	initPos: true,
	
	updateDisplay: function()
	{
		// get the elements
		var overlay = $('boseOverlay');
		var overlayContent = $('boseOverlayContent');
		var overlayOuterHead = $('boseOverlayOuterHead');
		var overlayOuter = $('boseOverlayOuter');
		var overlayInner = $('boseOverlayInner'); 
		var overlayClose = $('boseOverlayClose'); 
		var overlayLearnmore = $('boseOverlaylearnMore');
		var overlayTitle = $('boseOverlayTitle'); 

		// Set Title

		overlayTitle.innerHTML = BoseOverlay.title; 

		// get the window dimensions
		BoseOverlay.windowWidth = getWindowDimensions().w;
		BoseOverlay.windowHeight = getWindowDimensions().h
		
		// get any scroll offset
		var offset = getOffset();

		// resize and position the overlay
		overlay.style.top = offset.y+"px";
		overlay.style.left = offset.x+"px";
		overlay.style.width = BoseOverlay.windowWidth+'px';
		overlay.style.height = BoseOverlay.windowHeight+'px';
		overlay.style.visibility = 'visible';
		
		// give the overlay a class if it has been set
		if(BoseOverlay.overlayClass) {
		    /* overlay.setAttribute("className", ""+BoseOverlay.overlayClass+"");
		    overlay.setAttribute("class", ""+BoseOverlay.overlayClass+""); */
		    overlayContent.className = BoseOverlay.overlayClass;
		}

		// Center the content in the window
		var oTop = -1;
		var oLeft = -1; 
		if (BoseOverlay.windowWidth > (BoseOverlay.containerWidth+(BoseOverlay.margin*2)))
		{
			oLeft = ((BoseOverlay.windowWidth - BoseOverlay.containerWidth)*0.5) + offset.x;
		}
		else if (BoseOverlay.initPos)
		{
			oLeft = offset.x + 1;
		}

		if (BoseOverlay.windowHeight > (BoseOverlay.containerHeight+(BoseOverlay.margin*2)))
		{
			oTop = ((BoseOverlay.windowHeight - BoseOverlay.containerHeight)*0.5) + offset.y;
		}
		else if (BoseOverlay.initPos)
		{
			oTop = offset.y + 1;
		}
		
		BoseOverlay.initPos = false;

		// set the content styles
		if(oTop > 0)
		{
			overlayContent.style.top = oTop+'px';
		}
		if(oLeft > 0)
		{
			overlayContent.style.left = oLeft+'px';
		}
		overlayContent.style.width = BoseOverlay.containerWidth+'px';
		overlayContent.style.height = BoseOverlay.containerHeight+'px';
		overlayContent.style.visibility = 'visible';

		// set the outer wrapper
		overlayOuterHead.style.width = (BoseOverlay.containerWidth-30)+'px';
		overlayOuter.style.width = (BoseOverlay.containerWidth-30)+'px';

		if(BoseOverlay.learnMoreLink)
		{
			overlayOuter.style.height = (BoseOverlay.containerHeight-43)+'px';
		}
		else
		{
			overlayOuter.style.height = (BoseOverlay.containerHeight-70)+'px';
		}

		// set the inner wrapper 
		overlayInner.style.width = (BoseOverlay.contentWidth+14)+'px';
		overlayInner.style.height = (BoseOverlay.contentHeight+11)+'px';

		// Postion the close button
		overlayClose.style.left = (BoseOverlay.containerWidth-30)+"px";

		// Position the learnmore button
		if(BoseOverlay.learnMoreLink)
		{
			overlayLearnmore.style.top = (BoseOverlay.contentHeight+93)+"px";
			overlayLearnmore.style.left = (BoseOverlay.contentWidth-83)+"px";
			overlayLearnmore.style.visibility = 'visible';
			overlayLearnmore.href = BoseOverlay.learnMoreLink;
		}
		
	},
	/***
	** @param contentURL : The URL of the content to display in the overlay window
	** @param contentWidth : The width of the content to display in the overlay window
	** @param contentHeight : The height of the content to display in the overlay window
	** @param title : Optional title to display at the top of the overlay window.
	** @param learnMoreLink : Optional link to another page. If included, creates a learnmore button at the bottom of the window.
	** @param overlayClass: Optional class name for the overlay.
	***/

	open: function(contentURL,contentWidth,contentHeight,title,learnMoreLink,overlayClass)
	{
		/* Added try to handle errors if content has not loaded */
		try{
			if($('boseOverlayContent'))
			{
				// Disable all page events.
				GlobalController.disable();

				// Set Paramerters
				BoseOverlay.contentWidth = contentWidth;
				BoseOverlay.contentHeight = contentHeight;
				BoseOverlay.containerWidth = contentWidth+77;
				BoseOverlay.containerHeight = contentHeight+136;
				BoseOverlay.title = title;

				// Set the overlayClass if it exists
				if(overlayClass) {
				    BoseOverlay.overlayClass = overlayClass;
				}
				
				// Build the learnmore link
				
				// Build the learnmore link if one exists
				if(learnMoreLink)
				{
					var url = location.protocol+"//"+location.host+location.pathname+"?url="+learnMoreLink;
					BoseOverlay.learnMoreLink = url;
				}

				// get the window dimensions
				BoseOverlay.windowWidth = getWindowDimensions().w;
				BoseOverlay.windowHeight = getWindowDimensions().h;
				
				// set a resize event to updateDisplay
				window.onresize = BoseOverlay.updateDisplay;
				window.onscroll = BoseOverlay.updateDisplay;

				// 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';
				}

				// Write out the HTML for the Overlay
				var oContent = 
					'<div id="boseOverlayOuterHead"><div class="fill" ></div></div>'
					+'<div id="boseOverlayOuter">'
						+'<div id="boseOverlayTitle"></div>'
						+'<div class="clear"></div>'
						+'<div id="boseOverlayInner">'
							+'<div class="topLine"></div>'
							+'<div class="leftLine"></div>'
							+'<div class="rightLine"></div>'
							+'<div class="botLine"></div>'
							+'<div class="topLeft"></div>'
							+'<div class="topRight"></div>'
							+'<div class="botRight"></div>'
							+'<div class="botLeft"></div>'
							+'<div id="boseOverlayInnerContent"></div>'
						+'</div>'
					+'</div>'
					+'<a id="boseOverlaylearnMore" title="Learn More" alt="Learn More"></a>'
					+'<a id="boseOverlayClose" href="javascript:BoseOverlay.close();" title="Close this window" alt="Close this window"></a>';
				
				var overlayContent = $('boseOverlayContent');
				overlayContent.innerHTML = oContent;

				// Display the overlay and content
				BoseOverlay.updateDisplay();
				
				// Generate the iframe
				var wrapper = $('boseOverlayInnerContent');
				wrapper.innerHTML = "<iframe id='boseOverlayIFrame' frameborder='0' src='"+contentURL+"' width='"+contentWidth+"' height='"+contentHeight+"'></iframe>"

				// Clicking on the overlay will close the overlay.
				$('boseOverlay').onclick = function(e)
				{
					BoseOverlay.close();
				}

				// Hide any rollover that might be open.
				if($('rollover_content'))
				{
					$('rollover_content').childElements().each(function(el){
						el.style.visibility = 'hidden';
					});
				}

			} // end conditional
	} catch(e){
	
		// For Testing Purpose Only
		//alert(e.message);
	};

	},
	close: function()
	{
		
		// Remove the resize event
		window.onresize = null;
		window.onscroll = null;
		// remove the elements
		var overlay = $('boseOverlay');
		var overlayContent = $('boseOverlayContent');
		overlay.style.visibility = 'hidden';
		overlayContent.innerHTML = "";
		overlay.style.width = overlay.style.height = 0;
		overlayContent.style.width = overlayContent.style.height = 0;
		BoseOverlay.initPos = true;
		// 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 */
		GlobalController.init();
	}

}

/* Call function rather then method to fix Flex External Interface Error when calling a js object method */

function closeBoseOverlay()
{
	var t=setTimeout('BoseOverlay.close()',250);
}

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: getOffset
** author: Isaac Chellin
** company: Bose Corporation
** last updated: 8/20/2009
** description: Return the scroll Offset for the browser window as an object {x,y);
***/

function getOffset() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return {x:scrOfX, y:scrOfY};
}

/*--------------------------------------------------------------------------------------------------------*/

/***
** title: Footer Product Dropdown Selector
** author: Dan DeRose
** company: Bose Corporation
** last updated: 1/26/2010
** description: Upon changing the footer it redirects the user to the selected page
***/

function footerDropdown(t) {
	window.location.assign(t.value);
}

/*--------------------------------------------------------------------------------------------------------*/
