function validateEmail(emailid)
		{	
			if (emailid.charAt(0) == ' ')
			{
			alert("Email cannot have spaces");
			return false;
			}
			emailid = cutChars(emailid, " ");
			if(cutChars(emailid, ' ') == '')
			{
				return true;
			}
			at = emailid.indexOf("@");
			if(at <= -1) //one @ shd be there, not as the 1st char tho'
			{
				alert("Invlaid Emailid - no @");
				return false;
			}
			at1 = emailid.indexOf("@", at + 1);
			if(at1 != -1) //only one @ shd be there
			{
				alert("Invlaid Emailid - only one @");
				return false;
			}
			dot = emailid.indexOf(".", at + 1);
			if(dot - at < 2) //. shd be present, with atleast 1 char after @
			{
				alert("Invlaid Emailid - @.");
				return false;
			}
			if(emailid.indexOf(".@") != -1) //. shd not be just b4 @
			{
				alert("Invlaid Emailid - .@");
				return false;
			}
			if(emailid.indexOf("..") != -1)
			{
				alert("Invlaid Emailid - ..");
				return false;
			}
			if(emailid.charAt(emailid.length - 1) == "." || emailid.charAt(emailid.length - 2) == ".")
			{
				alert("Invlaid Emailid - last two chars");
				return false;
			}
			return true;
		}
	function cutChars(s, c)
		{
			var s1, x;
			x = s1 = "";
			l = s.length;
			for(i = 0; i < l; i++)
				if((x = s.charAt(i)) != c)
					s1+=x;
			return s1;
		}
		function isCharsInBag (s, bag)
		{
			var i;
			for (i = 0; i < s.length; i++)
			{

				var c = s.charAt(i);
				if (bag.indexOf(c) == -1) return false;
			}
			return true;
		}

function VerifyDetails()
{   var str=document.getElementById('f1');
   var name=str.name.value;
	if(name == "")
	    {
	    alert("Please enter Name!");
        str.name.focus();
        return false;
	    }
	
    var phone=str.phone.value;
	if(phone == "")
	    {
	    alert("Please enter Phone!");
        str.phone.focus();
        return false;
	    }
    var email=str.email.value;
	if(email == "")
	    {
	    alert("Please enter Email!");
        str.email.focus();
        return false;
	    }
	 if(!isCharsInBag(email,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890@_.-"))
	{
	   alert("Please Enter Valid Email. No special Characters allowed");
	  str.email.focus();
       return false;    
	}
	else if(!validateEmail(email))
	{
		str.email.focus();
		return false;
	}
			
	
	var reffered=str.reffered.value;
	if(reffered == "")
	    {
	    alert("Please Select: How did you find our website?");
        str.reffered.focus();
        return false;
	    }
   
   return true;
	
  
}
