// 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 temp, windowWidth, allCatWidth, logoWidth=33, leftWidth, midWidth=1, rightWidth=135, edgeWidth, smWidth=160, totalWidth, center, loc, font, pressed=false;
var menuTimer = null;
var layerText, styleText, leftText, topText, appVer=navigator.appVersion;
var rtimer;

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

function showMenu(layerNumber, src)
{
  var i;
  
  if (menuTimer != null) 
    {
      clearTimeout(menuTimer);
	
      if(layerOn!=layerNumber)
        hideMenu(layerOn);
    }

  if(!pressed)
    {    
      mainIndex=layerNumber;
      subIndex=-1;
    }  
  
  if(DOM)
    document.getElementById('main'+layerNumber).style.backgroundColor='#6666ff';
  else if(NS4)
    eval(layerText+'["'+'main'+layerNumber+'"]'+'.document.bgColor="#6666ff"');
  else if(IE4)
    eval(layerText+'["'+'main'+layerNumber+'"]'+'.style.backgroundColor="#6666ff"');
  
  if(eval('main['+layerNumber+'].sub==1'))
    {
      if(DOM)
	document.getElementById('sub'+layerNumber).style.visibility='visible';
      else if(NS4)
	{
	  for(i=0; i<eval('sub'+layerNumber+'.length'); i++)
	    eval(layerText+'["'+'sub'+layerNumber+i+'"]'+styleText+'.visibility="visible"');
	}
      else if(IE4)
	eval(layerText+'["'+'sub'+layerNumber+'"]'+styleText+'.visibility="visible"');
    }
  
  layerOn = layerNumber;
}

function hideMenu(layerNumber)
{
  var i;
  
  if (menuOn == 0)
    {
      if(DOM)
	document.getElementById('main'+layerNumber).style.backgroundColor='#000099';
      else if(NS4)
	eval(layerText+'["'+'main'+layerNumber+'"]'+'.document.bgColor="#000099"');
      else if(IE4)
	eval(layerText+'["'+'main'+layerNumber+'"]'+'.style.backgroundColor="#000099"');
      
      if(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="#6666ff"');
  else 
    src.bgColor='#6666ff';

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

  if(NS4)
    eval(layerText+'["'+'sub'+main+sub+'"]'+'.document.bgColor="#000099"');
  else
    src.bgColor='#000099';
  
  menuTimer = setTimeout("hideMenu(layerOn)", 700);
}

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

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 getCatLocation()
{
  var i;
  var cur = Math.round((leftWidth-allCatWidth)/2)+33;

  for(i=0; i<main.length; i++)
    {
      main[i].location=cur;
      cur=cur+main[i].width;
    }
}

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);
    }
}

windowWidth = Math.max(610, windowWidth);

font=10;
allCatWidth = getAllCatWidth(10, main);

if(IE4)
  sl=15;
else if(NS4)
  sl=9;
else
  sl=7;

edgeWidth=1;
if(windowWidth>980)
{
  edgeWidth=15;
  rightWidth=rightWidth+30;
  sl=sl+2;
}
else if(windowWidth>760)
{  
  edgeWidth=8;
  rightWidth=rightWidth+15;
  sl=sl+1;
}

leftWidth = Math.max(windowWidth-logoWidth-midWidth-rightWidth-edgeWidth, allCatWidth); 
totalWidth = logoWidth+leftWidth+midWidth+rightWidth+edgeWidth;

getCatLocation();

if(ot=='f')
  {
    myTop[4].url=myTop[0].url;
    myTop[4].title=myTop[0].title;
  }


