
function gebi(element) {
  return document.getElementById(element)
}

Browser = {
    IE:     !!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1),
    Opera:  navigator.userAgent.indexOf('Opera') > -1,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') === -1,
    MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
  },


faq = {
	prep_faqs: function(){
			if( document.getElementById && document.getElementsByTagName ){
				// apply onclick to the FAQ subheaders (dt)
				tempEl = document.getElementsByTagName("dt");
				for( var i=0; i < tempEl.length; i++ ){
					if(tempEl[i].parentNode.parentNode.parentNode.className.indexOf('faq') >= 0) {
						tempEl[i].onclick = function(){ return faq.toggle(this); };
					}
				}
				// apply onclick to the Close
				dd = document.getElementsByTagName("dd");
				for(i=0; i < dd.length; i++){
					if(dd[i].parentNode.parentNode.parentNode.className.indexOf('faq') >= 0) {
						a = traverse.down(dd[i], 'a');
						if(a.className.indexOf('close') >= 0){
							a.onclick = function(){ return faq.close_all(this.parentNode.parentNode.parentNode.getElementsByTagName("DD"), this); };
						}
					}
				}
			}
		},
		toggle: function(theTrigger){
			// store DDs
			var aryDDs = theTrigger.parentNode.getElementsByTagName("DD");
			// store the trigger's sibling
			var theSib = traverse.next(theTrigger);
			// store trigger class name
			var triggerClass = theTrigger.className;
			// close all dds
			faq.close_all(aryDDs, theTrigger);

			if (triggerClass.indexOf('open') >= 0) {
				theTrigger.className = "";
			} else {
				theSib.style.display = "block";
				theTrigger.className = "open";
			}
		},
		close_all: function(pAry, trigger){
			for( var i=0; i < pAry.length; i++ ){
				if(pAry[i].parentNode.parentNode.parentNode.className.indexOf('faq') >= 0) {
					pAry[i].style.display = "none";
				}
			}
			var aryDTs;
			if(trigger.tagName == "DT") {
				aryDTs = trigger.parentNode.getElementsByTagName("DT");
			} else if (trigger.tagName == "A") {
				aryDTs = trigger.parentNode.parentNode.parentNode.getElementsByTagName("DT");
			}
			for( var j=0; j < aryDTs.length; j++ ){
				if(aryDTs[j].parentNode.parentNode.parentNode.className.indexOf('faq') >= 0) {
					aryDTs[j].className = "";
				}
			}
			return false;
		}
}


tab = {
	prep_tabs: function(id){
	
		t = ((id == '' || id == undefined)? gebi('tabs') : gebi(id) )
		a = t.getElementsByTagName("a");
		for(i=0; i < a.length; i++){
			if(a[i].hash.indexOf('tab') >= 0){
				a[i].onclick = function(){
					tname = this.hash.replace('#','');
					return tab.cycle(tname);
				}
			}
		}	
	
		// if #tabName is in the URL, we should show the related tab's content when the page loads
		var theURL = location.href;		
		if (theURL.indexOf('#') >= 0) {		
			// split theURL into 2 parts and take the string to the right of the "#"
			var tabVal = theURL.split("#",2)[1];			
			// check for qString parameters
			if (tabVal.indexOf("?") >= 0) {				
				// if ? is present, spit the tabVal once so we only return what's left of the ?
				tabVal = tabVal.split("?",1)[0];
			}		
			tab.cycle(tabVal);
		}
	},
	cycle: function(tname){
		a = document.getElementsByTagName("a");
		div = document.getElementsByTagName("div");
		
		for(i=0; i < a.length; i++){
			if(a[i].hash.indexOf('tab') >= 0){
				aClassNames = ((a[i].hash == '#'+tname)? 'on' : '')
				a[i].className = aClassNames
			}
		}	
		
		for(i=0; i < div.length; i++){
			if(div[i].id != 'tabs' && div[i].id.indexOf('tab') >= 0){
				divClassNames = ((div[i].id == tname)? 'tab-content tab-content-on' : 'tab-content')
				div[i].className = divClassNames
			}
		}	
		return false;
	}
}

