// window.onerror = null;
var DOM = (document.getElementById)?true:false;
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4 && !DOM);
var IE4 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4);
var layerType = NS4?'layer':'div';
var menuOn = 0;
var layerOn;
var mainIndex, subIndex;
var windowWidth, smWidth=160, font, sl, pressed=false;
var menuTimer = null;
var layerText, styleText, leftText, topText, wHeight, appVer=navigator.appVersion;
var rtimer;

if(navigator.appName == "Netscape")
{
  layerText="document.layers";
  styleText="";
  leftText='.left';
  topText='.top';
  wHeight=window.innerHeight;
  windowWidth = window.innerWidth-16;
}
else
{
  layerText="document.all";
  styleText=".style";
  leftText='.pixelLeft';
  topText='.pixelTop';  
  wHeight=document.body.clientHeight;
  windowWidth = document.body.clientWidth;
  if(parseFloat(appVer.substr(appVer.indexOf("MSIE ")+5, 5))>=5)  
    windowWidth = windowWidth-16;
}

function getYPos(layerNumber, subIndex)
{
  var Yoffset, Y;

  if(navigator.appName == "Netscape") 
    Yoffset=window.pageYOffset;
  else 
    Yoffset=document.body.scrollTop; 

  Y = Math.min(parseInt(layerNumber)*20+subIndex*17+202+logoHeight+heightAdj, Yoffset+wHeight-5-(eval('sub'+layerNumber+'.length')-subIndex)*17);
  Y = Math.max(Yoffset+subIndex*17, Y);

  return(Y);
}  

function displayMenu(layerNumber, src)
{
  var i, myY, toSet;
  
  if(menuTimer != null)
    { 
      clearTimeout(menuTimer);

      if(layerOn!=layerNumber)
        hideMenu(layerOn);
    }

  if(!pressed)
    {  
      mainIndex=layerNumber;
      subIndex=-1;
    }  

  if(DOM)
    document.getElementById('main'+layerNumber).style.backgroundColor='#9999ff';  
  else if(NS4)
    eval(layerText+'["'+'main'+layerNumber+'"]'+'.document.bgColor="#9999ff"');  
  else if(IE4)
    eval(layerText+'["'+'main'+layerNumber+'"]'+'.style.backgroundColor="#9999ff"'); 
  
  if(eval('main['+layerNumber+'].sub==1'))
    {
      myY = getYPos(layerNumber, 0);
      
      if(DOM)
	{
	  document.getElementById('sub'+layerNumber).style.top=myY;
	  document.getElementById('sub'+layerNumber).style.visibility='visible';
	}
      else if(IE4)
	{
	  eval(layerText+'["'+'sub'+layerNumber+'"]'+styleText+topText+'='+myY);
	  eval(layerText+'["'+'sub'+layerNumber+'"]'+styleText+'.visibility="visible"');
	}
      else if(NS4)
	for(i=0; i<eval('sub'+layerNumber+'.length'); i++)
	  {
	    eval(layerText+'["'+'sub'+layerNumber+i+'"]'+styleText+topText+'='+myY);	      	    
	    eval(layerText+'["'+'sub'+layerNumber+i+'"]'+styleText+'.visibility="visible"');
	    myY = myY + 17;
	  }
    }
  layerOn = layerNumber;
}

function hideMenu(layerNumber)
{
  var i;
  
  if(DOM)
    document.getElementById('main'+layerNumber).style.backgroundColor='#999999';
  else if(NS4)
    eval(layerText+'["'+'main'+layerNumber+'"]'+'.document.bgColor="#999999"');
  else if(IE4)
    eval(layerText+'["'+'main'+layerNumber+'"]'+'.style.backgroundColor="#999999"');
  
  if (menuOn == 0 && eval('main['+layerNumber+'].sub==1'))
    {
      if(DOM)
	document.getElementById('sub'+layerNumber).style.visibility='hidden';
      else if(NS4)
	for(i=0; i<eval('sub'+layerNumber+'.length'); i++)
	  eval(layerText+'["'+'sub'+layerNumber+i+'"]'+styleText+'.visibility="hidden"');
      else if(IE4)
	eval(layerText+'["'+'sub'+layerNumber+'"]'+styleText+'.visibility="hidden"');
    }
}

