
var left_on = '/imagespublic/northNavDivider_left-over.gif';
var right_on = '/imagespublic/northNavDivider_right-over.gif';
var end_on = '/imagespublic/northNavDividerEnd_right-over.gif';
var both_off = '/imagespublic/northNavDivider.gif';
var end_off= '/imagespublic/northNavDividerEnd.gif';
var both_on = '/imagespublic/northNavDivider_both-over.gif';

//preload images
var lefton = new Image();		
lefton.src = left_on;
var righton = new Image();		
righton.src = right_on;
var endon = new Image();		
endon.src = end_on;
var bothoff = new Image();		
bothoff.src = both_off;
var endoff = new Image();		
endoff.src = end_off;
var bothon = new Image();		
bothon.src = both_on;

function SwapImages( index, on)
{
	
		
	if (on)
	{
		if (document['curve_' + (index - 1)] != null)
		{
			//alert(document['curve_' + (index - 1)].src + '\r\n' + righton.src + '\r\n' + (document['curve_' + (index - 1)].src == righton.src));
			if (document['curve_' + (index - 1)].src == righton.src)
			{
				document['curve_' + (index - 1)].src = bothon.src;
				//alert("both");
			}
			else
			{
				document['curve_' + (index - 1)].src = lefton.src;
			}
		}
		if (document['curve_' + index] != null)
		{
			if (document['curve_' + (index +1)] != null)
			{
				//alert(document['curve_' + (index +1)].src);
				if ((document['curve_' + (index +1)].src == righton.src) ||
					(document['curve_' + (index +1)].src == endon.src)) 
				{
					document['curve_' + index].src = bothon.src;
				}
				else
				{
					document['curve_' + index].src = righton.src;
				}
			}
			else
			{
				document['curve_' + index].src = endon.src;
			}
		}
	}
	else
	{
		//alert('going out');
		if (document['curve_' + (index - 1)] != null)
		{
			if (document['curve_' + (index - 1)].src == bothon.src)
			{
				document['curve_' + (index - 1)].src = righton.src;
			}
			else
			{
				document['curve_' + (index - 1)].src = bothoff.src;
			}
		}
		if (document['curve_' + index] != null)
		{
			if (document['curve_' + (index +1)] != null)
			{
				if ( (document['curve_' + (index +1)].src == righton.src) ||
					(document['curve_' + (index +1)].src == endon.src)) 
				{
					document['curve_' + index].src = lefton.src;
				}
				else
				{
					document['curve_' + index].src = bothoff.src;
				}
			}
			else
			{
				document['curve_' + index].src = endoff.src;
			}
		}
		
	}
}

function HideLayer(pLayer, bCascade) {
	for (var i=0; i<pLayer.length; i++) {
		pLayer[i].visibility = "hide";
		if (bCascade)
			HideLayer(pLayer[i].document.layers, true);
	}
}
		
function HideDivTags() {
	var pDivs  = "";
	var sDivNm = ""		;
	if (navigator.family == "IE") 
		pDivs  = document.all.tags("div");	
	else
		pDivs  = document.getElementsByTagName("div");	

	for (var i=0; i<pDivs.length; i++) {
		sDivNm = pDivs[i].id;
		if (sDivNm.substr(0,3) == "mnu")
			pDivs[i].className = "hide";
	}
}
		
function Toggle(pAnkr, pDivLyr) {
							
	var nArgs = arguments.length;
	var pLayer = document.layers;
	
	switch (navigator.family) {
		case "IE":
			HideDivTags();
			//alert(document.all["mnuDropA"].id);
		break;
		case "nn":
			HideLayer(pLayer, true);
			//alert(document.layers["mnuDropA"]);
		break;
		case "gecko":
			HideDivTags();
			pDivLyr = document.getElementById(pDivLyr);
		break;
		default:
		break;
	}
	
	if (nArgs != 0) {				
		// check which browser we are
		var pDynElem = (pLayer ? pDivLyr.visibility : pDivLyr.className);
		//alert('test ' + pDivLyr + ' ' + pDynElem);
		// be smart about namimg display classes
		pDynElem = (pDynElem = "hide" ? "show" : "hide");
		
		// make the changes to the style or class
		switch(navigator.family) {
			case "nn":
				pDivLyr.visibility = pDynElem;
				if (pDynElem == "show") {
					pDivLyr.left = pAnkr.x;
					pDivLyr.top  = pAnkr.y + 15;
				}
			break;
			default:
				pDivLyr.className = pDynElem;
			break;
		}
	}
	return(false);
}

function OnMouseOutCheck(pDiv) 
{
	
	//return;
	switch(navigator.family) {
		case "IE":
			if (!pDiv.contains(event.toElement)) Toggle();
		break;
		case "nn":
			Toggle();
		break;
		case "gecko":
			var e;
			if (!window.event) e=arguments.callee.caller.arguments[0];
			if (!containsTag(e.currentTarget, e.relatedTarget))
			{
				var pDivTag = document.getElementById(pDiv);
				if (!containsTag(pDivTag, e.relatedTarget))
				{ 
					containsTag(pDivTag, e.relatedTarget);
					Toggle();
				}
			}
		break;
		default:
		break;
	}	
}

function containsTag(containerNode, containedNode) 
{ 
	while (containedNode) 
	{
		if (containedNode == containerNode)
			return true; 
		containedNode = containedNode.parentNode;
	}
	return false;
}

/*  */

function openShim(menu)
{
	if (menu==null) return;
    var shim = getShim(menu);
    if (shim==null) shim = createMenuShim(menu,getShimId(menu.id));
    
    shim.style.width = menu.offsetWidth;
    shim.style.height = menu.offsetHeight;
    shim.style.position = "absolute";
    shim.style.top = menu.offsetTop;
    shim.style.left = menu.offsetLeft; 
    //HD00328348 , 26 July 2006, Hgauthier
    if ( screen.width == "800" ){
		if ( (menu.offsetLeft + menu.offsetWidth) > 775){
			menu.style.left = menu.offsetLeft - ((menu.offsetLeft + menu.offsetWidth) - 775);
		}
    }
    shim.style.zIndex = menu.style.zIndex - 1;
    shim.style.display = "block";
 
}

//Closes the shim associated with the menu
function closeShim(menu)
{
	if (menu==null) return;
    var shim = getShim(menu);
    if (shim!=null) shim.style.display = "none";
}

//Creates a new shim for the menu
function createMenuShim(menu)
{
    if (menu==null) return null;
	var shim = document.createElement("<iframe scrolling='no' frameborder='0'"+" src='/PublicContent/blank.html' style='position:absolute; top:0px;"+"left:0px; display:none'></iframe>"); 
    
    shim.name = getShimId(menu);
    shim.id = getShimId(menu);
    //Unremark this line if you need your menus to be transparent for some reason
    //shim.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
	
    if (menu.offsetParent==null || menu.offsetParent.id=="") 
    {
        window.document.body.appendChild(shim);
    }
    else 
    {
        menu.offsetParent.appendChild(shim); 
    }

    return shim;
}

//Creates an id for the shim based on the menu id
function getShimId(menu)
{
    if (menu.id==null) return "__shim";
    return "__shim"+menu.id;
}

//Returns the shim for a specific menu
function getShim(menu)
{
    return document.getElementById(getShimId(menu));
}

function getMenuItemCount(menu)
{
    var count = 0;
    var child = menu.firstChild;

    while (child)
    {
        if (child.nodeName=="DIV") count = count + 1;
        child = child.nextSibling;
    }
    return count;    
}