sh = { 
	prep_togglers: function(){
		if( document.getElementById && document.getElementsByTagName ){
			// apply onclick to the togglers
			c = gebi('content');
			d = document.getElementsByTagName("div");
			for(i=0; i < d.length; i++){
				if(d[i].className.indexOf('toggler') >= 0){
					d[i].onclick = function(){ return sh.toggle(this); }
				}
			}	
		}
	},
	prep_promos: function(){
		if( document.getElementById && document.getElementsByTagName ){
			
			// apply onclick to the promos
			c = gebi('content');
			dl = document.getElementsByTagName("dl");
			
			for(i=0; i < dl.length; i++){
				if(dl[i].className.indexOf('promo-item') >= 0 || dl[i].className.indexOf('new-product') >= 0){
					dts = dl[i].getElementsByTagName("dt");
					for(j=0; j < dts.length; j++){
						dts[j].onclick = function(){ return sh.toggle_promo(this, dts); }
						dts[j].onmouseover = function(){ this.className += (this.className.indexOf("roll") >= 0)? '' : ' roll'; }
						dts[j].onmouseout = function(){ this.className = this.className.toString().replace("roll", ""); }
					}
				}
			}
		}
	},
	toggle: function(item){
		iChild = traverse.next(item)
		indicator = item.getElementsByTagName("span");

		indicator[0].innerHTML = (indicator[0].className.length > 0)? 'Hide' : 'Show';
		indClName = ((indicator[0].className.length > 0)? '' : 'toggler-closed');
		chiClName = ((iChild.className.indexOf('-on') >= 0)? 'toggle-content' : 'toggle-content-on');
		
		indicator[0].className = indClName;
		iChild.className = chiClName;
	},
	toggle_promo: function(item, pAry){
		ddon = traverse.next(item)
		for( var i=0; i < pAry.length; i++ ){	
			dt = pAry[i];
			dd = traverse.next(dt);
			dt.className = (dt.className.indexOf("first") >= 0)? 'first' : '';
			dd.className = (dd.className.indexOf("first") >= 0)? 'clearfix first' : 'clearfix';
		}
		dtClName = ((item.className.indexOf('first') >= 0)? 'first on' : 'on')
		
		item.className = dtClName;
		ddon.className = (ddon.className.indexOf("first") >= 0)? 'clearfix first open' : 'clearfix open';
	}
}