function setMenuTimer()
{
  menuTimer = setTimeout("menuTimerOut()",700);
}

function menuTimerOut()
{   
  if (menuOn == 0)
    hideMenu(layerOn);
}

function subMenuIn(main, sub, src)
{
  clearTimeout(menuTimer);
  menuOn = 1;
  
  if(NS4)
    eval(layerText+'["'+'sub'+main+sub+'"]'+'.document.bgColor="#9999ff"');
  else
    src.bgColor='#9999ff';

  if(!pressed)
    {
      mainIndex=main;
      subIndex=sub;
    } 
}
 
function subMenuOut(main, sub, src) 
{
  menuOn = 0;	

  if(NS4)
    eval(layerText+'["'+'sub'+main+sub+'"]'+'.document.bgColor="#999999"');
  else
    src.bgColor='#999999';

  menuTimer = setTimeout("hideMenu(layerOn)", 700);
}

function handleResize()
{
  clearTimeout(rtimer);
  rtimer=setTimeout('window.location=window.location;',500);
}

function getDestination(e)
{
  setTimeout("G2()", 180);
  pressed=true;
}

function G2()
{
  if(subIndex==-1)
    window.location=menuBase+main[parseInt(mainIndex)].url;
  else
    window.location=menuBase+eval('sub'+mainIndex+'['+subIndex+'].url');
}


function getAllCatWidth(fo, obj)
{
  var result = 0.0;
  var c, code;
  var r, i, j;

  smWidth=135;
  for(i=0; i<obj.length; i++)
    {
      r=0.0;
      for(j=0; j<obj[i].title.length; j++)
	{
	  c=obj[i].title.charAt(j);
	  code=obj[i].title.charCodeAt(j);
	  
	  if(fo==10)
	    {  
	      if(c=='f' || c=='i' || c=='j' || c=='l' || c=='t' || c=='I')
		r+=.5;
	      else if(c=='r')
		r+=.62;
	      else if(c=='s')
		r+=.75;
	      else if(c=='c' || c=='k' || c=='v' || c=='y' || c=='z' || c=='J' || c=='Z' || (code>=48 && code<=57))
		r+=.88;
	      else if(c=='A' || c=='B' || c=='C' || c=='D' || c=='H' || c=='K' || c=='N' || c=='P' || c=='R' || c=='S' || c=='U' || c=='V' || c=='X')
		r+=1.125;
	      else if(c=='G' || c=='O' || c=='Q')
		r+=1.25;
	      else if(c=='w' || c=='M')
		r+=1.37;
	      else if(c=='m')
		r+=1.5;
	      else
		r+=1;
	    }
	  else
	    {
	      if(c=='i' || c=='j' || c=='l' || c=='I')
		r+=.43;
	      else if(c=='f' || c=='t')
		r+=.57;
	      else if(c=='r')
		r+=.72;
	      else if(c=='w' || c=='y' || c=='F')
		r+=.86;
	      else if(c=='A' || c=='B' || c=='C' || c=='D' || c=='G' || c=='H' || c=='K' || c=='N' || c=='P' || c=='R' || c=='S' || c=='U' || c=='V' || c=='X')
		r+=1.15;
	      else if(c=='O' || c=='Q')
		r+=1.3;
	      else if(c=='w' || c=='M')
		r+=1.45;
	      else if(c=='m')
		r+=1.58;
	      else
		r+=1;
	    }

	  if(c=='&' && obj[i].title.charAt(j+1)=='q' && obj[i].title.charAt(j+2)=='u' &&  obj[i].title.charAt(j+3)=='o' &&  obj[i].title.charAt(j+4)=='t' &&  obj[i].title.charAt(j+5)==';')
	    j=j+5;
	}
      
      if(fo==10)
	r=r*8.03;
      else
	r=r*6.9;
     
      obj[i].width=Math.round(r)+18;
      result=result+Math.round(r)+18;
      smWidth=Math.max(smWidth, Math.round(r)+6);
    } 

  return result;
}

