//Determine product pages that need customer height.

var isProductPage=false;
URLString = document.location;
if ((URLString.toString().search("item.aspx") > 0)|| (URLString.toString().search("search_results.aspx") > 0)) {
	isProductPage=true;
}
//Set default heights for menus globally
clipHeightArray=[121,121,121,121,121];
//Set custom heights for select pages to avoid global drop downs from interfering with form elements
if(isProductPage) {clipHeightArray=[121,121,121,91,91];}

function gMenuItemAttr (mName, mImage, mWidth, mCount) {
	this.mName = mName
	this.mImage = mImage
	this.mWidth = mWidth
	this.mCount = mCount
}

function gMenuListItems(mText,mUrl) {
	this.mText = mText
	this.mUrl = mUrl
}
	
function positionGlobalMenus(objID) {
	P7_Snap('imgHeader'+objID,'globalControlUp'+objID,-13,0)
	if (isScrolling(objID)){P7_Snap('imgHeader'+objID,'globalControlDown'+objID,-13,clipHeightArray[objID]+40)} else {P7_Snap('imgHeader'+objID,'globalControlDown'+objID,-13,eval('gScroll'+ objID).scrollHeight+40)} 
	//if (isScrolling(objID)){P7_Snap('imgHeader'+objID,'globalCont'+objID,-13,40)} else {P7_Snap('imgHeader'+objID,'globalCont'+objID,-13,30)}
	P7_Snap('imgHeader'+objID,'globalCont'+objID,-13,40)
	P7_Snap('imgHeader0','closeGlobalLayer',-70,-40)
}
//Hide and reset all z-indexes
function resetGlobalMenus() {
	vSwitch('closeGlobalLayer',0)	
	for (var i=0; i < gMenuCount; i++) {
		ChangeZindex('closeGlobalLayer',0);
		ChangeZindex('globalControlUp'+i,0);
		ChangeZindex('globalControlDown'+i,0);
		ChangeZindex('globalCont'+i,0,'globalText'+i);
		ChangeZindex('globalCont'+i,0);
		vSwitch('globalControlUp'+i,0)
		vSwitch('globalControlDown'+i,0)
		vSwitch('globalCont'+i,0)
		vSwitch('globalText'+i,0)
	}
}

//Activate Global Menus
function globalMenu(objID) {
	if (loaded){
		fixedClipHeight =121;
		ChangeZindex('closeGlobalLayer',2);
		ChangeZindex('globalControlUp'+objID,3);
		ChangeZindex('globalControlDown'+objID,4);
		ChangeZindex('globalCont'+objID,5,'globalText'+objID);
		ChangeZindex('globalCont'+objID,4);
		vSwitch('globalCont'+objID,1);
		vSwitch('globalControlUp'+objID,1);
		vSwitch('globalControlDown'+objID,1);
		vSwitch('globalText'+objID,1);
		vSwitch('closeGlobalLayer',1);
		positionGlobalMenus(objID);	
		return true;
	}
	else {return false;}
}
var clipWidthArray= new Array();

function globalMenuInit(){

	createGMenus();
	
	//Determine the true width of each menu by determining the actual width of the table that contains the items
	for (var i=0; i < gMenuCount; i++) {
		obj='globalContTable'+i
		el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:0;
		clipWidthArray[i] = el.offsetWidth
		document.write('<style>#globalCont'+i+ ' {WIDTH:'+clipWidthArray[i] +'px; CLIP: rect(0px '+clipWidthArray[i]+'px '+clipHeightArray[i]+'px 0px);}</style>');

	}
	
	loaded=true;
}


//Write global menus


function writeGlobalMenuClose() {
	document.write('<div id="closeGlobalLayer" style="width:100px; LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px; Z-INDEX: 0;" name="closeGlobalLayer"><a onmouseover="resetGlobalMenus()" href="#"><img src="img/clr.gif" width="650" height="270" border="0"></a></div>');
}

