<!--
var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;
var ns6 = (!document.all && document.getElementById)? true : false;


var mac = navigator.platform.indexOf('Mac');

var way2show = (ns4) ? "show" : "visible";
var way2hide = (ns4) ? "hide" : "hidden";

var noSwitch="";

//var reloaded = 0;

if (ns4)
  {
    var originalWidth = innerWidth;
    var originalHeight = innerHeight;
  }

function OpenLayerCode(layerId, layerBg, layerZIndex, layerWidth, layerHeight, layerLeft, layerTop, layerClass, layerVisibility, layerMouseOver, layerMouseOut, layerOnClick){
  var stuff = "<layer id=\"" + layerId + "\" Z-INDEX=" + layerZIndex + " BGCOLOR=\"" + layerBg + "\" WIDTH=" + layerWidth + " HEIGHT=" + layerHeight + " LEFT=" + layerLeft + " TOP=" + layerTop + " class=\"" + layerClass + "\" VISIBILITY=\"" + layerVisibility + "\" onmouseover=\"" + layerMouseOver + "\" onmouseout=\"" + layerMouseOut + "\" onFocus=\"" + layerOnClick + "\">\n";
  return stuff;
}

function CloseLayerCode(){
  return('</layer>');
}

function OpenDivCode(divId, divBg, divZIndex, divWidth, divHeight, divLeft, divTop, divClass, divVisibility, divMouseOver, divMouseOut, divOnClick){
  var stuff = "<div id=\"" + divId + "\" align=\"right\" class=\"" + divClass + "\" style=\"position:absolute; left:" + divLeft +"px; top:"+ divTop +"px; width:" + divWidth + "px; height:" + divHeight + "px; z-index:" + divZIndex + "; background-color:" + divBg + "; visibility:" + divVisibility + "; \" onmouseover=\"" + divMouseOver + "\" onmouseout=\"" + divMouseOut + "\" onclick=\"" + divOnClick + "\">\n";
  return stuff;
}

function CloseDivCode(){
  return('</div>');
}

//ack this is ugly
var subCats = new UcgArray();

//Create a new Category Object.  Expects catagory, name, id, itemTop, itemLeft, and then Family names and ids

