function checkEmail(emailValue)
{	//runs the validate script and returns error box or nonerror
	//allows blank email address

	if (emailValue == "")
	{
		return true;
	}

	if(!validEmail(emailValue))
	{
		alert("You have entered an invalid email address. Please re-enter it.");
		return false;
	}
	return true;		
}				

function checkEmailValue(emailValue)
{     //runs the validate script and returns error box or nonerror

	if (emailValue == "")
	{
		alert("You have not entered email address. Please re-enter it.");
		return false;
	}

	startPos = 0;

	commaPos = emailValue.indexOf(",",startPos+1);	//position of semicolomn
	while (commaPos != -1)
	{
		endPos = commaPos;
		emailElement = emailValue.substring(startPos,endPos);
		if(!validEmail(emailElement))
		{
			alert("You have entered an invalid email address. Please re-enter it.");
			return false;
		}
		startPos = endPos + 1;		
		commaPos = emailValue.indexOf(",",startPos);	//position of semicolomn
	}
	endPos = emailValue.length;
	emailElement = emailValue.substring(startPos,endPos);

	if(!validEmail(emailElement))
	{
		alert("You have entered an invalid email address. Please re-enter it.");
		return false;
	}
	return true;		
}				

function validEmail(email)
{
	invalidchars = " /:;"

// remove leading spaces
	while(email.substring(0,1)==" ")
	{
		email = email.substring(1,email.length);
	}

// remove trailing spaces
	while(email.substring(email.length-1,email.length)==" ")
	{

		email = email.substring(0,email.length-1);
	}

	if(email == "")
	{			//checks to see if blank field
		return false
	}
			
	for(i=0;i<invalidchars.length;i++){ //checks for invalid chars
			
	badchars = invalidchars.charAt(i)
			
	if(email.indexOf(badchars,0)!= -1)
	{
		return false
	}	
													}
	
	atPos = email.indexOf("@",1)  //holds position of "@"
			
	if(atPos == -1) 
	{	//checks to see if "@" present
		return false
	}
							
	if(email.indexOf("@",atPos+1) != -1) 
	{ //checks for second "@"
		return false
	}
							
	periodPos = email.indexOf(".",atPos) //holds position of "."
			
	if(periodPos == -1)
	{ //checks for presence of "."
		return false
	}
	if(periodPos+3 > email.length)
	{//makes sure at least two chars after the period
		return false
	}
	return true 
}

function doReset()
{
	document.forms[0].reset();
}

function FormCheck(mode, description)
{ 
	if (mode == "SHORT")
 {
		if(document.forms[0].RECEIVE_YES_NO[0].checked == false && document.forms[0].RECEIVE_YES_NO[1].checked == false)
	{
	alert("Please specify whether you wish to receive " + description +"?");
        document.forms[0].RECEIVE_YES_NO[0].focus();
		return false;
	}
      if(document.forms[0].RECEIVE_YES_NO[1].checked == true)
	// stop validation when "not to receive" response
	{
		return true;
	}
       if(!checkUnselects(document.forms[0].REQUESTED_VERSION))	
	{
		alert("Please select subscription format.");
        	document.forms[0].REQUESTED_VERSION[0].focus();
		return false;
	}

       {
	if((document.forms[0].EMAIL_ADDRESS.value == "")&&(document.forms[0].REQUESTED_VERSION[1].checked == true))
	       		{
			alert("Please specify your E-mail Address.");
       			document.forms[0].EMAIL_ADDRESS.focus();
			return false;
               		}
		if (document.forms[0].EMAIL_ADDRESS.value!='')	
		{
			if (!validEmail(document.forms[0].EMAIL_ADDRESS.value))
			{
			alert("You have entered an invalid email address. Please re-enter it.");
			document.forms[0].EMAIL_ADDRESS.focus();
			return false;
			}	
 	       if (document.forms[0].EMAIL_ADDRESS2.value == "")
	       {
		      alert("Please confirm your email address.");
		      document.forms[0].EMAIL_ADDRESS2.focus();
		      return false;
	       }
		  if(document.forms[0].EMAIL_ADDRESS.value.toUpperCase() != document.forms[0].EMAIL_ADDRESS2.value.toUpperCase())
		  {
			 alert("Confirmation email address does not match email address.");
	         document.forms[0].EMAIL_ADDRESS.focus();
			 return false;
          }        
		}
	
	}
	
       if (document.forms[0].PERSONAL_ID.value == "")
	{
 		alert('Please provide your personal identifier (city/town you were born in).');
		document.forms[0].PERSONAL_ID.focus();
		return false;
	}		
		
 }
        
    if ((mode == "SHORT") || (mode == "ABBR"))
	{
		return true;
	}
	if (mode == "ADD")
	{
		if(document.forms[0].FNAME.value == "")
		{
			alert("Please specify your First name.");
        		document.forms[0].FNAME.focus();
			return false;
		}
		if(document.forms[0].LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		document.forms[0].LNAME.focus();
			return false;
		}
	}
	if (mode != "RENEW")
	{
		if(document.forms[0].TITLE.value == "")
		{
			alert("Please specify your Title.");
	        	document.forms[0].TITLE.focus();
			return false;
		}
		if(document.forms[0].COMPANY.value == "")
		{
			alert("Please specify your Company.");
	        	document.forms[0].COMPANY.focus();
			return false;
		}
		if(document.forms[0].ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.forms[0].ADDRESS2.focus();
			return false;
		}
		if(document.forms[0].CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value == "")
		{
			alert("Please specify your State/Province or select 'I am not in the US or Canada'.");
		        document.forms[0].STATE.focus();
			return false;
		}
// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value,document.forms[0].ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.forms[0].STATE.focus();
			return false;
		}

		if (document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value == "53")
		{
			if (document.forms[0].COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.forms[0].COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.forms[0].ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.forms[0].ZIPCODE.focus();
				return false;
			}
		}
          }

		if(document.forms[0].EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	        	document.forms[0].EMAIL_ADDRESS.focus();
			return false;
		}
		if ((document.forms[0].EMAIL_ADDRESS.value != "") && (!validEmail(document.forms[0].EMAIL_ADDRESS.value)))
	{
		alert("You have entered an invalid email address. Please re-enter it.");
		document.forms[0].EMAIL_ADDRESS.focus();
		return false;
	}
	 	if (document.forms[0].EMAIL_ADDRESS2.value == "")
	    {
		  alert("Please confirm your email address.");
		  document.forms[0].EMAIL_ADDRESS2.focus();
		  return false;
	    }
		if(document.forms[0].EMAIL_ADDRESS.value.toUpperCase() != document.forms[0].EMAIL_ADDRESS2.value.toUpperCase())
		{
			alert("Confirmation email address does not match email address.");
	        document.forms[0].EMAIL_ADDRESS.focus();
			return false;
        }        
	document.forms[0].submit.disabled = true
}  


