<!--
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;
var nav = window.Event ? true : false;
if (nav) {
   window.captureEvents(Event.KEYDOWN);
   window.onkeydown = NetscapeEventHandler_KeyDown;
} else {
   document.onkeydown = MicrosoftEventHandler_KeyDown;
}

if (document.getElementById) {isID = 1; isDHTML = 1;}
else    {
	  if (document.all) {isAll = 1; isDHTML = 1;}
	  else {
		  browserVersion = parseInt(navigator.appVersion);
		  if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4))
		    {
		      isLayers = 1; isDHTML = 1;
		    }
	       }
	}

function findDOM(objectID,withStyle) 
{
	if(withStyle == 1) 
	    {
		if (isID)  { return (document.getElementById(objectID).style) ; }
		else {
			if (isAll) { return (document.all[objectID].style); }
			else {
				if (isLayers) { return (document.layers[objectID]); }
			     };
		     }
	    }
	else {
		if (isID) { return (document.getElementByID(objectID)) ; }
		else {
			if (isAll) { return (document.all[objectID]); }
			else {
				if (isLayers) { return (document.layers[objectID]); }
			     }
		      };
	      }
}
function setVisibility(objectID,state)
{
var dom = findDOM(objectID,1);
dom.visibility = state;
}

function NetscapeEventHandler_KeyDown(e) {
  if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') { return false; }
  return true;
}

function MicrosoftEventHandler_KeyDown() {
  if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit')
    return false;
  return true;
}

function setattrib(objectID, style, value) {
//if (navigator.appName.indexOf('Netscape')!= -1) {return true;}
var dom = findDOM(objectID,1);
dom[style] = value;
}

function LTrim(str)
{
for (var i=0; str.charAt(i)<=" "; i++);
return str.substring(i,str.length);
}

function RTrim(str)
{
for (var i=str.length-1; str.charAt(i)<=" "; i--);
return str.substring(0,i+1);
}

function Trim(str)
{
if(str == "" || str == null) return str;
return LTrim(RTrim(str));
}      