function CategoryItem(){
  //alert('category item');
  document.link = '#FFFFFF';
  this.cat = arguments[0];
  this.name = arguments[1];
  this.id = arguments[2];
  this.image = new Image();
  this.on_image = new Image();
  var src = PREFIX + this.id + POSTFIX;
  this.image.src = src;
  src = PREFIX + this.id + OVERFIX;
  this.on_image.src = src;
  var style = '';
  var width =  FAMILY_WIDTH - 2 * FAMILY_BORDER;
  this.itemTop = arguments[3];
  this.itemLeft = arguments[4];
  //alert(this.name + ' top=' + this.itemTop + ' left=' + this.itemLeft);
  this.genericArrow = arguments[5];
  this.subMenuOffset = arguments[6];
  var subMenuHeight = ARROW_HEIGHT + (FAMILY_HEIGHT + BAR_HEIGHT) * ((arguments.length - 6) / 2);
  if (arguments.length > 6) 
    if(ns4){
      if(mac != -1) 
        style = 'macNetscapeStyle';
      else
        style = 'pcNetscapeStyle';
      this.tempCode = OpenLayerCode("top" + this.id,MENU_BG_COLOR,1,'\"\"','\"\"',this.itemLeft,this.itemTop,"\"\"",way2show,"showFamilies('" + this.id + "');","hideFamilies('" + this.id + "');",''); 
      this.tempCode += '<a href="'+HTTP_SERVER+'/subcat/subcat.jsp?pageId=' + this.id + '"><img name="img' + this.id + '" src="' + this.image.src + '" height=' + this.image.height + ' width=' + this.image.width + ' alt="' + this.name + '" border=0></a>'; 
      this.tempCode += CloseLayerCode() + "\n";
      document.write(this.tempCode);
      this.tempCode = '';
      this.tempCode += OpenLayerCode("drp" + this.id,MENU_BG_COLOR,2,'\"\"','\"\"',this.itemLeft + this.subMenuOffset,this.itemTop + this.image.height,style,way2hide,"showFamilies('" + this.id + "');","hideFamilies('" + this.id + "');",'');   
      this.tempTop = 0;
      this.tempCode += OpenLayerCode("aro" + this.id,MENU_BG_COLOR,3,FAMILY_WIDTH,ARROW_HEIGHT,0,this.tempTop,"","inherit","","","");
      if(this.genericArrow){
        this.tempCode +='<img src="' + PREFIX + GENERIC_ARROW_IMAGE_NAME + '" height=' + ARROW_HEIGHT + ' width=' + FAMILY_WIDTH + '>';
      }else{
        this.tempCode +='<img src="' + PREFIX + this.id + ARROW_IMAGE_POSTFIX + '" height=' + ARROW_HEIGHT + ' width=' + FAMILY_WIDTH + '>';
      }
      this.tempTop += ARROW_HEIGHT;
      this.tempCode += CloseLayerCode() + "\n";
      for(var ct = 7; ct < arguments.length; ct += 2){
        this.tempCode += OpenLayerCode("fam" + arguments[ct+1],MENU_BG_COLOR,3,FAMILY_WIDTH - 2 * FAMILY_BORDER,FAMILY_HEIGHT, FAMILY_BORDER,this.tempTop,style,"inherit","familyItemOver(this);","familyItemOut(this);","");
        this.tempCode +='<a class="whiteLink" href="'+HTTP_SERVER+'/fam/fam.jsp?pageId=' + arguments[ct+1] + '">'+ arguments[ct] + '&nbsp;</a>';
        this.tempCode += CloseLayerCode() + "\n";
        this.tempTop += FAMILY_HEIGHT;
        this.tempCode += OpenLayerCode("bar" + arguments[ct+1],MENU_BG_COLOR,3,FAMILY_WIDTH,BAR_HEIGHT,0,this.tempTop,"","inherit","","","");
        this.tempCode += '<img src="' + PREFIX + BAR_IMAGE_NAME + '" height=' + BAR_HEIGHT + ' width=' + FAMILY_WIDTH + '>';
        this.tempCode += CloseLayerCode() + "\n";
        this.tempTop += BAR_HEIGHT;
      }
      this.tempCode += CloseLayerCode() + "\n";
  
    }else if(ie4 || ns6){
      if(mac != -1) 
        style = 'macIeStyle';
      else if(ie4)
        style = 'pcIeStyle';
      else if(ns6)  
        style = 'pcNetscapeStyle';
      // let's try starting with a width of 2 and changing that after load...
      this.tempCode = OpenDivCode("top" + this.id, MENU_BG_COLOR,1,2,SUB_CAT_HEIGHT,this.itemLeft,this.itemTop,"",way2show,"showFamilies('" + this.id + "');","hideFamilies('" + this.id + "');",'');
      this.tempCode += '<a href="'+HTTP_SERVER+'/subcat/subcat.jsp?pageId=' + this.id + '"><img name="img' + this.id + '" src="' + this.image.src + '" alt="' + this.name + '" border=0></a>'; 
      this.tempCode += CloseDivCode() + "\n";
      this.tempCode += OpenDivCode("drp" + this.id,MENU_BG_COLOR,2,FAMILY_WIDTH, subMenuHeight,this.itemLeft + this.subMenuOffset,this.itemTop + SUB_CAT_HEIGHT,style,way2hide,"showFamilies('" + this.id + "');","hideFamilies('" + this.id + "');",'');
      this.tempTop = 0;
      this.tempCode += OpenDivCode("aro" + this.id,MENU_BG_COLOR,3,FAMILY_WIDTH,ARROW_HEIGHT,0,this.tempTop,"","inherit","","","");
      if(this.genericArrow){
        this.tempCode +='<img src="' + PREFIX + GENERIC_ARROW_IMAGE_NAME + '" height=' + ARROW_HEIGHT + ' width=' + FAMILY_WIDTH + '>';
      }else{
        this.tempCode +='<img src="' + PREFIX + this.id + ARROW_IMAGE_POSTFIX + '" height=' + ARROW_HEIGHT + ' width=' + FAMILY_WIDTH + '>';
      }
      this.tempTop += ARROW_HEIGHT;
      this.tempCode += CloseDivCode() + "\n";
      for(ct = 7; ct < arguments.length; ct+=2){
        this.tempCode += OpenDivCode("fam" + arguments[ct+1],MENU_BG_COLOR,4,FAMILY_WIDTH - 2 * FAMILY_BORDER,FAMILY_HEIGHT,FAMILY_BORDER,this.tempTop,style,"inherit","familyItemOver(this);","familyItemOut(this);","goTo('"+HTTP_SERVER+"/fam/fam.jsp?pageId=" + arguments[ct+1] + "');");
        this.tempCode +='<a class="whiteLink" href="'+HTTP_SERVER+'/fam/fam.jsp?pageId=' + arguments[ct+1] + '">'+ arguments[ct] + '&nbsp;</a>';
        this.tempCode += CloseDivCode();
        this.tempTop += FAMILY_HEIGHT;
        this.tempCode += OpenDivCode("bar" + arguments[ct+1],MENU_BG_COLOR,4,FAMILY_WIDTH,BAR_HEIGHT,0,this.tempTop,"","inherit","","","");
        this.tempCode += '<img src="' + PREFIX + BAR_IMAGE_NAME + '"" height=' + BAR_HEIGHT + ' width=' + FAMILY_WIDTH + '>';
        this.tempCode += CloseDivCode();
        this.tempTop += BAR_HEIGHT;
      }
      this.tempCode += CloseDivCode() + "\n";
    }
  document.write(this.tempCode);
  //if(ie4)
  {
    // maintain an array of sub category ids for future use by ie
    var info = new Object;
    info.id = this.id;
    info.offset = this.subMenuOffset;
    subCats.push(info); 
  }
 delete this.tempCode;
}

