var currentTopLocation = String(top.location);  // get the current page
var directoryAdjustment = String("");

if(currentTopLocation.indexOf("index.html") == -1 && currentTopLocation.indexOf(".html") > -1)  // check if we are on the homepage or a subpage
	directoryAdjustment = String("../");

if (TransMenu.isSupported())
{
	var ms = new TransMenuSet(TransMenu.direction.down, 0, 0, TransMenu.reference.bottomLeft);
	var menu2 = ms.addMenu(document.getElementById("menu2"));
	menu2.addItem("Title", directoryAdjustment + "services/titleAndClosing.html", "0");
	menu2.addItem("Escrow", directoryAdjustment + "services/escrow.html", "0");
	menu2.addItem("Customer Service", directoryAdjustment + "services/customerServicePage.html", "0");
	menu2.addItem("Builder Services", directoryAdjustment + "services/builderServices.html", "0");
	menu2.addItem("Solutions Provider", directoryAdjustment + "services/solutionsProvider.html", "0");
	menu2.addItem("Commercial", "http://www.firstam.com/ncs/", "1");
//	menu2.addItem("Flood Zone Determinations", directoryAdjustment + "services/floodZoneDeterminations.html", "0");
//	menu2.addItem("Loan Document Services", directoryAdjustment + "services/loanDocumentServices.html", "0");
//	menu2.addItem("Property Data", directoryAdjustment + "services/propertyData.html", "0");
//	menu2.addItem("Property Appraisals", directoryAdjustment + "services/propertyAppraisals.html", "0");
//	menu2.addItem("Title Agency Underwriting", directoryAdjustment + "services/titleAgencyUnderwriting.html", "0");
	var menu5 = ms.addMenu(document.getElementById("menu5"));
//	menu5.addItem("Restricted Covenants", directoryAdjustment + "resources/restrictedCovenants.html", "0");
	menu5.addItem("Calculators", directoryAdjustment + "resources/calculators.html", "0");
//	menu5.addItem("Trem Reports", directoryAdjustment + "resources/tremReports.html", "0");
//	menu5.addItem("HOA Access", directoryAdjustment + "resources/HOAAccess.html", "0");
	menu5.addItem("Helpful Links", directoryAdjustment + "resources/helpfulLinks.html", "0");
	var menu6 = ms.addMenu(document.getElementById("menu6"));
//	menu6.addItem("Customer Service", directoryAdjustment + "contact/customerService.html", "0");
	menu6.addItem("Staff Directory", directoryAdjustment + "contact/staffDirectory.html", "0");
	menu6.addItem("Office Directory", directoryAdjustment + "contact/officeDirectory.html", "0");
	var menu7 = ms.addMenu(document.getElementById("menu7"));
	menu7.addItem("Online Ordering", directoryAdjustment + "onlineOrdering/onlineOrdering.html", "0");
//	menu7.addItem("Schedule Closing", directoryAdjustment + "onlineOrdering/scheduleClosing.html", "0");
//	menu7.addItem("Earnest Money Request", directoryAdjustment + "onlineOrdering/earnestMoneyRequest.html", "0");

	function init()
	{
		if (TransMenu.isSupported())
		{
			TransMenu.initialize();
			document.getElementById("menu1").onmouseover = function() { ms.hideCurrent(); this.className = "hover"; }
			document.getElementById("menu1").onmouseout = function() { this.className = ""; }
			menu2.onactivate = function() {document.getElementById("menu2").className = "hover"; };
			menu2.ondeactivate = function() {document.getElementById("menu2").className = ""; };
			menu5.onactivate = function() {document.getElementById("menu5").className = "hover"; };
			menu5.ondeactivate = function() {document.getElementById("menu5").className = ""; };
			menu6.onactivate = function() {document.getElementById("menu6").className = "hover"; };
			menu6.ondeactivate = function() {document.getElementById("menu6").className = ""; };
			menu7.onactivate = function() {document.getElementById("menu7").className = "hover"; };
			menu7.ondeactivate = function() {document.getElementById("menu7").className = ""; };
 
		}
	}

	TransMenu.spacerGif = directoryAdjustment + "images/x.gif";                     // path to a transparent spacer gif
	TransMenu.dingbatOn = directoryAdjustment + "images/submenu-on.gif";            // path to the active sub menu dingbat
	TransMenu.dingbatOff = directoryAdjustment + "images/submenu-off.gif";
	TransMenu.sub_indicator = true;

	TransMenu.menuPadding = 0;                             // padding between menu border and items grid
	TransMenu.itemPadding = 0;                             // additional padding around each item
	TransMenu.shadowSize = 2;                              // size of shadow under menu
	TransMenu.shadowOffset = 3;                            // distance shadow should be offset from leading edge
	TransMenu.shadowColor = "#888";                        // color of shadow (transparency is set in CSS)
	TransMenu.shadowPng = directoryAdjustment + "images/grey-40.png";               // a PNG graphic to serve as the shadow for mac IE5
	TransMenu.backgroundColor = "#2e2e2e";                   // color of the background (transparency set in CSS)
	TransMenu.backgroundPng = directoryAdjustment + "images/white-90.png";          // a PNG graphic to server as the background for mac IE5
	TransMenu.hideDelay = 400;                            // number of milliseconds to wait before hiding a menu
	TransMenu.slideTime = 200;

	TransMenu.renderAll();

	if ( typeof window.addEventListener != "undefined" )
		window.addEventListener( "load", init, false );
	else if ( typeof window.attachEvent != "undefined" )
	{  // IE
		window.attachEvent( "onload", init );
		//window.attachEvent( "onunload", disposeAllTabs );
	}
	else
	{
		if ( window.onload != null )
		{
			var oldOnload = window.onload;
			window.onload = function ( e ) { oldOnload( e ); init(); }
		}
		else
			window.onload = init();
	}

}
