//<!--
	// This file contains the data validation JavaScript functions
	// It is included in the HTML pages with forms that need these
	// data validation routines.
	
/* Check if the Existing Email feild is blank. 
If it is then cehck for the FirstName and the Email in the New users form 
Else check for email only for the existing users. 
If both of them are filled ask user to enter data only in one feild.*/
function fnValidateSubsForm(Obj)
{
// check for the publication checkboxes
// check for the publication checkboxes
	var total = 0;

	var max = Obj.pub.length;

	if (Obj.pub.checked == true) {
		total += 1;
	 }
	
	for (var idx = 0; idx < max; idx++){
		if (Obj.pub[idx].checked == true) {
			total += 1;
		 }
	}	

// the construct checks for the checkbox variable in gen_srch 
	if (Obj.kw == null && Obj.pl != null) {
		if (Obj.pl.checked == true)
		{
			total += 1;
		}
	}
// the construct checks for the checkbox variable in browse Search
	if (Obj.pl == null && Obj.kw != null) {
		if (Obj.kw.checked == true)
		{
			total += 1;
		}
	}

	if(total == 0)
		{
			alert('Please select a publication!');
			return false;
		} 
	else if ((Obj.NEWEMAIL.value == '') && (Obj.existingemail.value == ''))
	{
		alert('Please enter relevant details!');
		return false;
	}
	else if (Obj.existingemail.value == '')
		{
			if (Obj.FirstName.value == '')
			{
				alert('Please enter First Name!');
				Obj.FirstName.focus();
				return false;
			}
			if (Obj.NEWEMAIL.value == '')
			{
				alert('Please enter Email!');
				Obj.NEWEMAIL.focus();
				return false;
			}
			else
			{
				if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Obj.NEWEMAIL.value))
				{
					return (true);
				}
				else
				{
					alert("Invalid E-mail Address! Please re-enter.")
					Obj.NEWEMAIL.focus();
					return false;
				}
			}
		}
		else
		{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Obj.existingemail.value)){
			return (true);
		}
		else{
			alert("Invalid E-mail Address! Please re-enter.")
			Obj.existingemail.focus();
			return false;
			}		
		}
}
function check()
{
	var rel=document.srch.Criteria;
	if (rel.value == '')
	{
	alert("Please enter any word or phrase!")
	document.srch.Criteria.focus();
	return false;
	}
	return true;
}

// function for checking the validation for the subscription section
function fnSubscribe()
{
	if (FRM_LOGIN.email.value == '')
	{
			alert('Please enter email!');
			FRM_LOGIN.email.focus();
			return false;
	}else
		{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(FRM_LOGIN.email.value)){
			return (true);
		}
		else{
			alert("Invalid E-mail! Please re-enter.");
			FRM_LOGIN.email.focus();
			return false;
			}		
		}
}

// function for checking the validation for the subscription section
function fnSubscribeNew()
{
	if (FRM_LOGIN.email.value == '')
	{
			alert('Please enter email!');
			FRM_LOGIN.email.focus();
			return false;
	}
	else if(FRM_LOGIN.password.value == '')
	{
		alert('Please enter password!');
		FRM_LOGIN.password.focus();
		return false;
	}
	else
	{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(FRM_LOGIN.email.value))
		{
			return (true);
		}
		else
		{
			alert("Invalid E-mail! Please re-enter.");
			FRM_LOGIN.email.focus();
			return false;
		}		
	}
}

// function for checking the checkboxes checked in the subscription section
function fnSubscribeCheckbox()
{
	if (!document.FrmSubs.ProdLine.checked)
	{
			alert('Please select a checkbox!');
			return false;
	}
}
// function for validating the change details section
function fnSubsChangeDetails()
{
	if (document.frmChangeDetails.OldPassword.value == '')
	{
			alert('Please enter old password!');
			document.frmChangeDetails.OldPassword.focus();
			return false;
	}else if (document.frmChangeDetails.NewPassword.value == '')
	{
			alert('Please enter new password!');
			document.frmChangeDetails.NewPassword.focus();
			return false;
	}else if (document.frmChangeDetails.ConfirmedPassword.value == '')
	{
			alert('Please enter confirm password!');
			document.frmChangeDetails.ConfirmedPassword.focus();
			return false;
	}else if (document.frmChangeDetails.ConfirmedPassword.value != document.frmChangeDetails.NewPassword.value)
	{
			alert('New password and confirm password do not match!');
			return false;
	}
}

