var blnIsMac = false
var strPlatform = window.navigator.platform.toLowerCase()

if (strPlatform.indexOf("mac") > -1)
{ blnIsMac = true; }

var strLastMenu = "mnu_home"

function showMenu(strMenu) {
	if (!blnIsMac) {

		var objLayer
	
		hideMenu(strLastMenu)
	
		if (document.all) {
			objLayer = document.all[strMenu]
		}
		else if (document.getElementById) {
			objLayer = document.getElementById(strMenu)
		}
		else if (document.layers) {
			objLayer = getLayer(strMenu)
		}
	
		// show
		if (document.all) {
			objLayer.style.visibility = "visible";
		}
		else if (document.getElementById) {
			objLayer.style.visibility = "visible"
		}
		else if (document.layers) {
			if (parseFloat(navigator.appVersion) >= 4.08) {
				// move to position relative to image
				objImage = getImage("l_" + strMenu.substring(3, strMenu.length))
				intTop = getImagePageTop(objImage)
				intLeft = getImagePageLeft(objImage)
				objLayer.top = intTop + objImage.height
				objLayer.left = intLeft - 1
				
				// show
				objLayer.visibility = "show"
			}
		}
	
		strLastMenu = strMenu
	}
}

function hideMenu(strMenu) {

	if (!blnIsMac) {

		var objLayer
		var isIn = false
		var i = 0
		var blnIsFromFlash = false
		
		if (strMenu == "hideFromFlash")
			blnIsFromFlash = true
	
		if (strMenu == "" || blnIsFromFlash)
			strMenu = strLastMenu
	
		if (document.all) {
			objLayer = document.all[strMenu]
		}
		else if (document.getElementById) {
			objLayer = document.getElementById(strMenu)
		}
		else if (document.layers) {
			objLayer = getLayer(strMenu)
		}
	
		// hide
		if (document.all) {
			if (!blnIsFromFlash) {
				while (!isIn && i < document.all[strMenu].all.length) {
					if (window.event.toElement == document.all[strMenu].all[i])
						isIn = true
					i++
				}
				if (!isIn) {
					document.all[strMenu].style.visibility = "hidden"
				}
			}
			else {
				document.all[strMenu].style.visibility = "hidden"
			}
		}
		else if (document.getElementById) {
			objLayer.style.visibility = "hidden"
		}
		else if (document.layers) {
			if (parseFloat(navigator.appVersion) >= 4.08) {
				objLayer.visibility = "hide"
			}
		}
	}
}

// Determine browser.

var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;

//-----------------------------------------------------------------------------
// Layer utilities.
//-----------------------------------------------------------------------------

function getLayer(name) {

  if (document.layers)
    return findLayer(name, document);
  if (isMinIE4)
    return eval('document.all.' + name);
  return null;
}

function findLayer(name, doc) {

  var i, layer;

  for (i = 0; i < doc.layers.length; i++) {
    layer = doc.layers[i];
    if (layer.name == name)
      return layer;
    if (layer.document.layers.length > 0)
      if ((layer = findLayer(name, layer.document)) != null)
        return layer;
  }
  return null;
}

function resizeField(dir, theField, position){
    if (dir == 'max') {
        var charLen = 7.1;
        var wLen = 0;
        var prevwidth = '';
        
        //How wide should the dropdown really be?
        for(var i=0; i < theField.options.length; i++)
            if (theField.options[i].text.length > wLen)
                wLen = theField.options[i].text.length
		var newwidth = wLen*charLen;
        
        //Figure out how wide the field is NOW
        if(theField.style.width && theField.style.width!='null')
			prevwidth = theField.style.width;
		if(!theField.oldWidth || theField.oldWidth=='undefined' || theField.oldWidth=='')
			theField.oldWidth = prevwidth;
		
		//Remember how wide the field is now
		if(prevwidth!='')
			prevwidth = parseInt(prevwidth.replace("px", "").replace("%", ""));
        
		//Change the field to be wider.
        theField.style.position = 'absolute';
		if(prevwidth < newwidth)
       		theField.style.width = newwidth;
		
		if(position == 'left')
		    theField.style.posLeft = prevwidth - newwidth;
		else 
		    theField.style.posLeft = 0;
    } else {
        theField.style.position = 'relative';
        if(theField.oldWidth)
	        theField.style.width = theField.oldWidth;
	    else
	        theField.style.width = '';
        theField.oldWidth = '';
        theField.style.posLeft = 0;
    }
}

function resizeCasesField(dir, theField, position){
    if (dir == 'max') {
        var charLen = 6.5;
        var wLen = 0;
        var prevwidth = '';
        
        //How wide should the dropdown really be?
        for(var i=0; i < theField.options.length; i++)
            if (theField.options[i].text.length > wLen)
                wLen = theField.options[i].text.length
		var newwidth = wLen*charLen;
        
        //Figure out how wide the field is NOW
        if(theField.style.width && theField.style.width!='null')
			prevwidth = theField.style.width;
		if(!theField.oldWidth || theField.oldWidth=='undefined' || theField.oldWidth=='')
			theField.oldWidth = prevwidth;
		
		//Remember how wide the field is now
		if(prevwidth!='')
			prevwidth = parseInt(prevwidth.replace("px", "").replace("%", ""));
        
		//Change the field to be wider.
		if (newwidth>0)
		{
            theField.style.position = 'absolute';
		    if(prevwidth < newwidth)
       		    theField.style.width = newwidth;
    		
		    if(position == 'left')
		        theField.style.posLeft = prevwidth - newwidth;
		    else 
		        theField.style.posLeft = 0;
		}
    } else {
        theField.style.position = 'relative';
        if(theField.oldWidth)
	        theField.style.width = theField.oldWidth;
	    else
	        theField.style.width = '';
        theField.oldWidth = '';
        theField.style.posLeft = 0;
    }
}