//for check email ID
function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(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){
		    alert("Invalid E-mail ID")
		    return false;
		}

		 if (str.indexOf(at,(lat+2))!=-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;
		 }

 		 return true;					
	}

function checkField()
{
  var frm = document.frmValidate;
//Name is checked	
 if(frm.name.value == "")
  {
    alert("Please Enter Name");
    frm.name.focus();
    return false;
  }
  if(isNaN(frm.name.value)==false)
	{
	alert("Only Alphabet is allowed for name");
	frm.name.value="";
	frm.name.focus();
	return false;
	}

//Email is checked 
if(frm.email.value == "")
  {
    alert("Please Enter Email");
    frm.email.focus();
    return false;
  }  
  
  if(echeck(frm.email.value) == false)
    {
		frm.email.value="";
		frm.email.focus();
		return false;
	}	
	
//Title is checked
if(frm.title.value == "")
  {
    alert("Please Enter Title");
    frm.title.focus();
    return false;
  }
//Url is checked
if(frm.url.value == "")
  {
    alert("Please Enter Url");
    frm.url.focus();
    return false;
  }
//Description
if(frm.description.value == "")
  {
    alert("Please Enter Description");
    frm.description.focus();
    return false;
  }
//Category  
if(frm.category.value == "cid")
  {
    alert("Please Select category");
    frm.category.focus();
    return false;
  }
  
//Captcha
if(frm.txtCaptcha.value == "")
  {
    alert("Please Enter the Code shown");
    frm.txtCaptcha.focus();
    return false;
  }
	
//Terms and condition
var acc=document.getElementById("checkbox") 
if(!acc.checked)  { 
	alert ("Accept Terms of Agreement");
	return false;  
  }
    
return true;
}

//validation for reciprocal
//for check email ID
function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(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){
		    alert("Invalid E-mail ID")
		    return false;
		}

		 if (str.indexOf(at,(lat+2))!=-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;
		 }

 		 return true;					
	}

function reciprocalcheckField()
{
  var frm = document.reciprocalfrmValidate;

//Name is checked	
 if(frm.name.value == "")
  {
    alert("Please Enter Name");
    frm.name.focus();
    return false;
  }
  if(isNaN(frm.name.value)==false)
	{
	alert("Only Alphabet is allowed for name");
	frm.name.value="";
	frm.name.focus();
	return false;
	}

//Email is checked 
if(frm.email.value == "")
  {
    alert("Please Enter Email");
    frm.email.focus();
    return false;
  }  
  
  if(echeck(frm.email.value) == false)
    {
		frm.email.value="";
		frm.email.focus();
		return false;
	}	
	
//Title is checked
if(frm.title.value == "")
  {
    alert("Please Enter Title");
    frm.title.focus();
    return false;
  }
//Url is checked
if(frm.url.value == "")
  {
    alert("Please Enter Url");
    frm.url.focus();
    return false;
  }
  
//Category  
if(frm.category.value == "")
  {
    alert("Please Select category");
    frm.category.focus();
    return false;
  }

//Description
if(frm.description.value == "")
  {
    alert("Please Enter Description");
    frm.description.focus();
    return false;
  }
//Check
if(frm.check.value == "")
  {
    alert("Please Enter Reciprocal Link");
    frm.check.focus();
    return false;
  }
 
//Captcha
if(frm.txtCaptcha.value == "")
  {
    alert("Please Enter the Code shown");
    frm.txtCaptcha.focus();
    return false;
  }
	
//Terms and condition
var acc=document.getElementById("checkbox") 
if(!acc.checked)  { 
	alert ("Accept Terms of Agreement");
	return false;  
  }
    
return true;
}
