function getObjectRef (thisId) {
	if (document.getElementById) {
		return document.getElementById (thisId);
	}
	else if (document.all) {
		return document.all[thisId];
	}
	else {
		return null;
	}
}




// navigation menu core functions -- Starts

	var nmMenuIdDelimiter = "-";
	var nmLastShownMenu = [];
	var nmHoverCallBack = null;
	var nmCancelHoverCallBack = null;
	var nmShowMenuCallBack = null;
	var nmKillMenuCallBack = null;

	function nmGetObjectRef (thisId) {
		return getObjectRef (thisId);
	}
	function nmGetTotalOffset (thisObj, innerOffset, offsetType){
		if (!innerOffset) {
			innerOffset = 0;
		}
		if (thisObj.tagName.toLowerCase () != "body") {
			var offsetValue = 0;
			if (offsetType == "offsetTop") {
				offsetValue = thisObj.offsetTop;
			}
			else if (offsetType == "offsetLeft") {
				offsetValue = thisObj.offsetLeft;
			}
			return nmGetTotalOffset (thisObj.offsetParent, offsetValue + innerOffset, offsetType);
		}
		else {
			return innerOffset;
		}
	}
	function nmGetTotalOffsetTop (thisObj, innerOffset) {
		return nmGetTotalOffset (thisObj, innerOffset, "offsetTop");
	}
	function nmGetTotalOffsetLeft (thisObj, innerOffset) {
		return nmGetTotalOffset (thisObj, innerOffset, "offsetLeft");
	}
	
	
	function nmShowMenu (triggerObj, menuObj, changePos, triggerTop, triggerLeft, triggerHeight, triggerWidth, menuOffsetTop, menuOffsetLeft) {
		if (menuObj && changePos == true) {
			if (menuObj.style) {
				if (menuObj.style.top) {
					if (!triggerHeight ) { triggerHeight = 0;  }
					if (!triggerWidth  ) { triggerWidth = 0;   }
					if (!menuOffsetTop ) { menuOffsetTop = 0;  }
					if (!menuOffsetLeft) { menuOffsetLeft = 0; }
					
					
					if (triggerTop) {
						menuObj.style.top = triggerTop + triggerHeight + menuOffsetTop + "px";
					}
					if (triggerLeft) {
						menuObj.style.left = triggerLeft + triggerWidth + menuOffsetLeft + "px";
					}
				}
			}
			menuObj.style.display = "block";
		}
	}
	function nmShowMenuFromTrigger (thisObj, menuIdPrefix, arrayMenus, menuOffsetTop, menuOffsetLeft, flHover, e) {
		if (nmShowMenuCallBack) {
			nmShowMenuCallBack ();
		}
		if (nmCancelHoverCallBack) {
			nmCancelHoverCallBack ();
		}
		if (nmHoverCallBack && flHover == true) {
			nmHoverCallBack (thisObj);
		}
		var menuId = "";
		var thisShownMenu = [];
		if (menuIdPrefix) {
			menuId = menuIdPrefix;
		}
		if (!flHover) {
			flHover = false;
		}
		if (nmLastShownMenu.length > arrayMenus.length) {
			for (var i = (nmLastShownMenu.length-1); i >= arrayMenus.length; i--) {
				nmLastShownMenu[i].style.display = "none";
			}
			nmLastShownMenu.length = arrayMenus.length;
		}
		for (var i = 0; i < arrayMenus.length; i++) {
			menuId += (nmMenuIdDelimiter + arrayMenus[i][0]);
			var menuObj = nmGetObjectRef (menuId);
			thisShownMenu[thisShownMenu.length] = menuObj;
			if (menuObj) {
				var changePos = arrayMenus[i][1];
				var triggerTop = nmGetTotalOffsetTop (thisObj);
				var triggerLeft = nmGetTotalOffsetLeft (thisObj);
				var triggerHeight = thisObj.offsetHeight;
				var triggerWidth = thisObj.offsetWidth;
				nmShowMenu (thisObj, menuObj, changePos, triggerTop, triggerLeft, triggerHeight, triggerWidth, menuOffsetTop, menuOffsetLeft);
			}
			if (nmLastShownMenu[i]) {
				if (nmLastShownMenu[i] != menuObj) {
					nmLastShownMenu[i].style.display = "none";
				}
			}
		}
		nmLastShownMenu = thisShownMenu;
		if (!e) {
			e = window.event;
		}
		e.cancelBubble = true;
	}
	
	
	function nmKillMenus () {
		if (nmKillMenuCallBack) {
			nmKillMenuCallBack ();
		}
		if (nmLastShownMenu.length > 0) {
			for (var i=(nmLastShownMenu.length - 1); i > -1; i--) {
				if (nmLastShownMenu[i] && nmLastShownMenu[i].style) {
					nmLastShownMenu[i].style.display = "none";
				}
			}
		}
	}
	function nmInit () {
		if (document.getElementById || document.all) {
			if (document.captureEvents) {
				document.captureEvents(Event.MOUSEOVER); 
			}
			document.onmouseover = nmKillMenus;
		}
	}
	
	
	
	//navigation menu utility functions
	function showFirstMenuByObj (thisObj, arrayMenus, e) {

		nmShowMenuFromTrigger (thisObj,'TopNav',arrayMenus,0,-thisObj.offsetWidth, null, e);
	}
	function showFirstMenuById (thisId, arrayMenus, e) {
		var thisObj = nmGetObjectRef (thisId);
		if (thisObj) {
			nmShowMenuFromTrigger (thisObj,'TopNav',arrayMenus,0,-thisObj.offsetWidth, null, e);
		}
	}
	function showOtherMenu (thisObj, arrayMenus, flHover, e) {
		nmShowMenuFromTrigger (thisObj,'TopNav',arrayMenus,-25,-10,flHover,e);
	}
	var hoverObj = null;
	function hoverMenuCallBack (thisObj) {
		if (thisObj.style) {
			hoverObj = [thisObj, thisObj.className];
			thisObj.className = "SubTopNavItemOver";
		}
	}
	function cancelHoverMenuCallBack () {
		if (hoverObj) {
			hoverObj[0].className = hoverObj[1];
		}
	}
	nmHoverCallBack = hoverMenuCallBack;
	nmCancelHoverCallBack = cancelHoverMenuCallBack;
	