function PaidformCheck(mode, description)
{ 
  	if (!checkUnselects(document.paidform.SUBSCRIPTION))
	{
		alert ("Please select your subscription.");
		document.paidform.SUBSCRIPTION[0].focus();
		return false;
	}
       
	// check payment info if PAY_STAT=2 or credit payment
	
	if(!checkDropdown(document.paidform.CARD_TYPE))
	{
		alert("Please specify credit card.");
		document.paidform.CARD_TYPE.focus();
		return false;
	}

	if(document.paidform.CARD_NUMBER.value == "")
	{
		alert("Please specify credit card number.");
		document.paidform.CARD_NUMBER.focus();
		return false;
	}

	if(checkDropdown(document.paidform.CARD_TYPE))
	{
		// Visa
		if(document.paidform.CARD_TYPE.selectedIndex==1)
		{
			if (!isVisa(stripWhitespace(document.paidform.CARD_NUMBER.value)))
			{
				alert("Invalid credit card number. Please re-enter.")
				document.paidform.CARD_NUMBER.focus();
				return false;
			}
		}

		// MasterCard
		if(document.paidform.CARD_TYPE.selectedIndex==2)
		{
			if (!isMasterCard(stripWhitespace(document.paidform.CARD_NUMBER.value)))
			{
				alert("Invalid credit card number. Please re-enter.")
				document.paidform.CARD_NUMBER.focus();
				return false;
			}
		}

		// AmEx
		if(document.paidform.CARD_TYPE.selectedIndex==3)
		{
			if (!isAmericanExpress(stripWhitespace(document.paidform.CARD_NUMBER.value)))
			{
				alert("Invalid credit card number. Please re-enter.")
				document.paidform.CARD_NUMBER.focus();
				return false;
			}
		}

		// Discover
		if(document.paidform.CARD_TYPE.selectedIndex==4)
		{
			if (!isDiscover(stripWhitespace(document.paidform.CARD_NUMBER.value)))
			{
				alert("Invalid credit card number. Please re-enter.")
				document.paidform.CARD_NUMBER.focus();
				return false;
			}
		}
	}
	
	if(!checkDropdown(document.paidform.ExpMon))
	{
		alert('Please select the expiration month.');
		document.paidform.ExpMon.focus();
		return false;
	}

	if(!checkDropdown(document.paidform.ExpYear))
	{
		alert('Please select the expiration year.');
		document.paidform.ExpYear.focus();
		return false;
	}
	if(document.paidform.SCODE.value == "")
	{
		alert("Please specify Security Code.");
		document.paidform.SCODE.focus();
		return false;
	}

       	if (mode == "ADD")
	{
		if(document.paidform.FNAME.value == "")
		{
			alert("Please specify your First name.");
        		document.paidform.FNAME.focus();
			return false;
		}
		if(document.paidform.LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		document.paidform.LNAME.focus();
			return false;
		}
	}

	if (mode != "RENEW") 
	{
		if(document.paidform.ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.forms[0].ADDRESS2.focus();
			return false;
		}
		if(document.paidform.CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.paidform.STATE.selectedIndex == 0)
		{
			alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
		        document.paidform.STATE.focus();
			return false;
		}

		// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.paidform.STATE[document.paidform.STATE.selectedIndex].value,document.paidform.ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.paidform.STATE.focus();
			return false;
		}

		
		if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "53")
		{
			if(document.paidform.COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.paidform.COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.paidform.ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.paidform.ZIPCODE.focus();
				return false;
			}
		}

	}
	if((document.paidform.COUNTRY.value == "NIGERIA")||(document.paidform.COUNTRY.value == "GHANA"))
           {
		alert("We have encountered problems processing your order.Please contact ogjsub@pennwell.com to complete your subscription request.");
		return false;
	}
         
	if (!CheckEmail())
	{
		return false;
	}
	if (!CheckBillAddress())
	{
		return false;
	}			

	if (ObjectExists(document.paidform, "GRADUATION_YEAR"))
         {
         	if ((document.paidform.GRADUATION_YEAR.value != "") && (!ValidNum(document.paidform.GRADUATION_YEAR)))	
		 {
			alert("Please enter numbers only.");
			document.paidform.GRADUATION_YEAR.focus();
			return false;
		
		 }
         }

	if (!CheckPassword())
	{
		return false;
	}
}

 

function checkDropdown(selectBox)
{

	if(selectBox.selectedIndex == "0")
	{
		return false;
	}
	else
	{
		return true;
	}
}

function checkUnselects(radioItem)
{
	for(i=0;i<radioItem.length;i++)
	{
		if(radioItem[i].checked)
		{
			return true;
		}//end if
	}//end for
	return false;
}

// declare global variables
var i;

// two arrays for Canadian province/postal code validation
var CanCodes=new Array("54","55","56","57","58","59","60","66","61","62","63","64","65");
var CanLetters=new Array("T","UV","R","E","A","B","X","X","KLMNP","C","GHJ","S","Y");

