<!--//

// think rich javascript
// created: 11 May 2006
// Mammoth Solutions

browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);
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;
}

function swopPhoto(imgName) 
{
	if (ns3up || ie4up) 
		imgOn = (imgName);
		
	document.mainpic.src = imgOn;
}

function propertyShow(pid) 
{
	window.open('property-popup.php?id='+pid, '', 'resizable=no,scrollbars=yes,width=580,height=500');
}

// open privacy policy
function privacypolicy() 
{
	window.open('privacy-policy.php', '', 'resizable=no,scrollbars=yes,width=470,height=420');
}

// open terms & conditions
function termsandconditions() 
{
	window.open('terms-and-conditions.php', '', 'resizable=no,scrollbars=yes,width=570,height=550');
}

function doBondCalculation() 
{
	window.open('bond-calculator.php', '', 'resizable=no,scrollbars=yes,width=580,height=550');
}

// validation code 
function validateLogin()
{
	fv = new formValidator();
	
	if (fv.isEmpty("username"))
		fv.raiseError("Please specify your email address.");
	else
	if (!fv.isEmailAddress("username"))
		fv.raiseError("Please specify a valid email address when attempting to login.");
		
	if (fv.isEmpty("password"))
		fv.raiseError("Please specify a password.");			
	
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

function validateCCForm()
{
	fv = new formValidator();
	
	if (fv.isEmpty("Lite_Order_Amount"))
		fv.raiseError("An amount has not been specified.");
		
	if (fv.isEmpty("Ecom_BillTo_Postal_Name_First"))
		fv.raiseError("Please specify your first name.");			
	
	if (fv.isEmpty("Ecom_BillTo_Postal_Name_Last"))
		fv.raiseError("Please specify your last name.");			
		
	if (fv.isEmpty("Ecom_Payment_Card_Number"))
		fv.raiseError("Please specify your card number.");			
		
	if (fv.isEmpty("Ecom_Payment_Card_Number"))
		fv.raiseError("Please specify your card number.");			
		
	if (fv.isEmpty("Ecom_Payment_Card_ExpDate_Month"))
		fv.raiseError("Please specify your the expiry month of the credit card.");			
		
	if (fv.isEmpty("Ecom_Payment_Card_ExpDate_Year"))
		fv.raiseError("Please specify your the expiry year of the credit card.");			
		
	if (fv.isEmpty("Ecom_Payment_Card_Verification"))
		fv.raiseError("Please specify the CVC number");			
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

function validateRecommend()
{
	fv = new formValidator();
	
	if (fv.isEmpty("your_name"))
		fv.raiseError("Please specify your name.");
	
	if (fv.isEmpty("your_email"))
		fv.raiseError("Please specify your email.");
	else
	{
		if (!fv.isEmailAddress("your_email"))
			fv.raiseError("Please specify a your valid email address.");
	}
		
	if (fv.isEmpty("friend_name"))
		fv.raiseError("Please specify your friend's name.");

	if (fv.isEmpty("friend_email"))
		fv.raiseError("Please specify your friend's email address.");
	else
	{
		if (!fv.isEmailAddress("friend_email"))
			fv.raiseError("Please specify a valid email address for your friend.");
	}

	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

function validateContactUsForm()
{
	fv = new formValidator();
	
	if (fv.isEmpty("email"))
		fv.raiseError("Please specify your email address.");
		
	if (!fv.isEmpty("email"))
	{
		if (!fv.isEmailAddress("email"))
			fv.raiseError("Please specify a valid email address.");
	}	
	
	if (fv.isEmpty("your_name"))
		fv.raiseError("Please specify your name.");
		
	if (fv.isEmpty("message"))
		fv.raiseError("Please specify your message.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

function validateSubscribe()
{
	fv = new formValidator();
	
	if (!fv.isEmpty("subscribe"))
	{
		if (!fv.isEmailAddress("subscribe"))
			fv.raiseError("Please specify a valid email address.");
	}
	else
		fv.raiseError("Please enter an email address in order to subscribe for more information");
	
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

// nav rollover functions
function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findformElement(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function findformElement(n, d) { //v3.0
	  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=findformElement(n,d.layers[i].document); return x;
}

function validateRegistration()
{
	fv = new formValidator();
	
	if (fv.isEmpty("first_name"))
		fv.raiseError("Please specify your first name.");
	
	if (fv.isEmpty("surname"))
		fv.raiseError("Please specify your first name.");
		
	if (fv.isEmpty("email"))
		fv.raiseError("Please specify your email address.");
	else
	if (!fv.isEmailAddress("email"))
		fv.raiseError("Please specify a valid email address.");
		
	if (fv.isEmpty("confirm_email"))
		fv.raiseError("Please specify confirm your email address.");
		
	if (!fv.isSame("email", "confirm_email"))
		fv.raiseError("The email address differs from the confirmed email address. Please correct.");
		
	if (fv.isEmpty("city"))
		fv.raiseError("Please specify a city.");
		
	if (fv.isEmpty("province"))
		fv.raiseError("Please specify a province.");
		
	if (fv.isEmpty("postal_code"))
		fv.raiseError("Please specify a postal code.");
		
	if (fv.isEmpty("country"))
		fv.raiseError("Please specify a country.");		
		
	if (fv.isEmpty("register_password"))
		fv.raiseError("Please specify your password.");
	
	if (fv.isEmpty("confirm_password"))
		fv.raiseError("Please confirm your password.");		

	if (!fv.isSame("register_password", "confirm_password"))
		fv.raiseError("The password entered differs from the confirmed password. Please correct.");
		
	if (!fv.isChecked("terms"))
		fv.raiseError("The member registration will not be processed if the Terms and Conditions have not been accepted / agreed to.");
	
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;	
}


function validateMemberDetails()
{
	fv = new formValidator();
	
	if (fv.isEmpty("first_name"))
		fv.raiseError("Please specify your first name.");
	
	if (fv.isEmpty("surname"))
		fv.raiseError("Please specify your first name.");
		
	if (fv.isEmpty("email"))
		fv.raiseError("Please specify your email address.");
	else
	if (!fv.isEmailAddress("email"))
		fv.raiseError("Please specify a valid email address.");
		
	if (fv.isEmpty("confirm_email"))
		fv.raiseError("Please specify confirm your email address.");
		
	if (!fv.isSame("email", "confirm_email"))
		fv.raiseError("The email address differs from the confirmed email address. Please correct.");
		
	if (fv.isEmpty("city"))
		fv.raiseError("Please specify a city.");
		
	if (fv.isEmpty("province"))
		fv.raiseError("Please specify a province.");
		
	if (fv.isEmpty("postal_code"))
		fv.raiseError("Please specify a postal code.");
		
	if (fv.isEmpty("country"))
		fv.raiseError("Please specify a country.");		
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;	
}

function validateForgottenPassword()
{
	fv = new formValidator();
	
	if (fv.isEmpty("your_email"))
		fv.raiseError("Please specify your email address.");
	else
	{
		if (!fv.isEmailAddress("your_email"))
			fv.raiseError("Please specify a valid email address.");
	}
	
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

function validateOffer()
{
	fv = new formValidator();
	
	if (fv.isEmpty("property_description"))
		fv.raiseError("Please specify the property description.");
	
	if (fv.isEmpty("person_name"))
		fv.raiseError("Please specify name of entity / person.");
		
	if (fv.isEmpty("offer_price"))
		fv.raiseError("Please specify an offer price.");
		
	if (!fv.isCheckedRadio("finance"))
		fv.raiseError("Please specify how are you financing your investment.");
		
	if (!fv.isChecked("terms"))
		fv.raiseError("The offer will not be processed if the Terms and Conditions have not been accepted / agreed to.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
	
}	

function validateBondApplication()
{
	fv = new formValidator();
	
	/* ************
	
	if (fv.isEmpty(""))
		fv.raiseError("");
		
	if (!fv.isSelected(""))
		fv.raiseError("");
	
	************ */
	
	if (fv.isEmpty("Firstname"))
		fv.raiseError("Please provide your First Name.");
	
	if (fv.isEmpty("Surname"))
		fv.raiseError("Please provide us with your Surname.");
	
	if (fv.isEmpty("IDNo"))
		fv.raiseError("Please provide us with your ID number.");
		
	if (fv.isEmpty("address"))
		fv.raiseError("Please provide us with your address.");	
	
	if (fv.isEmpty("AddrArea"))
		fv.raiseError("Please provide us with your area.");
	
	if (fv.isEmpty("AddrPostalCode"))
		fv.raiseError("Please provide us with your Postal Code.");
		
	if (!fv.isEmpty("HomeEmail"))
	{
		if (!fv.isEmailAddress("HomeEmail"))
			fv.raiseError("Please provide us with a valid Email Address.");
	}
	else
		fv.raiseError("Please provide us with an Email Address.");
	
	var haveTelNo = false;
	var HomeTel = fv.findObj("HomeTelCode").value + " " + fv.findObj("HomeTelNo").value;
	var WorkTel = fv.findObj("WorkTelCode").value + " " +  fv.findObj("WorkTelNo").value;
	var Cell = fv.findObj("CellNo").value;
	
	if ( (trim(HomeTel) != "") || (trim(WorkTel) != "") || (trim(Cell) != "") )
		haveTelNo = true;
		
	if (!haveTelNo)
		fv.raiseError("Please supply at least one contact number");
	
	if (fv.isEmpty("EstimatedPurchasePrice"))
		fv.raiseError("Please provide an Purchase price for the property.");
	
	if (fv.isEmpty("LessDeposit"))
		fv.raiseError("Please provide the amount of funds that will be available for deposit.");
	
	if (fv.isEmpty("LoanAmount"))
		fv.raiseError("Please provide the amount of funds that is required to be loaned.");
	
	if (fv.isEmpty("MonthlyIncome"))
		fv.raiseError("Please provide us with your Monthly Income.");
		
	if (!fv.isSelected("AgreeToCreditCheck"))
		fv.raiseError("Please indicate if you agree to allow us to do a credit check on you.");		
	
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

function validateSubscribeInfo()
{
	fv = new formValidator();
	
	if (fv.isEmpty("subscriber_email"))
		fv.raiseError("Please provide email address.");

	if (fv.isEmpty("full_name"))
		fv.raiseError("Please provide your full names.");
		
	if (fv.isEmpty("area"))
		fv.raiseError("Please provide your area.");

	if (!fv.isSelected("heard"))
		fv.raiseError("Please let us know where you heard about us.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

//-->