moda = {
	sw: screen.width,
	sh: screen.height,
	clw: document.documentElement.clientWidth,
	clh: document.documentElement.clientHeight,
	imgAry: [],
	
	bodyH: function(){
		if (!Browser.IE){
			viewportheight = document.documentElement.offsetHeight
		}else {
			viewportheight = document.getElementsByTagName('body')[0].offsetHeight
		}
		return viewportheight;
	},
	bodyW: function(){
		if (!Browser.IE){
			viewportwidth = document.documentElement.offsetWidth
		}else {
			viewportwidth = document.getElementsByTagName('body')[0].offsetWidth
		}
		return viewportwidth;
	},
	
	attach_modal: function(){
		
		body = document.getElementsByTagName('body')[0];		
		
		//add our overlapping div append to the body tag
		modalbg = document.createElement('div');
		modal	= document.createElement('div');
		
		//Set our Attributes
		modalbg.setAttribute('id', 'modal_bg');
		modalbg.setAttribute('class', 'modal_bg');
		
		modal.setAttribute('id', 'modal-e');
		modal.setAttribute('class', 'modal-e');
		
		//Append to the document
		body.appendChild(modalbg)
		body.appendChild(modal)
		
	},
	prep_modal:function(){
		w = ((moda.sw > moda.bodyW())? moda.sw : moda.bodyW());
		h = ((moda.sh > moda.bodyH())? moda.sh : moda.bodyH());
		
		html = document.getElementsByTagName('html')[0]

		//Set H/W for BG
		gebi('modal_bg').style.height = h + 'px';
		gebi('modal_bg').style.width = w + 'px';
		
		gebi('modal_bg').style.display = "block";
		
		//Hide Scrollers
		html.style.overflow = "hidden";
		
		gebi('modal_bg').onclick = function(){
			moda.close_modal();
		}
		
	},
	pop_modal:function(item){
		var cItem, pItem, nItem
		
		moda.prep_modal();
		imgAry = moda.imgAry;
		
		for(i = 0; i < imgAry.length; i++){						
			// default the prev and next arrow action		
			pItem = (i - 1);
			nItem = (i+1);			
			// first image in the gallery
			if (i == 0) {
				pItem = ((imgAry.length)-1);								
			}			
			// on last image of the gallery
			if (i == imgAry.length-1) {
				nItem = 0;
			}						
			// check for a match
			if(item.href == imgAry[i].href || item === i){
				cItem = i;
				break;
			}			
		}
		
		txt = '';
		txt += '<div id="close-modal"><img src="/images/global/nexgen09/modal-close.gif" alt="close" onclick="moda.close_modal();" /></div>';
		txt += '<img src="' + imgAry[cItem] + '" id="the-image" />';
		txt += imgAry[cItem].title + '<br />';
		txt += '<div id="prod-link"><a href="' + imgAry[cItem].rel + '" class="blk">Enlarge</a></div>'
		txt += '<img src="/images/global/nexgen09/modal-prev.gif" onclick="moda.pop_modal('+ pItem +')" class="prev" title="Previous" />'; 
		txt += '<img src="/images/global/nexgen09/modal-next.gif" onclick="moda.pop_modal('+ nItem +')" class="next" title="Next" />';
		
		gebi('modal-e').innerHTML = txt;
		
		moda.posix_modal();
		
		//Kills the default href action 
		return false;
	},
	posix_modal:function(){
		//Safari fix
		sch = ((document.documentElement.scrollTop != 0)? document.documentElement.scrollTop : document.body.scrollTop )
		
		gebi('modal-e').style.display = "block";
		gebi('modal-e').style.left = (Math.ceil(document.documentElement.clientWidth/2) - Math.ceil(gebi('modal-e').offsetWidth/2)) + 20 + 'px';
		gebi('modal-e').style.top = (Math.ceil(document.documentElement.clientHeight/2) - Math.ceil(gebi('modal-e').offsetHeight/2)) + sch +  'px';
	},
	close_modal:function(){
		gebi('modal_bg').style.display = "none";
		gebi('modal-e').style.display = "none";
		document.getElementsByTagName('html')[0].style.overflow = "";
	},
	initialize:function(){
	moda.attach_modal();
	if(document.getElementById && document.getElementsByTagName ){
		c = gebi('prod-gallery-strip');
		a = c.getElementsByTagName("A");
		for(i=0; i < a.length; i++){
			moda.imgAry.push(a[i]);
			a[i].onclick = function(){ return moda.pop_modal(this);  }
		}			
	}
}

}

traverse = {
	next: function(pNode){
		var nextSib = pNode.nextSibling;
		while (nextSib.nodeType != 1) {
			nextSib = nextSib.nextSibling;
		}
		return nextSib;
	},
	previous: function(pNode){
		var prevSib = pNode.previousSibling;
		while (prevSib.nodeType != 1) {
			prevSib = prevSib.previousSibling;
		}	
		return prevSib;
	},
	down: function(pNode, strTagName){
		x = pNode.getElementsByTagName(strTagName);
		for(i=0; i < x.length; i++){
			child = x[i];
		}
		return child;
	},
	get_parent:function(pNode,strTagName){
		var groupParent = pNode.parentNode;
		while (groupParent.tagName != strTagName.toUpperCase()) {
			groupParent = groupParent.parentNode;
		}	
		return groupParent;
	}
}

