function f_submitSearch()
{
	var PriceMin = document.getElementById("PriceMin").value ;
	var PriceMax = document.getElementById("PriceMax").value ;
	var RentalType = document.getElementById("RentalType").value ;

	if ( PriceMin == '' ) document.getElementById("PriceMin").value = 0 ;

	if ( PriceMax == '' )
	{
		PriceMax = 20000000 ;
		if ( RentalType == 'S' ) PriceMax = 2000 ;
		if ( RentalType == 'L' ) PriceMax = 20000 ;
		document.getElementById("PriceMax").value = PriceMax ;
	}
	
	var x = parseFloat(PriceMin);
	var y = parseFloat(PriceMax);
	var e = true ;

	if ( isNaN(x) )
	{
		alert("Minimum Price is Invalid ");
		e = false ;
	}
	else if ( isNaN(y) )
	{
		alert("Maximum Price is Invalid ");
		e = false ;
	}
	else if ( x > y )
	{
		alert("Maximum Price is less than Minimum Price ");
		e = false ;
	}
	
	if ( e )
	{
		document.getElementById("quickSearchForm").action = "residential-property-search-results.php" ;
		document.getElementById("quickSearchForm").submit() ;
	}
}

function f_checkNumber( objname, decplaces, reqdfield )
{
	var num  = objname;
	var dp   = decplaces;
	var reqd = reqdfield;
	var x    = num.value;

	if ( x == "" )
	{
		if ( reqd )
		{
			alert( "Please enter a numeric value in this field " );
			num.select();
			num.focus();
			return false;
		}
		else
		{
			num.value = 0;
			return true;
		}
	}

	var dpFound  = false;
	var dpCount  = 0;
	var allValid = true;
	var checkOK ;

	if ( dp > 0 )
		checkOK = ".0123456789"
	else
		checkOK = "0123456789";
  
	for ( i = 0;  i < x.length;  i++ )
	{
		ch = x.charAt(i);
	
		for ( j = 0;  j < checkOK.length;  j++ )

			if ( ch == checkOK.charAt(j) )
			{
				if ( ch == "." )
				{
					if ( dpFound )  // more than one decimal point found
					{
						allValid = false;
						break;
					}
					else
					{
						dpFound = true;
					}
				}
				else
				{
					if ( dpFound ) dpCount++ ;
				}
		
				break;
			}
	  
		if ( j == checkOK.length )
		{
			allValid = false;
			break;
		}
	}
  
	if ( !allValid )
	{
		alert( "Please enter only numeric values in this field " );
		num.select();
		num.focus();
		return false;
	}

	if ( dpCount > dp )
	{
		alert( "Please enter only "+dp+" decimal places in this field " );
		num.select();
		num.focus();
		return false;
	}

	return true;
}