function showFamilies(id){

  //alert('show families');
  if(id != noSwitch) {
    if(ns4) 
       document.layers['top'+id].document.images[0].src = PREFIX + id + OVERFIX; 
    else if(ie4 || ns6)
       document.images['img'+id].src = PREFIX + id + OVERFIX;
  }     
    
  if(ns4 || ns6) 
    show('drp'+id);
  else if (ie4)
  {
    var el = document.all['drp'+id];
    if((window.event.x >= el.style.pixelLeft || window.event.x <= el.style.pixelWidth + el.style.pixelRight) && (window.event.y >= el.style.pixelTop || window.event.y <= el.style.pixelTop + el.style.pixelHeight))
    {
      show('drp'+id);
      hideTags('select');
    }
  }
}

function hideFamilies(id){

  //alert('hide families');
  if(id != noSwitch) {
    if(ns4)
      document.layers['top'+id].document.images[0].src = PREFIX + id + POSTFIX;
    else if(ie4 || ns6)
      document.images['img'+id].src = PREFIX + id + POSTFIX;
  }

  if(ns4 || ns6)
    hide('drp'+id);
  else if (ie4)
  {
    var off = (mac != -1) ? 25 : 1;
    var el = document.all['drp'+id];
    if(window.event.x-off <= el.style.pixelLeft || window.event.x >= (el.style.pixelWidth + el.style.pixelLeft) || window.event.y-1 <= el.style.pixelTop || window.event.y >= (el.style.pixelTop + el.style.pixelHeight))
    {
      hide('drp'+id);
      if(window.event.x-off <= START_LEFT || window.event.x >= tempLeft || window.event.y-1 <= START_TOP || window.event.y >= (START_TOP + SUB_CAT_HEIGHT))
        showTags('select');
    }
  }
}