/*

default_textbox_val: reset text boxes with a default value (like search in global header), script looks for a non-empty alt attribute in the input tag

*/
default_textbox_val = {

	prep: function(){
	
		if( document.getElementById && document.getElementsByTagName ){
			var textboxes = document.getElementsByTagName("input");
			for( var i=0; i < textboxes.length; i++ ){		
				if (textboxes[i].type=="text") {						
					if (textboxes[i].alt != "") {
						textboxes[i].onfocus = function(){
						return default_textbox_val.clear(this); 
						};
					}								
					if (textboxes[i].alt != "") {
						textboxes[i].onblur = function(){
						return default_textbox_val.reset(this); 
						};
					}					
				}		
			}
		}	
	
	},
	
	clear: function(pEl){
		if (pEl.value == pEl.alt) {
			pEl.value = "";	
		}
	},
	
	reset: function(pEl){
		if (pEl.value == "") {
			pEl.value = pEl.alt;
		}			
	}
}
carousel = {
	prep_images: function(){		
		a = gebi('carousel-strip').getElementsByTagName('A');		
		for(i=0; i < a.length; i++){						
			a[i].onclick = function(){ return carousel.cycle(this);  }			
		}
	},
	cycle: function(item){
		id = item.hash.replace('#', '')
		a = gebi('carousel-strip').getElementsByTagName('A');
		div = gebi('banner-img').getElementsByTagName("div");
		for(i=0; i < a.length; i++){
			aClassNames = ((a[i].hash == item.hash)? '' : '')
			a[i].className = aClassNames
		}
		for(i=0; i < div.length; i++){
			if(div[i].className.indexOf('detail') >= 0){
				divClassNames = ((div[i].id == id)? 'detail detail-on' : 'detail')
				div[i].className = divClassNames
			}
		}	
		return false;
	}
}


/*ADD NEW setWidth FUNCTION*/
function setWidth(theID) {
	if (gebi(theID)) {
		var aryTags = gebi(theID).getElementsByTagName("A");
		var tagWidth = parseInt(aryTags[0].offsetWidth);		
		var overallWidth = (((parseInt(aryTags.length) * tagWidth)) + 20) + "px";
		gebi(theID).style.width = overallWidth;
	}
}


/* suckerfish script to allow hover/rollover on non-anchor elements for IE */
function suckerfish(type, tag, parentId, theHoverClass) {
	//if (window.attachEvent) {
	//	window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):gebi(parentId).getElementsByTagName(tag);
			type(sfEls, theHoverClass);
	//	});
	//}
}

pseudoHover = function(sfEls, theHoverClass) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" "+theHoverClass;
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" "+theHoverClass+"\\b"), "");
		}
	}
}
/* end suckerfish */

/* popWin function */
function popWin(pEl) {
	var aryVals = pEl.className.split('_');
	var w = aryVals[1];
	var h = aryVals[2];
	var sc = "";
	if (aryVals.length > 2) {
		sc = ","+aryVals[3];
	}
	var strUrl = pEl.href;	
	var strFeatures	= "width="+w+",height="+h+sc;
	var strTarget		= "_blank";
	window.open(strUrl, strTarget, strFeatures);
	return false;
}

/* resizeFlashWrapper is used by various flash elements to dynamically resize their wrappers as the content changes size */
function resizeFlashWrapper(id, h) {
	document.getElementById(id).style.height = h + "px";
        if (id == "nav-global_flash") {
          document.getElementById("global_nav_obj").style.height = h + "px";
        }
}


/* --------------------------------------- */
/* HELPERS */

function isMatch(pEl,pMatch){
	if ((pEl.match(pMatch))==pMatch) {
		return true;
	} else {
		return false
	}	
}

