


function TopNavRollover (ImgId) {
		
	var ThisCell = null;
	if (document.getElementById) {
		ThisCell = document.getElementById ('TopNav' + ImgId);
				
	}
	else if(document.all){
		ThisCell = document.all['TopNav' + ImgId];
	}
	if (ThisCell == null) {
		return false;
	}
			
	if (ThisCell.className=="SiteTopNav"){
		ThisCell.className="SiteTopNavActive";
	}
	else{
		ThisCell.className="SiteTopNav";
	}
	return true;
}

function LoadImage(src) {
	if (document.images) {
		var NewImg = new Image();
		NewImg.src = src;
		return src;
	}
}
function PatchHomePageTable () {
 // Start: Home Page Init //
 if (document.all) {
	if (document.all.SearchRow2 && document.all.BottomLeftCell && document.all.BottomRightCell && document.all.AgentSearchTable && document.all.MortgageSearchTable ){
		if (document.all.BottomRightCell.offsetHeight>document.all.BottomLeftCell.offsetHeight){
			document.all.AgentSearchTable.height=document.all.SearchRow2.offsetHeight-2;
		}else{
			document.all.MortgageSearchTable.height=document.all.SearchRow2.offsetHeight-2;
		}
	}
 }
 else if (document.getElementById) {
	if (document.getElementById ("SearchRow2") && document.getElementById ("BottomLeftCell") && document.getElementById ("BottomRightCell")&& document.getElementById("MortgageSearchTable")  && document.getElementById("AgentSearchTable") ){
		if (document.getElementById("BottomRightCell").offsetHeight>document.getElementById("BottomLeftCell").offsetHeight){
			document.getElementById("AgentSearchTable").style.height=document.getElementById("SearchRow2").offsetHeight-2;
		}else{
			document.getElementById("MortgageSearchTable").style.height=document.getElementById("SearchRow2").offsetHeight-2;
		}
	}
 }
 // End: Home Page Init //
}


function ChangeLanguage( strServerName,strScriptName,strQString,lid) 
	{		window.location.href = eval("'http://" + strServerName + strScriptName + "?_lid=" + lid + "&" + strQString.replace("_lid=","_!lid=") + "'")
		return;
	}	function fnClearInnerHTML(elemId) {
		
	var ThisElem = null;
	if (document.getElementById) {
		ThisElem = document.getElementById (elemId);
				
	}
	else if (document.all){
		ThisElem = document.all[elemId];
	}
	if (ThisElem == null) {
		return false;
	}
			
	ThisElem.innerHTML="";
	return true;
}

function fnHideElem(elemId,blnDisplay) {
		
	var ThisElem = null;
	if (document.getElementById) {
		ThisElem = document.getElementById (elemId);
				
	}
	else if(document.all){
		ThisElem = document.all[elemId];
	}
	if (ThisElem == null) {
		return false;
	}
			
	ThisElem.style.visibility="hidden";	if (!blnDisplay)ThisElem.style.display="none";
	return true;
}

function fnShowElem(elemId) {
		
	var ThisElem = null;
	if (document.getElementById) {
		ThisElem = document.getElementById (elemId);
				
	}
	else if(document.all){
		ThisElem = document.all[elemId];
	}
	if (ThisElem == null) {
		return false;
	}
			
	ThisElem.style.visibility="visible";	ThisElem.style.display="block";
	return true;
}

function fnCheckInteger(input,msg) {
	
	var sStr = input.value;
	if (!sStr.length) return true;
	for ( var i = 0 ; i < sStr.length ; i++ ) {
		var ch = sStr.substring( i, i + 1);
		if (ch < "0" || ch > "9") {
			input.focus();
			if (msg!="")alert(msg);
			return false;
		}
	}
	return true;
}
function fnCheckCurrency(input,msg) {
	//var msg = "<%if lid = 1 then %>ˇHa especificado un valor monetario inválido!<%else%>You have specified an invalid currency value!<%end if%>";
	var sStr = input.value;
	if (!sStr.length) return true;
	if (sStr.length > 14) {
		input.focus();
		alert(msg);
		return false;
	}
	for ( var i = 0 ; i < sStr.length ; i++ ) {
		var ch = sStr.substring( i, i + 1);
		if ((ch < "0" || ch > "9") && ch != '.' && ch != ",") {
			input.focus();
			alert(msg);
			return false;
		}
	}
	return true;
}
function fnValidYear(input,msg) {
	var tm = new Date();
	var sStr = input.value
	if (!sStr.length)
		return true;
	if (!fnCheckInteger(input,'You have specified a non-numeric value!'))
		return false;
	if (input.value < 1900 || input.value > (1900 + tm.getYear() + 1)) {
		input.focus();
		alert(msg);
		return false;
	}
	return true;
}
function fnCheckDecimal(input,msg) {
	//var msg = "<%if lid = 1 then %>ˇHa especificado un valor que no es numérico!<%else%>You have specified a non-numeric value!<%end if%>";
	var sStr = input.value;
	if (!sStr.length)
		return true;
	// Catch errors that isNan() misses, such as:  "8 8" (causes errors later)
	for ( var i = 0 ; i < sStr.length ; i++ ) {
		var ch = sStr.substring( i, i + 1);
		if ((ch < "0" || ch > "9") && ch != '.' && ch != ",") {
			input.focus();
			alert(msg);
			return false;
		}
	}
	// isNaN() catches invalid inputs like ",8.5"
	if (isNaN(parseFloat(sStr))) {
			input.focus();
			alert(msg);
			return false;
	}
	input.value = parseFloat(sStr);  // prevent any other misunderstandings that can occur.
	return true;
}
function fnCheckBlank(input,msg) {
	//var msg = "<%if lid = 1 then %>ˇNo ha especificado un valor válido!<%else%>Input cannot be blank!<%end if%>";
	var sStr = input.value;
	for ( var i = 0 ; i < sStr.length ; i++ ) {
		var ch = sStr.substring( i, i + 1);
		if (ch != ' ') {
			return true;  // good, the input is not blank/empty
		}
	}
	input.focus();
	alert(msg);
	return false;
}
function fnCheckForInvalidCharacters(input){
//the search string can only contain numbers, upper or lowercase letters, spaces, or a comma
//the function returns true if any invalid character are present
	input = input.toUpperCase()
	for (var i=0 ; i < input.length; i++){
		asciiNum = input.charCodeAt(i)
		if  (asciiNum < 32 || (asciiNum>32 && asciiNum < 44) || (asciiNum > 45 && asciiNum < 48) || (asciiNum > 57 && asciiNum < 65) || (asciiNum > 90 && asciiNum < 95) || asciiNum > 95) {
			return true
		}
	}
	return false				
}

function runMySearch(form,strQS,err_msg){
	if (form){
		if(strQS!=""){
			location.href=form.action + "?" + strQS
		}else{
			alert(err_msg)
		}
	}
}


