var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
function getRef(id)
{
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}
function getSty(id)
{
	return (isNS4 ? getRef(id) : getRef(id).style);
}
var popTimer = 0;
var litNow = new Array();
var stayCol = -1;
function popOver(menuNum, itemNum)
{
	stayCol=1;
	clearTimeout(popTimer);
	hideAllBut(menuNum);
	targetNum = menu[menuNum][itemNum].target;
	if (targetNum > 0)
	{
		thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
		thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
		with (menu[targetNum][0].ref)
		{
			left = parseInt(thisX + menu[targetNum][0].x);
			top = parseInt(thisY + menu[targetNum][0].y);
			visibility = 'visible';
         display = "block";
		}
		if (MSIE && document.getElementById('searchLayer') && itemNum == 3)
		{
			document.getElementById('searchLayer').style.clip="rect(0 557 250 130)";
			document.getElementById('searchDummy').style.visibility="visible";
		}
   }
}
function popOut(menuNum, itemNum)
{
	if ((menuNum == 0) && !menu[menuNum][itemNum].target)
	{
		hideAllBut(0);
		stayCol=0;
	}
	else
	{
		popTimer = setTimeout('hideAllBut(0)', 500);
		stayCol=0;
	}
}
function getTree(menuNum, itemNum)
{
	itemArray = new Array(menu.length);
	while(1)
	{
		itemArray[menuNum] = itemNum;
		if (menuNum == 0)
			return itemArray;
		itemNum = menu[menuNum][0].parentItem;
		menuNum = menu[menuNum][0].parentMenu;
   }
}
var tempMainNum = "";
function sendColor(menuNum,itemNum,main)
{
	if (tempMainNum != "" && tempMainNum != String(menuNum) + String(itemNum))
	{
		changeCol(litNow,false,main);
	}
	litNow = getTree(menuNum,itemNum);
	changeCol(litNow,true,main);
	tempMainNum = String(menuNum) + String(itemNum);
}
function resetColor(menuNum,itemNum,main)
{
	changeCol(litNow,false,main);
}
function changeCol(changeArray,isOver,main)
{
	for (menuCount = 0; menuCount < changeArray.length; menuCount++)
	{
		if (changeArray[menuCount])
		{
			if(menuCount == 0)
			{
				var newCol = isOver ? menu[menuCount][0].overColPrimary : menu[menuCount][0].backCol;
				var newTextClass = isOver ? menu[menuCount][0].textOverPrimaryClass : menu[menuCount][0].textPrimaryClass;
			}
			else
			{
				var newCol = isOver ? menu[menuCount][0].overColLayer : menu[menuCount][0].backCol;
				var newTextClass = isOver ? menu[menuCount][0].textOverLayerClass : menu[menuCount][0].textLayerClass;
			}
			itemName = 'menu' + menuCount + 'item' + changeArray[menuCount];
			anchorName = 'anchorMenu'  +menuCount + changeArray[menuCount];
			if(MSIE && menuCount == 0 && main ==1)
         {
				getRef(anchorName).className = newTextClass;
			}
			else if(N6x && menuCount == 0 && main ==1)
			{
				document.anchors[anchorName].className = newTextClass;
			}
			with (menu[menuCount][changeArray[menuCount]].ref)
			{
				if (main == 1)
				{

						backgroundColor = newCol;

         	}
				else if (itemName.indexOf("menu0") == -1)
				{

						backgroundColor = newCol;

				}
			}
     	}
   }
}
function hideAllBut(menuNum)
{
	if (menuNum==0 && stayCol == 0)
	{
		changeCol(litNow, false,1);
	}
	var keepMenus = getTree(menuNum, 1);
	for (count = 0; count < menu.length; count++)
	if (!keepMenus[count])
		menu[count][0].ref.visibility = 'hidden';
      /* // menu[count][0].ref.display = "none"; */
	if (MSIE && document.getElementById("searchLayer") && menuNum != 3)
	{
		document.getElementById('searchLayer').style.clip="rect(0 557 250 0)";
		document.getElementById('searchDummy').style.visibility="hidden";
	}
}
function Menu(isVert, popInd, x, y, width, overColPrimary, overColLayer, backCol,  borderClass, textPrimaryClass, textLayerClass, textOverPrimaryClass, textOverLayerClass)
{
	/* // True or false - a vertical menu? */
	this.isVert = isVert;
	this.popInd = popInd;
	this.x = x;
	this.y = y;
	this.width = width;
	this.overColPrimary = overColPrimary;
	this.overColLayer = overColLayer;
	this.backCol = backCol;
	this.borderClass = borderClass;
	this.textPrimaryClass = textPrimaryClass;
	this.textLayerClass = textLayerClass;
	this.textOverPrimaryClass = textOverPrimaryClass;
	this.textOverLayerClass = textOverLayerClass;
	this.currentTextClassPrimary = textPrimaryClass;
	this.currentTextClassLayer = textLayerClass;
	this.parentMenu = null;
	this.parentItem = null;
	this.ref = null;
}
function Item(text, href, frame, length, spacing, target)
{
	this.text = text;
	this.href = href;
	this.frame = frame;
	this.length = length;
	this.spacing = spacing;
	this.target = target;
	this.ref = null;
}
/* var prefixPluginMain=""; */
var prefixPluginMain="../media/siteimg/";