// check if first letter of postal code matches selected Canadian province
// StateCD is 2-digit code that Omeda uses to identify Canadian provinces (value of STATE field)
// PostCD is entered postal code (value of ZIPCODE field)
function ValidCanPostal(StateCD, PostCD)
{
	var fletter=PostCD.substring(0,1);
	fletter = fletter.toUpperCase();

	for(i=0;i<13;i++)
	{
		if (StateCD==CanCodes[i])
		{
			if (CanLetters[i].indexOf(fletter,0) == -1)
			{
				return false;
			}
			else
			{
				return true;
			}
		}
	}
	return true;
}
function PaidformCheck2(mode, description)
{ 
	{
		if(!checkDropdown(document.forms[0].CARD_TYPE))
		{
			alert("Please specify credit card.");
        		document.forms[0].CARD_TYPE.focus();
			return false;
		}

		if(document.forms[0].CARD_NUMBER.value == "")
		{
			alert("Please specify credit card number.");
        		document.forms[0].CARD_NUMBER.focus();
			return false;
		}

		if(checkDropdown(document.forms[0].CARD_TYPE))
		{
			// Visa
			if(document.forms[0].CARD_TYPE.selectedIndex==1)
			{
				if (!isVisa(stripWhitespace(document.forms[0].CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.forms[0].CARD_NUMBER.focus();
					return false;
				}
			}

			// MasterCard
			if(document.forms[0].CARD_TYPE.selectedIndex==2)
			{
				if (!isMasterCard(stripWhitespace(document.forms[0].CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.forms[0].CARD_NUMBER.focus();
					return false;
				}
			}

			// AmEx
			if(document.forms[0].CARD_TYPE.selectedIndex==3)
			{
				if (!isAmericanExpress(stripWhitespace(document.forms[0].CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.forms[0].CARD_NUMBER.focus();
					return false;
				}
			}

			// Discover
			if(document.forms[0].CARD_TYPE.selectedIndex==4)
			{
				if (!isDiscover(stripWhitespace(document.forms[0].CARD_NUMBER.selectedIndex==4)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.forms[0].CARD_NUMBER.focus();
					return false;
				}
			}
		}
	
		if(!checkDropdown(document.forms[0].ExpMon))
		{
 		alert('Please select the expiration month.');
		document.forms[0].ExpMon.focus();
 		return false;
		}

		if(!checkDropdown(document.forms[0].ExpYear))
		{
 			alert('Please select the expiration year.');
			document.forms[0].ExpYear.focus();
 			return false;
		}
		if(document.forms[0].SCODE.value == "")
		{
			alert("Please specify Security Code.");
        		document.forms[0].SCODE.focus();
			return false;
		}

	}

	
	if (mode != "RENEW")
	{
		if(document.forms[0].ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.forms[0].ADDRESS2.focus();
			return false;
		}
		if(document.forms[0].CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value == "")
		{
			alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
		        document.forms[0].STATE.focus();
			return false;
		}

		// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value,document.forms[0].ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.forms[0].STATE.focus();
			return false;
		}

		

		if (document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value == "53")
		{
			if(document.forms[0].COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.forms[0].COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.forms[0].ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.forms[0].ZIPCODE.focus();
				return false;
			}
		}
	}
        if((document.paidform.COUNTRY.value == "NIGERIA")||(document.paidform.COUNTRY.value == "GHANA"))
           {
		alert("We have encountered problems processing your order.Please contact ogjsub@pennwell.com to complete your subscription request.");
		
		return false;

		}
    if (!CheckEmail())
	{
		return false;
	}
	if (!CheckPassword())
	{
		return false;
	}
 
} 
function CheckEmail()
{
		if (document.paidform.EMAIL_ADDRESS.value == "")
		{
			alert('Please specify your e-mail address');
        	document.paidform.EMAIL_ADDRESS.focus();
			return false;
		}
        if(!validEmail(document.paidform.EMAIL_ADDRESS.value))
	    {
		      alert("You have entered an invalid email address. Please re-enter it.");
		      document.paidform.EMAIL_ADDRESS.focus();
		      return false;
	    }
        if (document.paidform.EMAIL_ADDRESS2.value == "")
	    {
		  alert("Please confirm your email address.");
		  document.paidform.EMAIL_ADDRESS2.focus();
		  return false;
	    }
		if(document.paidform.EMAIL_ADDRESS.value.toUpperCase() != document.paidform.EMAIL_ADDRESS2.value.toUpperCase())
		{
			alert("Confirmation email address does not match email address.");
	        document.paidform.EMAIL_ADDRESS.focus();
			return false;
        } 

    return true;       
}
function CheckPassword()
{
    if (document.paidform.WEB_ACCESS_PASSWORD.value == "")
    {
			alert('Please enter your password');
        	document.paidform.WEB_ACCESS_PASSWORD.focus();
			return false;
	}
	//once password entered, it should be confirmed
	if (document.paidform.WEB_ACCESS_PASSWORD.value != "")
	{
		if(document.paidform.WEB_ACCESS_PASSWORD.value.length < 3)
		{
			alert('Password should be at least 3 characters long.');
        		document.paidform.WEB_ACCESS_PASSWORD.focus();
			return false;
		}
		if (document.paidform.PASSWORD2.value == "")
		{
			alert('Please confirm your password');
        		document.paidform.PASSWORD2.focus();
			return false;
		}
		if (document.paidform.PASSWORD2.value != document.paidform.WEB_ACCESS_PASSWORD.value)
		{
			alert('Please re-enter your password');
        		document.paidform.WEB_ACCESS_PASSWORD.focus();
			return false;
		}

	}
	return true;
}
function PaidEffortCheck(mode, description)
{ 
	
	if (!checkUnselects(document.paidform.SUBSCRIPTION))
		{
			alert ("Please select your subscription.");
			document.paidform.SUBSCRIPTION[0].focus();
			return false;
		}
       
	

	// check payment info if PAY_STAT=2 or credit payment
	
	{
		if(!checkDropdown(document.paidform.CARD_TYPE))
		{
			alert("Please specify credit card.");
        		document.paidform.CARD_TYPE.focus();
			return false;
		}

		if(document.paidform.CARD_NUMBER.value == "")
		{
			alert("Please specify credit card number.");
        		document.paidform.CARD_NUMBER.focus();
			return false;
		}

		if(checkDropdown(document.paidform.CARD_TYPE))
		{
			// Visa
			if(document.paidform.CARD_TYPE.selectedIndex==1)
			{
				if (!isVisa(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// MasterCard
			if(document.paidform.CARD_TYPE.selectedIndex==2)
			{
				if (!isMasterCard(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// AmEx
			if(document.paidform.CARD_TYPE.selectedIndex==3)
			{
				if (!isAmericanExpress(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// Discover
			if(document.paidform.CARD_TYPE.selectedIndex==4)
			{
				if (!isDiscover(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}
		}
	
		if(!checkDropdown(document.paidform.ExpMon))
		{
 		alert('Please select the expiration month.');
		document.paidform.ExpMon.focus();
 		return false;
		}

		if(!checkDropdown(document.paidform.ExpYear))
		{
 			alert('Please select the expiration year.');
			document.paidform.ExpYear.focus();
 			return false;
		}
		if(document.paidform.SCODE.value == "")
		{
			alert("Please specify Security Code.");
        		document.paidform.SCODE.focus();
			return false;
		}

	}

       	if (mode == "ADD")
	{
		if(document.paidform.FNAME.value == "")
		{
			alert("Please specify your First name.");
        		document.paidform.FNAME.focus();
			return false;
		}
		if(document.paidform.LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		document.paidform.LNAME.focus();
			return false;
		}
	}

	if (mode != "RENEW") 
	{
		if(document.paidform.ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.forms[0].ADDRESS2.focus();
			return false;
		}
		if(document.paidform.CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.forms[0].STATE[document.paidform.STATE.selectedIndex].value == "")
		{
			alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
		        document.paidform.STATE.focus();
			return false;
		}

		// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.paidform.STATE[document.paidform.STATE.selectedIndex].value,document.paidform.ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.paidform.STATE.focus();
			return false;
		}

		
		if (document.forms[0].STATE[document.paidform.STATE.selectedIndex].value == "53")
		{
			if(document.paidform.COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.paidform.COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.paidform.ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.paidform.ZIPCODE.focus();
				return false;
			}
		}
	}
      if((document.paidform.COUNTRY.value == "NIGERIA")||(document.paidform.COUNTRY.value == "GHANA"))
      {
		   alert("We have encountered problems processing your order.Please contact ogjsub@pennwell.com to complete your subscription request.");
		   return false;
       }

	if (!CheckEmail())
	{
		return false;
	}   
	if (!CheckPassword())
	{
		return false;
	}
}
function IsCanadian(StateCD)
{
	for(i=0;i<13;i++)
	{
		if (StateCD==CanCodes[i])
		{
			return true;
		}
	}
	return false;
}
function PaidformCheck39(mode, description)
{ 
          
	// check payment info if PAY_STAT=2 or credit payment
	
	{
		if(!checkDropdown(document.paidform.CARD_TYPE))
		{
			alert("Please specify credit card.");
        		document.paidform.CARD_TYPE.focus();
			return false;
		}

		if(document.paidform.CARD_NUMBER.value == "")
		{
			alert("Please specify credit card number.");
        		document.paidform.CARD_NUMBER.focus();
			return false;
		}

		if(checkDropdown(document.paidform.CARD_TYPE))
		{
			// Visa
			if(document.paidform.CARD_TYPE.selectedIndex==1)
			{
				if (!isVisa(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// MasterCard
			if(document.paidform.CARD_TYPE.selectedIndex==2)
			{
				if (!isMasterCard(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// AmEx
			if(document.paidform.CARD_TYPE.selectedIndex==3)
			{
				if (!isAmericanExpress(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// Discover
			if(document.paidform.CARD_TYPE.selectedIndex==4)
			{
				if (!isDiscover(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}
		}
	
		if(!checkDropdown(document.paidform.ExpMon))
		{
 		alert('Please select the expiration month.');
		document.paidform.ExpMon.focus();
 		return false;
		}

		if(!checkDropdown(document.paidform.ExpYear))
		{
 			alert('Please select the expiration year.');
			document.paidform.ExpYear.focus();
 			return false;
		}
		if(document.paidform.SCODE.value == "")
		{
			alert("Please specify Security Code.");
        		document.paidform.SCODE.focus();
			return false;
		}

	}

       	if (mode == "ADD")
	{
		if(document.paidform.FNAME.value == "")
		{
			alert("Please specify your First name.");
        		document.paidform.FNAME.focus();
			return false;
		}
		if(document.paidform.LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		document.paidform.LNAME.focus();
			return false;
		}
	}

	if (mode != "RENEW") 
	{
		if(document.paidform.ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.forms[0].ADDRESS2.focus();
			return false;
		}
		if(document.paidform.CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.forms[0].STATE[document.paidform.STATE.selectedIndex].value == "")
		{
			alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
		        document.paidform.STATE.focus();
			return false;
		}

		// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.paidform.STATE[document.paidform.STATE.selectedIndex].value,document.paidform.ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.paidform.STATE.focus();
			return false;
		}

		
		if (document.forms[0].STATE[document.paidform.STATE.selectedIndex].value == "53")
		{
			if(document.paidform.COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.paidform.COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.paidform.ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.paidform.ZIPCODE.focus();
				return false;
			}
		
		}
	
    	}
     if((document.paidform.COUNTRY.value == "NIGERIA")||(document.paidform.COUNTRY.value == "GHANA"))
           {
		alert("We have encountered problems processing your order.Please contact ogjsub@pennwell.com to complete your subscription request.");
		
		return false;

		}
	if (!CheckEmail())
	{
		return false;
	}
	if (!CheckPassword())
	{
		return false;
	}
}
function PaidformCheckUpgrade(mode, description)
{ 
	if (!CheckEmail())
	{
		return false;
	}

	if (!CheckPassword())
	{
		return false;
	}

		if(!checkDropdown(document.paidform.CARD_TYPE))
		{
			alert("Please specify credit card.");
        		document.paidform.CARD_TYPE.focus();
			return false;
		}

		if(document.paidform.CARD_NUMBER.value == "")
		{
			alert("Please specify credit card number.");
        		document.paidform.CARD_NUMBER.focus();
			return false;
		}

		if(checkDropdown(document.paidform.CARD_TYPE))
		{
			// Visa
			if(document.paidform.CARD_TYPE.selectedIndex==1)
			{
				if (!isVisa(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// MasterCard
			if(document.paidform.CARD_TYPE.selectedIndex==2)
			{
				if (!isMasterCard(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// AmEx
			if(document.paidform.CARD_TYPE.selectedIndex==3)
			{
				if (!isAmericanExpress(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// Discover
			if(document.paidform.CARD_TYPE.selectedIndex==4)
			{
				if (!isDiscover(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}
		}
	
		if(!checkDropdown(document.paidform.ExpMon))
		{
 		alert('Please select the expiration month.');
		document.paidform.ExpMon.focus();
 		return false;
		}

		if(!checkDropdown(document.paidform.ExpYear))
		{
 			alert('Please select the expiration year.');
			document.paidform.ExpYear.focus();
 			return false;
		}
		if(document.paidform.SCODE.value == "")
		{
			alert("Please specify Security Code.");
        		document.paidform.SCODE.focus();
			return false;
		}

}

 function PaidformCheckCredit(mode, description)
{ 
        if (!checkUnselects(document.paidform.RECEIVE_YES_NO))
    		{
    			alert("Please specify whether you wish to receive Oil & Gas Journal.");
            		document.forms[0].RECEIVE_YES_NO[0].focus();
    			return false;
    		}


    		if (document.paidform.RECEIVE_YES_NO[1].checked)
    		// stop validation when "not to receive" response
    		{
    			return true;
    		}
	if (!checkUnselects(document.paidform.REQUESTED_VERSION))
    		{
    			alert("Please specify your preferred format.");
            		document.paidform.REQUESTED_VERSION[0].focus();
    			return false;
    		}

	if (mode == "ADD")
	{
		if(document.paidform.FNAME.value == "")
		{
			alert("Please specify your First name.");
        		document.paidform.FNAME.focus();
			return false;
		}
		if(document.paidform.LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		document.paidform.LNAME.focus();
			return false;
		}
	}
	
	if (mode != "RENEW")
	{
		if(document.paidform.ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.paidform.ADDRESS2.focus();
			return false;
		}
		if(document.paidform.CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.paidform.CITY.focus();
			return false;
		}
		if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "")
		{
			alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
		        document.paidform.STATE.focus();
			return false;
		}

		// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.paidform.STATE[document.paidform.STATE.selectedIndex].value,document.paidform.ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.paidform.STATE.focus();
			return false;
		}

		

		if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "53")
		{
			if(document.paidform.COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.paidform.COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.paidform.ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.paidform.ZIPCODE.focus();
				return false;
			}
		}
	}
if((document.paidform.COUNTRY[document.paidform.COUNTRY.selectedIndex].value == "NIGERIA")||(document.paidform.COUNTRY[document.paidform.COUNTRY.selectedIndex].value == "GHANA"))
           {
		alert("We have encountered problems processing your order.Please contact ogjsub@pennwell.com to complete your subscription request.");
		
		return false;

		}

    if (!CheckEmail())
	{
		return false;
	}
	if (!CheckPassword())
	{
		return false;
	}
    if (document.paidform.PERSONAL_ID.value == "")
	{
 		alert('Please provide your personal identifier (city or town were you born in).');
		document.paidform.PERSONAL_ID.focus();
 		return false;
	}
 
} 
function CheckedRadioValue(radioItem)
{
	for(i=0;i<radioItem.length;i++)
	{
		if(radioItem[i].checked)
		{
			return radioItem[i].value;
		}//end if
	}//end for
	return false;
}
function AnswerCheck(form)
{ 
	if (!checkUnselects(form.OGJO_DAILY))
	{
		alert("Please specify whether you wish to receive Oil & Gas Journal Daily Update.");
		form.OGJO_DAILY[0].focus();
		return false;
	}
        	
        if (!checkUnselects(form.OGJO_ED))
	{
		alert("Please specify whether you wish to receive Oil & Gas Journal Weekly E&D Report.");
		form.OGJO_ED[0].focus();
		return false;
	}
     
	if (!checkUnselects(form.NG_LNG_REPORT))
	{
		alert("Please specify whether you wish to receive OGJ Monthly Natural Gas & LNG Report.");
		form.NG_LNG_REPORT[0].focus();
		return false;
	}
	if (!checkUnselects(form.PIPELINE_REPORT))
	{
		alert("Please specify whether you wish to receive OGJ Monthly Pipeline Report.");
		form.PIPELINE_REPORT[0].focus();
		return false;
	}
	if (!checkUnselects(form.REFINING_REPORT))
	{
		alert("Please specify whether you wish to receive OGJ Monthly Refining Report.");
		form.REFINING_REPORT[0].focus();
		return false;
	}
	if (!checkUnselects(form.DP_REPORT))
	{
		alert("Please specify whether you wish to receive OGJ Monthly Drilling & Production Report.");
		form.DP_REPORT[0].focus();
		return false;
	}
	if (!checkUnselects(form.WWP_NEWSLETTER))
	{
		alert("Please specify whether you wish to receive OGJ Washington Pulse.");
		form.WWP_NEWSLETTER[0].focus();
		return false;
	}
        	
	if (!checkUnselects(form.PENNENERGY_NEWS))
	{
		alert("Please specify whether you wish to receive PennEnergy Perspectives.");
		form.PENNENERGY_NEWS[0].focus();
		return false;
	}
      	if(form.FNAME.value == "")
		{
			alert("Please specify your First name.");
        		form.FNAME.focus();
			return false;
		}
       if(form.LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		form.LNAME.focus();
			return false;
		}
        if(form.ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	form.ADDRESS2.focus();
			return false;
		}
	if(form.CITY.value == "")
		{
			alert("Please specify your City.");
	        	form.CITY.focus();
			return false;
		}

	if (form.STATE.selectedIndex == 0)
		{
			alert("Please specify your State/Province.");
		        form.STATE.focus();
			return false;
		}
	 // validate Canadian state/postal code combination
		if (!ValidCanPostal(form.STATE[form.STATE.selectedIndex].value,form.ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		form.STATE.focus();
			return false;
		}

		if (form.STATE[form.STATE.selectedIndex].value == "53")
		{
			if (form.COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		form.COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (form.ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		form.ZIPCODE.focus();
				return false;
			}
		}
		
		
		
        if(form.EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
        	        form.EMAIL_ADDRESS.focus();
			return false;
       		 }
	if(!validEmail(form.EMAIL_ADDRESS.value))
	{
			alert("You have entered an invalid email address. Please re-enter it.");
			form.EMAIL_ADDRESS.focus();
			return false;
	}
     	if (form.EMAIL_ADDRESS2.value == "")
	    {
		  alert("Please confirm your email address.");
		  form.EMAIL_ADDRESS2.focus();
		  return false;
	    }
		if(form.EMAIL_ADDRESS.value.toUpperCase() != form.EMAIL_ADDRESS2.value.toUpperCase())
		{
			alert("Confirmation email address does not match email address.");
	        form.EMAIL_ADDRESS.focus();
			return false;
        }           
	if (!checkUnselects(form.WEB_JOB_TITLE))
		{
		alert("Please select your job title.");
			form.WEB_JOB_TITLE[0].focus();
			return false;
		}
	if (!checkUnselects(form.WEB_BUSINESS))
		{
		alert("Please select the category that best describes your primary business.");
			form.WEB_BUSINESS[0].focus();
			return false;
		}
	if(!checkDropdown(form.WEB_EMPLOYEES))
		{
			alert("Please select the number of employees in your entire organization.");
        		form.WEB_EMPLOYEES.focus();
			return false;
		}
	
	return true;
} 
function PaidformCheckJobSite(mode, description)
{ 
        
		if(document.paidform.FNAME.value == "")
		{
			alert("Please specify your First name.");
        		document.paidform.FNAME.focus();
			return false;
		}
		if(document.paidform.LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		document.paidform.LNAME.focus();
			return false;
		}
	
		if(document.paidform.ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.paidform.ADDRESS2.focus();
			return false;
		}
		if(document.paidform.CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.paidform.CITY.focus();
			return false;
		}
		if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "")
		{
			alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
		        document.paidform.STATE.focus();
			return false;
		}

		// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.paidform.STATE[document.paidform.STATE.selectedIndex].value,document.paidform.ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.paidform.STATE.focus();
			return false;
		}

		

		if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "53")
		{
			if(document.paidform.COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.paidform.COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.paidform.ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.paidform.ZIPCODE.focus();
				return false;
			}
		}

 

              if (document.paidform.EMAIL_ADDRESS.value == "")
		{
		alert("Please specify your email address.");
       		document.paidform.EMAIL_ADDRESS.focus();
		return false;
		}	

        if ((document.paidform.EMAIL_ADDRESS.value != "") && (!validEmail(document.paidform.EMAIL_ADDRESS.value)))
	      {
		    alert("You have entered an invalid email address. Please re-enter it.");
		    document.paidform.EMAIL_ADDRESS.focus();
		    return false;
	      }
 	    if (document.paidform.EMAIL_ADDRESS2.value == "")
	    {
		  alert("Please confirm your email address.");
		  document.paidform.EMAIL_ADDRESS2.focus();
		  return false;
	    }
		if(document.paidform.EMAIL_ADDRESS.value.toUpperCase() != document.paidform.EMAIL_ADDRESS2.value.toUpperCase())
		{
			alert("Confirmation email address does not match email address.");
	        document.paidform.EMAIL_ADDRESS.focus();
			return false;
        }        
	
	return true;
 
} 
function PaidformCheckTele(mode, description)
{ 
        
	if(document.paidform.FNAME.value == "")
	{
		alert("Please specify your First name.");
        	document.paidform.FNAME.focus();
		return false;
	}
	if(document.paidform.LNAME.value == "")
	{
		alert("Please specify your Last name.");
        	document.paidform.LNAME.focus();
		return false;
	}
	
	if(document.paidform.ADDRESS2.value == "")
	{
		alert("Please specify your Street Address.");
	        document.paidform.ADDRESS2.focus();
		return false;
	}
	if(document.paidform.CITY.value == "")
	{
		alert("Please specify your City.");
	        document.paidform.CITY.focus();
		return false;
	}
	if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "")
	{
		alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
		document.paidform.STATE.focus();
		return false;
	}

	// validate Canadian state/postal code combination
	if (!ValidCanPostal(document.paidform.STATE[document.paidform.STATE.selectedIndex].value,document.paidform.ZIPCODE.value))
	{
		alert ("Invalid Canadian province/postal code combination.");
        	document.paidform.STATE.focus();
		return false;
	}
	if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "53")
	{
		if(document.paidform.COUNTRY.value == "")
		{
			alert("Please specify your Country.");
	        	document.paidform.COUNTRY.focus();
			return false;
		}
	}
	else
	{
		if (document.paidform.ZIPCODE.value.length < 5)
		{
			alert("Please specify your Zip/Postal Code.");
	        	document.paidform.ZIPCODE.focus();
			return false;
		}
	}
    
        
	if(!checkUnselects(document.forms[0].REQUESTED_VERSION))	
	{
		alert("Please select subscription format.");
        	document.forms[0].REQUESTED_VERSION[0].focus();
		return false;
	}
        if ((CheckedRadioValue(document.paidform.REQUESTED_VERSION) == 'D') && (document.paidform.EMAIL_ADDRESS.value == ""))
 	{
 		alert("Email is required for digital version.");
       		document.paidform.EMAIL_ADDRESS.focus();
		return false;
	}
	if ((document.paidform.EMAIL_ADDRESS.value != "") && (!validEmail(document.paidform.EMAIL_ADDRESS.value)))
	{
		alert("You have entered an invalid email address. Please re-enter it.");
		document.paidform.EMAIL_ADDRESS.focus();
		return false;
	}
	if (document.paidform.EMAIL_ADDRESS.value != "") 
	{
		if (document.paidform.EMAIL_ADDRESS2.value == "") 
		{
			alert("Please confirm your email address.");
			document.paidform.EMAIL_ADDRESS2.focus();
			return false;
		}   
		if(document.paidform.EMAIL_ADDRESS.value.toUpperCase() != document.paidform.EMAIL_ADDRESS2.value.toUpperCase())
		{
			alert("Confirmation email address does not match email address.");
		        document.paidform.EMAIL_ADDRESS.focus();
			return false;
		}
	}
	if ((document.paidform.WEB_ACCESS_PASSWORD.value != "")&& (document.paidform.PASSWORD2.value == ""))
	{
		alert("Please confirm your password.");
        	document.paidform.PASSWORD2.focus();
		return false;
	}
	if (document.paidform.WEB_ACCESS_PASSWORD.value != document.paidform.PASSWORD2.value)
	{
		alert("Confirmation password does not match password entered. Please re-enter your password.");
        	document.paidform.WEB_ACCESS_PASSWORD.focus();
		return false;
	}

       	if(!checkUnselects(document.paidform.SUBSCRIPTION))	
	{
		alert("Please select your subscription.");
        	document.paidform.SUBSCRIPTION[0].focus();
		return false;
	}
	
	if (!checkUnselects(document.paidform.PAY_STAT))	
	{
		alert ("Please specify payment method.");
        	document.paidform.PAY_STAT[0].focus();
		return false;
	}
	if (document.paidform.PAY_STAT[1].checked)
	// check payment info if PAY_STAT=2
	{
		if (!CheckPaymentInfo())
		{
			return false;
		}
		if (!CheckBillAddress())
		{
			return false;
		}			
        }
	return true;
 
} 
function CheckPaymentInfo()
{
	if(!checkDropdown(document.paidform.CARD_TYPE))
	{
		alert("Please specify credit card.");
        	document.paidform.CARD_TYPE.focus();
		return false;
	}

	if(document.paidform.CARD_NUMBER.value == "")
	{
		alert("Please specify credit card number.");
        	document.paidform.CARD_NUMBER.focus();
		return false;
	}

	// Visa
	if(document.paidform.CARD_TYPE.selectedIndex == 1)
	{
		if (!isVisa(stripWhitespace(document.paidform.CARD_NUMBER.value)))
		{
			alert("Invalid credit card number. Please re-enter.")
        		document.paidform.CARD_NUMBER.focus();
			return false;
		}
	}

	// MasterCard
	if(document.paidform.CARD_TYPE.selectedIndex == 2)
	{
		if (!isMasterCard(stripWhitespace(document.paidform.CARD_NUMBER.value)))
		{
			alert("Invalid credid card number. Please re-enter.")
        		document.paidform.CARD_NUMBER.focus();
			return false;
		}
	}
	
	// AmEx
	if(document.paidform.CARD_TYPE.selectedIndex == 3)
	{
		if (!isAmericanExpress(stripWhitespace(document.paidform.CARD_NUMBER.value)))
		{
			alert("Invalid credid card number. Please re-enter.")
        		document.paidform.CARD_NUMBER.focus();
			return false;
		}
	}
	
	// Discover
	if(document.paidform.CARD_TYPE.selectedIndex == 4)
	{
		if (!isDiscover(stripWhitespace(document.paidform.CARD_NUMBER.value)))
		{
			alert("Invalid credid card number. Please re-enter.")
        		document.paidform.CARD_NUMBER.focus();
			return false;
		}
	}

	if(!checkDropdown(document.paidform.ExpMon))
	{
 		alert('Please select the expiration month.');
		document.paidform.ExpMon.focus();
 		return false;
	}

	if(!checkDropdown(document.paidform.ExpYear))
	{
 		alert('Please select the expiration year.');
		document.paidform.ExpYear.focus();
 		return false;
	}
var d, month, year;
   	d = new Date();
    
	month = d.getMonth() + 1;
	year = d.getFullYear() - 2000;
	if (document.paidform.ExpYear[document.paidform.ExpYear.selectedIndex].value < year)
	{
 		alert('Invalid Expiration date.');
		document.paidform.ExpYear.focus();
 		return false;
	}
	else
	{
		if (document.paidform.ExpYear[document.paidform.ExpYear.selectedIndex].value == year)
		{
			if (document.paidform.ExpMon[document.paidform.ExpMon.selectedIndex].value < month)
			{
 				alert('Invalid Expiration date.');
				document.paidform.ExpMon.focus();
 				return false;
			}
		}
	}
	if(document.paidform.SCODE.value == "")
	{
		alert('Please enter security code.');
		document.paidform.SCODE.focus();
		return false;
	}
	// zh
	return true;
}
function CheckBillAddress()
{
	if (!ObjectExists(document.paidform, "SAME_ADDRESS"))
	{
		return true;
	}
	if (!document.paidform.SAME_ADDRESS.checked)
	{
		return true;
	}
	if(document.paidform.PD_BILLING_NAME.value == "")
	{
		alert("Please specify Name on card.");
	        document.paidform.PD_BILLING_NAME.focus();
		return false;
	}
	if(document.paidform.PD_BILLING_ADDRESS2.value == "")
	{
		alert("Please specify Billing Street Address.");
	        document.paidform.PD_BILLING_ADDRESS2.focus();
		return false;
	}
	if(document.paidform.PD_BILLING_CITY.value == "")
	{
		alert("Please specify Billing City.");
	        document.paidform.PD_BILLING_CITY.focus();
		return false;
	}
	if (document.paidform.PD_BILLING_STATE.selectedIndex == 0)
	{
		alert ("Please specify Billing State/Province or select 'Not in the U.S. or Canada'.");
		document.paidform.PD_BILLING_STATE.focus();
		return false;
	}
	// validate Canadian state/postal code combination
	if (!ValidCanPostal(document.paidform.PD_BILLING_STATE[document.paidform.PD_BILLING_STATE.selectedIndex].value,document.paidform.PD_BILLING_ZIPCODE.value))
	{
		alert ("Invalid Canadian province/postal code combination in Billing Address.");
        	document.paidform.PD_BILLING_STATE.focus();
		return false;
	}
	if (document.paidform.PD_BILLING_STATE[document.paidform.PD_BILLING_STATE.selectedIndex].value == "53")
	{
		if (document.paidform.PD_BILLING_COUNTRY.value == "")
		{
			alert("Please specify Billing Country.");
	        	document.paidform.PD_BILLING_COUNTRY.focus();
			return false;
		}
	}
	else
	{
		if (document.paidform.PD_BILLING_ZIPCODE.value.length < 5)
		{
			alert("Please specify Billing Zip/Postal Code.");
	        	document.paidform.PD_BILLING_ZIPCODE.focus();
			return false;
		}
	}
	return true;
}


function disable_enable()
{

	if (document.paidform.KILL_ADD_NEW_NAME.checked)
	{ 
		document.getElementById("firstname").readOnly = false;
		document.getElementById("lastname").readOnly = false;
		return true;
	}
	else
	{
		document.getElementById("firstname").readOnly = true;
		document.getElementById("lastname").readOnly = true;
		return true;
	}
}
function ValidNum(NumObj)
{
	var myNum, cleanNum;
	
	myNum = NumObj.value
	cleanNum = parseInt(myNum);

	if ( myNum == "")
	{
		return true;
	}
       	if(myNum != cleanNum)
	
	{
		return false;
	}
	return true;
}  
function FormCheckOTR(mode, description)
{ 
    if(document.forms[0].FNAME.value == "")
		{
			alert("Please specify your First name.");
        		document.forms[0].FNAME.focus();
			return false;
		}
		if(document.forms[0].LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		document.forms[0].LNAME.focus();
			return false;
		}
		if(document.forms[0].COMPANY.value == "")
		{
			alert("Please specify your Company.");
	        	document.forms[0].COMPANY.focus();
			return false;
		}
		if(document.forms[0].ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.forms[0].ADDRESS2.focus();
			return false;
		}
		if(document.forms[0].CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value == "")
		{
			alert("Please specify your State/Province or select 'I am not in the US or Canada'.");
		        document.forms[0].STATE.focus();
			return false;
		}
// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value,document.forms[0].ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.forms[0].STATE.focus();
			return false;
		}

		if (document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value == "53")
		{
			if (document.forms[0].COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.forms[0].COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.forms[0].ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.forms[0].ZIPCODE.focus();
				return false;
			}
		}
         

		if(document.forms[0].EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	        	document.forms[0].EMAIL_ADDRESS.focus();
			return false;
		}
		if ((document.forms[0].EMAIL_ADDRESS.value != "") && (!validEmail(document.forms[0].EMAIL_ADDRESS.value)))
		{
		alert("You have entered an invalid email address. Please re-enter it.");
		document.forms[0].EMAIL_ADDRESS.focus();
		return false;
		}
	 	if (document.forms[0].EMAIL_ADDRESS2.value == "")
	    {
		  alert("Please confirm your email address.");
		  document.forms[0].EMAIL_ADDRESS2.focus();
		  return false;
	    }
		if(document.forms[0].EMAIL_ADDRESS.value.toUpperCase() != document.forms[0].EMAIL_ADDRESS2.value.toUpperCase())
		{
			alert("Confirmation email address does not match email address.");
	        document.forms[0].EMAIL_ADDRESS.focus();
			return false;
        } 
        if (!checkUnselects(document.forms[0].JOB_TITLE))
		{
		       alert ("Please specify your job function.");
			document.forms[0].JOB_TITLE[0].focus();
			return false;
		}
        if (document.forms[0].WEB_ACCESS_PASSWORD.value == "")
    	{
		alert('Please enter your password');
        	document.forms[0].WEB_ACCESS_PASSWORD.focus();
		return false;
	}
	//once password entered, it should be confirmed
	if (document.forms[0].WEB_ACCESS_PASSWORD.value != "")
	{
		if(document.forms[0].WEB_ACCESS_PASSWORD.value.length < 3)
		{
			alert('Password should be at least 3 characters long.');
        		document.forms[0].WEB_ACCESS_PASSWORD.focus();
			return false;
		}
		if (document.forms[0].PASSWORD2.value == "")
		{
			alert('Please confirm your password');
        		document.forms[0].PASSWORD2.focus();
			return false;
		}
		if (document.forms[0].PASSWORD2.value != document.forms[0].WEB_ACCESS_PASSWORD.value)
		{
			alert('Please re-enter your password');
        		document.forms[0].WEB_ACCESS_PASSWORD.focus();
			return false;
		}

	} 
   
   if (document.forms[0].PERSONAL_ID.value == "")
	{
 		alert('Please provide your personal identifier (city or town were you born in).');
		document.forms[0].PERSONAL_ID.focus();
		return false;
	}      
	return true;
}  
function AnswerCheckTOC(form)
{ 
	if (!checkUnselects(form.TOC_NEWS))
	{
		alert("Please specify whether you wish to receive Weekly Table of Contents Alert.");
		form.TOC_NEWS[0].focus();
		return false;
	}
        if(form.TOC_NEWS[1].checked == true)
	// stop validation when "not to receive" response
	{
		return true;
	}
        if(form.FNAME.value == "")
		{
			alert("Please specify your First name.");
        		form.FNAME.focus();
			return false;
		}
       if(form.LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		form.LNAME.focus();
			return false;
		}
        if(form.ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	form.ADDRESS2.focus();
			return false;
		}
	if(form.CITY.value == "")
		{
			alert("Please specify your City.");
	        	form.CITY.focus();
			return false;
		}

	if (form.STATE.selectedIndex == 0)
		{
			alert("Please specify your State/Province.");
		        form.STATE.focus();
			return false;
		}
	 // validate Canadian state/postal code combination
		if (!ValidCanPostal(form.STATE[form.STATE.selectedIndex].value,form.ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		form.STATE.focus();
			return false;
		}

		if (form.STATE[form.STATE.selectedIndex].value == "53")
		{
			if (form.COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		form.COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (form.ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		form.ZIPCODE.focus();
				return false;
			}
		}
		
		
		
        if(form.EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
        	        form.EMAIL_ADDRESS.focus();
			return false;
       		 }
	if(!validEmail(form.EMAIL_ADDRESS.value))
	{
			alert("You have entered an invalid email address. Please re-enter it.");
			form.EMAIL_ADDRESS.focus();
			return false;
	}
     	if (form.EMAIL_ADDRESS2.value == "")
	    {
		  alert("Please confirm your email address.");
		  form.EMAIL_ADDRESS2.focus();
		  return false;
	    }
		if(form.EMAIL_ADDRESS.value.toUpperCase() != form.EMAIL_ADDRESS2.value.toUpperCase())
		{
			alert("Confirmation email address does not match email address.");
	        form.EMAIL_ADDRESS.focus();
			return false;
        }           
	if (!checkUnselects(form.WEB_JOB_TITLE))
		{
		alert("Please select your job title.");
			form.WEB_JOB_TITLE[0].focus();
			return false;
		}
	if (!checkUnselects(form.WEB_BUSINESS))
		{
		alert("Please select the category that best describes your primary business.");
			form.WEB_BUSINESS[0].focus();
			return false;
		}
	
	return true;
}
function ObjectExists(form,fieldname)
{
	for ( i=0; i < form.elements.length; i++)
	{
		if (form.elements[i].name == fieldname)
		{
			return true;
		}
	}
	return false;
}
function PaidformCheckLand(mode, description)
{ 
	
	
  		if (!checkUnselects(document.paidform.SUBSCRIPTION))
		{
			alert ("Please select your subscription.");
			document.paidform.SUBSCRIPTION[0].focus();
			return false;
		}
     	if (mode == "ADD")
	{
		if(document.paidform.FNAME.value == "")
		{
			alert("Please specify your First name.");
        		document.paidform.FNAME.focus();
			return false;
		}
		if(document.paidform.LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		document.paidform.LNAME.focus();
			return false;
		}
	}

	if (mode != "RENEW") 
	{
		if(document.paidform.ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.forms[0].ADDRESS2.focus();
			return false;
		}
		if(document.paidform.CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.paidform.STATE.selectedIndex == 0)
		{
			alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
		        document.paidform.STATE.focus();
			return false;
		}

		// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.paidform.STATE[document.paidform.STATE.selectedIndex].value,document.paidform.ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.paidform.STATE.focus();
			return false;
		}

		
		if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "53")
		{
			if(document.paidform.COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.paidform.COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.paidform.ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.paidform.ZIPCODE.focus();
				return false;
			}
		}

	}
         if (!CheckEmail())
	{
		return false;
	}
	{
		if(!checkDropdown(document.paidform.CARD_TYPE))
		{
			alert("Please specify credit card.");
        		document.paidform.CARD_TYPE.focus();
			return false;
		}

		if(document.paidform.CARD_NUMBER.value == "")
		{
			alert("Please specify credit card number.");
        		document.paidform.CARD_NUMBER.focus();
			return false;
		}

		if(checkDropdown(document.paidform.CARD_TYPE))
		{
			// Visa
			if(document.paidform.CARD_TYPE.selectedIndex==1)
			{
				if (!isVisa(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// MasterCard
			if(document.paidform.CARD_TYPE.selectedIndex==2)
			{
				if (!isMasterCard(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// AmEx
			if(document.paidform.CARD_TYPE.selectedIndex==3)
			{
				if (!isAmericanExpress(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// Discover
			if(document.paidform.CARD_TYPE.selectedIndex==4)
			{
				if (!isDiscover(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}
		}
	
		if(!checkDropdown(document.paidform.ExpMon))
		{
 		alert('Please select the expiration month.');
		document.paidform.ExpMon.focus();
 		return false;
		}

		if(!checkDropdown(document.paidform.ExpYear))
		{
 			alert('Please select the expiration year.');
			document.paidform.ExpYear.focus();
 			return false;
		}
		if(document.paidform.SCODE.value == "")
		{
			alert("Please specify Security Code.");
        		document.paidform.SCODE.focus();
			return false;
		}

	}

	if (!CheckPassword())
	{
		return false;
	}
}

// functions to handle billing address section

function showMe (it, box) 
{
	var vis = (box.checked) ? "block" : "none";
  	document.getElementById(it).style.display = vis;
}
// paystat : which ID (1) or (2)
// stat : (h)ide or (s)how
function toggleFlag(paystat,stat) 
{
	if (stat=='s') eval("document.all."+paystat+".style.visibility='visible';");
	if (stat=='h') eval("document.all."+paystat+".style.visibility='hidden';");
}

function CheckStatus(billaddr)
{
	if (document.paidform.SAME_ADDRESS.checked)
	{
	      document.getElementById('billaddr').style.display = 'block';
	}
}
function calculate(el) {
    var dispterm;
    var copy;
      
  	if (el.value == "01")
    
	{
                dispterm = "1 year";
		document.forms[0].DISPTERM.value=dispterm
                copy = "12"
                document.forms[0].COPY.value=copy
                
        }
	if (el.value == "02")
    
	{
                dispterm = "2 year";
		document.forms[0].DISPTERM.value=dispterm
    	        copy = "24"
                document.forms[0].COPY.value=copy 
        }
	if (el.value == "03")
    
	{
                dispterm = "3 year";
		document.forms[0].DISPTERM.value=dispterm
    	        copy = "36"
                document.forms[0].COPY.value=copy 
        }
}
function showhideCountry(STATE)
{
var st = (document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value);
if (st == "53")
   {
    document.getElementById('country').style.display = "block";
    }
else
  {
    document.getElementById('country').style.display = "none";
    }
  	
}
function PaidformCheckiPad(mode, description)
{ 
	
	
  		if (!checkUnselects(document.paidform.SUBSCRIPTION))
		{
			alert ("Please select your subscription.");
			document.paidform.SUBSCRIPTION[0].focus();
			return false;
		}
     	if (mode == "ADD")
	{
		if(document.paidform.FNAME.value == "")
		{
			alert("Please specify your First name.");
        		document.paidform.FNAME.focus();
			return false;
		}
		if(document.paidform.LNAME.value == "")
		{
			alert("Please specify your Last name.");
        		document.paidform.LNAME.focus();
			return false;
		}
	}

	if (mode != "RENEW") 
	{
		if(document.paidform.ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.forms[0].ADDRESS2.focus();
			return false;
		}
		if(document.paidform.CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.paidform.STATE.selectedIndex == 0)
		{
			alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
		        document.paidform.STATE.focus();
			return false;
		}

		// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.paidform.STATE[document.paidform.STATE.selectedIndex].value,document.paidform.ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.paidform.STATE.focus();
			return false;
		}

		
		if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "53")
		{
			if(document.paidform.COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.paidform.COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.paidform.ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.paidform.ZIPCODE.focus();
				return false;
			}
		}

	}
         if (!CheckEmail())
	{
		return false;
	}
         if (!CheckBillAddress())
	{
		return false;
	}
	{
		if(!checkDropdown(document.paidform.CARD_TYPE))
		{
			alert("Please specify credit card.");
        		document.paidform.CARD_TYPE.focus();
			return false;
		}

		if(document.paidform.CARD_NUMBER.value == "")
		{
			alert("Please specify credit card number.");
        		document.paidform.CARD_NUMBER.focus();
			return false;
		}

		if(checkDropdown(document.paidform.CARD_TYPE))
		{
			// Visa
			if(document.paidform.CARD_TYPE.selectedIndex==1)
			{
				if (!isVisa(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// MasterCard
			if(document.paidform.CARD_TYPE.selectedIndex==2)
			{
				if (!isMasterCard(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// AmEx
			if(document.paidform.CARD_TYPE.selectedIndex==3)
			{
				if (!isAmericanExpress(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}

			// Discover
			if(document.paidform.CARD_TYPE.selectedIndex==4)
			{
				if (!isDiscover(stripWhitespace(document.paidform.CARD_NUMBER.value)))
				{
					alert("Invalid credit card number. Please re-enter.")
        				document.paidform.CARD_NUMBER.focus();
					return false;
				}
			}
		}
	
		if(!checkDropdown(document.paidform.ExpMon))
		{
 		alert('Please select the expiration month.');
		document.paidform.ExpMon.focus();
 		return false;
		}

		if(!checkDropdown(document.paidform.ExpYear))
		{
 			alert('Please select the expiration year.');
			document.paidform.ExpYear.focus();
 			return false;
		}
		if(document.paidform.SCODE.value == "")
		{
			alert("Please specify Security Code.");
        		document.paidform.SCODE.focus();
			return false;
		}

	}

	if (!CheckPassword())
	{
		return false;
	}
}
function DemoFormCheck(mode, description)
{ 
              	if(document.forms[0].ADDRESS2.value == "")
		{
			alert("Please specify your Street Address.");
	        	document.forms[0].ADDRESS2.focus();
			return false;
		}
		if(document.forms[0].CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value == "")
		{
			alert("Please specify your State/Province or select 'I am not in the US or Canada'.");
		        document.forms[0].STATE.focus();
			return false;
		}
// validate Canadian state/postal code combination
		if (!ValidCanPostal(document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value,document.forms[0].ZIPCODE.value))
		{
			alert ("Invalid Canadian province/postal code combination.");
        		document.forms[0].STATE.focus();
			return false;
		}

		if (document.forms[0].STATE[document.forms[0].STATE.selectedIndex].value == "53")
		{
			if (document.forms[0].COUNTRY.value == "")
			{
				alert("Please specify your Country.");
	        		document.forms[0].COUNTRY.focus();
				return false;
			}
		}
		else
		{
			if (document.forms[0].ZIPCODE.value.length < 5)
			{
				alert("Please specify your Zip/Postal Code.");
	        		document.forms[0].ZIPCODE.focus();
				return false;
			}
		}
        

		if(document.forms[0].EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	        	document.forms[0].EMAIL_ADDRESS.focus();
			return false;
		}
		if ((document.forms[0].EMAIL_ADDRESS.value != "") && (!validEmail(document.forms[0].EMAIL_ADDRESS.value)))
	       {
			alert("You have entered an invalid email address. Please re-enter it.");
			document.forms[0].EMAIL_ADDRESS.focus();
			return false;
	        }
	 	if (document.forms[0].EMAIL_ADDRESS2.value == "")
	        {
		  	alert("Please confirm your email address.");
		  	document.forms[0].EMAIL_ADDRESS2.focus();
		  	return false;
	        }
		if(document.forms[0].EMAIL_ADDRESS.value.toUpperCase() != document.forms[0].EMAIL_ADDRESS2.value.toUpperCase())
		{
			alert("Confirmation email address does not match email address.");
	        	document.forms[0].EMAIL_ADDRESS.focus();
			return false;
        	}  
//question 1

	if (!checkUnselects(document.forms[0].JOB_TITLE))
		{
			alert("Please select categories that best describes your job function.");
			document.forms[0].JOB_TITLE[0].focus();
			return false;
		}
if (CheckedRadioValue(document.forms[0].JOB_TITLE)=="12")
			{
				if(document.forms[0].JOB_TITLE_OTHER.value == "")
				{
					alert("Please specify your job function's description.");
	        			document.forms[0].JOB_TITLE_OTHER.focus();
					return false;
				}
			}
//question 2

	if (!checkUnselects(document.forms[0].BUSINESS))
		{
		alert("Please select categories that best describes your primary business.");
			document.forms[0].BUSINESS[0].focus();
			return false;
		}

	if (CheckedRadioValue(document.forms[0].BUSINESS)=="46")
			{
				if(document.forms[0].BUSINESS_OTHER.value == "")
				{
					alert("Please specify your primary business description.");
	        			document.forms[0].BUSINESS_OTHER.focus();
					return false;
				}
			}

//question 3

	if (!checkUnselects(document.forms[0].PRIM_ACTIVITY))
		{
		alert("Please select categories that best describes your firm's primary business activity.");
			document.forms[0].PRIM_ACTIVITY[0].focus();
			return false;
		}

	if (CheckedRadioValue(document.forms[0].PRIM_ACTIVITY)=="70")
			{
				if(document.forms[0].PRIM_ACTIVITY_OTHER.value == "")
				{
					alert("Please specify your firm's primary business activity description.");
	        			document.forms[0].PRIM_ACTIVITY_OTHER.focus();
					return false;
				}
			}
//question 4

	if (!checkDropdown(document.forms[0].EMPLOYEES))
		{
		alert ("Please select the number of employees in your entire organization.");
		document.forms[0].EMPLOYEES.focus();
		return false;
		}	
        	  
	
//Personal ID
      if (!checkDropdown(document.forms[0].PERSONAL_ID))
		{
		alert ("Please select your Personal Identifier.");
		document.forms[0].PERSONAL_ID.focus();
		return false;
		}	

	return true;
}  

