/* Special purpose routine to check the fields that are supposed to be filled have been filled
   or else return back to the form. */
function contactForm(contact) {
  allCorrect=true ;
  
  if (contact.FirstName.value=="" || 
      contact.LastName.value=="" ||
	  contact.Phone.value=="" ||
	  contact.Email.value=="" ) {
    allCorrect=false ;
  }
  if (allCorrect==false)
  {
    alert("Please fill in all fields marked *") ;
	return false ;
  } 
    return true ;
}

/* Generic check email function*/
function checkEmail(emailAddy) {
  if (emailAddy.value.length==0)
  {
    return true ;
  }
  if (emailAddy.value.indexOf("@",0) < 1 || emailAddy.value.indexOf(".",0) < 1)
  {
    alert("Please check the field:\n The email address appears incorrectly formed") ;
    emailAddy.focus() ;
	return false ;
  }
  return true ;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  activeArea();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//Keep Image on if in each area
function activeArea() {
	if (location.href.indexOf('CompanyProfile.aspx') != -1) {
		MM_swapImage('Company Profile','','/img/nv_company_profile_on.gif',1);
	}
	if (location.href.indexOf('Services.aspx') != -1) {
		MM_swapImage('Services','','/img/nv_services_on.gif',1);
	}
	if (location.href.indexOf('Technology.aspx') != -1) {
		MM_swapImage('Technology','','/img/nv_technology_on.gif',1);
	}
	if (location.href.indexOf('ContactUs.aspx') != -1) {
		MM_swapImage('Contact Us','','/img/nv_contact_us_on.gif',1);
	}
}

//no spam email address
var user;
var domain;
var suffix;
function nospam(user,domain,suffix) {
	document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}

function nospamsml(user,domain,suffix) {
	document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '" class="lnkNBlack10UL">' + user + '@' + domain + '.' + suffix + '</a>');
}

//netscape css fix

function WM_netscapeCssFix() {
   if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn()

//prevents window from capture in frames

if (top.location != self.location) {
        top.location = self.location
}

//popup windows for references

function popupWindow(referenceHTML, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	windowProperties = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,resizable'
	reference = window.open(referenceHTML, 'refName', windowProperties)
	if (parseInt(navigator.appVersion) >= 4) { reference.window.focus(); }
	}

//popup windows for calculators

function popupCalculator(mypage,myname,w,h,scroll) {
	var wi = screen.width - 100;
	var he = screen.height - 100;
	var winl = (screen.width - wi) / 2;
	var wint = ((screen.height - he) / 2) - 20;
	winprops = 'height='+he+',width='+wi+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function PrintThisPage() 
{ 
	var w = 700;
	var h = 450;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var sOption = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,resizable'
   	var sWinHTML = document.getElementById('contentarea').innerHTML; 
   	var winprint=window.open("","",sOption);
       winprint.document.open(); 
       winprint.document.write('<html><head><title>Real Choice Mortgages - Home Loans, Investment Loans, Finance - Real Choice Mortgages, Croydon, Melbourne, Australia</title>'); 
       winprint.document.write('<link rel="stylesheet" href="http://www.tonychartres.com.au/inc/artlandishprint.css" type="text/css">'); 
       winprint.document.write('</head>'); 
       winprint.document.write('<body><a name="top"></a>'); 
       winprint.document.write('<table width="100%" "cellpadding="0" cellspacing="0"><tr><td align="left" class="txtNBlue11"><b>Real Choice Mortgages - 1300 555 645</b><br>');
	   winprint.document.write('<a href="mailto:enquiries@tonychartres.com.au" class="lnkNBlue11HL">enquiries@tonychartres.com.au</a><br><br></td>');
	   winprint.document.write('<td align="right"><span class="txtNBlack10">[<a href="javascript:window.close()" class="lnkNBlack10HL">close window</a>]</span></td></tr></table>'); 
       winprint.document.write(sWinHTML);          
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
       winprint.focus(); 
}

