// browser detection:
var ua = navigator.userAgent;
var ns = (navigator.appName.toLowerCase().indexOf("netscape")!=-1)?1:0;
var ns4 = (document.layers)?1:0;
var ns6 = (document.getElementById && ns)?1:0;
var mac = (navigator.userAgent.toLowerCase().indexOf("mac")!=-1)?1:0;
var macie4 = (mac && !ns && parseInt(ua.substr(ua.indexOf("MSIE")+4,2)) <= 4)?1:0;
var macie = (mac && !ns)?1:0;


if (ns || ns6) document.write('<LINK rel=stylesheet type="text/css" href="ross_ns.css">');
else document.write('<LINK rel=stylesheet type="text/css" href="ross.css">');


//getting the content height:
var contH="100%"
var contW="100%"
var contWL="100%"
var contWR="100%"
var headerH= 311 //287 //281
var headerH2=90 //66
var middleM=656
var footerH=39 //79
function GetContentH(){
	if (ns) 
		{
		contH=window.innerHeight-headerH-footerH
		contH2=window.innerHeight-headerH2-footerH-47
		contW=(window.innerWidth-middleM)/2
		contWL=contW-50
		contWR=contW+50
//		contWScroll=contW-5
		}
	else 
		{
			
			 contH=document.body.clientHeight-headerH-footerH
			 contH2=document.body.clientHeight-headerH2-footerH-47 //41
			 contW=parseInt((document.body.clientWidth-middleM)/2)
		 	 contWL=contW-50
			 contWR=contW+50
//			 contWScroll=contW+3
		}
}

// START: fixing the page content on resize >>>
FixNSWindow();
function FixNSWindow() {
	if (ns6 || ns && (parseInt(navigator.appVersion) == 4)) {
		if (typeof document.NS == 'undefined') document.NS = new Object;
		if (typeof document.NS.NS_scaleFont == 'undefined') {
			document.NS.FixCssInNS = new Object;
			document.NS.FixCssInNS.initWindowWidth = window.innerWidth;
			document.NS.FixCssInNS.initWindowHeight = window.innerHeight;
		}
		window.onresize = FixCssInNS;
	}
}
function FixCssInNS() {
	if (document.NS.FixCssInNS.initWindowWidth != window.innerWidth || document.NS.FixCssInNS.initWindowHeight != window.innerHeight) document.location = document.location;
}
ReloadWindow();
function ReloadWindow(){if (!ns) setTimeout("window.onresize=new Function('window.location.reload()')",200);}
// <<< END: fixing the page content on resize

//-->


var arrMenu=new Array(
"images/mnut1_off.gif","images/mnut1_on.gif","index.shtml","hom",
"images/mnut2_off.gif","images/mnut2_on.gif","loan_process.shtml","Loan",
"images/mnut3_off.gif","images/mnut3_on.gif","meet_clients.shtml","meet",
"images/mnut4_off.gif","images/mnut4_on.gif","about.shtml","about",
"images/mnut5_off.gif","images/mnut5_on.gif","contact.shtml","contact",

"images/mnul1_off.gif","images/mnul1_on.gif","refinance.shtml","refinance",
"images/mnul2_off.gif","images/mnul2_on.gif","cash_out.shtml","cash",
"images/mnul3_off.gif","images/mnul3_on.gif","consolidate.shtml","consolidate",
"images/mnul4_off.gif","images/mnul4_on.gif","problem.shtml","Problem",
"images/mnul5_off.gif","images/mnul5_on.gif","no_hassle.shtml","no",
"images/mnul6_off.gif","images/mnul6_on.gif","home_construction.shtml","construction",
"images/mnul7_off.gif","images/mnul7_on.gif","home_builders.shtml","builders",
"images/mnul8_off.gif","images/mnul8_on.gif","glossary.shtml","glossary"
)

//string for top_menu generate
var strInitialTable = new String("");
var strContentTable = new String("");
//string for bottom_menu generate
var strBottomTable = new String("");
var strInitialBottomTable = new String("");

var objMenu1On = new Array();
var objMenu1Off = new Array();

function Preload(){
	// START: preload image
	for (var i=0; i<arrMenu.length; i+=4){
		var j=(parseInt(i/4))
		objMenu1On[j] = new Image();
		objMenu1On[j].src = arrMenu[i+1];

		objMenu1Off[j] = new Image();
		objMenu1Off[j].src = arrMenu[i];
	}
	// END: preload image
}