function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); }
function openMail(host) { var mailwindow = window.open("http://" + host +"/.sc/ms/em", "EmailFriend", "width=500,height=400,resizable,scrollbars,status"); if(!isIE4()) mailwindow.focus(); }

for(i=0; i<main.length; i++)
{
  if(main[i].sub==1)
    {
      getAllCatWidth(9, eval('sub'+i));
      eval('sub'+i+'.smWidth='+smWidth);
    } 
}

if(ot=='f')
  {
    myTop[4].url=myTop[3].url+'/co3';
    myTop[4].title='My Account';
  }

if(IE4)
  sl=18;
else if(DOM)
  sl=10;
else 
  sl=13;

if(priceMode=='2' || priceMode=='3')
  itemString='<td width=100% align=center>'+loginlink+'</td>';
else
  itemString='<td width=40% align=right><a href='+myTop[2].url+'><img src='+idomain+'/ac/cart.gif width=23 height=20 border=0></a></td><td width=60%><a href='+myTop[2].url+' class=s>Items: '+items+'</a></td>';

document.writeln('<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td rowspan=3 width=1 bgcolor=white><img src='+idomain+'/ac/b.gif width=1 height=1></td><td colspan=2 bgcolor=#999999 width=1600><img src='+idomain+'/ac/b.gif width=605 height=1></td><td rowspan=3 width=1 bgcolor=white><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr><tr><td width=75%><table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td colspan=6 width=100% height=3 bgcolor=black><img src='+idomain+'/ac/b.gif width=400 height=1></td></tr>');

if(topHTML=="")
  document.writeln('<tr bgcolor=#999999><td width=5% height=22><img src='+idomain+'/ac/b.gif width=10 height=1></td><td width=20% align=center valign=middle><font color=white face=arial>&#149;</font> <a href='+myTop[0].url+' class=head7>'+myTop[0].title+'</a></td><td width=20% align=center valign=middle><font color=white face=arial>&#149;</font> <a href='+myTop[1].url+' class=head7>'+myTop[1].title+'</a></td><td width=24% align=center valign=middle><font color=white face=arial>&#149;</font> <a href='+myTop[3].url+' class=head7>'+myTop[3].title+'</a></td><td width=26% align=center valign=center><font color=white face=arial>&#149;</font> <a href='+myTop[4].url+' class=head7>'+myTop[4].title+'</a></td><td width=5%><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr>');
else
  document.writeln('<tr bgcolor=#999999><td colspan=6 width=100% height=22>'+topHTML+'</td></tr>');

document.writeln('</table></td><td width=25%><table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td valign=top><img src='+idomain+'/c7/m1.gif width=20 height=22></td>'+itemString+'</tr><tr><td bgcolor=#999999 height=3 colspan=3><img src='+idomain+'/ac/b.gif width=100 height=1></td></tr></table></td></tr><tr><td colspan=2 bgcolor=black height=3><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr></table>');