function familyItemOver(obj){
  if(ns4){
    obj.bgColor = MENU_OVER_BG_COLOR;
  }else{
    obj.style.backgroundColor = MENU_OVER_BG_COLOR;
  }
}

function familyItemOut(obj){
  if(ns4){
    obj.bgColor = MENU_BG_COLOR;
  }else{
    obj.style.backgroundColor = MENU_BG_COLOR;
  }
}

function SetCategory(){
/*
  var url = document.URL;
  var id = 0;
  var name = '';
  var img_name = '';

  var match = /.*subCatId=(\d+)/;

  if(url.match(match)) {
    id = url.match(match)[1];
    name = 'top' + id;
    noSwitch = id;
    if(ns4) 
    {
      if (document.layers[name]) { 
        document.layers[name].document.images[0].src = PREFIX + id + OVERFIX;
      }
    }
    else if(ie4){ 
       if (document.all['img' + id]) {
         document.all['img' + id].src = PREFIX + id + OVERFIX;
       }  
    }
    else if(ns6){ 
       if (document.getElementById('top' + id)) {
         document.getElementById('top' + id).src = PREFIX + id + OVERFIX;
       }  
    }
 } //if statement
*/
}
 
function CheckForBug(){
  for(i in document.layers){
    if(i.substing(0,3) == 'top'){
      if((document.layers[i].top == document.layers[i + "drp"].top) && (document.layers[i].left == document.layers[i + "drp"].left)){ if (true) alert("Found bug, reloading!"); window.setTimeout("location.reload();", 200); break;}
    }
  }
}

function Expand(){
    //alert('expand');
    //alert('ie4=' + ie4 + ' ns4=' + ns4 + ' ns6=' + ns6 + ' mac=' + mac);
  //if(ie4 && mac != -1)
  {
    if(DEBUG_FLAG) alert("expanding...");
    //oi, this is bound to be fun!
    var t=START_LEFT; 
    var el;
    var id;
    var te = '';
    //alert('sub cats = ' + subCats.length);
    for(var i=0; i<subCats.length; i++)
    {
      id = subCats[i].id;
      el = document.all['top'+id];
      el.style.pixelLeft = t;
      el.style.pixelWidth = document.all['img'+id].width;
      el.style.pixelHeight = document.all['img'+id].height;
      //alert('left=' + el.style.pixelLeft + ' width=' + el.style.pixelWidth);
      te += "for t = " + t + "\n" + el.id + " x = " + el.style.pixelLeft + " width = " + el.style.pixelWidth + " height = " + el.style.pixelHeight + "\n";
      el = document.all['drp'+id];
      el.style.pixelLeft = t+subCats[i].offset;
      el.style.pixelTop = START_TOP + SUB_CAT_HEIGHT;
      el.style.pixelWidth = FAMILY_WIDTH;
      //t+=document.all['top'+id].style.pixelWidth;
      t+=document.all['img'+id].width;
      //alert('diff=' + t);
    }
    /*
    if(reloaded == 0)
    {
      window.setTimeout("location.reload();", 200);
      reloaded = 1;
    }
    */
    /*
    var reload = readCookie('reloaded');
    if(reload == null)
    {
      if(checkCookieSupport())
      {
        createCookie('reloaded','1',0);
        window.setTimeout("location.reload();", 0);
      }
    }
    */
    
    //document.cookie = 'reload=0; expires=Thu, 2 Aug 2001 20:47:11 UTC; path=/';
    
    
    //CheckForBug();
  }
}  


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 var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function checkCookieSupport()
{
	createCookie('test','test',0);
	var result = readCookie('test');
	if(result == null)
	{
	  // no cookies
	  return false;
	}
	else
	{
	  // yes cookies
	  return true;
	}
}

//-->