for(i=0; i<main.length; i++)
{
  if(NS4)
    document.writeln('<layer id=main'+i+' Z-INDEX=5 top='+eval(69+logoHeight+heightAdj)+' bgcolor=#000099 width='+main[i].width+' left='+main[i].location+' onmouseover="showMenu('+"'"+i+"'"+', this);" onmouseout=setMenuTimer();><table cellspacing=0 cellpadding=0 border=0 width='+main[i].width+' height=24>');
  else
    document.writeln('<div id=main'+i+' style="position: absolute; Z-INDEX: 5; background-color: #000099; width='+main[i].width+'; top:'+eval(69+logoHeight+heightAdj)+'; left: '+main[i].location+';"><table cellspacing=0 cellpadding=0 border=0 width='+main[i].width+' height=24 onmouseover="showMenu('+"'"+i+"'"+', this);" onmouseout=setMenuTimer(); onclick=getDestination(null);>'); 
  
  document.writeln('<tr><td width=1 rowspan=3><img src='+idomain+'/c5/t1.gif width=1 height=24></td><td width='+(main[i].width-2)+' height=1><img src='+idomain+'/c5/t1.gif width='+(main[i].width-2)+' height=1></td><td width=1 rowspan=3><img src='+idomain+'/c5/t1.gif width=1 height=24></td></tr><tr><td align=center height=22><table cellspacing=0 cellpadding=0 border=0 width='+(main[i].width-2)+' height=22><tr><td width=1 rowspan=3><img src='+idomain+'/c5/t2.gif width=1 height=22></td><td width='+(main[i].width-4)+' height=1><img src='+idomain+'/c5/t2.gif width='+(main[i].width-4)+' height=1></td><td width=1 rowspan=3><img src='+idomain+'/c5/t2.gif width=1 height=22></td></tr><tr><td nowrap align=center height=20><a class=WB10NY href="'+menuBase+main[i].url+'">'+main[i].title+'</a></td></tr><tr><td height=1><img src='+idomain+'/c5/t2.gif width='+(main[i].width-4)+' height=1></td></tr></table></td></tr><tr><td height=1><img src='+idomain+'/c5/t1.gif width='+(main[i].width-2)+' height=1></td></tr></table></'+layerType+'>');

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

for(i=0; i<main.length; i++)
{
  if(main[i].sub==1)
    {
      smWidth=eval('sub'+i+'.smWidth');
      if(NS4)
	{	  
	  for(j=0; j<eval('sub'+i+'.length'); j++)
	    {   
	      document.writeln('<layer id=sub'+i+j+' Z-INDEX=5 bgcolor=#000099 width='+(smWidth-2)+' TOP='+eval(j*16+93+logoHeight+heightAdj)+' LEFT='+(main[i].location+1)+' VISIBILITY=hidden onmouseover="subMenuIn('+"'"+i+"', '"+j+"', this)"+'" onmouseout="subMenuOut('+"'"+i+"'"+", '"+j+"', this)"+'"><table cellspacing=0 cellpadding=0 border=0 width='+(smWidth-2)+' height=17><tr><td width=1 rowspan=3><img src='+idomain+'/c5/t2.gif width=1 height=17></td><td width='+(smWidth-4)+' height=1><img src='+idomain+'/c5/t2.gif width='+(smWidth-4)+' height=1></td><td width=1 rowspan=3><img src='+idomain+'/c5/t2.gif width=1 height=17></td></tr><tr><td align=center nowrap height=15><a class=WB9NY href="'+menuBase+eval('sub'+i+'['+j+'].url')+'">'+eval('sub'+i+'['+j+'].title')+'</a></td></tr><tr><td height=1><img src='+idomain+'/c5/t2.gif width='+(smWidth-4)+' height=1></td></tr></table></layer>');
	    }
	}
      else
	{
	  document.writeln('<div id=sub'+i+' style="position: absolute; Z-INDEX: 5; background-color: #000099; width='+(smWidth-2)+'; TOP:'+eval(93+logoHeight+heightAdj)+'; LEFT: '+(main[i].location+1)+'; VISIBILITY: hidden;"><table cellspacing=0 cellpadding=0 border=0><tr><td width=1 bgcolor=#cc99ff><img src='+idomain+'/ac/b.gif width=1 height=1></td><td><table cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=#cc99ff height=1><img src='+idomain+'/ac/b.gif width='+(smWidth-2)+' height=1></td></tr>');
	  
	  for(j=0; j<eval('sub'+i+'.length'); j++)
	    document.writeln('<tr><td height=15 align=center valign=top nowrap onmouseover="subMenuIn('+"'"+i+"', '"+j+"', this)"+'" onmouseout="subMenuOut('+"'"+i+"'"+", '"+j+"', this)"+'" onclick=getDestination(null)><a class=WB9NY href="'+menuBase+eval('sub'+i+'['+j+'].url')+'">'+eval('sub'+i+'['+j+'].title')+'</a></td></tr><tr><td bgcolor=#cc99ff height=1 onmouseover="clearTimeout(menuTimer); menuOn = 1;" onmouseout="menuOn=0; menuTimer=setTimeout('+"'"+'hideMenu(layerOn)'+"'"+', 700);" onclick=getDestination(null)><img src='+idomain+'/ac/b.gif width=1 height=1></td></tr>');
	  
	  document.writeln('</table></td><td width=1 bgcolor=#cc99ff><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');
    }
}

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');
}