function validate() {
var required = false;
var numpropval = true;
var numloanamt = true;
var numpcode = false;
var optional = false;
var loval = false;
var hival = false;
var hi_lvr = false;
var msgtext = "";
var x;
if (MM_findObj('fullname').value.search(/\w/) == -1) 
	{
	setattrib('lblfullname','color','red');
	setattrib('lblfullname','fontWeight','bold');
	required = true;
	}
else
	{
	setattrib('lblfullname','color','black');
	setattrib('lblfullname','fontWeight','normal');
	}
	
if ((MM_findObj('primaryphone').value.search(/\w/) == -1)  && (MM_findObj('altphone').value.search(/\w/) == -1))
	{
	setattrib('lblprimaryphone','color','red');
	setattrib('lblaltphone','color','red');
	setattrib('lblprimaryphone','fontWeight','bold');
	setattrib('lblaltphone','fontWeight','bold');
	optional = true;
	}
else
	{
	setattrib('lblprimaryphone','color','black');
	setattrib('lblaltphone','color','black');
	setattrib('lblprimaryphone','fontWeight','normal');
	setattrib('lblaltphone','fontWeight','normal');
	}

if ((MM_findObj('email').value.search(/\w/) == -1))
	{
	setattrib('lblemail','color','red');
	setattrib('lblemail','fontWeight','bold');
	required = true;
	}
else
	{
	setattrib('lblemail','color','black');
	setattrib('lblemail','fontWeight','normal');
	}
	
if (MM_findObj('state').value == '?') 
	{
	setattrib('lblstate','color','red');
	setattrib('lblstate','fontWeight','bold');
	required = true;
	}
else
	{
	setattrib('lblstate','color','black');
	setattrib('lblstate','fontWeight','normal');
	}
	
x = MM_findObj('postcode');
x.value = Trim(x.value);
if (x.value.search(/\D/) != -1 || x.value.search(/./) == -1)
	{
	setattrib('lblpostcode','color','red');
	setattrib('lblpostcode','fontWeight','bold');
	required = true;
	numpcode=true;
	if (x.value.search(/\D/) != -1)
	numpcode=false;
	}
else
	{
	setattrib('lblpostcode','color','black');
	setattrib('lblpostcode','fontWeight','normal');
	numpcode=true;
	}

x = MM_findObj('loanamount');
x.value = Trim(x.value);
if (x.value.search(/\D/) != -1 || x.value.search(/./) == -1)
	{
	setattrib('lblloanamount','color','red');
	setattrib('lblloanamount','fontWeight','bold');
	required = true;
	numloanamt = true;
	if(x.value.search(/\D/) != -1)
	numloanamt = false;
	}
else
	{
	numloanamt = true;
	loanamt = x.value;
	if (x.value < 75000)
		{
		setattrib('lblloanamount','color','red');
	setattrib('lblloanamount','fontWeight','bold');
		loval = true;
		}
	if (x.value >= 1000000)
		{
		hival = true;
		setattrib('lblloanamount','color','red');
		setattrib('lblloanamount','fontWeight','bold');
		}
	if (!loval && !hival)
		{
		setattrib('lblloanamount','color','black');
		setattrib('lblloanamount','fontWeight','normal');
		}
	}
	
x = MM_findObj('propertyvalue');
x.value = Trim(x.value);
if (x.value.search(/\D/) != -1 && x.value.search(/./) != -1)
	{
	setattrib('lblpropertyvalue','color','red');
	setattrib('lblpropertyvalue','fontWeight','bold');
	numpropval = false;
	}
else
	{
	numpropval = true;
	setattrib('lblpropertyvalue','color','black');
	setattrib('lblpropertyvalue','fontWeight','normal');
	if(numloanamt && !isNaN(x.value) && x.value > 0 && (loanamt > (x.value * 0.95)))
		{
		hi_lvr = true;
		}
	else
		{
		hi_lvr = false;
		}
	}

if (required) 
	{
	msgtext = "Please enter all required fields so we can promptly respond to your request\n";
	}
if (!numloanamt)
	{
	msgtext = msgtext + "The requested loan amount must be entered as digits only";
	}
if (!required && optional)
	{
	msgtext = "Please supply at least one contact number so we can promptly respond to your request";
	}
if (!numpropval)
	{
	msgtext += "\nThe property value must be entered as digits only";
	}
if (!numpcode)
	{
	msgtext += "\nPlease enter a numeric Postcode."
	}
if (loval)
	{
	msgtext = "We're sorry, but cannot assist you with loan requests of less than $75,000.";
	msgtext += "\nIf you are wishing to refinance your existing mortgage, please make sure";
	msgtext += "\nyou've entered the total value of the current amount owing on the current";
	msgtext += "\nmortgage, plus any additional amount required.";
	msgtext += "\nIf you are looking for a personal loan, please check our Personal Loan page.";
	}
if (hi_lvr)
	{
	msgtext = "We're sorry, but cannot assist you with loans that exceed 95% of the property value.";
	}
if (required || optional || !numloanamt || !numpropval || loval || hi_lvr)
	{
	alert(msgtext);
	return false;
	}
if (hival)
	{
	msgtext += "You have entered a loan value of at least $1,000,000. Press OK if this";
	msgtext += "\nis correct, or Cancel to change it before submitting your request.";
	if (confirm(msgtext))
		{
//		form1("getquote").disabled = true
		return true;	
		}
	else
		return false;
	}

//setVisibility('button','hidden');
//form1("getquote").disabled = true
return true;	
}

function openwin(target)
{
window.open(target,"privacy","height=200, width=400, scrollbars=yes")
}

function textCounter(field, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
	{
	field.value = field.value.substring(0, maxlimit);
	}
}

//-->
