function LoginFormCheck()
{ 
	if (document.forms[0].HAVE_RDRNUM[0].checked == false && document.forms[0].HAVE_RDRNUM[1].checked == false && document.forms[0].HAVE_RDRNUM[2].checked == false)
	{
		alert ("Please select one of the options.");
        	document.forms[0].HAVE_RDRNUM[0].focus();
		return false;
	}
	if (document.forms[0].HAVE_RDRNUM[0].checked == true)
	{
		if  (document.forms[0].RDRNUM.value == "")
		{
			alert ("Please enter your account number.");
      				document.forms[0].RDRNUM.focus();
			return false;
		}
		if ( document.forms[0].LNAME_FIRST4.value == "")
		{
			alert ("Please enter first 4 letters of your last name.");
	       		document.forms[0].LNAME_FIRST4.focus();
			return false;
		}
	}
	if (document.forms[0].HAVE_RDRNUM[1].checked == true)
	{
		if  (document.forms[0].EMAIL_ADDRESS.value == "")
		{
			alert ("Please enter your email 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;
		}
	}
	
	return true;
}

function AnswerCheck(mode, description)
{ 
	
	if (document.forms[0].EMAIL_ADDRESS.value == "")  // newsletter only page
	{
		alert("Email address is needed.");
		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 (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].COMPANY.value == "")
		{
			alert("Please specify your Company name.");
        		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.selectedIndex == 0)
		{
	    	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 (!CheckDropdown(document.forms[0].PRIMARY_BUSINESS))
	{
		alert("Please select your primary business.");
        	document.forms[0].PRIMARY_BUSINESS.focus();
		return false;
	}
	if (document.forms[0].PRIMARY_BUSINESS[document.forms[0].PRIMARY_BUSINESS.selectedIndex].value == "99")
	{
		if (document.forms[0].PRIMARY_BUSINESS_DESC.value == "")
		{
			alert("Please specify your primary business - other.");
	        	document.forms[0].PRIMARY_BUSINESS_DESC.focus();
			return false;
		}
    }

	if (!CheckDropdown(document.forms[0].JOB_TITLE))
	{
		alert("Please select your title.");
        	document.forms[0].JOB_TITLE.focus();
		return false;
	}
	if (document.forms[0].JOB_TITLE[document.forms[0].JOB_TITLE.selectedIndex].value == "99")
	{
		if (document.forms[0].JOB_TITLE_DESC.value == "")
		{
			alert("Please specify your title - other.");
	        	document.forms[0].JOB_TITLE_DESC.focus();
			return false;
		}
    }
	
	if (!CheckDropdown(document.forms[0].PERSONAL_ID))
	{
		alert("Please select your personal identifier.");
        	document.forms[0].PERSONAL_ID.focus();
		return false;
	}    
 }
 
function formCheck(mode, description)
{ 




	if (mode != "PROSP")
	{
		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].ABU_RECEIVE[0].checked == false) && (document.forms[0].ABU_RECEIVE[1].checked == false))
		{
			alert("Please specify whether you wish to receive Architect Weekly?");
	        	document.forms[0].ABU_RECEIVE[0].focus();
			return false;
		}
                if ((document.forms[0].ARCH_NEWSWIRE[0].checked == false) && (document.forms[0].ARCH_NEWSWIRE[1].checked == false))
		{
			alert("Please specify whether you wish to receive Architect Newswire?");
	        	document.forms[0].ARCH_NEWSWIRE[0].focus();
			return false;
		}

		if(document.forms[0].RECEIVE_YES_NO[1].checked == true && document.forms[0].ABU_RECEIVE[1].checked == true && document.forms[0].ARCH_NEWSWIRE[1].checked == true)
	// stop validation when "not to receive" response for both the magazine and newsletter
		{
			return true;
		}
	}

	if ((mode == "SHORT") || (mode == "ABBR"))
	{
		return true;
	}

	if (mode != "PROSP")
	{
		if (document.forms[0].EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	       		document.forms[0].EMAIL_ADDRESS.focus();
			return false;
	    }
  		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 ((mode == "ADD") || (mode == "PROSP"))
	{
		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].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.selectedIndex == 0)
		{
			alert("Please specify your State.");
		        document.forms[0].STATE.focus();
			return false;
		}

		
		if (document.forms[0].ZIPCODE.value.length < 5)
		{
			alert("Please specify your Zip Code.");
	        	document.forms[0].ZIPCODE.focus();
			return false;
		}		
	}
	
	if(document.forms[0].formname.vaule == "ADD1")
	// validation for part1 of the new ADD page
	{
		if (!checkDropdown(document.forms[0].PRIMARY_BUSINESS))
		{
			alert("Please select your primary business.");
	        	document.forms[0].PRIMARY_BUSINESS.focus();
			return false;
		}
		
		var BP = (document.forms[0].PRIMARY_BUSINESS[document.forms[0].PRIMARY_BUSINESS.selectedIndex].value)
		if (BP == '99')
		{
			if (document.forms[0].PRIMARY_BUSINESS_DESC.value == '') 
			{ 
				alert("Please specify your primary business - other.");
		        	document.forms[0].PRIMARY_BUSINESS_DESC.focus();
				return false;
			}
		}
	
		if ((BP=='04') || (BP == '05') || (BP == '06') || (BP == '99'))
		{
			document.forms[0].action = "https://hw.omeda.com/cgi-win/arch.cgi";
			//document.forms[0].action = "http://web.omeda.com/cgi-win/arch.cgi";
		}
		return true;
	}
	else // validation for part2 of the new ADD or the rever
	{
		if (!CheckDemos(document.forms[0]))
		{
			return false;
		}
     } 
 }  