function GenerateMenuTop(){
	strContentTable=""
		for(var i = 0; i < 20; i+=4){
			var j=parseInt(i/4)
			if(menuID == arrMenu[i+3]) strContentTable += "<TD align=right><A href='" + arrMenu[i+2] + "'><IMG src='" + arrMenu[i+1] + "' border=0 name='mnu" + j + "'></A></TD>";
			else strContentTable += "<TD align=right><A href='" + arrMenu[i+2] + "' onmouseover=On('" + j + "') onmouseout=Off('" + j + "')><IMG src='" + arrMenu[i] + "' border=0 name='mnu" + j + "'></A></TD>";
		}
		strInitialTable = "<TABLE cellspacing=0 cellpadding=0 border=0><TR>" + strContentTable + "</TR></TABLE>";
		document.write(strInitialTable);
	}
	
function GenerateLeftMenu(){
	for(var i =20 ; i < arrMenu.length; i+=4){
		var j=parseInt(i/4)
		if(menuLeftID==arrMenu[i+3]) strBottomTable += "<TR><TD colspan='3'><A href='" + arrMenu[i+2] + "'><IMG src='" + arrMenu[i+1] + "' border=0 name='mnu" + j + "'></A></TD></TR>";
		else strBottomTable += "<TR><TD colspan='3'><A href='" + arrMenu[i+2] + "' onmouseover=On('"+j+"') onmouseout=Off('"+j+"')><IMG src='" + arrMenu[i] + "' border=0 name='mnu" + j + "'></A></TD></TR>";
	}
	strInitialBottomTable = "<TABLE cellspacing=0 cellpadding=0 border=0 width=163><tr><td colspan='3'><img src='images/ttl_mnu.gif' width=163 height=19 border=0></td></tr>" + strBottomTable + "<tr><td width='1' bgcolor='CCBC9B'><img src='images/spacer.gif' width=1 height=1 border=0></td><td width='161' height='20' background='images/bg_ttl_mnu1.gif'><img src='images/spacer.gif' width=161 height=20 border=0></td><td width='1' bgcolor='CCBC9B'><img src='images/spacer.gif' width=1 height=1 border=0></td></tr></TABLE>";
	document.write(strInitialBottomTable);
}

function GenerateLeftMenu2(){
	for(var i =20 ; i < arrMenu.length; i+=4){
		var j=parseInt(i/4)
		if(menuLeftID==arrMenu[i+3]) strBottomTable += "<TR><TD colspan='3'><A href='" + arrMenu[i+2] + "'><IMG src='" + arrMenu[i+1] + "' border=0 name='mnu" + j + "'></A></TD></TR>";
		else strBottomTable += "<TR><TD colspan='3'><A href='" + arrMenu[i+2] + "' onmouseover=On('"+j+"') onmouseout=Off('"+j+"')><IMG src='" + arrMenu[i] + "' border=0 name='mnu" + j + "'></A></TD></TR>";
	}
	strInitialBottomTable = "<TABLE cellspacing=0 cellpadding=0 border=0 width=163><tr><td><img src='images/ttl_mnu.gif' width=163 height=19 border=0></td></tr>" + strBottomTable + "<tr></TABLE>";
	document.write(strInitialBottomTable);
}	

function On(mnuNo) {
	if (document.images) {
		var imgName = "mnu" + mnuNo;
		if(ns6) document.images[imgName].src = objMenu1On[mnuNo].src;
		if(ns) eval("document.images['" + imgName + "'].src = objMenu1On[" + mnuNo + "].src");
		else document.images[imgName].src = objMenu1On[mnuNo].src;
	}
}

// function off - call on onmouseout
function Off(mnuNo) {
	if (document.images) {
		var imgName = "mnu" + mnuNo;
		if(ns6) document.images[imgName].src = objMenu1Off[mnuNo].src;
		else if(ns) eval("document.images['" + imgName + "'].src = objMenu1Off[" + mnuNo + "].src");
			else document.images[imgName].src = objMenu1Off[mnuNo].src;
	}
}

function emailAdressIsValid(str){
	var emailAdressFormat = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,3}$/;
	if(str=="")
		{
			return 2
		}
		else if (!(emailAdressFormat.test(str)))
			{
				return 1;
			}
			else
			{				
				return false;
			}
}
function Trim(strToTrim) {
	while(strToTrim.charAt(0)==' '){strToTrim = strToTrim.substring(1,strToTrim.length);}
	while(strToTrim.charAt(strToTrim.length-1)==' '){strToTrim = strToTrim.substring(0,strToTrim.length-1);}
	return strToTrim;
}