for(i=0; i<main.length; i++)
{
  if(NS4)
    document.writeln('<layer id=main'+i+' Z-INDEX=5 width=162 top='+eval(i*20+200+logoHeight+heightAdj)+' left=6 bgcolor=#999999 onmouseover="displayMenu('+"'"+i+"'"+', this);" onmouseout=setMenuTimer();><table cellspacing=0 cellpadding=0 border=0 width=162 height=22><tr><td bgcolor=black><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr><tr><td bgcolor=white><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr><tr><td align=center height=18 nowrap><a class=maincat7 href="'+menuBase+main[i].url+'">'+main[i].title+'</a></td></tr><tr><td bgcolor=black><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr><tr><td bgcolor=white><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr></table></'+layerType+'>');
  else
    {
      document.writeln('<div id=main'+i+' style="position: absolute; background-color: #999999; Z-INDEX: 5; width=162; top: '+eval(i*20+200+logoHeight+heightAdj)+'; left: 6;"><table cellspacing=0 cellpadding=0 border=0 width=162 height=22 onmouseover="displayMenu('+"'"+i+"'"+', this);" onmouseout=setMenuTimer(); onclick=getDestination(null);><tr><td bgcolor=black><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr><tr><td bgcolor=white><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr><tr><td align=center height=18 nowrap><a class=maincat7 href="'+menuBase+main[i].url+'">'+main[i].title+'</a></td></tr><tr><td bgcolor=black><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr><tr><td bgcolor=white><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr></table></'+layerType+'>');
      if(IE4) eval(layerText+'["'+'main'+i+'"]'+styleText+'.cursor="hand"');
    }	
}

for(i=0; i<main.length; i++)
{
  if(NS4)
    {
      if(main[i].sub==1)
	{
	  smWidth=eval('sub'+i+'.smWidth');
	  for(j=0; j<eval('sub'+i+'.length'); j++)
	    {   
	      document.writeln('<layer id=sub'+i+j+' Z-INDEX=5 bgcolor=#999999 width='+smWidth+' TOP='+eval(i*20+j*17+202+logoHeight+heightAdj)+' LEFT=169 VISIBILITY=hidden onmouseover="subMenuIn('+"'"+i+"', '"+j+"', this)"+'" onmouseout="subMenuOut('+"'"+i+"'"+", '"+j+"', this)"+'"><table cellspacing=0 cellpadding=0 border=0 width='+smWidth+' height=17><tr><td align=center height=17 nowrap><a class=subcat7 href="'+menuBase+eval('sub'+i+'['+j+'].url')+'">'+eval('sub'+i+'['+j+'].title')+'</a></td></tr></table></layer>');
	    }	
	}	
    }
  else
    {
      if(main[i].sub==1)
	{
	  smWidth=eval('sub'+i+'.smWidth');
	  
	  document.writeln('<div id=sub'+i+' style="position: absolute; width='+smWidth+'; Z-INDEX: 5; TOP: eval(i*20+202+logoHeight+heightAdj); LEFT: 169; VISIBILITY: hidden;"><table cellspacing=0 cellpadding=0 border=0 bgcolor=#999999><tr><td width=1 bgcolor=#9999ff><img src='+idomain+'/ac/b.gif width=1 height=1></td><td><table cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=#9999ff height=1><img src='+idomain+'/ac/b.gif width='+smWidth+' height=1></td></tr>');
	  
	  for(j=0; j<eval('sub'+i+'.length'); j++) 
	    document.writeln('<tr><td bgcolor=#999999 height=17 align=center valign=top nowrap onmouseover="subMenuIn('+"'"+i+"', '"+j+"', this)"+'" onmouseout="subMenuOut('+"'"+i+"'"+", '"+j+"', this)"+'" onclick=getDestination(null)><a class=subcat7 href="'+menuBase+eval('sub'+i+'['+j+'].url')+'">'+eval('sub'+i+'['+j+'].title')+'</a></td></tr>');
	  
	  document.writeln('<tr><td bgcolor=#9999ff height=1><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr></table></td><td width=1 bgcolor=#9999ff><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr></table></div>');

	  if(IE4) eval(layerText+'["'+'sub'+i+'"]'+styleText+'.cursor="hand"');
	}
    }
}

if(NS4)
{
  for(i=0; i<eval(layerText+'.length'); i++)
    {
      eval(layerText+'['+i+'].captureEvents(Event.MOUSEUP)');
      eval(layerText+'['+i+'].onmouseup=getDestination');
    }
}
