function clear()
{
	document.form.reset();
}


function validate()
{
	
	var x  = document.Contact;
	if(x.firstname.value=='')
	{
		alert("Enter your First Name");
		x.firstname.focus();
		x.firstname.select();
		return false;
	}
	else if(x.firstname.value.substring(0, 1)==' ')
	{
		alert("First character of a First Name should not be space");
		x.firstname.focus();
		x.firstname.select();
		return false;
	}
	for (var i = 0; i < x.firstname.value.length; i++) 
	{
		var ch = x.firstname.value.substring(i, i + 1);
		if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != ' ' && ch!='.') 
		{
			alert("\nThe Name field only accepts letters & spaces.\n\nPlease re-enter your Name.");
			x.firstname.focus();
			x.firstname.select();
			return false;
		}
	}

	if(x.lastname.value=='')
	{
		alert("Enter your Last Name");
		x.lastname.focus();
		x.lastname.select();
		return false;
	}
	else if(x.lastname.value.substring(0, 1)==' ')
	{
		alert("First character of a Last Name should not be space");
		x.lastname.focus();
		x.lastname.select();
		return false;
	}
	for (var i = 0; i < x.lastname.value.length; i++) 
	{
		var ch = x.lastname.value.substring(i, i + 1);
		if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != ' ' && ch!='.') 
		{
			alert("\nThe Name field only accepts letters & spaces.\n\nPlease re-enter your Name.");
			x.lastname.focus();
			x.lastname.select();
			return false;
		}
	}


	var x2 = x.Email.value;
	if(x2=='')
	{
		alert("Enter your EMail I.D");
		x.Email.focus();
		x.Email.select();
		return false;
	}
	for (var i = 0, count1=0, count2=0; i < x2.length; i++) 
	{
		var ch=x2.substring(i, i + 1);
		if(ch=='@')
		count1++;
		if(ch=='.')
		count2++;
	}
	if((count1!=1)||(count2<1))
	{
		alert("Enter a proper EMail I.D \n\ne.g., username@example.com");
		x.Email.focus();
		x.Email.select();
		return false;
	} 	
	for(var i=0; i<x2.length; i++) 
	{
		var ch = x2.substring(i, i + 1);
		if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != '@' && ch!='.' && ch!='_' && ch!='-' && isNaN(ch)) 
		{
			alert("\nThe EMail I.D field only accepts letters, numbers and -,  _,  .\n\nPlease re-enter your User I.D.");
			x.Email.select();
			x.Email.focus();
			return false;
		}
	}
	for(i=0; i<x2.length; i++)
	{
		ch = x2.substring(i, i+1);
		if(ch == '@')
		break;
	}
	ch = x2.substring(0, i);
	if (((ch< "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch!='.' && ch!='_' && ch!='-' && isNaN(ch))
	{
		alert("\nThe EMail I.D field only accepts letters, numbers and -,  _,  .\n\nPlease re-enter your E-Email I.D.");
		x.Email.select();
		x.Email.focus();
		return false;
	}
	for(j=i+1; j<x2.length; j++)
	{
		ch = x2.substring(j, j+1);
		if(ch == '.')
		break;
	}
	ch = x2.substring(i+1, j);
	if ((ch< "a" || "z" < ch) && (ch < "A" || "Z" < ch))
	{
		alert("\nEnter proper EMail I.D");
		x.Email.select();
		x.Email.focus();
		return false;
	}
	ch = x2.substring(j+1);
	if ((ch< "a" || "z" < ch) && (ch < "A" || "Z" < ch))
	{
		alert("\nEnter proper EMail I.D");
		x.Email.select();
		x.Email.focus();
		return false;
	}

	if(x.Telephone)
	{
		if(x.Telephone.value=='')
		{
			alert("Enter your Telephone Number");
			x.Telephone.focus();
			x.Telephone.select();
			return false;
		}
		else if(x.Telephone.value.substring(0, 1)==' ')
		{
			alert("First character of a Telephone Number should not be space");
			x.Telephone.focus();
			x.Telephone.select();
			return false;
		}
	}

	if(x.sub)
	{
		if(x.sub.value=='')
		{
			alert("Enter your Subject");
			x.sub.focus();
			return false;
		}
	}

	if(x.message)
	{
		if(x.message.value=='')
		{
			alert("Enter your Message");
			x.message.focus();
			return false;
		}
		/*else if(x.message.value.substr(0, 1)==' ')
		{
			alert("First character of your Message should not be space");
			x.message.focus();
			x.message.select();
			return false;
		}*/
	}


	if(x.qualification)
	{
		if(x.qualification.value=='')
		{
			alert("Enter your Qualification");
			x.qualification.focus();
			return false;
		}
		/*else if(x.qualification.value.substr(0, 1)==' ')
		{
			alert("Please do not leave space at the starting");
			x.qualification.focus();
			x.qualification.select();
			return false;
		}*/
	}

	if(x.attachresume)
	{
		if(x.attachresume.value=="") 
			{
				alert('Upload the Resume in PDF or Document Format');  
				x.attachresume.focus();
				return false;  
			}
			extArray = new Array(".pdf", ".doc");
			if(x.attachresume.value !="") 
				{
					validformFile = /(.doc|.pdf|.DOC|.PDF)$/;
					if(!validformFile.test(x.attachresume.value))
						{
							alert("Please upload files that end in types:  " + extArray + "\nPlease select a new " + "file to upload and submit again.");
							x.attachresume.focus();
							x.attachresume.select();
							return false;
						}
				}
	}


	if (document.getElementById("sendingmail").style.display = "none")
		{
			document.getElementById("sendingmail").style.display = "block";
			document.getElementById("formtable").style.display = "none";
		}


}

