function ValidateEmail( Email )
	{
		var atCharPresent = false;
		var dotPresent = false;

		for ( var Idx = 0; Idx < Email.length; Idx++ )
		{
			if ( Email.charAt ( Idx ) == '@' )
				atCharPresent = true;
			if ( Email.charAt ( Idx ) == '.' )
				dotPresent = true;
		}

		if ( !atCharPresent || !dotPresent )
			return false;

		return true;
	}


function validate(theForm){
	if (theForm.name.value == ""){
		alert("Please fill in your name");
		theForm.name.focus();
		return false;
	}
	if (theForm.phone.value == ""){
		alert("Please fill in your Phone");
		theForm.phone.focus();
		return false;
	}
    if (theForm.email.value == ""){
		alert("Please fill in your Email");
		theForm.email.focus();
		return false;
	}
	if ( !ValidateEmail( theForm.email.value ) )
			{
				alert( "Invalid E-mail " + theForm.email.value );
				theForm.email.focus( );
				return false;
			}

			if ( theForm.fileupload1.value == "" )
			{
				alert( "Please select your resume file." );
				theForm.fileupload1.focus( );
				return false;
			}
				
			var     extPos = theForm.fileupload1.value.lastIndexOf( "." );
            if ( extPos == - 1)
            {
                alert( "Only doc or pdf files can be added." );
				theForm.fileupload1.focus( );
				return false;
			}
            else
            {
				var extn =  theForm.fileupload1.value.substring(
					extPos + 1, theForm.fileupload1.value.length );
				if ( extn != "doc" && extn != "docx" && extn != "pdf" )
				{
                	alert( "Only doc or pdf files can be added." );
					theForm.fileupload1.focus( );
					return false;
				}
			}
}

