function validcomment()
{
	if(document.frmname.name.value=="")
	{
		alert("Please Enetr the Name");
		frmname.name.focus();
		return false;
	}
	if(document.frmname.email.value=="")
	{
		alert("Please Enetr the Email Id");
		frmname.email.focus();
		return false;
	}
	if(validateEmail(document.frmname.email.value) == false)
	{
		alert('Enter the correct Email ID.');
		document.frmname.email.focus();
		return false;
	}			
	if(document.frmname.comment.value=="")
	{
		alert("Please Enetr the Comment");
		frmname.comment.focus();
		return false;
	}
		
	return ture;
}







function validations()
{	
	if(document.frmregist.username.value =="")
	{
		 alert("please enter username ");
		 document.frmregist.username.focus();
		 return false;
	}
	if(document.frmregist.password.value =="")
	{
		 alert("please enter password ");
		 document.frmregist.password.focus();
		 return false;
    }
	if(document.frmregist.name.value =="")
	{
		 alert("please enter Firstname ");
	    document.frmregist.name.focus();
		return false;
	}
	if(document.frmregist.surname.value =="")
	{
		 alert("please enter Lastname ");
	    document.frmregist.surname.focus();
		return false;
	}
	if(document.frmregist.email.value =="")
	{
		 alert("please enter Email ");
	    document.frmregist.email.focus();
		return false;
	}
	if(document.frmregist.phone.value =="")
	{
		 alert("please enter Phone Number ");
	    document.frmregist.phone.focus();
		return false;
	}
	if(document.frmregist.country.value =="")
	{
		 alert("please enter Country ");
	     document.frmregist.country.focus();
		 return false;
	}
	if(document.frmregist.state.value =="")
	{
		 alert("please enter State ");
	    document.frmregist.state.focus();
		return false;
	}
	if(document.frmregist.city.value =="")
	{	
		 alert("please enter City ");
	    document.frmregist.city.focus();
		return false;
	}
	if(document.frmregist.zip.value =="")
	{
		 alert("please enter Post code ");
		 document.frmregist.zip.focus();
		 return false;
	}
	if(document.frmregist.gradyear.value =="")
	{
		 alert("Please enter year of high school graduation  ");
		 document.frmregist.gradyear.focus();
		 return false;
	}
	if(document.frmregist.satscore.value =="")
	{
		 alert("please enter SAT Score ");
		 document.frmregist.satscore.focus();
		 return false;	
	}
	if(document.frmregist.gpa.value =="")
	{
		 alert("please enter GPA ");
		 document.frmregist.gpa.focus();
		 return false;
	}
	document.frmregist.submit();
}

function chkagree()
{
   if(document.getElementById("chk").checked== false)
   {
      alert("Plese accept the terms and conditions.");
      return false;
   }
    if( document.frm.essay_title.value.length==0)
		   {
			   alert("Enter the title");
			   frm.essay_title.focus();
			   return false;
		   }
   document.frm.submit();
}

//remove the preceeding and ending spaces from a string.
function trimStr(str)
{var i, pBegin, pEnd, strTemp
 //find the preceeding spaces
 for (i = 0 ; i < String(str).length; i++)
 {if (String(str).charAt(i) != " ")
	{pBegin = i;
	 break;
	}
 }
 
 //find ending spaces
 for (i = String(str).length -1; i >= 0; i--)
 {if (String(str).charAt(i) != " ")
	{pEnd = i;
	 break;
	} 
 }
 
 //the new string.
 strTemp = String(str).substr(pBegin, pEnd - pBegin +1 );
 return (strTemp);
}

//FUNCTION TO VALIDATE EMAIL
function validateEmail(email)
{
//a valid email would have only one @ and one . after the @ in the string and a value before and after @ and .
 var iAtF = 0;
 var iDotF = 0;
 var iDotL = 0;
 var iSpace = 0;
 var iStrLength = 0; //for length of string

 iAtF = String(email).indexOf("@");
 iAtL = String(email).lastIndexOf("@");
 if (iAtF < 1 )
	return (false);
 if (iAtF != iAtL)
	return(false);
	
 iDotL = String(email).lastIndexOf(".");
 if (iDotL < iAtF + 2)
	return(false);

 iSpace = String(email).indexOf(" ");
 if (iSpace > 0 )
	return(false);

 iStrLength = String(email).length;
 if(iDotL==iStrLength-1 ||iDotL==iStrLength-2) 
	return(false);
		
 return(true);
}

