


// pragma page ""
// pragma page "Menu::Declarations::Globals"
////////////////////////////////////////////////////////////////
//
// Global variable declarations
//
////////////////////////////////////////////////////////////////
var gbInitMenu			= false;
var gbTimer				= false;
var gsLayerRef			= '';
var gsStyleRef			= '';
var gsVisibleRef		= '';
var gsMenuMain			= new Array();
var gsMenuAbout			= new Array();
var gsMenuServices		= new Array();
var gsMenuIndustryLinks		= new Array();
var gsMenuEmployment		= new Array();
var gsMenuContacts		= new Array();
var gTimeOut			= 1000;
var gTimerId			= null;


// pragma page "Menu::Object::MenuItem"
////////////////////////////////////////////////////////////////
//
// Constructor for MenuItem objects.
//
////////////////////////////////////////////////////////////////
function MenuItem( sDescription , sLink , vLevel )
{
	//
	// Init object
	//
	this.msDescription	= sDescription;
	this.msLink			= sLink;
	this.mLevel			= vLevel;
}



// pragma page "Menu::Function::BuildMenuArrays"
////////////////////////////////////////////////////////////////
//
// Create new objects
//
////////////////////////////////////////////////////////////////
function BuildMenuArrays()
{
	//
	// About menu
	//
	gsMenuAbout[ gsMenuAbout.length ]			= new MenuItem( "Corporate Profile"					, "../aboutus/corporateprofile.aspx"				, 1 );
	gsMenuAbout[ gsMenuAbout.length ]			= new MenuItem( "Management Team"				, "../aboutus/managementteam.aspx"				, 1 );
	gsMenuAbout[ gsMenuAbout.length ]			= new MenuItem( "Our Customers"					, "../aboutus/ourcustomers.aspx"				, 1 );
	gsMenuAbout[ gsMenuAbout.length ]			= new MenuItem( "What's New"			, "../aboutus/whatsnew.aspx"				, 1 );
	gsMenuAbout[ gsMenuAbout.length ]			= new MenuItem( "Blog"			, "http://cusinc.blogspot.com"				, 1 );

	//
	// Services menu
	//
	gsMenuServices[ gsMenuServices.length ]		= new MenuItem( "Underground Locating Services" , "../services/UndergroundLocatingServices.aspx"				, 1 );
	gsMenuServices[ gsMenuServices.length ]		= new MenuItem( "Sub-Surface Engineering"			, "../services/subsurface.aspx"			, 1 );
	gsMenuServices[ gsMenuServices.length ]		= new MenuItem( "Damage and Claims Management"			, "../services/dacmgmt.aspx"		, 1 );
	gsMenuServices[ gsMenuServices.length ]		= new MenuItem( "Field Audit and Compliance Verification"				, "../services/fieldaudit.aspx"			, 1 );
	gsMenuServices[ gsMenuServices.length ]		= new MenuItem( "Ticket Management"					, "../services/ticketmanagement.aspx"		, 1);

	//
	// Industry Links menu
	//
	gsMenuIndustryLinks[ gsMenuIndustryLinks.length ]	= new MenuItem( "Industry Organizations"	, "../industrylinks/industryorganizations.aspx"				, 1 );
	gsMenuIndustryLinks[ gsMenuIndustryLinks.length ]	= new MenuItem( "One Call Centers"		, "../industrylinks/onecallcenters.aspx"				, 1 );
	gsMenuIndustryLinks[ gsMenuIndustryLinks.length ]	= new MenuItem( "Frequently Asked Questions"					, "../industrylinks/faq.aspx"		, 1 );

	//
	// Employment menu
	//
	gsMenuEmployment[ gsMenuEmployment.length ]	= new MenuItem( "Open Positions"						, "../employment/openpositions.aspx"				, 1 );
	gsMenuEmployment[ gsMenuEmployment.length ]	= new MenuItem( "Application Form"					, "../employment/applicationform.aspx"				, 1 );

	//
	// Contacts menu
	//
	gsMenuContacts[ gsMenuContacts.length ]		= new MenuItem( "Corporate Phone List"						, "../contacts/corporatephonelist.aspx"				, 1 );
	gsMenuContacts[ gsMenuContacts.length ]		= new MenuItem( "State By State Contacts"				, "../contacts/statebystate.aspx"			, 1 );
	gsMenuContacts[ gsMenuContacts.length ]		= new MenuItem( "Request Information"					, "../contacts/requestinformation.aspx"			, 1 );
}


