<!-- Begin Drop Down Nav Menu Functions -->

//Chrome Drop Down Menu v2.01- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: November 14th 06- added iframe shim technique

var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
disablemenuclick: true, //when user clicks on a menu item with a drop down menu, disable menu item's link?
enableswipe: 0, //enable swipe effect? 1 for yes, 0 for no
enableiframeshim: 1, //enable "iframe shim" technique to get drop down menus to correctly appear on top of controls such as form objects in IE5.5/IE6? 1 for yes, 0 for no

//No need to edit beyond here////////////////////////
dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},

swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually
this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}
else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)
},

showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)" //hide menu via clipping
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}
else if (e.type=="click")
obj.visibility="hidden"
},

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},

dropit:function(obj, e, dropmenuID){
if (this.dropmenuobj!=null) //hide previous menu
this.dropmenuobj.style.visibility="hidden" //hide menu
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
obj.onclick=function(){return !cssdropdown.disablemenuclick} //disable main menu item link onclick?
this.dropmenuobj=document.getElementById(dropmenuID)
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
this.dropmenuobj.onmouseout=function(e){cssdropdown.dynamichide(e)}
this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e)
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")
this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
this.positionshim() //call iframe shim function
}
},

positionshim:function(){ //display iframe shim function
if (this.enableiframeshim && typeof this.shimobject!="undefined"){
if (this.dropmenuobj.style.visibility=="visible"){
this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
this.shimobject.style.left=this.dropmenuobj.style.left
this.shimobject.style.top=this.dropmenuobj.style.top
}
this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
}
},

hideshim:function(){
if (this.enableiframeshim && typeof this.shimobject!="undefined")
this.shimobject.style.display='none'
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},

delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay) //hide menu
},

clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
},

startchrome:function(){
for (var ids=0; ids<arguments.length; ids++){
var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
var relvalue=menuitems[i].getAttribute("rel")
menuitems[i].onmouseover=function(e){
var event=typeof e!="undefined"? e : window.event
cssdropdown.dropit(this,event,this.getAttribute("rel"))
}
}
}
}
if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
this.shimobject=document.getElementById("iframeshim") //reference iframe object
}
}

}
<!-- End Drop Down Nav Menu Functions -->

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

<!-- Begin ARC Sub Menu Functions -->
function arcDrop(div) {
	if(document.getElementById(div).style.display == 'none') {
		document.getElementById(div).style.display = '';	
	}else {
		document.getElementById(div).style.display = 'none';	
	}
}

<!-- End ARC Sub Menu Functions -->
///
//pop up code
<!--
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
		newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
	}
//-->
//pop up code end

/////////////////////////////////////////////////////////////////////////////
function formHandler(form){ //quick nav for arc
	var URL = document.form.site.options[document.form.site.selectedIndex].value;
	window.location.href = URL;
}
/////////////////////////////////////////////////////////////////////////////

<!-- Begin User Preferences Toolbar Functions -->

//test function to toggle menu
function toggleMenu(mode,save) {
	
	//check to see if save is defined, if not set default value (true)
	save = typeof(save) != 'undefined' ? save : true;
	
	if (mode == "hide") {
		if (document.getElementById('left-side')) {document.getElementById('left-side').style.display = "none";}
		if (document.getElementById('left-side')) {document.getElementById('container').style.background = "url('') white"; }
		if (document.getElementById('right-side')) { document.getElementById('right-side').style.width = "100%"; }
		if (document.getElementById('contain-content')) { document.getElementById('contain-content').style.width = "99%"; }
		if (document.getElementById('files-container')){ document.getElementById('files-container').style.width = "593px";}
		
		//adjust our map details and google maps div back to original width
		if ($('map') && $('mapDetails')) {
			if ($('map')) {$('map').setStyle({width: '345px'});}
			if ($('mapDetails')) {$('mapDetails').setStyle({width: '400px'});}
		}//if ($('map') ||$('mapDetails'))	
	} else if (mode == "show") {
		if (document.getElementById('left-side')){document.getElementById('left-side').style.display = "";}	
		if (document.getElementById('show')){document.getElementById('show').style.display = "none";}
		if (document.getElementById('hiding')){document.getElementById('hiding').style.display = "";}	
		//if (document.getElementById('right-pane')){document.getElementById('right-pane').style.padding = "10px 10px 10px 210px";}
		//if (document.getElementById('right-pane')){document.getElementById('right-pane').style.width = "780px";}
		if (document.getElementById('files-container')){ document.getElementById('files-container').style.width = "350px";}
		
		//adjust our map details and google maps div to fit with the product browse/attribute search menu showing
		if ($('map') && $('mapDetails')) {
			if ($('map')) {$('map').setStyle({width: '275px'});}
			if ($('mapDetails')) {$('mapDetails').setStyle({width: '300px'});}
		}//if ($('map') ||$('mapDetails'))	
	}//if (mode == "hide")
	
	//only update our cookie when specified
	if (save) {
		//update our cookie
		saveProductBrowsePreference(mode);	
	} //if (save)
}