/*

On window load, initialize various functions

*/
if(window.addEventListener){ // Mozilla, Netscape, Firefox
 // BEGIN: Attach event FireFox
  window.addEventListener("load", function() {
  setWidth("related-prod-strip");
  setWidth("prod-gallery-strip");
  setWidth("carousel-strip");

  /* call for suckerfish elements, fsm_common.js */
  /* BH: added if to check for nav-global */
  if (gebi('nav-global')){
     //suckerfish(pseudoHover, "LI", "nav-global", "sfhover");
  }
  // check for faq/article page before preping faq show/hide
  if(gebi('tabs')){
    tab.prep_tabs();
  }

  // look for horizontal scrolling image gallery
  if(gebi('prod-gallery-strip')){
    moda.initialize();
  }


  //FAQ & Togglers's by Class - We break then out into seperate loops so that they are only called once each go
  /* BH added if to check for content */
  c = gebi('body');
  d = document.getElementsByTagName("div");
  dl = document.getElementsByTagName("dl");
  for(i=0; i < d.length; i++){
    if(d[i].className.indexOf('faq') >= 0){
      faq.prep_faqs();
      break;
    }
  }
  for(i=0; i < d.length; i++){
    if(d[i].className.indexOf('toggler') >= 0){
      sh.prep_togglers();
      break;
    }
  }
  for(i=0; i < dl.length; i++){
    if(dl[i].className.indexOf('promo-item') >= 0 || dl[i].className.indexOf('new-product') >= 0){
      sh.prep_promos();
      break;
    }
  }

  if(gebi('carousel-strip')){
    carousel.prep_images();
  }
  // Clear text box on focus and reset to default if user doesn't enter anything
  default_textbox_val.prep();
 },false); // END Attach Event FireFox

} else { // IE
  // BEGIN: Attach event IE
  window.attachEvent("onload", function() {
  setWidth("related-prod-strip");
  setWidth("prod-gallery-strip");
  setWidth("carousel-strip");
	
  /* call for suckerfish elements, fsm_common.js */
  /* BH: added if to check for nav-global */
  if (gebi('nav-global')){
     suckerfish(pseudoHover, "LI", "nav-global", "sfhover");
  }	
  	if(gebi('trackHelp')) {
		pseudoHover([gebi("trackHelp")], "sfhover");
	}
  // check for faq/article page before preping faq show/hide
  if(gebi('tabs')){ 
    tab.prep_tabs();
  }
	
  // look for horizontal scrolling image gallery
  if(gebi('prod-gallery-strip')){ 
    moda.initialize();
  }
	
	
  //FAQ & Togglers's by Class - We break then out into seperate loops so that they are only called once each go
  /* BH added if to check for content */
  c = gebi('body');
  d = document.getElementsByTagName("div");
  dl = document.getElementsByTagName("dl");
  for(i=0; i < d.length; i++){
    if(d[i].className.indexOf('faq') >= 0){
      faq.prep_faqs();
      break;
    }
  }
  for(i=0; i < d.length; i++){
    if(d[i].className.indexOf('toggler') >= 0){
      sh.prep_togglers();
      break;
    }
  }
  for(i=0; i < dl.length; i++){
    if(dl[i].className.indexOf('promo-item') >= 0 || dl[i].className.indexOf('new-product') >= 0){
      sh.prep_promos();
      break;
    }
  }

  if(gebi('carousel-strip')){
    carousel.prep_images();
  }
  // Clear text box on focus and reset to default if user doesn't enter anything
  default_textbox_val.prep();
 }); // END Attach Event IE
}
window.onresize=function(){
	if(gebi('modal-e') && gebi('modal-e').style.display == "block"){
		moda.posix_modal();
	}
        if(gebi('overlay_window')) {
                reposition_overlay(); 
        } 
}

/* goModal and clearModal control the viewing space of flash galleries */
function goModal(blockID, wrapperID) {
        blockID=wrapperID;
	if(BrowserDetect.browser == "Firefox" || (BrowserDetect.browser == "Explorer" && BrowserDetect.version == "6.0")) {
		document.getElementById(blockID).style.height = "600px"
	} else {
		document.getElementById(blockID).style.zIndex = 2600;
		document.getElementById(blockID).style.position = "fixed";
		document.getElementById(blockID).getElementsByTagName("div")[0].style.padding = "0px";
		var headers = document.getElementById(blockID).getElementsByTagName("h2");
		headers[0].style.display = "none";
		var paragraphs = document.getElementById(blockID).getElementsByTagName("p");
		for(var i = 0; i < paragraphs.length; i++) {
			paragraphs[i].style.display = "none";
		}
	}
	document.getElementById(wrapperID).style.height = "100%";
}

function clearModal(blockID, wrapperID, closedHeight) {
	if(BrowserDetect.browser == "Firefox" || (BrowserDetect.browser == "Explorer" && BrowserDetect.version == "6.0")) {
		document.getElementById(blockID).style.height = "160px"
	} else {
		document.getElementById(blockID).style.zIndex = 2500;
		document.getElementById(blockID).style.position = "relative";
		document.getElementById(blockID).getElementsByTagName("div")[0].style.padding = "10px";
		var headers = document.getElementById(blockID).getElementsByTagName("h2");
		headers[0].style.display = "inline";
		var paragraphs = document.getElementById(blockID).getElementsByTagName("p");
		for(var i = 0; i < paragraphs.length; i++) {
			paragraphs[i].style.display = "block";
		}
	}
	document.getElementById(wrapperID).style.height = closedHeight + "px";
}