// navigation menu core functions -- Ends

function GetObjectById (thisId) {
	var thisObj = null;
	if (document.all) {
		thisObj = document.all[thisId];
	}
	else if (document.getElementById) {
		thisObj = document.getElementById(thisId);
	}
	if (thisObj) {
		return thisObj;
	}
	else {
		return false;
	}
}
function ShowSubSection2 (thisId, isSubObj) {
	if (!isSubObj) {
		thisId = thisId + "-sub";
	}
	var thisObj = GetObjectById (thisId);
	if (thisObj) {
		thisObj.style.display = "inline";
	}
}
function HideSubSection2 (thisId, isSubObj) {
	if (!isSubObj) {
		thisId = thisId + "-sub";
	}
	var thisObj = GetObjectById (thisId);
	if (thisObj) {
		thisObj.style.display = "none";
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function OfficeLocator_OnChange (thisSelect) {
		alert ('ok');
	var queryField = "";
	if (thisSelect.name == "StateSelect") {
		queryField = "strState";
	}
	else if (thisSelect.name == "CountrySelect") {
		queryField = "strCountry";
	}
	if (queryField != "" && thisSelect.selectedIndex > 0) {
		var selectedValue = thisSelect.options[thisSelect.selectedIndex].value;
		//var actionUrl = "http://seddev.stewartlink.com/";
		var actionUrl = "http://199.253.17.102/";
		var queryString = actionUrl + "?" + queryField + "=" + selectedValue;
		var officeWin = window.open (queryString,'officeWin','status=yes,scrollbars=yes,resizable=yes,width=600,height=400');
	}
}


function validate () {
    if (document.title_order_form.transaction_type.value == "Select One") {
     alert("You must select a transaction type.");
     return false;
    }
	if (document.title_order_form.loan_type.value == "Select One") {
     alert("You must select a loan type.");
     return false;
    }
	if (document.title_order_form.property_street_number.value == "") {
     alert("You must provide a property street number.");
     return false;
    }
	if (document.title_order_form.property_street_name.value == "") {
     alert("You must provide a property street name.");
     return false;
    }
	if (document.title_order_form.property_city.value == "") {
     alert("You must provide a property city.");
     return false;
    }
	if (document.title_order_form.property_state.value == "") {
     alert("You must provide a property state.");
     return false;
    }
	if (document.title_order_form.property_zip.value == "") {
     alert("You must provide a property zip code.");
     return false;
    }
	if (document.title_order_form.property_county.value == "") {
     alert("You must provide a property county.");
     return false;
    }
	if (document.title_order_form.services.value != "" && document.title_order_form.services.value != "Select One") {
     if (document.title_order_form.need_by.value == "") {
     alert('You must provide a "need by date".');
     return false;
	 }
    }
	if (document.title_order_form.my_first_name.value == "") {
     alert("You must provide a first name.");
     return false;
    }
	if (document.title_order_form.my_last_name.value == "") {
     alert("You must provide a last name.");
     return false;
    }
	if (document.title_order_form.my_phone.value == "") {
     alert("You must provide a phone number.");
     return false;
    }
    else
     return true;
   }
   function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
