// declare global variables
var i;
var IT_DECISION;
var PURCH_AUTH;
var SOFTWARE_SPECIFY;
var SOFTWARE_SPEC_OUTSRC;
var PRODUCTS_SPECIFY;
var ENTERPRISE_SOFTWARE;
var PRODUCTS_IN_USE;
var ENEWSLETTERS;
var ENEWSLETTERS_ALL;
var SubmitFlag;
var errMsg;
var errFlag;
var UCASEtemplate;

SubmitFlag = false;

// on load calculate indices for all group of checkboxes with 'None of the Above' option

//function InitIndex2(formindex)
//{

//	var UCASEtemplate = document.forms[0].template.value.toUpperCase();  //due netscape 4.75
	//UCASEtemplate = document.getElementsByName("template")[0].value.toUpperCase();
//	if ((UCASEtemplate == "NMI" && document.forms[formindex].skipq1.value=="") || UCASEtemplate != "NMI")
//	{
//		for ( i=0; i < document.forms[formindex].elements.length; i++)
//		{
//			GetIndex(formindex, "IT_DECISION");
//			IT_DECISION = i;
//			i++;
//			break;
//		}
//	}	
//}

function InitIndex3(formindex)
{
	var UCASEtemplate = document.forms[0].template.value.toUpperCase();  //due netscape 4.75
	//UCASEtemplate = document.getElementsByName("template")[0].value.toUpperCase();
	for ( i=0; i < document.forms[formindex].elements.length; i++)
	{
		if ((UCASEtemplate == "NMI" && document.forms[formindex].skipq5.value=="") || UCASEtemplate != "NMI")
		{
			GetIndex(formindex, "SOFTWARE_SPECIFY");
			SOFTWARE_SPECIFY = i;
			i++;
	
			GetIndex(formindex, "SOFTWARE_SPEC_OUTSRC");
			SOFTWARE_SPEC_OUTSRC = i;
			i++;
		}
		if ((UCASEtemplate == "NMI" && document.forms[formindex].skipq6.value=="") || UCASEtemplate != "NMI")
		{
			GetIndex(formindex, "PRODUCTS_SPECIFY");
			PRODUCTS_SPECIFY = i;
			i++;
		}
	
		if ((UCASEtemplate == "NMI" && document.forms[formindex].skipq7.value=="") || UCASEtemplate != "NMI")
		{
			GetIndex(formindex, "ENTERPRISE_SOFTWARE");
			ENTERPRISE_SOFTWARE = i;
			i++;
		}
		
		if ((UCASEtemplate == "NMI" && document.forms[formindex].skipq8.value=="") || UCASEtemplate != "NMI")
		{
			GetIndex(formindex, "PRODUCTS_IN_USE");
			PRODUCTS_IN_USE = i;
			i++;
		}
		
		break;
	}

}

function InitIndex4(formindex)
{
	if (document.forms[formindex].OfferNewsLetters.value == "0")
	{
		return;
	}
	
	var UCASEtemplate = document.forms[0].template.value.toUpperCase();  //due netscape 4.75
	//UCASEtemplate = document.getElementsByName("template")[0].value.toUpperCase();
	if (UCASEtemplate != "NMI")
	{
		for ( i=0; i < document.forms[formindex].elements.length; i++)
		{
			GetIndex(formindex, "ENEWSLETTERS");
			ENEWSLETTERS = i;
			i++;
	
			GetIndex(formindex, "ENEWSLETTERS-99");
			ENEWSLETTERS_ALL = i;
			i++;
	
			break;
		}
	}
}

function InitIndexAll(formindex)
{
	for ( i=0; i < document.forms[formindex].elements.length; i++)
	{
		GetIndex(formindex, "IT_DECISION");
		IT_DECISION = i;
		i++;
		
		GetIndex(formindex, "PURCH_AUTH");
		PURCH_AUTH = i;
		i++;

		break;
	}
}

function InitIndexForShorter(formindex)
{
	for ( i=0; i < document.forms[formindex].elements.length; i++)
	{
		GetIndex(formindex, "IT_DECISION");
		IT_DECISION = 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
			// groupname - generic name of group of checkboxes (Example: "PRODUCTS")
			// none - 'None of the above' option (Example: "98" if "PRODUCTS-98" 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)&&(document.forms[formindex].elements[j].name.substring(0,namelen) == groupname))
 						{
 							OptionChecked = true;
 						}
					}
 				}
				j++;
				LoopCount--;
			}
			break;
		}
	}
}