var menuWritten=0;
function writeMenus()
{
	if (!isDOM && !isIE4 && !isNS4) return;
    	for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0])
    	{
		var str = '', itemX = 0, itemY = 0;
		for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem])
    		{
			if((currMenu >0) && (currItem == 1))
			{
				itemY += 2;
			}
		            var itemID = 'menu' + currMenu + 'item' + currItem;
		            var w = (isVert ? width : length);
						var innerw = w-4;
		            var h = (isVert ? length : width);
			if((currItem ==  (menu[currMenu].length - 1)) && (currMenu > 0))
			{
				h -= 2;
			}
            if (isDOM || isIE4)
            {
		/* // str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; visibility: inherit; z-index: 50;'; */
      str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; z-index: 50;';
		if (backCol) str += 'background: ' + backCol + '; ';
	           str += '" ';
          		}
            if (borderClass) str += 'class="' + borderClass + '" ';

	var anchorid='anchorMenu'  +currMenu + currItem;

            if ((currMenu > 0) )
          		{
		// Add mouseover handlers and finish div.
      str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';
		str += '<table width="' + (w) + '" border="0" cellspacing="0" cellpadding="0">';
		str += '<tr><td bgcolor="#A9A9A9" height="1" colspan="5"></td></tr>';
		str += '<tr><td bgcolor="#A9A9A9" width="1"></td><td bgcolor="#FFFFFF" width="1"></td>';
		str += '<td bgcolor="#FFFFFF" width="156" ></td><td bgcolor="#FFFFFF" width="1"></td><td bgcolor="#A9A9A9" height="1"></td></tr>';

		str += '<tr><td bgcolor="#A9A9A9" width="1"></td><td bgcolor="#FFFFFF" width="1"></td>';
		str += '<td align="left" height="' + (h) + '">' + '<a name="' + anchorid + '" onMouseOver="sendColor(' + currMenu + ',' + currItem + ',0)" onmouseout="resetColor(' + currMenu + ',' + currItem + ',0)" class="' + currentTextClassLayer + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>') + text + '</a></td>';
		str += '<td bgcolor="#FFFFFF" width="1"></td><td bgcolor="#A9A9A9" width="1"></td>';
	}
            if ((currMenu == 0))
          		{
		// Add mouseover handlers and finish div.
          str += '>';
		str += '<table width="' + (w) + '" border="0" cellspacing="0" cellpadding="0">';
		str += '<tr><td bgcolor="#A9A9A9" height="1" width="' + w + '" colspan="4"></td></tr>';
		str += '<tr><td bgcolor="#A9A9A9" width="1"></td><td bgcolor="#FFFFFF" width="1"></td>';
		str += '<td bgcolor="#FFFFFF" width="' + innerw + '" ></td><td bgcolor="#FFFFFF" width="1"></td></tr>';
		str += '<tr><td bgcolor="#A9A9A9" width="1"></td><td bgcolor="#FFFFFF" width="1"></td>';
		str += '<td align="center" width="' + innerw + '" height="' + (h) + '">' + '<a name="' + anchorid + '" onMouseOver="sendColor(' + currMenu + ',' + currItem + ',1);popOver(' + currMenu + ',' + currItem + ');" onMouseOut="popOut(' + currMenu + ',' + currItem + ');" class="' + currentTextClassPrimary + '" href="' + href + '"' +(frame ? ' target="' + frame + '">' : '>') + text + '</a></td>';
		str += '<td bgcolor="#FFFFFF" width="1"></td></tr>';
		str += '<tr><td bgcolor="#A9A9A9" height="1" colspan="4"></td>';
          		}
            if (target > 0)
          		{
		/* // Set target's parents to this menu item. */
		menu[target][0].parentMenu = currMenu;
		menu[target][0].parentItem = currItem;

		/* // Add a popout indicator. */
		if (popInd)
			str += '<td class="' + textClass + '" align="right">' + popInd + '</td>';
          		}
	if(currItem == (menu[currMenu].length-1) && (currMenu >0))
	{
		str += '<tr><td bgcolor="#A9A9A9" height="1" colspan="5"></td></tr>';
	}
	str += '</tr></table></div>';

   if (isVert)
	{
		itemY += length + spacing;
	}
          		else
	{
		itemX += length + spacing;
	}
}
if (isDOM)
{
       var newDiv = document.createElement('div');
       document.getElementsByTagName('body').item(0).appendChild(newDiv);
       newDiv.innerHTML = str;
       ref = newDiv.style;
       ref.position = 'absolute';
       /* // ref.visibility = 'hidden'; */
       ref.zIndex = '50';
       ref.display = "none";
}
if (isIE4)
{
   document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden; z-index:50;">' + str + '</div>');
   ref = getSty('menu' + currMenu + 'div');
    }