//test function to save product browse menu preference
function saveProductBrowsePreference(mode) {
	//let's create our cookie with their product browse menu preference
	createCookie("pBrowsePref",mode,365); 	
}

//test function to get product browse menu preference (reads from cookie)
//and set's the style property of our product-menu element
function getProductBrowsePreference() {
	//let's retrieve our product browse menu preference
	var pref = readCookie("pBrowsePref");
	
	if (pref == "hide") {
		toggleMenu("hide");
	} else if (pref == "show") {
		toggleMenu("show");
	}
}

//function to create our cookie
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

//function to read our cookie (by passed in name)
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
<!-- End User Preferences Toolbar Functions -->

<!-- Begin Product Page Functions -->
function changeImg(id) {
	if ($(id).className == "expand") {
		$(id).className = "collapse";
	} else {
		$(id).className = "expand";
	}	
	return;
} //function changeImg(id)

//used on our products index
function showDiv(divRef) {
	//get our nav and div elements for setting current item visibility, etc.
	var navContainerArray = $('products-nav').getElementsByTagName('a');
	var divContainerArray = $('files-container').getElementsByTagName('div');
		
	//reset our other nav links
	for (j = 0; j < navContainerArray.length; j++) {
		navContainerArray[j].className = " ";
	}//for (j = 0; j < navContainerArray; j++)
	
	//hide all our other divs	
	for (i = 0; i < divContainerArray.length; i++) {
		if (divContainerArray[i].id != '' && divContainerArray[i].className != 'highslide-html-content') {
			divContainerArray[i].style.display = "none";			
		}//if (divContainerArray[i].id != '')
	}//for (i = 0; i < divContainerArray.length; i++)
	
	//attempt to show our div and set our current link
	if ($(divRef)) {
		//set our active nav link
		$('nav-' + divRef).className = "current";
		
		//show our div
		$(divRef).style.display = "block";				
	}//if ($(divRef))		
}//function showDiv(divRef)

/******* Begin Product Page Tab Functions *******/
function setActiveTab(tab) {
	//inactivate our previously active tab
	for (var i = 0; i < $('tabNav').getElementsByTagName('li').length;i++) {
		$('tabNav').getElementsByTagName('li')[i].className = "";
	} //for (var i = 0; i < $('tabnav').getElementsByTagName('a').length;i++)
	
	//set our active tab
	$(tab+'Tab').className = "active";	
	//show our content for this tab
	showContent(tab);	
} //function setActiveTab(tab)

function showContent(div) {
	var productContentArray = $('ContentDivContainer').immediateDescendants();
	//hide all our other divs
	for (var i = 0; i < productContentArray.length;i++) {	
		if (!(productContentArray[i].className == 'clear')) {
			productContentArray[i].style.display = "none";		
		}//if (!(contentDivContainerArray[i].className == 'clear'))
	} //for (var i = 0; i < contentDivContainerArray.length;i++)

	//reset our ex/col images
	resetExColImg(div);
	//show our div
	if ($(div+'Content')) { $(div+'Content').style.display = "block"; } //if ($(div+'Content'))	
	//if ($('ContentDivContainer')) { $('ContentDivContainer').style.display = "block"; }
} //function showContent(div) 

