function validateEntryForm(obj){
	
	
	if(!validateEmail(obj.email.value))
	{
		obj.email.focus();
		return false;	
	}
	
	
	if(obj.opr.value=='submit')
	{	
		var ans_five, ans_four, ans_three;
		if(obj.ans_three)
			ans_three = obj.ans_three.value;
		else
			ans_three = 'N/A';
			
		if(obj.ans_four)
			ans_four = obj.ans_four.value;
		else
			ans_four = 'N/A';
			
		if(obj.ans_five)
			ans_five = obj.ans_five.value;
		else
			ans_five = 'N/A';
			
		if ((checkEmpty(obj.authority.value)) || (checkEmpty(obj.projectname.value)) || (checkEmpty(obj.personnel.value)) || (checkEmpty(obj.proj_summary.value)) || (checkEmpty(obj.ans_one.value)) || (checkEmpty(obj.ans_two.value)) || (checkEmpty(ans_three)) || (checkEmpty(ans_four)) || (checkEmpty(ans_five)))
		{
			alert('Please fill all the fields!');
			obj.authority.focus();
			return false;
		}
	}
	
	return true;

}

function validateLoginForm(obj){
	if(!validateEmail(obj.email.value))
	{
		obj.email.focus();
		return false;	
	}
	return true;
}

function checkEmpty(str){
	if(trim(str)==''){		
		return true;
	}
	return false;
}
function validateEmail(str){
	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(str.match(emailRegEx)){
		return true;	
	}else{
		alert('Please enter a valid email address.');
		return false;
	}
}

function trim(Str){
   var i = 0; var StrippedString="";
   while ((Str.charAt(i)==" ")&&(i<Str.length)) i++;
   StrippedString = Str.substring(i,Str.length)
   if(StrippedString.length==0) StrippedString="";
   if(StrippedString.length>0){
      i=StrippedString.length-1;
      while ((StrippedString.charAt(i)==" ")&&(i>0)) i--;
      if(i>0) StrippedString = StrippedString.substring(0,i+1);
      else if (i==0) StrippedString = StrippedString.substring(0,1);
      else StrippedString="";
   }
   return StrippedString;
}