// function to check the Personal Details
function fnPersonaldetails()
{ // fn Start
	
if (document.frmPersonaldetails.fname.value == '')
	{
			alert('Please enter first name!');
			document.frmPersonaldetails.fname.focus();
			return false;
	}else if (document.frmPersonaldetails.lname.value == '')
	{
			alert('Please enter last name!');
			document.frmPersonaldetails.lname.focus();
			return false;
	}else if (document.frmPersonaldetails.NewEmail.value == '')
	{
			alert('Please enter email!');
			document.frmPersonaldetails.NewEmail.focus();
			return false;
	}else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmPersonaldetails.NewEmail.value)))
	{
		alert("Invalid E-mail! Please re-enter.");
		document.frmPersonaldetails.NewEmail.focus();
		return false;
	}else if (document.frmPersonaldetails.company.value == '')
	{
			alert('Please enter comapny!');
			document.frmPersonaldetails.company.focus();
			return false;
	}		

} // fn End
// function to verify the mailing feilds
function fnVerifyFormDetails()
{ // fn Start
if (document.frmDetails.name.value == '')
	{
			alert('Please enter Name!');
			document.frmDetails.name.focus();
			return false;
	}else if (document.frmDetails.from.value == '')
	{
			alert('Please enter Email!');
			document.frmDetails.from.focus();
			return false;
	}else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmDetails.from.value)))
	{
		alert("Invalid E-mail! Please re-enter.");
		document.frmDetails.from.focus();
		return false;
	}else if(document.frmDetails.country.value == '')
	{
			alert('Please enter Country!');
			document.frmDetails.country.focus();
			return false;
	}
	else if(document.frmDetails.product.value == '')
	{
			alert('Please enter Product(s) of Interest!');
			document.frmDetails.product.focus();
			return false;
	}		
	return true;
}
// Function to validate feedback form

function fnValidateFeedback()
{
	if (document.frmFeedback.txtName.value == '')
		{
				alert('Please enter Name!');
				document.frmFeedback.txtName.focus();
				return false;
		}else if (document.frmFeedback.txtEmail.value == '')
		{
				alert('Please enter Email!');
				document.frmFeedback.txtEmail.focus();
				return false;
		}else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmFeedback.txtEmail.value)))
		{
			alert("Invalid E-mail! Please re-enter.");
			document.frmFeedback.txtEmail.focus();
			return false;
		}else if(document.frmFeedback.txtComments.value == '')
		{
				alert('Please enter Comments!');
				document.frmFeedback.txtComments.focus();
				return false;
		}
	return true;
}
// Function to check to and from date - General Search
function fnValidateDate()
{
	if (Date.parse(document.frmSearch.adate.value) >= Date.parse(document.frmSearch.bdate.value))
	{
		alert('"From" Date must be less than "To" Date.');
		document.frmSearch.adate.value = "";
		document.frmSearch.bdate.value = "";
		return false;
	}
	return true;
}

// Function to check to and from date - Fulltext Search
function fnValidateFullDate()
{
	if (Date.parse(document.srch.Version1.value) >= Date.parse(document.srch.Version2.value))
	{
		alert('"From" Date must be less than "To" Date.');
		document.srch.Version1.value = "";
		document.srch.Version2.value = "";
		return false;
	}
	return true;
}

// Function Confirm removal of subscription - subscription
function fnConfirmUnsubscribe()
{
	if (document.frmEmailDetails.txtemail.value == '')
		{
				alert('Please enter Username/ Email!');
				document.frmEmailDetails.txtemail.focus();
				return false;
		}else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmEmailDetails.txtemail.value) == false)
		{
				alert('Please enter a valid Username/ Email!');
				document.frmEmailDetails.txtemail.focus();
				return false;		
		}else if (document.frmEmailDetails.txtpassword.value == '')
		{
				alert('Please enter a Password!');
				document.frmEmailDetails.txtpassword.focus();
				return false;
		}else if (confirm("Are you sure you want to continue?"))
		{
				document.frmEmailDetails.submit();
				return true;
		}else
			return false;	
}

// -->