//function to reset our expand/collapse images
//images weren't preserving status when switching tabs 
//(because we're changing the class name, instead of setting the image src)
//function to reset our expand/collapse images
//images weren't preserving status when switching tabs 
//(because we're changing the class name, instead of setting the image src)
function resetExColImg(parentDivID) {	
	if (parentDivID) {
		var spanArray = $(parentDivID+'Content').getElementsByTagName('span');
		var divArray = $(parentDivID+'Content').getElementsByTagName('div');
	
		//reset our defacto configurator, only on our elements page
		if (parentDivID == 'elements') {
			var tArray = $(parentDivID+'Content').immediateDescendants();				
			for (k = 0; k < tArray.length; k++) {	
					if (tArray[k].id != '') {				
						activateAll(tArray[k].id);
					}//if (typeof(tArray[k]) == "[object HTMLDivElement]")
			}//for (k = 0; k < tArray.length; k++)
		}//if (parentDivID == 'elements')	
	
		//need to iterate through the divs as well (since we're doing some funky stuff for this site's product pages)
		for (j = 0; j < divArray.length; j++) {		
			if (divArray[j].className == "ex-col-content") {
				divArray[j].style.display = "none";
			}//if (divArray[j].id != '')		
		}//for (j = 0; j < divArray.length; j++)
			
		//iterate through our span tags within the ContentDivContainer
		for (var i = 0; i < spanArray.length;i++) {
			//only reset our spans with "excol" in them (these are our expand/collapse image span tags)
			if (spanArray[i].id.indexOf('excol') != -1) {			
				spanArray[i].className = "expand";
			} //if (spanArray[i].id.indexOf('excol') != -1)
		} //for (var i = 0; i < spanArray.length;i++)				
	}//if (parentDivID)	
} //function resetExColImg(parentDivID)

<!-- End Product Page Functions -->

<!-- Begin Search Functions -->
function searchFocus(searchBox){
	if (searchBox.value == 'Quick Search'){
		searchBox.value = '';
	}
	searchBox.className = 'input';
}

function breadCrumbs(text){
	if ($('bread-crumbs')) { //ensure we have a valid object
		$('bread-crumbs').innerHTML = '<b>' + text + '</b>';
	}
}
<!-- End Search Functions -->

function getAbsPath(site) {
	var host = window.location.host;
	
	if (host == "webq1.insidehli.com" || host == "dev.insidehli.com") {
		//now we have to check to see if we're on the dev or test site (dev is our default db connection)
		if (window.location.pathname.match(/_test/g)) {
			//we're on testing site	
			return 'http://' + host + '/' + site + '_test/';						
		} else {
			//we're on dev (or we're defaulting to dev)
			return 'http://' + host + '/' + site + '_dev/';								
		}//if (window.location.pathname.match(/_test/g))		
	} else if (host == "qa.sportslighting.com") {
		//we're on qa site
		return 'http://qa.sportslighting.com/';
	} else {
		//we're on production site
		return 'http://www.sportslighting.com/';
	} //if (host == "webq1.insidehli.com" || host == "dev.insidehli.com") 	
}//function getAbsPath()

//------- BEGIN AJAX FUNCTIONS -------//

//We're appending a unique key/value at the end of our url to prevent caching in 
//frickin Internet Exploiter (http://www.codestore.net/store.nsf/unid/BLOG-20071130)
function bogusQueryStringParam() {
	return '&_' + new Date().getTime();
}

function showLoader(target) {
		$(target).innerHTML = '<div id="' + target + '-loading-div">\n' +
							  '<table cellpadding="3" cellspacing="0"  border="0">\n' +
							  '<tr>\n' +
							  '<td><img src="' + getAbsPath('sls') + 'images/ajax-loader.gif" /></td>\n' +
							  '<td>&nbsp;Loading...</td>\n' +
							  '</tr>\n' +
							  '</table>\n' +   
							  '</div>';
}//function showLoader(target)

function hideLoader(target) {
		$(target).innerHTML = '';
}//function hideLoader(target)

function getDesignSolutionsTable() {
	var sport = $F('sport-menu');

	if (sport.strip() != '') {
		//show our solution table
		url = getAbsPath('sls') + 'resources/design_solutions/' + sport + '.php?' + bogusQueryStringParam();
		var myAjax = new Ajax.Updater('design-solutions', url, {onCreate: function() {showLoader('design-solutions');}});

		//show our design solutions section
		$('design-solutions').show();
	} else {
		//hide our design solutions section
		$('design-solutions').hide();		
	}
	
	//reset our menu
	$('sport-menu').selectedIndex = 0;
	return;
}

//------- END AJAX FUNCTIONS -------//