function fxoXp1Bag(){
		  				
                document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="745" height="300" id="bagShell" align="middle">\n');
                document.write('<param name="allowScriptAccess" value="always" />\n');
                document.write('<param name="FlashVars" value="referrer='+encodeURIComponent(document.referrer)+'">\n');
                document.write('<param name="allowFullScreen" value="false">\n');
                document.write('<param name="movie" value="/templates/components/flash_components/carousel.swf">\n');
                document.write('<param name="quality" value="high">\n');
                document.write('<param name="wmode" value="transparent">\n');
                document.write('<param name="bgcolor" value="#ffffff">\n');
                document.write('<embed src="/templates/components/flash_components/carousel.swf" FlashVars="referrer='+encodeURIComponent(document.referrer)+'" quality="high" wmode="transparent" bgcolor="#cccccc" width="745" height="300" name="bagShell" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" >\n');
                document.write('</embed>\n');
                document.write('</object>\n');
			}

/* --------------------- Flyout Menu js Begin--------------*/


function fx_indexOf(arr, obj) {
	for(var i = 0; i < arr.length; i++) {
		if(arr[i] == obj) { return i; }
	}
	return -1;
}

qa = {
	menuTabs: [],
	hoverIndex: null,
	hoverTimeout: -1,
	init: function() {
		var menu = gebi("flyoutMenuList").childNodes;
		for(var i = 0; i < menu.length; i++) {
			if(menu[i].tagName && menu[i].tagName.toLowerCase() == "li") {
				this.menuTabs.push(menu[i]);
			}
		}
		for(i = 0; i < this.menuTabs.length; i++) {
			this.menuTabs[i].onmouseover = function(e) {
				clearTimeout(qa.hoverTimeout);
				qa.hoverIndex = (Array.prototype.indexOf) ? qa.menuTabs.indexOf(this) : fx_indexOf(qa.menuTabs, this);
				qa.hoverTimeout = setTimeout("qa.showMenu()", 250);
			}
			this.menuTabs[i].onmouseout = function(e) {
				var relTarg = (e) ? e.relatedTarget : window.event.toElement;
				while(relTarg && relTarg != this && relTarg.tagName != "BODY" && relTarg.tagName != "HTML") {
					relTarg = relTarg.parentNode;
				}
				if(relTarg == this) { return; } // bubbled rolloff
				clearTimeout(qa.hoverTimeout);
				qa.hoverTimeout = setTimeout("qa.hideMenu()", 250);
			}
		}
	},
	showMenu: function() {
		this.hideMenu();
		this.menuTabs[this.hoverIndex].className = (this.menuTabs[this.hoverIndex].className.indexOf("last") > -1) ? "last hover" : "hover";
	},
	hideMenu: function() {
		for(i = 0; i < this.menuTabs.length; i++) {
			this.menuTabs[i].className = (this.menuTabs[i].className.indexOf("last") > -1) ? "last" : "";
		}
	}
}


/*

On window load, initialize various functions

*/
if(window.addEventListener){ // Mozilla, Netscape, Firefox
 // BEGIN: Attach event FireFox
  window.addEventListener("load", function() {
  

  /* call for suckerfish elements, fsm_common.js */
  /* BH: added if to check for nav-global */
  
	if(gebi('flyoutMenuList')) {
		qa.init();
	}
  
 },false); // END Attach Event FireFox

} else { // IE
  // BEGIN: Attach event IE
  window.attachEvent("onload", function() {
  
	
  
	if(gebi('flyoutMenuList')) {
		//suckerfish(pseudoHover, "LI", "flyoutMenuList", "sfhover");
		qa.init();
	}
  
 }); // END Attach Event IE
}






/* --------------------- Flyout Menu js End--------------*/

/* --------------------- Promo River js Begin--------------*/




