//**************************************
// Validation of Links Addition
//**************************************
function LinksValidator(theform)
{

//Link Category
if(theform.CatID.value=="")
		{	
		alert("Please Select Link Category.");
		theform.CatID.focus();
		return (false);
		}

//Link Title
		if (theform.txtTitle.value=="")
		{
		alert("Please Provide LinkTitle.");
		theform.txtTitle.focus();
		return false;
		}

//LinkURL
	if(theform.txtUrl.value == "") 
	   {
	   alert("Please Provide Your Link URL.");
	   theform.txtUrl.focus();
	   return false;
	   }

//Details
	if(theform.txtDetails.value == "") 
	   {
	   alert("Please Provide Link Details.");
	   theform.txtDetails.focus();
	   return false;
	   }
	   
//Reciprocal URL
	if(theform.txtReciprocal.value == "") 
	   {
	   alert("Please Provide Our Reciprocal URL- Link Details.");
	   theform.txtReciprocal.focus();
	   return false;
	   }	   

//Submitter Name
	if(theform.txtSubmitter.value == "") 
	   {
	   alert("Please Enter Name of Link Submitter (Contact Person in Future).");
	   theform.txtSubmitter.focus();
	   return false;
	   }

//SUBMITTER EMAIL ID
	if(theform.txtEmail.value == "") 
	   {
	   alert("Please Provide Your Email ID.");
	   theform.txtEmail.focus();
	   return false;
	   }
   
	if (theform.txtEmail.value != "")
	{
	// Test if Valid Email Address, Must have @ and .
	var checkEmail = "@.";
	var checkStr = theform.txtEmail.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
		for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkEmail.length;  j++)
			{
			if (ch == checkEmail.charAt(j) && ch == "@")
			EmailAt = true;
			if (ch == checkEmail.charAt(j) && ch == ".")
			EmailPeriod = true;
			  if (EmailAt && EmailPeriod)
			  break;
			  if (j == checkEmail.length)
			  break;
			}
		// if both the @ and . were in the string
			if (EmailAt && EmailPeriod)
			{
			EmailValid = true
			break;
			}
		}
	}

		if (!EmailValid)
		{
		alert("Please Enter Valid Email ID.");
		theform.txtEmail.focus();
		return (false);
		}
}