// pragma page "Menu::Function::GetMenuInfo"
////////////////////////////////////////////////////////////////
//
// Gets menu info
//
////////////////////////////////////////////////////////////////
function GetMenuInfo( sMenuCategory , sArray )
{
	var sMenu	= '';
	var sLevel	= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	var iMenuWidth = 144;
	if(sMenuCategory == 'Services')
	    iMenuWidth = 200;

	sMenu		+= '<table border="0" cellpadding="1" cellspacing="0" bgcolor="' + gsMenuBorder + '" width="'+ iMenuWidth +'">';
	sMenu		+= '	<tr>';
	sMenu		+= '		<td>';
	sMenu		+= '			<table border="0" cellpadding="2" cellspacing="0" bgcolor="' + gsMenuBackground + '" width="'+ (iMenuWidth -2) +'">';

	for ( var i = 0; i < sArray.length; i++ )
	{
		if ( sArray[ i ].mLevel == 2 )
		{
			sMenu	+= '			<tr id="tr' + sMenuCategory + i + '" class="dyUselMenu" onMouseOver="Select( \'tr' + sMenuCategory + i + '\' , \'Menu\' ); StopTime();" onMouseOut="Unselect( \'tr' + sMenuCategory + i + '\' , \'Menu\' ); StartTime();" onClick="location.href=\'' + sArray[ i ].msLink + '\'"><td class="gbMenuItem" height="18">' + sLevel + sArray[ i ].msDescription + '</td></tr>';
		}
		else
		{
			sMenu	+= '			<tr id="tr' + sMenuCategory + i + '" class="dyUselMenu" onMouseOver="Select( \'tr' + sMenuCategory + i + '\' , \'Menu\' ); StopTime();" onMouseOut="Unselect( \'tr' + sMenuCategory + i + '\' , \'Menu\' ); StartTime();" onClick="location.href=\'' + sArray[ i ].msLink + '\'"><td class="gbMenuItem" height="18">' + sArray[ i ].msDescription + '</td></tr>';
		}
	}
	sMenu		+= '			</table>';
	sMenu		+= '		</td>';
	sMenu		+= '	</tr>';
	sMenu		+= '</table>';

	//
	// Return correct menu
	//
	return( sMenu );
}


// pragma page "Menu::Function::HideAll"
////////////////////////////////////////////////////////////////
//
// Hides all visible layers
//
////////////////////////////////////////////////////////////////
function HideAll()
{
	HideLayer( 'mnuAbout' );
	HideLayer( 'mnuServices' );
	HideLayer( 'mnuIndustryLinks' );
	HideLayer( 'mnuEmployment' );
	HideLayer( 'mnuContacts' );
}


// pragma page "Menu::Function::HideLayer"
////////////////////////////////////////////////////////////////
//
// Hides inputted visible layer
//
////////////////////////////////////////////////////////////////
function HideLayer( sLayerName )
{
	//
	// Ensure initialization successful
	//
	if ( gbInitMenu )
	{
		document.getElementById( sLayerName ).style.visibility = "hidden";
	}
	else
	{
		return;
	}
}


// pragma page "Menu::Function::InitializeMenus"
////////////////////////////////////////////////////////////////
//
// Initialize menus and variables
//
////////////////////////////////////////////////////////////////
function InitializeMenus()
{
	gsLayerRef		= "document.getElementByID";
	gsStyleRef		= ".style";
	gsVisibleRef	= "visible";
	gbInitMenu 		= true;
}


// pragma page "Menu::Function::Select"
////////////////////////////////////////////////////////////////
//
// Highlights inputted row/cell
//
////////////////////////////////////////////////////////////////
function Select( sRowName , sStyle )
{
	//
	// Ensure initialization successful
	//
	if ( gbInitMenu )
	{
		document.getElementById( sRowName ).className = "dySel" + sStyle;
	}
	else
	{
		return;
	}
}


// pragma page "Menu::Function::findPoxX and findPosY"
////////////////////////////////////////////////////////////////
//
// Helps to find an elements x and y coords when positioning
// divs or whatever using relative positioning (like when your 
// page is centered).
//
////////////////////////////////////////////////////////////////
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }


// pragma page "Menu::Function::ShowLayer"
////////////////////////////////////////////////////////////////
//
// Displays inputted hidden layer
//
////////////////////////////////////////////////////////////////
function ShowLayer( sLayerName, menuItem )
{
    
	//
	// Ensure initialization successful
	//
	if ( gbInitMenu )
	{
	    // Added next line for centered page layout...
	    document.getElementById( sLayerName ).style.left = (findPosX(menuItem)-2) + 'px';
		document.getElementById( sLayerName ).style.visibility = "visible";		
	}
	else
	{
		return;
	}
}


// pragma page "Menu::Function::SortByDescription"
////////////////////////////////////////////////////////////////
//
// Function that sorts site index objects by description.
//
////////////////////////////////////////////////////////////////
function SortByDescription( a , b )
{
	if ( a.msDescription < b.msDescription )
	{
		return -1;
	}
	else
	if ( a.msDescription > b.msDescription )
	{
		return 1;
	}
	else
	{
		if ( a.msCategory < b.msCategory )
		{
			return -1;
		}
		else
		if ( a.msCategory > b.msCategory )
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
}


// pragma page "Menu::Function::StartTime"
////////////////////////////////////////////////////////////////
//
// Starts timeout timer
//
////////////////////////////////////////////////////////////////
function StartTime()
{
	//
	// If has timed out
	//
	if ( gbTimer == false )
	{
		gTimerId	= setTimeout( "HideAll()" , gTimeOut );
		gbTimer		= true;
	}
}


// pragma page "Menu::Function::StopTime"
////////////////////////////////////////////////////////////////
//
// Stops timeout timer
//
////////////////////////////////////////////////////////////////
function StopTime()
{
	//
	// If timer is active
	//
	if ( gbTimer )
	{
		clearTimeout( gTimerId );
		gTimerId	= null;
		gbTimer		= false;
	}
}


// pragma page "Menu::Function::Unselect"
////////////////////////////////////////////////////////////////
//
// Unhighlights inputted row/cell
//
////////////////////////////////////////////////////////////////
function Unselect( sRowName , sStyle )
{
	//
	// Ensure initialization successful
	//
	if ( gbInitMenu )
	{
		document.getElementById( sRowName ).className = "dyUsel" + sStyle;
	}
	else
	{
		return;
	}
}


// pragma page "Menu::Execute"
////////////////////////////////////////////////////////////////
//
// Execute the following code
//
////////////////////////////////////////////////////////////////
BuildMenuArrays();