function writeGlobalMenuControlUp(gmID){
	clippingWidth=(parseInt(clipWidthArray[gmID]) -14)
	clrWidth=clippingWidth-gMenuAttr[gmID].mWidth-clrWidthArray[gmID]
	document.write('<div id="globalControlUp'+gmID+'" class="divHeaderMenu" style="left: -3000px; top: 0px; visibility: hidden; position: absolute; z-index: 0;"> ');
	document.write('  <table width="'+gMenuAttr[gmID].mWidth+'" border="0" cellspacing="0" cellpadding="0">');
	document.write('    <tr> ');
	document.write('      <td nowrap="nowrap"><div style="margin-left:13px;"><a href="'+serverName+categoryURLPath+''+urlParamsForOmniture+'">'+ gMenuAttr[gmID].mImage +'</a><a href="#" onmouseover="resetGlobalMenus();"><img src="img/clr.gif" width="'+clrWidthArray[gmID]+'" height="22" border="0" alt="" /></a><a href="#" onmouseover="resetGlobalMenus(); globalMenu('+(gmID + 1)+')"><img src="img/clr.gif" width="'+clrWidth+'" height="22" border="0" alt="" /></a></div></td>');
	document.write('    </tr>');
	document.write('  </table> ');
	document.write('  <table width="'+gMenuAttr[gmID].mWidth+'" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">');
	document.write('    <tr>');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="1" height="1" alt="" /></td>');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="12" height="1" alt="" /></td>');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="'+(gMenuAttr[gmID].mWidth-14)+'" height="1" alt="" /></td>');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="1" height="1" alt="" /></td>');
	document.write('    </tr>');
	document.write('    <tr>'); 
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="1" height="17" alt="" /></td>');
	document.write('      <td>&nbsp;</td>');
	document.write('      <td><img src="img/clr.gif" width="'+ clippingWidth +'" height="1" alt="" /><br />');
	document.write('        <div ><a style="display:block;" onmouseup="noScroll();" onmousedown="scroll(-4,\''+gmID+'\',121);return false;" onmouseover="self.status=\'Scroll up...\'; return true;" onfocus="this.blur();" onmouseout="noScroll();self.status=\'\'; return true;" href="javascript:noScroll();"><img src="img/arrow_up.gif" width="73" height="14" border="0" alt="Scroll Up" /></a></div></td>');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="1" height="1"></td>');
	document.write('    </tr>');
	document.write('  </table>');
	document.write('</div>');
}

function writeGlobalMenuControlDown(gmID){
	clippingWidth=(parseInt(clipWidthArray[gmID]) -4)
	document.write('<div id="globalControlDown'+gmID+'" class="divHeaderMenu"> ');
	document.write('  <table width="'+gMenuAttr[gmID].mWidth+'" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">');
	document.write('    <tr> ');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="1" height="1"></td>');
	document.write('      <td><img src="img/clr.gif" width="1" height="22"></td>');
	document.write('      <td bgcolor="#FFFFFF"><a style="display:block;" onmouseup=noScroll(); onmousedown="scroll(4,\''+gmID+'\',121);return false;" ');
	document.write('            onmouseover="self.status=\'Scroll down...\'; return true;" ');
	document.write('        onfocus=this.blur(); onmouseout="noScroll();self.status=\'\'; return true;" ');
	document.write('        href="javascript:noScroll();"><img src="img/arrow_down.gif" width="73" height="14" border="0" alt="Scroll Down"></a></td>');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="1" height="1"></td>');
	document.write('    </tr>');
	document.write('    <tr> ');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="1" height="1"></td>');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="12" height="1"></td>');
	document.write('      <td bgcolor="#989898"><img src="img/clr.gif" width="'+(clippingWidth-10)+'" height="1"></td>');
	document.write('      <td bgcolor="#989898" width="1"><img src="img/clr.gif" width="1" height="1"></td>');
	document.write('    </tr>');
	document.write('  </table>');
	document.write('</div>');
}


function writeGlobalMenuControls() {
	for (var i=0; i < gMenuCount; i++) {
		writeGlobalMenuControlUp(i);
		writeGlobalMenuControlDown(i);
	}
	writeGlobalMenuClose() ;
}

function writeGlobalMenu() {
	globalMenuInit();
	writeGlobalMenuControls();
}

function createGMenus() {
	gCont0=new makeObj('globalCont0')
	gScroll0=new makeObj('globalText0','globalCont0')
	gScroll0.moveIt(0,0)
	gCont0.css.visibility='hidden'
	gCont1=new makeObj('globalCont1')
	gScroll1=new makeObj('globalText1','globalCont1')
	gScroll1.moveIt(0,0)
	gCont1.css.visibility='hidden'
	gCont2=new makeObj('globalCont2')
	gScroll2=new makeObj('globalText2','globalCont2')
	gScroll2.moveIt(0,0)
	gCont2.css.visibility='hidden'
	gCont3=new makeObj('globalCont3')
	gScroll3=new makeObj('globalText3','globalCont3')
	gScroll3.moveIt(0,0)
	gCont3.css.visibility='hidden'
	if (gMenuCount > 4) {
		gCont4=new makeObj('globalCont4')
		gScroll4=new makeObj('globalText4','globalCont4')
		gScroll4.moveIt(0,0)
		gCont4.css.visibility='hidden'	
	}
}