function fnValidEditorialTeam()
{	
	document.reg.firstname.value = trimStr(document.reg.firstname.value);
	document.reg.lastname.value = trimStr(document.reg.lastname.value);
	document.reg.email.value = trimStr(document.reg.email.value);
	document.reg.message.value = trimStr(document.reg.message.value);
	
	if(document.reg.firstname.value=='')
	{
		alert("Enter the First Name.");
		reg.firstname.focus();
		return false;
	}
	if(document.reg.lastname.value=='')
	{
		alert("Enter the Last Name.");
		reg.lastname.focus();
		return false;
	}
	if(document.reg.email.value=='')
	{
		alert("Enter the Email ID.");
		reg.email.focus();
		return false;
	}
	if(validateEmail(document.reg.email.value) == false)
	{
		alert('Enter the correct Email ID.');
		document.reg.email.focus();
		return false;
	}	
			
	return true;	
}
//- this is used to edit validaction.
function fnValidEditorialupdatetTeam()
{
	document.student.name.value = trimStr(document.student.name.value);
	document.student.from.value = trimStr(document.student.from.value);
	document.student.email.value = trimStr(document.student.email.value);
	document.student.message.value = trimStr(document.student.message.value);
	
	if(document.student.name.value.length==0)
	{
		alert("Enter the Name");
		student.name.focus();
		return false;
	}
	if(document.student.from.value.length==0)
	{
		alert("Enter the Last name");
		student.from.focus();
		return false;
	}
	if(document.student.email.value.length==0)
     
	{
		alert("Enter the Email Id");
		student.email.focus();
		return false;
	}	
	if(validateEmail(document.student.email.value) == false)
	{
		alert('Enter the correct Email ID.');
		document.student.email.focus();
		return false;
	}			
	return true;	
}
	
function validsubmit()
	
	{
    document.frm.essay_title.value = trimStr(document.frm.essay_title.value);	
    document.frm.name.value = trimStr(document.frm.name.value);
    document.frm.email.value = trimStr(document.frm.email.value);
    document.frm.description.value = trimStr(document.frm.description.value);
	  
   if( document.frm.essay_title.value.length==0)
       {
	   alert("Enter the Essay Title");
	   frm.essay_title.focus();
	   return false;
       }
   if( document.frm.name.value.length==0)
       {
	   alert("Enter the First Name");
	   frm.name.focus();
	   return false;
	   }
   if( document.frm.surname.value.length==0)
       {
	   alert("Enter the Last Name");
	   frm.surname.focus();
	   return false;
	   }
 if(document.getElementById('category_type_id').selectedIndex == 0 )
   {
	 alert('Please select the category.');
	 document.getElementById('category_type_id').focus();
	 return false;
   }
   if( document.frm.email.value.length==0)
	   {
	   alert("Enter the Email Id");
	   frm.email.focus();
	   return false;
	   }
   if(validateEmail(document.frm.email.value) == false)
      {
	  alert('Enter the correct Email ID.');
	  document.frm.email.focus();
	   return false;
	  }			
  if( document.frm.description.value.length==0)
	  {
      alert("Enter the Essay");
      frm.description.focus();
      return false;
	  }
  if(document.getElementById("chp").checked== true)
     {
	 if(validateEmail(document.frm.email1.value) == false)
      {
	  alert('Enter the correct Email ID.');
	  document.frm.email1.focus();
	   return false;
	  }	
	  else
	  {
	  if(document.frm.email2.value !='')
	  {
	  	if(validateEmail(document.frm.email2.value) == false)
	  	{
	  		alert('Enter the correct Email ID.');
	  		document.frm.email2.focus();
	   		return false;
	  	}
		else
		if(document.frm.email3.value !='')
	  {
		{if(validateEmail(document.frm.email3.value) == false)
	  	{
	  		alert('Enter the correct Email ID.');
	  		document.frm.email3.focus();
	   		return false;
	  	}
		else
		if(document.frm.email4.value !='')
	  {
		{if(validateEmail(document.frm.email4.value) == false)
	  	{
	  		alert('Enter the correct Email ID.');
	  		document.frm.email4.focus();
	   		return false;
	  	}
		}}
		}
	  }
	  }
	  
	  }
	  
	 }
	 /* if(validateEmail(document.frm.email3.value) == false)
      {
	  alert('Enter the correct Email ID.');
	  document.frm.email3.focus();
	   return false;
	  }			
	  if(validateEmail(document.frm.email4.value) == false)
      {
	  alert('Enter the correct Email ID.');
	  document.frm.email4.focus();
	   return false;
	  }			
     }*/
  if(document.getElementById("chk").checked== false)
     {
	  alert("Plese accept the terms and conditions.");
   	  return false;
     }
      document.frm.submit();
	   return true;
	
}

function fnShowHideFriendTable(obj,trFriend)
{
	if(obj.checked)
		document.getElementById(trFriend).style.display='block';
	else
		document.getElementById(trFriend).style.display='none';
	}
	
		
		

