/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}
//  End -->

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function validateFormFields( )	{

	 var rtn = false;
	 var rtnMsg = "Please provide the following information:\n\n";
	 
	 //Property Owner's Name | txt_submission_owners_name
	 if ( trim(document.frm_newlisting.txt_submission_owners_name.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Property Owner's Name\n";
	    rtn = true;
	 }
	 //Address Line 1 | txt_submission_address1
	 if ( trim(document.frm_newlisting.txt_submission_address1.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Address Line 1\n";
	    rtn = true;
	 }
	 //City | txt_submission_city
	 if ( trim(document.frm_newlisting.txt_submission_city.value) == "" )	{
	 		rtnMsg = rtnMsg + "* City\n";
	    rtn = true;
	 }
	 //State | txt_submission_state
	 if ( trim(document.frm_newlisting.txt_submission_state.value) == "" )	{
	 		rtnMsg = rtnMsg + "* State\n";
	    rtn = true;
	 }
	 //Zip | txt_submission_zip
	 if ( trim(document.frm_newlisting.txt_submission_zip.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Zip\n";
	    rtn = true;
	 }
	 //County | txt_submission_county
	 if ( trim(document.frm_newlisting.txt_submission_county.value) == "" )	{
	 		rtnMsg = rtnMsg + "* County\n";
	    rtn = true;
	 }
	 //Property Type | txt_property_type
	 if ( trim(document.frm_newlisting.txt_property_type.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Property Type\n";
	    rtn = true;
	 }
	 //Beginning Listing Date | txt_submission_listing_startdate
	 if ( trim(document.frm_newlisting.txt_submission_listing_startdate.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Beginning Listing Date\n";
	    rtn = true;
	 }
	 //Offered Sales Price | txt_submission_price
	 if ( trim(document.frm_newlisting.txt_submission_price.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Offered Sales Price\n";
	    rtn = true;
	 }
	 //Phones | txt_phone1 | txt_phone2
	 if ( trim(document.frm_newlisting.txt_phone1.value) == "" && trim(document.frm_newlisting.txt_phone2.value) == "" )	{
	 		rtnMsg = rtnMsg + "* [At least one] Phone Number to Display in MLS\n";
	    rtn = true;
	 }
	 //Commission | txt_commission | txt_other_commission
	 if ( trim(document.frm_newlisting.txt_commission.value) == "" && trim(document.frm_newlisting.txt_other_commission.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Commission Percentage to Offer Buyer's Realtor\n";
	    rtn = true;
	 }
	 if ( trim(document.frm_newlisting.txt_commission.value) == "O" && trim(document.frm_newlisting.txt_other_commission.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Commission Percentage to Offer Buyer's Realtor\n";
	    rtn = true;
	 }
	 //Email Address | txt_email_address
	 if ( trim(document.frm_newlisting.txt_email_address.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Email Address\n";
	    rtn = true;
	 }
	 //Defects | txt_defects_yn | txt_defects
	 if ( trim(document.frm_newlisting.txt_defects_yn.value) == "" )	{
	 		rtnMsg = rtnMsg + "* Does the property have any defects that must be disclosed?\n";
	    rtn = true;
	 }
	 if ( trim(document.frm_newlisting.txt_defects_yn.value) == "Yes" && trim(document.frm_newlisting.txt_defects.value) == "" ) {
	 		rtnMsg = rtnMsg + "* [Please list property defects]\n";
	    rtn = true;
	 }
	 //Pay Type | txt_paytype
	 if ( trim(document.frm_newlisting.txt_paytype.value) == "" )	{
	 		rtnMsg = rtnMsg + "* How do you wish to pay?\n";
	    rtn = true;
	 }
	 //T&C | cbx_terms
	 if ( document.frm_newlisting.cbx_terms.checked != true )	{
	 		rtnMsg = rtnMsg + "* You must accept the Terms and Conditions\n";
	    rtn = true;
	 }

	 if ( rtn ) { 
	 		alert(rtnMsg);
	 		return false;
	 }
	 else { return true; }
}
