

	var validator = {
		
		isEmailId : function(str){
				if(str == null)
				{
					//alert("Please enter valid emailId");
					return false;
				}
				str = this.trim(str);
				if(str.search(/\s/) != -1)
				{
					//alert("Please enter a valid emaiId");
					return false;
				}
				var p_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				var matches = str.match(p_email);
				if(matches == null || matches[0] != str)
				{
					//alert("Please enter a valid emaiId");
					return false;
				}
				
				
				return true;
				
		},
		
		trim: function(str)
		{
			str = str.replace(/\s+/g," ");
			str = str.replace(/^\s|\s$/g,"");
			return str;
		},
		
	};
	
	


	function formValidator()
	{
		var d = document;
		var form = d.reg_form;
		var block = d.getElementById("block");
		var flat = d.getElementById("flat");
		var house = d.getElementById("house_id");
		var pwd = d.getElementById('pwd');
		
		//Checking if the user has read terms & conditions.
		if(block)
		{
			if(block.value == '0' || flat.value == '')
			{
				alert("Please fill in your house details.");
				return false;
			}
		}

		if(house)
		{
			if(house.value == '')
			{
				alert("Please fill in the house detail");
				house.focus();
				return false;
			}
		}
		
		if(d.getElementById('first_name').value == '') 
		{
			alert("Please fill in your name.");
			d.getElementById('first_name').focus();
			return false;
		}
	
		//checking that the confirm password is same.		
		if((pwd) && (pwd.value == ''))
		{	
			alert('Please provide a password for your CommonFloor account');
			pwd.focus();
			return false;
		}
		
		if(d.getElementById("captcha").value == '') {
			alert("Please enter the text displayed in the image");
			d.getElementById("captcha").focus();
			return false;
		}
		
		
		if(d.getElementById("tnc").checked != true) {
			alert("Please go through our Terms of service.");
			return false;
		}

		return true;
		
	}
	