promoRiver = {
	shell: null,
	leftMost: 0,
	rightBtn: null,
	leftBtn: null,
	promotions: null,
	w: 225, //width of an individual promo
	destination: 0,
	i: -1,
	init: function() {
		this.shell = gebi("promoShell");
		this.promotions = this.shell.getElementsByTagName("a");
		if(this.promotions.length > 3) {
			this.shell.style.width = this.promotions.length * this.w + "px";
			this.rightBtn = gebi("promoRight");
			this.leftBtn = gebi("promoLeft");
			this.rightBtn.className = "active";
			this.shell.style.left = 0;
			this.enable();
		}
	},
	right: function() {
		promoRiver.disable();
		promoRiver.leftMost++;
		promoRiver.leftBtn.className = "active";
		if(promoRiver.leftMost + 3 == promoRiver.promotions.length) {
			promoRiver.rightBtn.className = "";
		}
		promoRiver.animate();
	},
	left: function(e) {
		promoRiver.disable();
		promoRiver.leftMost--;
		promoRiver.rightBtn.className = "active";
		if(promoRiver.leftMost == 0) {
			promoRiver.leftBtn.className = "";
		}
		promoRiver.animate();
	},
	animate: function() {
		promoRiver.destination = promoRiver.leftMost * -promoRiver.w;
		promoRiver.i = setInterval(promoRiver.tick, 30);
	},
	tick: function() {
		var cLeft = parseInt(promoRiver.shell.style.left);
		if(Math.abs(cLeft - promoRiver.destination) < 5) {
			promoRiver.shell.style.left = promoRiver.destination + "px";
			clearInterval(promoRiver.i);
			promoRiver.enable();
			return;
		}
		if(cLeft > promoRiver.destination) {
			promoRiver.shell.style.left = (cLeft - 15) + "px";
		} else {
			promoRiver.shell.style.left = (cLeft + 15) + "px";
		}
	},
	enable: function() {
		this.rightBtn.onclick = function() {
			promoRiver.right();
			return false;
		}
		this.leftBtn.onclick = function() {
			promoRiver.left();
			return false;
		}
	},
	disable: function() {
		this.rightBtn.onclick = null;
		this.leftBtn.onclick = null;
	}
}
/*

On window load, initialize various functions

*/
if(window.addEventListener){ // Mozilla, Netscape, Firefox
 // BEGIN: Attach event FireFox
  window.addEventListener("load", function() {
  

  /* call for suckerfish elements, fsm_common.js */
  /* BH: added if to check for nav-global */
  
	if(gebi('promoRiver')) {
		promoRiver.init();
	}
  
 },false); // END Attach Event FireFox

} else { // IE
  // BEGIN: Attach event IE
  window.attachEvent("onload", function() {
  
	
  
	if(gebi('promoRiver')) {
		
		promoRiver.init();
	}
  
 }); // END Attach Event IE
}

/* --------------------- Promo River js End--------------*/


/* --------------------- IE 8-7 Split Sliding door buttons issue fix Begin--------------*/

//This is a fix for sliding door buttons that are split in IE 8 browser due to it's 6 different combinations of Browser mode and Document mode.
//Document mode only works in IE 8 JS scripting engine
if(document.documentMode!='undefined')
{
	if(document.documentMode==7)
	{
	//document.write("Yes, this is in IE7 mode  :   " + document.documentMode );
	document.write("<style>button {width:auto;	overflow:visible;} .btn-30-bl-arw{border-bottom:0px;border-left:0px;border-right:0px;border-top:0px;PADDING-TOP: 0px;overflow:visible;} .btn-20-lgr {border-bottom:0px;border-left:0px;border-right:0px;border-top:0px;PADDING-TOP: 0px;overflow:visible;} .text{float:left;width:120px;height:15px;padding:3px 3px 0 3px;border:1px solid #CCC;margin-top:5px;color:#333;font-family:Arial,sans-serif;}</style>");
	}

	//Document Mode=5 is Quirks document mode
	if(document.documentMode==5)
	{
	//document.write("Yes, this is in IE5 mode  :   " + document.documentMode );
	document.write("<style>button {width:auto;	overflow:visible;} .btn-30-bl-arw{border-bottom:0px;border-left:0px;border-right:0px;border-top:0px;PADDING-TOP: 0px;overflow:visible;} .btn-20-lgr {border-bottom:0px;border-left:0px;border-right:0px;border-top:0px;PADDING-TOP: 1px;overflow:visible;} .text{float:left;width:120px;height:15px;padding:3px 3px 0 3px;border:1px solid #CCC;margin-top:5px;color:#333;font-family:Arial,sans-serif;}</style>");
	}
}

//document.write(document.documentMode);

/* --------------------- IE 8-7 Split Sliding door buttons issue fix End--------------*/