function QualformPage1Check(mode, description)
{ 	
	// validations for part1 of the new ADD page
	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].ABU_RECEIVE[0].checked == false) && (document.forms[0].ABU_RECEIVE[1].checked == false))
	{
		alert("Please specify whether you wish to receive Architect Weekly?");
        	document.forms[0].ABU_RECEIVE[0].focus();
		return false;
	}
	if ((document.forms[0].ARCH_NEWSWIRE[0].checked == false) && (document.forms[0].ARCH_NEWSWIRE[1].checked == false))
	{
		alert("Please specify whether you wish to receive Architect Newswire?");
        	document.forms[0].ARCH_NEWSWIRE[0].focus();
		return false;
	}

	if(document.forms[0].RECEIVE_YES_NO[1].checked == true && document.forms[0].ABU_RECEIVE[1].checked == true && document.forms[0].ARCH_NEWSWIRE[1].checked == true)
	// stop validation when "not to receive" response for both the magazine and newsletter
	{
		return true;
	}
	if (document.forms[0].EMAIL_ADDRESS.value == "")
	{
		alert("Please specify your E-mail Address.");
       		document.forms[0].EMAIL_ADDRESS.focus();
		return false;
    }
 		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 (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(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 (ObjectExists(document.forms[0], "COUNTRY"))
	{ // country field is no need to be in the free renewal form
		if (document.forms[0].STATE.selectedIndex == 0)
		{
	    	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;
			}
		}	
	}
	else
	{
		if (document.forms[0].STATE.selectedIndex == 0)
		{
			alert("Please specify your State.");
		        document.forms[0].STATE.focus();
			return false;
		}		
		if (document.forms[0].ZIPCODE.value.length < 5)
		{
			alert("Please specify your Zip Code.");
	        	document.forms[0].ZIPCODE.focus();
			return false;
		}		
	}	
	
	if (!CheckDropdown(document.forms[0].PRIMARY_BUSINESS))
	{
		alert("Please select your primary business.");
        	document.forms[0].PRIMARY_BUSINESS.focus();
		return false;
	}
 
	var BP = (document.forms[0].PRIMARY_BUSINESS[document.forms[0].PRIMARY_BUSINESS.selectedIndex].value)
	if (BP == '99')
	{
		if (document.forms[0].PRIMARY_BUSINESS_DESC.value == '') 
		{ 
			alert("Please specify your primary business - other.");
	        	document.forms[0].PRIMARY_BUSINESS_DESC.focus();
			return false;
		}
	}

	if ((BP=='04') || (BP == '05') || (BP == '06') || (BP == '99'))
	{
		document.forms[0].action = "https://hw.omeda.com/cgi-win/arch.cgi";
		//document.forms[0].action = "http://web.omeda.com/cgi-win/arch.cgi";
	}
 }  