// This function is running with assumption that 'Check All' 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 CheckAll(formindex,start,allindex)
			// 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: "PRODUCTS")
			// 'Check All' option index (Example: "98" if "PRODUCTS-98" is
			//			a name of 'Check All' checkbox
{
	if (document.forms[formindex].elements[allindex].checked==true)
	{
		for ( var j=start; j < allindex; j++)
		{
 			document.forms[formindex].elements[j].checked = true;
		}
	}
}

function CheckOptions(formindex,start,allindex)
			// 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: "PRODUCTS")
			// 'Check All' option index (Example: "98" if "PRODUCTS-98" is
			//			a name of 'Check All' checkbox
{
	if (document.forms[formindex].elements[allindex].checked==true)
	{
		for ( var j=start; j < allindex; j++)
		{
			if (document.forms[formindex].elements[j].checked==true)
			{
 				document.forms[formindex].elements[j].checked = false;
			}
		
		}
	}
}
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 true
	}
			
	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 checkEmail1(emailValue)
{     //runs the validate script and returns error box or nonerror

	// remove leading spaces
	while(emailValue.substring(0,1)==" ")
	{
		emailValue = emailValue.substring(1,emailValue.length);
	}

// remove trailing spaces
	while(emailValue.substring(emailValue.length-1,emailValue.length)==" ")
	{

		emailValue = emailValue.substring(0,emailValue.length-1);
	}

	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 wait(sec) {
	var Digital = new Date();
	var offset = sec;
	var seconds = Digital.getSeconds();
	var stopSeconds = seconds+offset;
	if (stopSeconds > 60) {
		stopSeconds = stopSeconds - 60;
	}
	
	while (seconds < stopSeconds) {
		//alert("seconds = " + seconds + ", stopSeconds = " + stopSeconds);
		Digital = new Date();
		seconds = Digital.getSeconds();
	}	
}

function openAndWrite() {
	//alert("Entering openAndWrite() ...");
	newWin = window.open("", "PartialSubmitWindow", "width=5,height=5,scrollbars=no,menubar=no");
	window.focus();
	newWin.document.write("<html>");
	newWin.document.write("<body>");

   // var page = document.getElementsByName("page")[0].value;  //due to lower version of netscape
    var page = document.forms[0].page.value;    //due to lower version of netscape
	newWin.document.write("<form method='post' name='" + page + "' action='ewk.cgi'>");

	var elems = document.forms[0].elements;
	var elems_length = elems.length;

	for (var j=0; j<elems_length; j++) {
		var elem_name = elems[j].name;
		var elem_type = elems[j].type;
		var val = "";
		var writeFlag = true;
			
		if (elem_name != "" && (elem_type == "text" || elem_type == "hidden" || elem_type == "radio" || elem_type == "checkbox" || elem_type == "select-one")) {

			if (elem_type == "text" || elem_type == "hidden") {
					val = elems[j].value;
			}

			if (elem_type == "radio") {
					if (elems[j].checked) {
						val = elems[j].value;
					}
					else {
						writeFlag = false;
					}
			}
			
			if (elem_type == "checkbox") {
					if (elems[j].checked) {
						val = "1";
					}
			}	
			
			if (elem_type == "select-one") {
					val = elems[j].value;
			}		
				if (writeFlag) {
				newWin.document.write("<p>" + "<font size=1 face=Arial>"+ "Thank you for your time! \n Please wait..." + "</font></p><input type='hidden' name='" + elem_name + "' value='");
				//newWin.document.write("<h5>" + elem_name + ":</h5><input type='text' name='" + elem_name + "' value='");
				newWin.document.write(val);
				newWin.document.write("'><br><br><br><br>");
			}
		}
	}

	newWin.document.write("</form>");
	newWin.document.write("</body>");
	newWin.document.write("</html>");
	newWin.document.close();
	newWin.document.forms[0].submit();
}

function ConfirmQuit(formindex)
{
	if(document.forms[0].RECEIVE_YES_NO[1].checked == true)
	{
		if ((ObjectExists("istRECEIVE_YES_NO")) || (ObjectExists("bslRECEIVE_YES_NO")))
		{
			if (ObjectExists("istRECEIVE_YES_NO"))
			{
				// RECEIVE_YES_NO question for IST
				if ((document.forms[0].RECEIVE_YES_NO[1].checked == true) && (document.forms[0].istRECEIVE_YES_NO[1].checked == true))
				{
	    				return "You answered 'No' to the question: I wish to receive eWEEK FREE." + 
					       "\nYou answered 'No' to the question: I wish to receive CIO Insight FREE." +
					       "\n\nIf you made this choice in error, please press 'Cancel', return to the question and select 'Yes' for one or both of these publications.";
	  			}
			}
			if (ObjectExists("bslRECEIVE_YES_NO"))
			{
				// RECEIVE_YES_NO question for eWEEK
				if ((document.forms[0].RECEIVE_YES_NO[1].checked == true) && (document.forms[0].bslRECEIVE_YES_NO[1].checked == true))
				{
	    				return "You answered 'No' to the question: I wish to receive eWEEK FREE." + 
					       "\nYou answered 'No' to the question: I wish to receive Baseline FREE." +
					       "\n\nIf you made this choice in error, please press 'Cancel', return to the question and select 'Yes' for one or both of these publications.";
	  			}
			}
		}
		else
		{
    			return "You answered 'No' to the question: I wish to receive eWEEK FREE." + 
			       "\n\nIf you made this choice in error, please press 'Cancel', return to the question and select 'Yes'\n\n";
		}
	}
	else
	{
		if ((SubmitFlag == true) || (document.forms[0].G.value == "1"))
		{
			return;
		}

		document.forms[formindex].returns.value = "1";
		return "The form should take under 5 minutes to complete.  That's just 5 minutes for a FREE 1-year subscription to eWEEK {$195 value for non-selected professionals}.";
	}

}

function IncompleteSubmit(formindex)
{
	if ((SubmitFlag == true) || (document.forms[0].G.value == "1"))
	{
		return;
	}
	
	document.forms[formindex].PMF.value="1";		
	openAndWrite();
	document.forms[formindex].PMF.value="0";
}

function doSubmit()
{
	SubmitFlag = true;
	return;
}

function doSubmitDemoBlock()
{
	SubmitFlag = false;
	errMsg = "Every question must be answered in order to submit the form:\n\n";
	var UCASEtemplate = document.forms[0].template.value.toUpperCase();  //due netscape 4.75		

	if (document.forms[0].page.value=="Page2")	// start page2
	{
		//receive/continue to receive
		if (UCASEtemplate != "ONEPAGE" && UCASEtemplate != "NMI" && UCASEtemplate != "WHEND" && UCASEtemplate != "PMF" && UCASEtemplate != "ICROSS")
		{
			if (!checkUnselects(document.forms[0].RECEIVE_YES_NO))
			{
				alert ("Please specify whether you want to receive/continue to receive eWEEK on a complimentary basis.");
				document.forms[0].RECEIVE_YES_NO[0].focus();
				SubmitFlag = false;				
				return false;
			}
		}
				
		// Question A
		if (!checkUnselects(document.forms[0].REQUESTED_VERSION))
		{
			alert (errMsg + "Question A - Subscription Format.");
			document.forms[0].REQUESTED_VERSION[0].focus();
			SubmitFlag = false;				
			return false;
		}
		
		// question 1 IT_DECISION
		if (!CheckboxChecked('IT_DECISION'))
		{
			var QuestionFocus="IT_DECISION-01";
			alert (errMsg + "Question 1 - It Decision.");
			document.forms[0].elements[QuestionFocus].focus();
			SubmitFlag = false;	
			return false;
		}
		
		if (UCASEtemplate == "POPUPEMBED" || UCASEtemplate == "POPUP" || UCASEtemplate == "POPUNDER")
		{
			//question 2 industry "radio"
			if (!checkUnselects(document.forms[0].INDUSTRY))
			{
				alert (errMsg + "Question 2- Primary Business.");
				document.forms[0].INDUSTRY[0].focus();
				SubmitFlag = false;				
				return false;
			}
			
			if ((document.forms[0].INDUSTRY[25].checked==true)&& (document.forms[0].INDUSTRY_DESC.value==""))
			{
				alert(errMsg + "Question 2 - other.")
				document.forms[0].INDUSTRY_DESC.focus();
				SubmitFlag = false;				
				return false;
			}
		}
		else  //question 2 industry "select one"
		{
			if (!checkDropdown(document.forms[0].INDUSTRY))
			{
				alert(errMsg + "Question 2- Primary Business.")
				document.forms[0].INDUSTRY.focus();
				SubmitFlag = false;				
				return false;
			}
			
			if ((document.forms[0].INDUSTRY[document.forms[0].INDUSTRY.selectedIndex].value == '99') && (document.forms[0].INDUSTRY_DESC.value == ''))
			{
				alert(errMsg + "Question 2 - other.")
				document.forms[0].INDUSTRY_DESC.focus();
				SubmitFlag = false;				
				return false;
			}
		}		
		
		//question 3a
		if (!checkUnselects(document.forms[0].JOB_TITLE))
		{
			alert (errMsg + "Question 3a - Job title.");
			document.forms[0].JOB_TITLE[0].focus();
			SubmitFlag = false;				
			return false;
		}
		
		if ((document.forms[0].JOB_TITLE[8].checked==true)&& (document.forms[0].Q2_IT_DESC.value==""))
		{
			alert(errMsg + "Question 3a - Other IT Management.")
			document.forms[0].Q2_IT_DESC.focus();
			SubmitFlag = false;				
			return false;
		}
	
		if ((document.forms[0].JOB_TITLE[14].checked==true)&& (document.forms[0].Q2_CORP_DESC.value==""))
		{
			alert(errMsg + "Question 3a - Other Corporate Management.")
			document.forms[0].Q2_CORP_DESC.focus();
			SubmitFlag = false;				
			return false;
		}
		
		if ((document.forms[0].JOB_TITLE[17].checked==true)&& (document.forms[0].Q2_MGMT_DESC.value==""))
		{
			alert(errMsg + "Question 3a - Other Management.")
			document.forms[0].Q2_MGMT_DESC.focus();
			SubmitFlag = false;				
			return false;
		}
		
		if ((document.forms[0].JOB_TITLE[18].checked==true)&& (document.forms[0].JOB_TITLE_DESC.value==""))
		{
			alert(errMsg + "Question 3a - Job title - Other.")
			document.forms[0].JOB_TITLE_DESC.focus();
			SubmitFlag = false;				
			return false;
		}
		
		//question 3b check boxes JOB_FUNCTION
		if (!CheckboxChecked('JOB_FUNCTION'))
		{
			var QuestionFocus="JOB_FUNCTION-01";
			alert (errMsg + "Question 3b - Job function.");
			document.forms[0].elements[QuestionFocus].focus();
			SubmitFlag = false;				
			return false;
		}
	
		for ( var j=0; j < document.forms[0].elements.length; j++)
		{
			if (document.forms[0].elements[j].name.substring(0,12) == "JOB_FUNCTION")
			{
				if (document.forms[0].elements[j].checked)
				{
					v=document.forms[0].elements[j].name.substring(13,15)
					if ((v=="13") && (document.forms[0].JOB_FUNCT_INFO_DESC.value==""))
					{
						alert (errMsg + "Question 3b - Other IT Management.");
						document.forms[0].JOB_FUNCT_INFO_DESC.focus();
						return false;
	
					}
					//due to card conversion is not yet implemented to PMF & NMI templates
					if (UCASEtemplate == "PMF")
					{	
						if ((v=="20") && (document.forms[0].JOB_FUNCT_CORP_DESC.value==""))
						{
							alert (errMsg + "Question 3b - Other Corporate Management.");
							document.forms[0].JOB_FUNCT_CORP_DESC.focus();
							return false;
						}
					}
					else	//due to card conversion is not yet implemented to PMF & NMI templates
					{
						if ((v=="22") && (document.forms[0].JOB_FUNCT_CORP_DESC.value==""))
						{
							alert (errMsg + "Question 3b - Other Corporate Management.");
							document.forms[0].JOB_FUNCT_CORP_DESC.focus();
							return false;
		
						}
					}
					
					if ((v=="99") && (document.forms[0].JOB_FUNCTION_CD_DESC.value=="")) 
					{
						alert (errMsg + "Question 3b - Other.");
						document.forms[0].JOB_FUNCTION_CD_DESC.focus();
						return false;
					}										
				}	
			}
		}
		
		//question 4 
		if ((!checkDropdown(document.forms[0].SOFTWARE_THIS_LOC)) && (!checkDropdown(document.forms[0].SOFTWARE_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Software.")
			document.forms[0].SOFTWARE_THIS_LOC.focus();
			return false;
		}
		
		if ((!checkDropdown(document.forms[0].SECURITY_THIS_LOC)) && (!checkDropdown(document.forms[0].SECURITY_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Security.")
			document.forms[0].SECURITY_THIS_LOC.focus();
			return false;
		}
	
		if ((!checkDropdown(document.forms[0].STORAGE_THIS_LOC)) && (!checkDropdown(document.forms[0].STORAGE_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Storage.")
			document.forms[0].STORAGE_THIS_LOC.focus();
			return false;
		}
		
		if ((!checkDropdown(document.forms[0].NETWORKING_THIS_LOC)) && (!checkDropdown(document.forms[0].NETWORKING_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Networking.")
			document.forms[0].NETWORKING_THIS_LOC.focus();
			return false;
		}
	
		if ((!checkDropdown(document.forms[0].LARGE_SYS_THIS_LOC)) && (!checkDropdown(document.forms[0].LARGE_SYS_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Large systems.")
			document.forms[0].LARGE_SYS_THIS_LOC.focus();
			return false;
		}
		
		if ((!checkDropdown(document.forms[0].INTERNET_THIS_LOC)) && (!checkDropdown(document.forms[0].INTERNET_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Internet.")
			document.forms[0].INTERNET_THIS_LOC.focus();
			return false;
		}
			
		if ((!checkDropdown(document.forms[0].OUTSOURCE_THIS_LOC)) && (!checkDropdown(document.forms[0].OUTSOURCE_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Outsource.")
			document.forms[0].OUTSOURCE_THIS_LOC.focus();
			return false;
		}
	
		if ((!checkDropdown(document.forms[0].WIRELESS_THIS_LOC)) && (!checkDropdown(document.forms[0].WIRELESS_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Wireless.")
			document.forms[0].WIRELESS_THIS_LOC.focus();
			return false;
		}
		
		if ((!checkDropdown(document.forms[0].DESKTOPS_THIS_LOC)) && (!checkDropdown(document.forms[0].DESKTOPS_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Desktops.")
			document.forms[0].DESKTOPS_THIS_LOC.focus();
			return false;
		}
		
		if ((!checkDropdown(document.forms[0].PERIPHERAL_THIS_LOC)) && (!checkDropdown(document.forms[0].PERIPHERAL_OTHR_LOC)))
		{
			alert(errMsg + "Question 4 - Peripheral Equipment.")
			document.forms[0].PERIPHERAL_THIS_LOC.focus();
			return false;
		}
	}		// end page2

  	if (document.forms[0].page.value=="Page3")	// start page3
  	{
		// question 5
		if ((!CheckboxChecked('SOFTWARE_SPECIFY')) && (!CheckboxChecked('SOFTWARE_SPEC_OUTSRC')))
		{
			var QuestionFocus="SOFTWARE_SPECIFY-01";
			alert (errMsg + "Question 5 - Enterprise Business Applications.");
			document.forms[0].elements[QuestionFocus].focus();
			SubmitFlag = false;	
			return false;
		}
			
		//question 6 PRODUCTS_SPECIFY	
		if (!CheckboxChecked('PRODUCTS_SPECIFY'))
		{
			var QuestionFocus="PRODUCTS_SPECIFY-01";
			alert (errMsg + "Question 6 - Products specify.");
			document.forms[0].elements[QuestionFocus].focus();
			SubmitFlag = false;	
			return false;
		}
		
		//question 7 ENTERPRISE_SOFTWARE	
		if (!CheckboxChecked('ENTERPRISE_SOFTWARE'))
		{
			var QuestionFocus="ENTERPRISE_SOFTWARE-01";
			alert (errMsg + "Question 7 - Enterprise software.");
			document.forms[0].elements[QuestionFocus].focus();
			SubmitFlag = false;	
			return false;
		}
	
		//question 8 PRODUCTS_IN_USE
		if (!CheckboxChecked('PRODUCTS_IN_USE'))
		{
			
			var QuestionFocus="PRODUCTS_IN_USE-01";
			alert (errMsg + "Question 8 - Products in use.");
			document.forms[0].elements[QuestionFocus].focus();
			SubmitFlag = false;	
			return false;
		}
		
		//question 9 EMPLOYEES_ENTR_ORG	
		if (!checkDropdown(document.forms[0].EMPLOYEES_ENTR_ORG))
		{
			alert(errMsg + "Question 9 - Number of Employees in Entire Organization.")
			document.forms[0].EMPLOYEES_ENTR_ORG.focus();
			SubmitFlag = false;	
			return false;
		}
  	}		// end page3

	SubmitFlag = true;
	return true;
}

function CheckboxChecked(CheckBoxName)
{
var ChLength = CheckBoxName.length + 1;
var vName = CheckBoxName + "-";

var CBindex = 0;
	for ( i=0; i < document.forms[0].elements.length; i++)
	{
		if (document.forms[0].elements[i].type == "checkbox")
		{
			if (document.forms[0].elements[i].name.substring(0,ChLength)==vName)
			{
				if (CBindex==0) {CBindex = i;}
				if (document.forms[0].elements[i].checked)
				{
					return true;
					break;
				}
			}
		}
	}
	//document.forms[0].elements[CBindex].focus();
	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;
}

function ObjectExists(fieldname)
{
	for ( i=0; i < document.forms[0].elements.length; i++)
	{
		if (document.forms[0].elements[i].name == fieldname)
		{
			return true;
		}
	}
	return false;
}

//Privacy Policy Link
function PopupPrivacyPolicy()
{
	window.open("http://www.ziffdavisenterprise.com/PrivacyPolicy.htm","","height=500, width=780,toolbar=yes,resizable=yes,scrollbars=yes");
}	

