
var mnu = "&mnu=";
var selectedRecord = 0;



//Function Show ( layerId ) - Takes the numeric id and shows the given menu container.  
//Also swaps the arrow picture in the given Menu itemId
function show( layerId )
{
	//Test to make sure the object is valid and browser is IE compatible
    if ( document.getElementById && document.getElementById( "menuCont-" + layerId ) )
    {
        if ( document.getElementById( "menuCont-" + layerId ).className == "MenuContainerHidden" )
		{
			//Expand the sub menu of this id and create the string to pass the menu info to the next page
            document.getElementById( "menuCont-" + layerId ).className = "MenuContainerVisible";
			//mnu = mnu + "&mnu=" + layerId;
			mnu = mnu + layerId + ",";
			
			//Swap the Arrow picture of the Menu Item if it exists
			if ( document.getElementById( "menuItemPic-" + layerId ) )
				document.getElementById( "menuItemPic-" + layerId ).src = "images/menu1-arrow02.gif";
		}
        else
		{
			//Hide the sub menu of this id and remove that var from the string to pass
            document.getElementById( "menuCont-" + layerId ).className = "MenuContainerHidden";
			//mnu = mnu.replace( "&mnu=" + layerId, "" );
			mnu = mnu.replace( layerId + ",", "" );
			
			//Swap the Arrow picture of the Menu Item if it exists
			if ( document.getElementById( "menuItemPic-" + layerId ) )
				document.getElementById( "menuItemPic-" + layerId ).src = "images/menu1-arrow01.gif";
		}
    }
}


//Function Over( obj )  -  Takes an obj ref and depending on the class, 
//sets it to a mouseOver version of the class.
function menuOver( obj )
{
    if ( obj.className == "Category" )
        obj.className = "CategoryOver";

    else if ( obj.className == "CategoryOver" )
        obj.className = "Category";

    else if ( obj.className == "MenuItem" )
        obj.className = "MenuItemOver";

    else if ( obj.className == "MenuItemOver" )
        obj.className = "MenuItem";
}

//Function action( pass ) - Takes an argument to pass along in the href and then
//redirects the browser. usually pass should = an action or rec_id
function action( homepage, pass )
{
    window.location = homepage + "?" + pass + mnu;
}


//Function redirect( url ) - Takes a url argument to redirect the user.  If this url is
//external it should begin with 'http://' and will then be opened in a separate window.
//If it does not then the link will be treated as relative and open in the same window.
function redirect( url )
{
	if ( url != "" )
	{
		
		if ( url.substring( 0, 7 ) == "http://" )
		{	//Open a link in a new window
			window.open( url ); 
		}
		else
		{	//Open the link in the same window - Does not pass menu information
			 window.location = url
		}
	}
}

//Function setSelectedRecord( id ) - Takes an id to a record and sets this record as the
//currently selected item - this menu item will be highlighted and not change on mouseover.
function setSelectedRecord( id )
{
	if ( id > 0 )
	{
		selectedRecord = id;
		//alert( "The id is" + id );
		
		if ( document.getElementById && document.getElementById( "menuCategory-" + id ) )
    	{
			document.getElementById( "menuCategory-" + id ).className = "CategorySelected";
    	}
		else if	( document.getElementById && document.getElementById( "menuItem-" + id ) )
		{
			document.getElementById( "menuItem-" + id ).className = "MenuItemSelected";
		}
		else
		{
			//alert( id + " is not in the menu - its parent should probably be highlighted" );
		}
	}
}


//Function toggleDropMenuVisibilityIE( id, makeVisible ) - Takes an id to an element and a boolean
//value - True will make the element visible, false will make it hidden.
function toggleDropMenuVisibility( menuHead, menuId, makeVisible )
{
	if ( menuHead && menuId && document.getElementById( menuId ) )
	{
		if ( makeVisible)
		{
			//Make this group visible
			document.getElementById( menuId ).style.visibility = "visible";
			//document.getElementById( menuId ).style.display = "block";
			menuHead.className = "dropDownMenuOver";
		}
		else
		{
			//Make this group hidden
			document.getElementById( menuId ).style.visibility = "hidden";
			//document.getElementById( menuId ).style.display = "none";
			menuHead.className = "dropDownMenu";
		}
	}
}

function homeMiniOver( id, state )
{	
	var image;
	var src = new String();
	
	if ( id && document.getElementById( id ) )
	{
		image = document.getElementById( id )
		
		src = image.src;
		if( state )
			src = src.replace("_off", "_over");
		else
			src = src.replace("_over", "_off");
		
		image.src = src;
	}
}

