
function validate(form)
{
		
	if(Trim(form.PropertyType.value).length < 1)
	{
		alert("Enter Property Type")
		form.PropertyType.focus() 
		 
		return false	
	}	
	
	if(Trim(form.District.value).length < 1)
	{
		alert("Enter District")
		form.District.focus() 
		 
		return false	
	}		
	if(Trim(form.Place.value).length > 100)
	{
		alert("Maximum allowed length of Place is 100 !!!")
		form.Place.select()
		form.Place.focus() 
		 
		return false	
	}		
	if(Trim(form.Purpose.value).length < 1)
	{
		alert("Enter Purpose")
		form.Purpose.focus() 
		 
		return false	
	}		
	
	
	if(form.Details.value>1000)
	{
		alert("Details (limit exceeds) ")
		form.Details.select()
		form.Details.focus() 		 
		return false		
	}	
	
	if(Trim(form.Name.value).length < 1)
	{
		alert("Enter Name")
		form.Name.select()
		form.Name.focus() 
		 
		return false	
	}	
	if(Trim(form.Name.value).length > 50)
	{
		alert("Maximum allowed length of Name is 50 !!!")
		form.Name.select()
		form.Name.focus() 
		 
		return false	
	}	
	if(Trim(form.Address.value).length < 1)
	{
		alert("Enter Address")
		form.Address.select()
		form.Address.focus() 
		 
		return false	
	}	
	if(Trim(form.Address.value).length > 150)
	{
		alert("Maximum allowed length of Address is 150 !!!")
		form.Address.select()
		form.Address.focus() 
		 
		return false	
	}	
	
	if(Trim(form.Pin.value).length < 1)
	{
		alert("Enter Pin")
		form.Pin.select()
		form.Pin.focus() 
		 
		return false	
	}	
	if(Trim(form.Pin.value).length > 50)
	{
		alert("Maximum allowed length of Pin is 50 !!!")
		form.Pin.select()
		form.Pin.focus() 
		 
		return false	
	}
	if(Trim(form.Phone.value).length > 50)
	{
		alert("Maximum allowed length of Phone is 50 !!!")
		form.Phone.select()
		form.Phone.focus() 
		 
		return false	
	}
	if(Trim(form.Mobile.value).length > 50)
	{
		alert("Maximum allowed length of Mobile is 50 !!!")
		form.Mobile.select()
		form.Mobile.focus() 
		 
		return false	
	}
	if(Trim(form.Email.value).length > 50)
	{
		alert("Maximum allowed length of Email is 50 !!!")
		form.Email.select()
		form.Email.focus() 
		 
		return false	
	}
	if(Trim(form.Website.value).length > 100)
	{
		alert("Maximum allowed length of Website is 100 !!!")
		form.Website.select()
		form.Website.focus() 
		 
		return false	
	}			
	form.submitbutton.disabled = true;
	return true;
}
function checkNumeric(objValue)
{
	 
		  var charpos = objValue.value.search("[^0-9.]"); 
		  if(objValue.value.length > 0 &&  charpos >= 0) 
		  {                            
			//alert("\n [Error character position " + eval(charpos+1)+"]"); 
			return false; 
		  }
	      else
	      {
				return true;
		  }
                         
           
}

function LTrim(str)
{
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            // We have a string with leading blank(s)...
            var j=0, i = s.length;
            // Iterate from the far left of string until we
            // don't have any more whitespace...
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            // Get the substring from the first non-whitespace
            // character to the end of the string...
            s = s.substring(j, i);
        }
        return s;
}
// Trims all spaces to the right of a specific string
function RTrim(str)
{
        // We don't want to trip JUST spaces, but also tabs,
        // line feeds, etc.  Add anything else you want to
        // "trim" here in whitespace
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            // We have a string with trailing blank(s)...
            var i = s.length - 1;       // Get length of string
            // Iterate from the far right of string until we
            // don't have any more whitespace...
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            // Get the substring from the front of the string to
            // where the last non-whitespace character is...
            s = s.substring(0, i+1);
        }
        return s;
}
                                                                                                                        
// Trims all spaces to the left and right of a specific string by calling RTim
// and LTrim
function Trim(str)
{
        return RTrim(LTrim(str));
}

function changeUnit(name)
{
	var str = name.value
	
	if(Trim(str).length > 0)
	{
		if( (Trim(str) == "1") || (Trim(str) == "4"))
		{
			document.addproduct.AreaUnit.value = "cent"
		}
		else if( (Trim(str) == "2") || (Trim(str) == "3") || (Trim(str) == "5"))
		{
			document.addproduct.AreaUnit.value = "sq.ft"
		}		
		return true;
	}
	else
	{
		document.addproduct.AreaUnit.value = ""
		//alert ("Please select property type");
		name.focus();
		return false;		
	}
}
function changePurposeText(name)
{
	var str = name.value
	
	if(Trim(str).length > 0)
	{
		if(Trim(str) == "Rent")
		{
			document.addproduct.PriceText.value = "Monthly Rent"
		}
		else if(Trim(str) == "Sale")
		{
			document.addproduct.PriceText.value = "Total Price"
		}		
		else if(Trim(str) == "Both")
		{
			document.addproduct.PriceText.value = "Price/Rent"
		}		
		return true;
	}
	else
	{
		document.addproduct.PriceText.value = ""
		//alert ("Please select property type");
		name.focus();
		return false;		
	}
}