function QualformPage2Check()
{ 
   	//if (!CheckDemos(document.forms[0]))
	//{
	//	return false;
	//}
	// client needs specify message for each of the demos validation
	if (!CheckDropdown(document.forms[0].EMPLOYEES))
	{
		alert("Please select number of employees.");
			document.forms[0].EMPLOYEES.focus();
		return false;
	}

	if (!CheckUnselects(document.forms[0].REGISTERED_ARCHITECT)) 
	{
		alert("Please select registered architect.");
	 		document.forms[0].REGISTERED_ARCHITECT[0].focus();
	 	return false;
	}

	if (!CheckUnselects(document.forms[0].LEED_ACCREDITED_PROF)) 
	{
		alert("Please select LEED accredited professional.");
	 		document.forms[0].LEED_ACCREDITED_PROF[0].focus();
	 	return false;
	}

	if (!CheckDropdown(document.forms[0].JOB_TITLE))
	{
		alert("Please select your job title.");
        	document.forms[0].JOB_TITLE.focus();
		return false;
	}
	if (document.forms[0].JOB_TITLE[document.forms[0].JOB_TITLE.selectedIndex].value == "99")
	{
		if (document.forms[0].JOB_TITLE_DESC.value == "")
		{
			alert("Please specify your job title - other.");
	        	document.forms[0].JOB_TITLE_DESC.focus();
			return false;
		}
    }
	
	if (!CheckboxChecked(document.forms[0],'PROJECTS_INVOLVED'))
	{
		alert("Please select the projects involved in.");
			document.forms[0].PROJECTS_INVOLVED.focus();
		return false;
	}
	if (document.getElementById('PROJECTS_INVOLVED99').checked)
	{
		if (document.forms[0].PROJECTS_INVOLVED_CD_DESC.value == '')
		{ 
			alert("Please specify the projects involved - other.");
				document.forms[0].PROJECTS_INVOLVED_CD_DESC.focus();
			return false;
		}
	}
	
	if (!CheckboxChecked(document.forms[0],'SPECIFY'))
 	{
		alert("Please specify the products and services specified.");
			document.forms[0].SPECIFY.focus();
		return false;
	}
	
	if (!CheckDropdown(document.forms[0].PERSONAL_ID))
	{
		alert("Please specify the Personal Identifier: Last digit of birth year.");
			document.forms[0].PERSONAL_ID.focus();
		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 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 = " /:;"

	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 PaidformCheck(mode, description)
{ 
	var UCASEdisPaid = document.paidform.DisPaid.value.toUpperCase();
	// since the discount paid page has only for 1 yr and it has been pre-checked
	// we don't ask the following question
	if (UCASEdisPaid == "")
	{
		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[0].checked)
	// check payment info if PAY_STAT=2
	{
		if (!CheckPaymentInfo())
		{
			//alert(CheckPaymentInfo())
			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.forms[0].STATE.selectedIndex == 0)
		{
			alert("Please specify your State/Province or select 'I am not in the U.S. or Canada'.");
			document.forms[0].STATE.focus();
			return false;
		}
		
		if (document.paidform.STATE.selectedIndex == 0)
		//if (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "53")
		{
		    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.forms[0].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 (((mode == "ADD")|| (mode == "COA"))&& (document.paidform.STATE[document.paidform.STATE.selectedIndex].value == "53") &&
	  (document.paidform.PAY_STAT[1].checked == true))
	{
		alert("Bill me later option is only available in the U.S. and Canada");
        	document.paidform.PAY_STAT[1].focus();
		return false;
	}
	if ((mode == "RENEW") && (document.paidform.PAY_STAT[1].checked == true) &&  (document.paidform.GEOSTATE.value == "53"))
	{
		alert("Bill me later option is only available in the U.S. and Canada");
	        document.paidform.PAY_STAT[1].focus();
		return false;
	}

	if (((document.paidform.ABU_RECEIVE.checked ) ||(document.paidform.ARCH_NEWSWIRE.checked))&&(document.forms[0].EMAIL_ADDRESS.value == ""))
	{
		alert("Email address is needed for newsletter subscription.");
		document.forms[0].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 (ObjectExists(paidform, "PRIMARY_BUSINESS"))
	{ // this demo is not display in the new ADD paid when it comes from the nonqual free ADD form
		if (!CheckDropdown(document.paidform.PRIMARY_BUSINESS))
		{
			alert("Please select your primary business.");
	        	document.paidform.PRIMARY_BUSINESS.focus();
			return false;
		}
		if (document.paidform.PRIMARY_BUSINESS[document.paidform.PRIMARY_BUSINESS.selectedIndex].value == "99")
		{
			if (document.paidform.PRIMARY_BUSINESS_DESC.value == "")
			{
				alert("Please specify your primary business - other.");
		        	document.paidform.PRIMARY_BUSINESS_DESC.focus();
				return false;
			}
	    }
	}
	
	if (!CheckDropdown(document.paidform.EMPLOYEES))
	{
		alert("Please select number of employees.");
			document.paidform.EMPLOYEES.focus();
		return false;
	}


	if (!CheckUnselects(document.paidform.REGISTERED_ARCHITECT)) 
	{
		alert("Please select registered architect.");
	 		document.paidform.REGISTERED_ARCHITECT[0].focus();
	 	return false;
	}

	if (!CheckUnselects(document.paidform.LEED_ACCREDITED_PROF)) 
	{
		alert("Please select LEED accredited professional.");
	 		document.paidform.LEED_ACCREDITED_PROF[0].focus();
	 	return false;
	}

	if (!CheckDropdown(document.paidform.JOB_TITLE))
	{
		alert("Please select your job title.");
        	document.paidform.JOB_TITLE.focus();
		return false;
	}
	if (document.paidform.JOB_TITLE[document.paidform.JOB_TITLE.selectedIndex].value == "99")
	{
		if (document.paidform.JOB_TITLE_DESC.value == "")
		{
			alert("Please specify your job title - other.");
	        	document.paidform.JOB_TITLE_DESC.focus();
			return false;
		}
    }
	
	if (!CheckboxChecked(document.paidform,'PROJECTS_INVOLVED'))
	{
		alert("Please select the projects involved in.");
			document.paidform.PROJECTS_INVOLVED.focus();
		return false;
	}
	if (document.getElementById('PROJECTS_INVOLVED99').checked)
	{
		if (document.paidform.PROJECTS_INVOLVED_CD_DESC.value == '')
		{ 
			alert("Please specify the projects involved - other.");
				document.paidform.PROJECTS_INVOLVED_CD_DESC.focus();
			return false;
		}
	}
	
	if (!CheckboxChecked(document.paidform,'SPECIFY'))
 	{
		alert("Please specify the products and services specified.");
			document.paidform.SPECIFY.focus();
		return false;
	}
    
   return true;
}
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;
}
function CheckedRadioValue(radioItem)
{
	for(i=0;i<radioItem.length;i++)
	{
		if(radioItem[i].checked)
		{
			return radioItem[i].value;
		}//end if
	}//end for
	return false;
}
// declare global variables
var i;
var QUES_6;


// on load calculate indices for all group of checkboxes with 'None of the Above' option
function InitIndex(formindex)
{
	for ( i=0; i < document.forms[formindex].elements.length; i++)
	{
		GetIndex(formindex, "QUES_6");
		QUES_6 = i;
		i++;


		break;
	}

}

function GetIndex(formindex, GroupName)
{
	var namelen = GroupName.length;

	while (document.forms[formindex].elements[i].name.substring(0,namelen) != GroupName)
	{
		i++;
	}
}


// This function is running with assumption that 'None of the Above' option is the very last
// in the group of checkboxes.
// Start index must be calculation on when document is being loaded using InitIndex() function

function checker(formindex,start,groupname,none)
			// formindex - index of the form within current document, starts with 0
			// start - start index for group of checkboxes
			// generic name of group of checkboxes (Example: "QUES_6")
			// 'None of the above' option (Example: "19" if "QUES_6-19" is
			//			a name of 'None of the above' checkbox
{
	var namelen = groupname.length;
	var OptionChecked = false;
	var LoopCount = parseInt(none);
	var NoneName = groupname + "-" + none;


	for ( var j=start; j < document.forms[formindex].elements.length; j++)
	{
		if (document.forms[formindex].elements[j].name.substring(0,namelen) == groupname)
		{	// group of check boxes located: continue loop inside the group
			while (LoopCount>=0)
			{
				if (document.forms[formindex].elements[j].name == NoneName)
 				{
 					if (OptionChecked == true)
 					{
 						document.forms[formindex].elements[j].checked = false;
 					}
 					LoopCount=0;	//break the loop when reach None option
 				}
 				else
 				{
					if (OptionChecked != true)
					{
 						if (document.forms[formindex].elements[j].checked==true)
 						{
 							OptionChecked = true;
 						}
					}
 				}
				j++;
				LoopCount--;
			}
			break;
		}
	}
}
function CheckboxChecked(thisform,CheckBoxName)
{
var ChLength = CheckBoxName.length + 1;
var vName = CheckBoxName + "-";

var CBindex = 0;

	for ( i=0; i < thisform.elements.length; i++)
	{
		if (thisform.elements[i].type == "checkbox")
		{
			if (thisform.elements[i].name.substring(0,ChLength)==vName)
			{
				if (CBindex==0) {CBindex = i;}
				if (thisform.elements[i].checked)
				{
					return true;
					break;
				}
			}
		}

	}

	thisform.elements[CBindex].focus();
	return false;
}
function CheckPaymentInfo()
{
var d, month, year;
   	d = new Date();

	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 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;
		}
	}

	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 enter security code.');
		document.paidform.SCODE.focus();
		return false;
	}
	month = d.getMonth() + 1;
	year = d.getFullYear() - 2000;
	if (document.paidform.ExpYear[document.paidform.ExpYear.selectedIndex].value < year)
	{
 		alert('Invalid Expiration date.');
		document.paidform.ExpMon.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;
			}
		}
	}
	month = d.getMonth() + 1;
	year = d.getFullYear() - 2000;
	if (document.paidform.ExpYear[document.paidform.ExpYear.selectedIndex].value < year)
	{
 		alert('Invalid Expiration date.');
		document.paidform.ExpMon.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;
			}
		}
	}
	

	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 PrepopNewsletter()
{
	if ((CheckedRadioValue(document.forms[0].RECEIVE_YES_NO) == "1") && (CheckedRadioValue(document.forms[0].ABU_RECEIVE) == ""))
	{ 
		document.getElementById("ABU_RECEIVE-0").checked = true;
		return true;
	}
        if ((CheckedRadioValue(document.forms[0].RECEIVE_YES_NO) == "1") && (CheckedRadioValue(document.forms[0].ARCH_NEWSWIRE) == ""))
	{ 
		document.getElementById("ARCH_NEWSWIRE-0").checked = true;
		return true;
	}
}
function FormatChange(mode, description)
{ 
		if (!CheckUnselects(document.forms[0].RECEIVE_YES_NO))
		{
			alert("Please specify whether you wish to receive " + description +"?");
        		document.forms[0].RECEIVE_YES_NO[0].focus();
			return false;
		}
		if (!CheckUnselects(document.forms[0].REQUESTED_VERSION))
		{
			alert("Please specify requested version.");
        		document.forms[0].REQUESTED_VERSION[0].focus();
			return false;
		}

                if (!CheckUnselects(document.forms[0].ABU_RECEIVE))
		{
			alert("Please specify whether you wish to receive Architect Weekly?");
        		document.forms[0].ABU_RECEIVE[0].focus();
			return false;
		}
		if (!CheckUnselects(document.forms[0].ARCH_NEWSWIRE))
		{
			alert("Please specify whether you wish to receive Architect Newswire?");
        		document.forms[0].ARCH_NEWSWIRE[0].focus();
			return false;
		}
		               
		
		if(document.forms[0].RECEIVE_YES_NO[1].checked == true && document.forms[0].ABU_RECEIVE[1].checked == true && document.forms[0].ARCH_NEWSWIRE[1].checked == true)
	// stop validation when "not to receive" response for both the magazine and newsletter
		{
			return true;
		}
                
                if (document.forms[0].EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	       		document.forms[0].EMAIL_ADDRESS.focus();
			return false;
	    	}
  		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].CITY.value == "")
		{
			alert("Please specify your City.");
	        	document.forms[0].CITY.focus();
			return false;
		}
		if (document.forms[0].STATE.selectedIndex == 0)
		{
	    	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 (!CheckDropdown(document.forms[0].PRIMARY_BUSINESS))
	{
		alert("Please select your primary business.");
        	document.forms[0].PRIMARY_BUSINESS.focus();
		return false;
	}
	if (document.forms[0].PRIMARY_BUSINESS[document.forms[0].PRIMARY_BUSINESS.selectedIndex].value == "99")
	{
		if (document.forms[0].PRIMARY_BUSINESS_DESC.value == "")
		{
			alert("Please specify your primary business - other.");
	        	document.forms[0].PRIMARY_BUSINESS_DESC.focus();
			return false;
		}
    	}

	if (!CheckDropdown(document.forms[0].JOB_TITLE))
	{
		alert("Please select your title.");
        	document.forms[0].JOB_TITLE.focus();
		return false;
	}
	if (document.forms[0].JOB_TITLE[document.forms[0].JOB_TITLE.selectedIndex].value == "99")
	{
		if (document.forms[0].JOB_TITLE_DESC.value == "")
		{
			alert("Please specify your title - other.");
	        	document.forms[0].JOB_TITLE_DESC.focus();
			return false;
		}
    	}
	
	 
		if (!CheckDropdown(document.forms[0].PERSONAL_ID))
		{
			alert("Please specify the Personal Identifier: Last digit of birth year.");
			document.forms[0].PERSONAL_ID.focus();
			return false;
		}
}			


