	function validate(theForm) {
		
		if (theForm.name.value=='') {
			alert("Please enter full name");
			theForm.name.focus();
			return false;
		}
		
		if (theForm.number.value==''){
			alert("Please enter your contact number");
			theForm.number.focus();
			return false;
		}
		
		if (theForm.number.value!=''){
			if ((!isNumeric(theForm.number.value))||(theForm.number.value.length < 10)){
				alert("Please enter a valid contact number");
				theForm.number.value = '';
				theForm.number.focus();
				return false;
			}
		}
		
		if (!emailCheck(theForm.email.value)){
			theForm.email.value = '';
			theForm.email.focus();
			return false;
		}
		
		if (theForm.query.value=='') {
			alert("Please enter your query");
			theForm.query.focus();
			return false;
		}		
	}

	function login(downloadlogin) 
	{
		if (!emailCheck(theForm.username.value))
		{
			downloadlogin.username.value = '';
			downloadlogin.username.focus();
			return false;
		}
		
		if (downloadlogin.password.value=='') 
		{
			alert("Please enter your password");
			downloadlogin.password.focus();
			return false;
		}		
	}
	
	function isNumeric(str)
	{
	var pattern = "0123456789+-)( ";
	var i = 0;
		do
		{
			var pos = 0;
			for (var j=0;j<pattern.length;j++)
				if (str.charAt(i)==pattern.charAt(j))
					pos = 1;
			i++;
		}
		while (pos==1 && i<str.length)
		if (pos==0)
			return false;
		return true;
	}
	
	function emailCheck (emailStr) 
	{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
		if (matchArray==null) 
		{
		alert("Please enter a valid email address (check @ and .'s)")
		return false
		}
	var user=matchArray[1]
	var domain=matchArray[2]
		if (user.match(userPat)==null) 
		{
	   	// user is not valid
	   	alert("The username doesn't seem to be valid.")
	   	return false
		}
	var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) 
		{
	   	// this is an IP address
	  	for (var i=1;i<=4;i++) 
		{
	    if (IPArray[i]>255) 
			{
	        alert("Destination IP address is invalid!")
			return false
	    	}
	   	}
	   	return true
	}
	var domainArray=domain.match(domainPat)
		if (domainArray==null) 
		{
		alert("The domain name doesn't seem to be valid.")
	   	return false
		}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
		{
		alert("The address must end in a three-letter domain, or two letter country.")
	   	return false
		}
		if (len<2) 
		{
		var errStr="This address is missing a hostname!"
		alert(errStr)
		return false
		}
		return true;
	}