for (currItem = 1; currItem < menu[currMenu].length; currItem++)
{
            itemName = 'menu' + currMenu + 'item' + currItem;
            if (isDOM || isIE4)
		menu[currMenu][currItem].ref = getSty(itemName);
	           if (isNS4)
		menu[currMenu][currItem].ref = ref.document[itemName];
    }
	}
	with(menu[0][0])
	{
		ref.left = x;
		ref.top = y;
		/* // ref.visibility = 'visible'; */
      ref.display = "block";
	}
	menuWritten=1;
} /* // end of writemenu() */
var menu = new Array();
var defOverPrimary = '#FF9900';
var defOverLayer='#FFFFFF';
var defBack = '#E5E5E5';
var defLength = 21;
PrintMouseOver = new Image();
PrintMouseOver.src = prefixPluginMain + "printIcon_rollover.gif";
PrintNormal = new Image();
PrintNormal.src = prefixPluginMain + "printIcon.gif";
BackMouseOver = new Image();
BackMouseOver.src = prefixPluginMain + "backIcon_rollover.gif";
BackNormal = new Image();
BackNormal.src = prefixPluginMain + "backIcon.gif";
TopMouseOver = new Image();
TopMouseOver.src = prefixPluginMain + "topIcon_rollover.gif";
TopNormal = new Image();
TopNormal.src = prefixPluginMain + "topIcon.gif";
var popOldWidth = window.innerWidth;
nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');
if (isNS4)
	document.captureEvents(Event.CLICK);
document.onclick = clickHandle;
function clickHandle(evt)
{
	if (isNS4) document.routeEvent(evt);
	 hideAllBut(0);
}
function changeImage(Idx, Image)
{
	window.document.images[Idx].src = Image.src;
}
var win;
var winPath="";
function openBrWindow(theURL,winName,features)
{
   if ((typeof win != 'object') || (typeof win == 'object' && win.closed))
	{
      win = window.open(theURL,winName,features);
      win.opener = self;
      win.focus();
   }
   else
   {
      if (winPath != theURL)
		{
			win.location.href = theURL;
		}
      win.focus();
      winPath = theURL;
   }
}
function openAppWindow(theURL,winName,features)
{
   var appWindow=null;
   appWindow = window.open(theURL,winName,features);
   appWindow.opener = self;
   appWindow.focus();
}


