var bugchars = '!#$^&*()+|}{[]?><~%:;/,=`"\'';
function CharsInBag(s)
{   var i;
var lchar="";
    // Search through string's characters one by one.
    // If character is not in bag.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
		if(i>0)lchar=s.charAt(i-1)
        if (bugchars.indexOf(c) != -1 || (lchar=="." && c==".")) return false;
    }
    return true;
}
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is not a number.
        var c = s.charAt(i);
        if ((c >= "0") && (c <= "9") && (c != ".")) return false;
    }
    // All characters are numbers.
    return true;
}
function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var lastdot=str.lastIndexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.substring(lastdot+1)==""){
		    alert("Invalid E-mail ID")
		    return false
		}
		 
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		if(CharsInBag(str)==false){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 var arrEmail=str.split("@")
		 var ldot=arrEmail[1].indexOf(".")
		 if(isInteger(arrEmail[1].substring(ldot+1))==false){
		    alert("Invalid E-mail ID")
		    return false
		 }
	}
function ValidateForm(){
var email=document.resumeform.email;
var name=document.resumeform.name;
var fname=document.resumeform.fname;
var dob=document.resumeform.dob;
var contactno=document.resumeform.contactno;
var address=document.resumeform.address;
var area=document.resumeform.area;
var functional=document.resumeform.functional;
var university=document.resumeform.university;
var qualification=document.resumeform.qualification;
var experience=document.resumeform.experience;
var photo=document.resumeform.photo;
var resume=document.resumeform.resume;
var veri=document.resumeform.verification;
if((name.value==null)||(name.value==""))
	{
		document.getElementById('name').style.color="red";
		document.getElementById('name').background="images/error.GIF";
		name.focus()
		return false
	}
	else
	{
		document.getElementById('name').style.color="";
		document.getElementById('name').background="";
	}
if((fname.value==null)||(fname.value==""))
	{
		document.getElementById('fname').style.color="red";
		document.getElementById('fname').background="images/error.GIF";
		fname.focus()
		return false
	}
	else
	{
		document.getElementById('fname').style.color="";
		document.getElementById('fname').background="";
	}
if((dob.value==null)||(dob.value==""))
	{
		document.getElementById('dob').style.color="red";
		document.getElementById('dob').background="images/error.GIF";
		dob.focus()
		return false;
	}
	else
	{
		document.getElementById('dob').style.color="";
		document.getElementById('dob').background="";
	}
if((email.value==null)||(email.value==""))
	{
		document.getElementById('email').style.color="red";
		document.getElementById('email').background="images/error.GIF";
		email.focus()
		return false;
	}
else if(echeck(email.value)==false)
	{
	document.resumeform.email.focus();
	return false;
	}
	else
	{
		document.getElementById('dob').style.color="";
		document.getElementById('dob').background="";
	}
if((contactno.value==null)||(contactno.value==""))
	{
		document.getElementById('contactno').style.color="red";
		document.getElementById('contactno').background="images/error.GIF";
		contactno.focus()
		return false;
	}
		else
	{
		document.getElementById('contactno').style.color="";
		document.getElementById('contactno').background="";
	}
if((address.value==null)||(address.value==""))
	{
		document.getElementById('address').style.color="red";
		document.getElementById('address').background="images/error.GIF";
		address.focus()
		return false
	}
		else
	{
		document.getElementById('address').style.color="";
		document.getElementById('address').background="";
	}
if((area.value==null)||(area.value==""))
	{
		document.getElementById('area').style.color="red";
		document.getElementById('area').background="images/error.GIF";
		area.focus()
		return false
	}
		else
	{
		document.getElementById('area').style.color="";
		document.getElementById('area').background="";
	}
if((functional.value==null)||(functional.value==""))
	{
		document.getElementById('functional').style.color="red";
		document.getElementById('functional').background="images/error.GIF";
		functional.focus()
		return false
	}
		else
	{
		document.getElementById('functional').style.color="";
		document.getElementById('functional').background="";
	}
if((university.value==null)||(university.value==""))
	{
		document.getElementById('university').style.color="red";
		document.getElementById('university').background="images/error.GIF";
		university.focus()
		return false
	}
		else
	{
		document.getElementById('university').style.color="";
		document.getElementById('university').background="";
	}
	if((qualification.value==null)||(qualification.value==""))
	{
		document.getElementById('qualification').style.color="red";
		document.getElementById('qualification').background="images/error.GIF";
		qualification.focus()
		return false
	}
		else
	{
		document.getElementById('qualification').style.color="";
		document.getElementById('qualification').background="";
	}
if((experience.value==null)||(experience.value==""))
	{
		document.getElementById('experience').style.color="red";
		document.getElementById('experience').background="images/error.GIF";
		experience.focus()
		return false
	}
		else
	{
		document.getElementById('experience').style.color="";
		document.getElementById('experience').background="";
	}
if((resume.value==null)||(resume.value==""))
	{
		document.getElementById('resume').style.color="red";
		document.getElementById('resume').background="images/error.GIF";
		resume.focus()
		return false
	}
		else
	{
		document.getElementById('resume').style.color="";
		document.getElementById('resume').background="";
	}
if((veri.value==null)||(veri.value==""))
	{
		document.getElementById('verification').style.color="red";
		document.getElementById('verification').background="images/error.GIF";
		alert("entered code blank")
		veri.focus()
		return false
	}
else
	{
		document.getElementById('verification').style.color="";
		document.getElementById('verification').background="";
	}
return true;
}