<!--
/* <![CDATA[ */
var btnPrevious = false;
function PropertyListingValidateForm(theForm,theDetails)
{
if(btnPrevious == false)
{	
	// Validate Standard Form Fields	
	success = SellerWizardValidation(theForm,theDetails);
	if (success == false)
	{
		return false;
	}	
	
	// Step 1 Validation
	if(theDetails.indexOf("ConfirmEmailAddress")!=-1)
	{
		if (theForm.ConfirmEmailAddress.value == "")
		  {
		    alert("Please enter a value for the \"Confirm Email Address\" field.");
		    theForm.ConfirmEmailAddress.focus();
		    return (false);
		  }

		  if (theForm.Username.value != theForm.ConfirmEmailAddress.value)
		  {
		    alert("The \"Email Address\" and \"ConfirmEmailAddress\" fields do not match.");
		    theForm.ConfirmEmailAddress.focus();
		    return (false);
		  }     
	}
	
	if(theDetails.indexOf("Password")!=-1)
	{
		if (theForm.Password.value == "")
		  {
		    alert("Please enter a value for the \"Password\" field.");
		    theForm.Password.focus();
		    return (false);
		  }

		  if (theForm.Password.value.length < 6)
		  {
		    alert("The \"Password\" field must be at least 6 characters.");
		    theForm.Password.focus();
		    return (false);
		  }
	}

	if(theDetails.indexOf("ConfirmPassword")!=-1)
	{
		  if (theForm.ConfirmPassword.value == "")
		  {
		    alert("Please enter a value for the \"Confirm Password\" field.");
		    theForm.ConfirmPassword.focus();
		    return (false);
		  }

		  if (theForm.Password.value != theForm.ConfirmPassword.value)
		  {
		    alert("The \"Password\" and \"Confirm Password\" fields do not match.");
		    theForm.ConfirmPassword.focus();
		    return (false);
		  }
	}

	if(theDetails.indexOf("PhoneWork")!=-1)
	{  
		  // Telephone
		  if (theForm.PhoneWork.value == "")
		  {
		    alert("Please enter a value for the \"Office Number\" field.");
		    theForm.PhoneWork.focus();
		    return (false);
		  }

		  if (theForm.PhoneWork.value.length < 1)
		  {
		    alert("Please enter at least 1 characters in the \"Office Number\" field.");
		    theForm.PhoneWork.focus();
		    return (false);
		  }

		  if (theForm.PhoneWork.value.length > 50)
		  {
		    alert("Please enter at most 50 characters in the \"Office Number\" field.");
		    theForm.PhoneWork.focus();
		    return (false);
		  }
	}

	if(theDetails.indexOf("UnitNumber")!=-1)
	{  
		  // UnitNumber
		  if (theForm.UnitNumber.value == "")
		  {
		    alert("Please enter a value for the \"Unit Number\" field.");
		    theForm.UnitNumber.focus();
		    return (false);
		  }

	}

	if(theDetails.indexOf("StreetNumber")!=-1)
	{  
		  // StreetNumber
		  if (theForm.StreetNumber.value == "")
		  {
		    alert("Please enter a value for the \"Street Number\" field.");
		    theForm.StreetNumber.focus();
		    return (false);
		  }

	}

	if(theDetails.indexOf("StreetName")!=-1)
	{  
		  // StreetName
		  if (theForm.StreetName.value == "")
		  {
		    alert("Please enter a value for the \"Street Name\" field.");
		    theForm.StreetName.focus();
		    return (false);
		  }

	}

	if(theDetails.indexOf("PostCode")!=-1)
	{  
		  // PostCode
		  if (theForm.PostCode.value == "")
		  {
		    alert("Please enter a value for the \"Postcode\" field.");
		    theForm.PostCode.focus();
		    return (false);
		  }

	}

	if(theDetails.indexOf("Suburb")!=-1)
	{  
		  // Suburb
		  if (theForm.Suburb.value == "")
		  {
		    alert("Please enter a value for the \"Suburb\" field.");
		    theForm.Suburb.focus();
		    return (false);
		  }

	}

	if(theDetails.indexOf("State")!=-1)
	{  
		  // State
		  if (theForm.State.value == "")
		  {
		    alert("Please enter a value for the \"State\" field.");
		    theForm.State.focus();
		    return (false);
		  }

	}

	if(theDetails.indexOf("Price")!=-1)
	{  
		  // Price
		  if (theForm.Price.value == "")
		  {
		    alert("Please enter a value for the \"Price\" field.");
		    theForm.Price.focus();
		    return (false);
		  }
		  
		  var numArray = $("input[name='Price']").parse({format:"#.#", locale:"us"});
					
		if(numArray == null || numArray.length > 1)
		{
			alert("You have not entered a number. Please enter only digits and decimal points in the sale price.")
			$("input[name='Price']").focus();
			return false;
		}
		
		var priceVal = numArray[0];
		$("input[name='Price']").val(priceVal);

	}

	if(theDetails.indexOf("ListingStartDate")!=-1)
	{  
		  // Date for property to go live
		  if (theForm.ListingStartDate.value == "")
		  {
		    alert("Please enter a value for the \"Date for property to go live\" field.");
		    theForm.ListingStartDate.focus();
		    return (false);
		  }

                  var checkStr = theForm.ListingStartDate.value;		  
		  if (checkStr.charAt(2) != "-" || checkStr.charAt(5) != "-")
		  {
		    alert("Please enter the date in the format dd-mm-yyyy.");
		    theForm.ListingStartDate.focus();
		    return (false);
		  }
		  
		  if ((checkStr.charAt(3) != "0" && checkStr.charAt(3) != "1") || (checkStr.charAt(3) == "1" && (checkStr.charAt(4) != "0" && checkStr.charAt(4) != "1" && checkStr.charAt(4) != "2")) || (checkStr.charAt(3) == "0" && checkStr.charAt(4) == "0"))
		  {
		    alert("Please enter a month between 01 and 12.");
		    theForm.ListingStartDate.focus();
		    return (false);
		  }

		  if ((checkStr.charAt(0) != "0" && checkStr.charAt(0) != "1" && checkStr.charAt(0) != "2" && checkStr.charAt(0) != "3")  
			|| (checkStr.charAt(0) == "3" && (checkStr.charAt(1) != "0" && checkStr.charAt(1) != "1")) 
			|| (checkStr.charAt(0) == "0" && checkStr.charAt(1) == "0"))
		  {
		    alert("Please enter a Day between 01 and 31.");
		    theForm.ListingStartDate.focus();
		    return (false);
		  }

		  if (theForm.ListingStartDate.value.length != 10)
		  {
		    alert("Please enter the date in the format dd-mm-yyyy.");
		    theForm.ListingStartDate.focus();
		    return (false);
		  }
	}
	
	if(theDetails.indexOf("Description")!=-1)
	{  
		  // Price
		  if (theForm.Description.value == "")
		  {
		    alert("Please enter a summary of your property.");
		    theForm.Description.focus();
		    return (false);
		  }
	}

	// Step 2 Validation
	if(theDetails.indexOf("TermsandConditions")!=-1)
	{  
		  // Terms and Conditions
		  if (theForm.TermsandConditions.checked != 1)
		  {
		    alert("You must agree to the Terms and Conditions to continue.");
		    theForm.TermsandConditions.focus();
		    return (false);
		  }

	}

	if(theDetails.indexOf("AgencyAgreement")!=-1)
	{  
		  // Agency Agreement
		  if (theForm.AgencyAgreement.checked != 1)
		  {
		    alert("You must agree to the Agency Agreement to continue.");
		    theForm.AgencyAgreement.focus();
		    return (false);
		  }

	}

	if(theDetails.indexOf("Service")!=-1)
	{  
		// Service
		var serviceChecked = false;
		if(typeof(theForm["Service[]"].length) == 'undefined')
		{
			//Only 1 service
			if (theForm["Service[]"].checked == true)
			{
				serviceChecked = true;		    
			}
		}
		else
		{
			for (i = 0;  i < theForm["Service[]"].length;  i++)
			{		  
				if (theForm["Service[]"][i].checked == true)
				  {
					serviceChecked = true;		    
				  }
			}
		}
		if (serviceChecked == false)
		{
			alert("You must select at least one service.");
			if(typeof(theForm["Service[]"].length) == 'undefined')
			{
				theForm["Service[]"].focus();
			}
			else
				theForm["Service[]"][0].focus();
			return (false);
		}

	}

	// Step 3 Validation
	if(theDetails.indexOf("PaymentMethod")!=-1)
	{  
		  // PaymentMethod
		  if (theForm.PaymentMethod.selectedIndex == 0)
		  {
		    alert("Please select a Payment Method.");
		    theForm.PaymentMethod.focus();
		    return (false);
		  }	

		if(theForm.PaymentMethod.value=="CreditCard")
		{
			// Name On Card
			  if (theForm.NameOnCard.value == "")
			  {
			    alert("Please enter the name on your credit card.");
			    theForm.NameOnCard.focus();
			    return (false);
			  }
			
			  if (theForm.NameOnCard.value.length < 1)
			  {
			    alert("Please enter the name on your credit card.");
			    theForm.NameOnCard.focus();
			    return (false);
			  }
			
			//CreditCardMonth
			  if (theForm.CreditCardMonth.selectedIndex < 0)
			  {
			    alert("Please select an \"Expiration Month\".");
			    theForm.CreditCardMonth.focus();
			    return (false);
			  }
			
			  if (theForm.CreditCardMonth.selectedIndex == 0)
			  {
			    alert("The first \"Expiration Month\" is not a valid selection.  Please choose one of the other \"Expiration Months\".");
			    theForm.CreditCardMonth.focus();
			    return (false);
			  }
			  
			//CreditCardYear
			  if (theForm.CreditCardYear.selectedIndex < 0)
			  {
			    alert("Please select an \"Expiration Year\".");
			    theForm.CreditCardYear.focus();
			    return (false);
			  }
			
			  if (theForm.CreditCardYear.selectedIndex == 0)
			  {
			    alert("The first \"Expiration Year\" is not a valid selection.  Please choose one of the other \"Expiration Years\".");
			    theForm.CreditCardYear.focus();
			    return (false);
			  }
			  
			//CreditCardType
			  if (theForm.CreditCardType.selectedIndex < 0)
			  {
			    alert("Please select a \"Credit Card Type\".");
			    theForm.CreditCardType.focus();
			    return (false);
			  }
			
			  if (theForm.CreditCardType.selectedIndex == 0)
			  {
			    alert("The first \"Credit Card Type\" is not a valid selection.  Please choose one of the other \"Credit Card Types\".");
			    theForm.CreditCardType.focus();
			    return (false);
			  }
			  
			//Check Expiration Date is greater than current date
			  time=new Date();
			  month=time.getMonth();
			  month=month+1;
			  year=time.getYear();
			  if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000))		
			  year="19" + year;
			  if (navigator.appName == "Netscape")
			  year=1900 + year;
			  year=parseInt(year);
			  ExpiryYear=parseInt(theForm.CreditCardYear.value)
			  if(ExpiryYear==year)
			  {
			  	ExpiryMonth=parseInt(theForm.CreditCardMonth.value);
			  	if(ExpiryMonth<month)
			  	{
			  		alert("The \"Expiration Dates\" that you have selected for your \"Credit Card\" indicated that it is expired. Please verify that your \"Expiration Month\" and \"Expiration Year\" are correct.")
			  		theForm.CreditCardMonth.focus();
			 		return (false);
			  	}
			  }
				
			  //CreditCardNum
			  if (theForm.CreditCardNum.value.length < 1)
			  {
			    alert("Please enter a \"valid credit card number\".");
			    theForm.CreditCardNum.focus();
			    return (false);
			  }
			  else
			  {
				  //CreditCardNum
				  cardNumberIn=theForm.CreditCardNum.value;
				  cardNumberIn=stripWhitespace (cardNumberIn);
				  cardNumberIn=stripCharsNotInBag(cardNumberIn,"0123456789");
				  theForm.CreditCardNum.value=cardNumberIn;
				  cardTypeIn =theForm.CreditCardType.value;
				  cardTypeIn = cardTypeIn.toUpperCase();
				  
				  if(cardNumberIn != "")
				  {
					  if(cardTypeIn != "BANKCARD" && parseInt(cardTypeIn) == "NaN")
					  {
					  	if(isCardMatch(cardTypeIn,cardNumberIn))
					  	{
					  		//return (true);
					  	}
					  	else
					  	{
					  		 alert("Your \"Credit Card Number\" and/or your \"Credit Card Type\" are not correct. Please confirm that you have entered these details correctly.");
				  			 theForm.CreditCardNum.focus();
							 return (false);
					  	}
					  }
					  else
					  {
					  	if(!isCreditCard(cardNumberIn))
					  	{
					  		alert("Please enter a valid Credit Card Number.");
		  			 		theForm.CreditCardNum.focus();
							return (false);
					  	}
					  }
				}
				else
				{
					 alert("Please enter a valid Credit Card Number.");
		  			 theForm.CreditCardNum.focus();
					 return (false);	
				}
			  }
			  
			  //CreditCardAddSecurityNum
			  if(theDetails.indexOf("CreditCardAddSecurityNum")!=-1)
			  {
				  if(theForm.CreditCardAddSecurityNum.value.length < 1 || theForm.CreditCardAddSecurityNum.value.length > 3)
		  	  	  {
		  	  		alert("You have not entered a correct value for the \"Additional Security Credit Card Numbers\". Please verify the numbers on the back of your credit card.");
		  			theForm.CreditCardAddSecurityNum.focus();
					return (false);
		  	  	  }
		  	  	  if(!isInteger(theForm.CreditCardAddSecurityNum.value))
		  	  	  {
		  	  		alert("You have not entered a correct value for the \"Additional Security Credit Card Numbers\". Please verify the numbers on the back of your credit card.");
		  			theForm.CreditCardAddSecurityNum.focus();
					return (false);
		  	  	  }
		  	  }
		}
		  
		if(theForm.PaymentMethod.value!="CreditCard" && (theForm.CreditCardMonth.selectedIndex>0 || theForm.CreditCardYear.selectedIndex>0 || theForm.CreditCardType.selectedIndex>0 || theForm.CreditCardNum.value!=""))
		{
		  	 alert("You have selected Payment Method: \"" + theForm.PaymentMethod.value + "\" but you have entered \"Credit Card\" Information. Please confirm you have chosen the correct \"Payment Method\". If you are not using \"Credit Card\" for payment please remove all Credit Card Details.");
		  	 theForm.PaymentMethod.focus();
			 return (false);
		}
	}

	// Step 4 Validation
	if(theDetails.indexOf("SignContactName")!=-1 && typeof(theForm.SignContactName) != 'undefined')
	{  
		  // SignContactName
		  if(typeof(theForm.ContactDetailsNotRequired) != 'undefined' && theForm.ContactDetailsNotRequired.checked == false)
		  {
			  if (theForm.SignContactName.value == "")
			  {
			    alert("Please enter a \"Contact Name\" for the sign.");
			    theForm.SignContactName.focus();
			    return (false);
			  }
		 }
	}
	
	if(theDetails.indexOf("SignContactNumber")!=-1 && typeof(theForm.SignContactNumber) != 'undefined')
	{  
		  // SignContactName
		  if(typeof(theForm.ContactDetailsNotRequired) != 'undefined' && theForm.ContactDetailsNotRequired.checked == false)
		  {
			  if (theForm.SignContactNumber.value == "")
			  {
			    alert("Please enter a \"Contact Number\" for the sign.");
			    theForm.SignContactNumber.focus();
			    return (false);
			  }
		 }
	}

	if(theDetails.indexOf("HasReadPropertyGuide")!=-1 && typeof(theForm.HasReadPropertyGuide) != 'undefined')
	{  
		  // Has Read Property Guide
		  if (theForm.HasReadPropertyGuide.checked == false)
		  {
		    alert("You must Read the Property Guide before you continue.");
		    theForm.HasReadPropertyGuide.focus();
		    return (false);
		  }
	}

	if(theDetails.indexOf("HasContractOfSale")!=-1 && typeof(theForm.HasContractOfSale) != 'undefined')
	{  
		  // Has Contract Of Sale 
		  if (theForm.HasContractOfSale.checked == false)
		  {
		    alert("You must have the Contract For Sale before you continue.");
		    theForm.HasContractOfSale.focus();
		    return (false);
		  }
	}

	if(theDetails.indexOf("HasPhotosReady")!=-1 && typeof(theForm.HasPhotosReady) != 'undefined')
	{  
		  // Has Photos Ready
		  if (theForm.HasPhotosReady.checked == false)
		  {
		    alert("You must have Photos ready before you continue.");
		    theForm.HasPhotosReady.focus();
		    return (false);
		  }
	}
}
	
	return (true);
}
/* ]]> */
//-->