function AnswerCheckNewswire(mode, description)
{ 
	if (!CheckUnselects(document.forms[0].ARCH_NEWSWIRE))
		{
		alert("Please specify whether you wish to receive " + description +"?");
        	document.forms[0].ARCH_NEWSWIRE[0].focus();
		return false;
		}
        
	if(document.forms[0].ARCH_NEWSWIRE[1].checked == true)
	// stop validation when "not to receive" response
	{
		return true;
	}
	
	if (document.forms[0].EMAIL_ADDRESS.value == "")  // newsletter only page
	{
		alert("Email address is needed for Architect Newswire.");
		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 (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].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.selectedIndex == 0)
		{
	    	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;
			}
		}
	}
}
function AnswerCheckAll(mode, description)
{ 
	if ((document.forms[0].ABU_RECEIVE[0].checked == false) && (document.forms[0].ABU_RECEIVE[1].checked == false))
		{
			alert("Please specify whether you wish to receive Architect Weekly?");
	        	document.forms[0].ABU_RECEIVE[0].focus();
			return false;
		}
                if ((document.forms[0].ARCH_NEWSWIRE[0].checked == false) && (document.forms[0].ARCH_NEWSWIRE[1].checked == false))
		{
			alert("Please specify whether you wish to receive Architect Newswire?");
	        	document.forms[0].ARCH_NEWSWIRE[0].focus();
			return false;
		}

		if(document.forms[0].ABU_RECEIVE[1].checked == true && document.forms[0].ARCH_NEWSWIRE[1].checked == true)
	// stop validation when "not to receive" response for both newsletters
		{
			return true;
		}
	
	if (document.forms[0].EMAIL_ADDRESS.value == "")  
	{
		alert("Email address is needed.");
		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 (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].COMPANY.value == "")
		{
			alert("Please specify your Company name.");
        		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.selectedIndex == 0)
		{
	    	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 (!CheckDropdown(document.forms[0].PRIMARY_BUSINESS))
	{
		alert("Please select your primary business.");
        	document.forms[0].PRIMARY_BUSINESS.focus();
		return false;
	}
	if (document.forms[0].PRIMARY_BUSINESS[document.forms[0].PRIMARY_BUSINESS.selectedIndex].value == "99")
	{
		if (document.forms[0].PRIMARY_BUSINESS_DESC.value == "")
		{
			alert("Please specify your primary business - other.");
	        	document.forms[0].PRIMARY_BUSINESS_DESC.focus();
			return false;
		}
    }

	if (!CheckDropdown(document.forms[0].JOB_TITLE))
	{
		alert("Please select your title.");
        	document.forms[0].JOB_TITLE.focus();
		return false;
	}
	if (document.forms[0].JOB_TITLE[document.forms[0].JOB_TITLE.selectedIndex].value == "99")
	{
		if (document.forms[0].JOB_TITLE_DESC.value == "")
		{
			alert("Please specify your title - other.");
	        	document.forms[0].JOB_TITLE_DESC.focus();
			return false;
		}
    }
	
	if (!CheckDropdown(document.forms[0].PERSONAL_ID))
	{
		alert("Please select your personal identifier.");
        	document.forms[0].PERSONAL_ID.focus();
		return false;
	}    
 }
function DualFormCheck()
{
		if(document.forms[0].RECEIVE_YES_NO[1].checked == true)
		{
			return true;
		}

		if (document.forms[0].EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	       		document.forms[0].EMAIL_ADDRESS.focus();
			return false;
	    }
  		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].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.selectedIndex == 0)
		{
			alert("Please specify your State.");
		        document.forms[0].STATE.focus();
			return false;
		}

		
		if (document.forms[0].ZIPCODE.value.length < 5)
		{
			alert("Please specify your Zip Code.");
	        	document.forms[0].ZIPCODE.focus();
			return false;
		}	
		if (!CheckUnselects(document.forms[0].SPEC_LIGHTING_PROD))
		{
			alert("Please select Question 1.");
        		document.forms[0].SPEC_LIGHTING_PROD[0].focus();
			return false;
		}
		
		if (!CheckDropdown(document.forms[0].BUSINESS))
		{
			alert("Please select Question 2.");
        	document.forms[0].BUSINESS.focus();
			return false;
		}
		
		
		
		if (document.forms[0].BUSINESS[document.forms[0].BUSINESS.selectedIndex].value == "12")
		{
			if (document.forms[0].BUSINESS_DESC.value == "")
			{
			alert("Please specify your Primary Business - other.");
	        	document.forms[0].BUSINESS_DESC.focus();
			return false;
			}
    	}
		
		
		if (!CheckDropdown(document.forms[0].TITLE_CODE))
		{
			alert("Please select Question 3.");
        	document.forms[0].TITLE_CODE.focus();
			return false;
		}
		
		
		
		if (document.forms[0].TITLE_CODE[document.forms[0].TITLE_CODE.selectedIndex].value == "10")
		{
			if (document.forms[0].TITLE_CODE_DESC.value == "")
			{
			alert("Please specify your Job Title - other.");
	        	document.forms[0].TITLE_CODE_DESC.focus();
			return false;
			}
    	}
		
		
		
		if (!CheckDropdown(document.forms[0].PERSONAL_ID))
		{
			alert("Please select your personal identifier.");
        	document.forms[0].PERSONAL_ID.focus();
			return false;
		}    
		
			
		return true;
}