
// Start build array to store all bad words. This is an abridged list.
	
var arrBadWord = new Array(
"*",
"?",
"ASDF",
"ASSHOLE",
"BASTARD",
"BITCH",
"BITCHSLAP",
"CLIT",
"CLITORIS",
"COCKSUCKER",
"CUM",
"CUMM",
"CUNNILINGUS",
"CUNT",
"DAMN",
"DAMNIT",
"DICKHEAD",
"DIKE",
"DIPSHIT",
"DIZZY",
"DOUCHE",
"DOUCHEBAG",
"DUMBASS",
"DYKE",
"EJACULATE",
"ERECTION",
"FAG",
"FAGGOT",
"FART",
"FARTFACE",
"FUCK",
"FUCKER",
"FUCKFACE",
"FUCKHEAD",
"FUCKING",
"FUCKU",
"FUCKYOU",
"GODDAMNIT",
"HOMO",
"IDIOT",
"INMATE",
"JACKASS",
"JERKOFF",
"KICKASS",
"KIKE",
"KISSASS",
"LABIA",
"LARD-ASS",
"LESBIAN",
"MOTHERFUCKER",
"MUFF",
"N.A.",
"N/A",
"NA",
"NIGGER",
"NONE",
"ORGASM",
"PECKER",
"PECKERHEAD",
"PENCILDICK",
"PENIS",
"PIMP",
"PUSSY",
"QUEER",
"RECTUM",
"RETARD",
"SCROTUM",
"SCUMBAG",
"SEMEN",
"SHIT",
"SHITFACE",
"SHITFACED",
"SHITHEAD",
"TEST",
"TESTICLE",
"TIT",
"TITS",
"TITTY",
"TWAT",
"URINARY",
"URINATE",
"URINE",
"VAGINA",
"WHORE",
"XXX");	
	
// End build array to store all bad words.	


//** Start isBadWord function. This function checks for bad words on landing page. 10/31/02 Ken L.

function isBadWord(sUserWord){	
	
	sUserWord = Trim(sUserWord);		// call to "Trim" in MyUtility.js. Removes leading and trailing whitespace characters from sUserWord.
	
	sUserWord = sUserWord.toUpperCase();	//convert to uppercase
	
	// Start iteration over every element in the arrBadWord array to determine match between sUserWord
	// and bad word.
	
		for (var i = 0; i < arrBadWord.length; i++) {
		      if (sUserWord == arrBadWord[i]) {
				return true;
		      }
		}	// End iteration over every element in the arrBadWord array.
	
}	// End isBadWord function 10/31/02 Ken L.


/* New Code to fix TOB/JF/JT error */
function ClearSelect() {
document.form1.elements["Class_TOB"].options[0].selected=true;
document.form1.elements["Class_JF"].options[0].selected=true;
//document.form1.elements["Class_JT"].options[0].selected=true;

document.form1.elements["Type of Business"].options[0].selected=true;
document.form1.elements["Job Function"].options[0].selected=true;
document.form1.elements["Job Title"].options[0].selected=true;
}
/* End New Code */ 


function VerifyFormElements(theForm) {
	
	var FirstName = theForm.elements["First Name"].value;
	var LastName = theForm.elements["Last Name"].value;
	var Email = theForm.elements["Email"].value.toUpperCase();
	var ConfEmail = theForm.elements["Confirm Email"].value.toUpperCase();
	/* New Code to fix TOB/JF/JT error */

        //var TOB = parseInt(theForm.elements["Type of Business"].options[theForm.elements["Type of Business"].selectedIndex].value);	     
        
	var intIndex = theForm.elements["Type of Business"].selectedIndex;

        if (intIndex != -1)
          var TOB = parseInt(theForm.elements["Type of Business"].options[intIndex].value);
        else
         {
                //setSelect();
		alert("All answers must be provided. Please follow the red arrow.");
		return false;
         }
	/* End New Code */	
	
	if (isWhitespace(FirstName)){
		alert("An entry for first name must be provided.");
		theForm.elements["First Name"].focus();
		return false;
	}
	
	if (!isValidName(FirstName)){
		alert("Please enter a valid first name.");
		theForm.elements["First Name"].focus();
		return false;
	}
	
	//** Start call to new code for bad word. 10/31/02 Ken L.
		
	if (isBadWord(FirstName)){
		alert("Please enter a valid first name.");
		theForm.elements["First Name"].focus();
		return false;
	}
	//** End call to new code for bad word.  10/31/02 Ken L.
	
	if (isWhitespace(LastName)){
		alert("An entry for last name must be provided.");
		theForm.elements["Last Name"].focus();
		return false;
	}
	
	if (!isValidName(LastName)){
		alert("Please enter a valid last name.");
		theForm.elements["Last Name"].focus();
		return false;
	}
	
	//** Start call to new code for bad word. 10/31/02 Ken L.
	
	if (isBadWord(LastName)){
		alert("Please enter a valid last name.");
		theForm.elements["Last Name"].focus();
		return false;
	}
	//** End call to new code for bad word.  10/31/02 Ken L.
	
	if (isWhitespace(Email)){
		alert("An entry for email must be provided.");
		theForm.elements["Email"].focus();
		return false;
	}
	
	if (!isEmail(Trim(Email))){
		alert ("Please enter a valid email (myname@xyz.com).");
		theForm.elements["Email"].focus();	
		return false;
	}
	
	if (isWhitespace(ConfEmail)){
		alert("An entry for confirm email must be provided.");
		theForm.elements["Confirm Email"].focus();
		return false;
	}
	
	if (Trim(Email) != Trim(ConfEmail)) {
		alert("Please re-enter email and confirm email identically.");
		theForm.elements["Email"].focus();
		return false;
	}
	
	if (setSelect()){
		alert("All answers must be provided. Please follow the red arrow.");
		return false;
	}
	
	if (TOB == -1){alert("Based on the business profile you have provided, \nwe are unable to locate any applicable free\n"+ 
		      "business magazines.\n\nYou may wish to double-check your selections. \nThe answers provided may not be exact matches\n" +
		      "to your professional status, however, you should\nchoose the answers that best describe your\ntype of business, job function and job title.");
			  theForm.elements["Type of Business"].focus();return false;
	}
	
	//document.forms[0].EFLAG.value="2";
	return true;
}


//Functions used for our Welcome.asp and GetMoreMags.asp pages
//to handle our qualification attempt questions.

//Function to fill or Lists from our selected Class.
function fillLists(objClassSelect,objListSelect,strListArray) {
	//Declare our variables.
	var intIndex;
	var intValue;
	var strArray;
	var intCounter;
	var intOne;
	var intTwo;
	var intTotal;

	//Get our index of our selected item and retrieve its value.
	intIndex = objClassSelect.selectedIndex;
	intValue = objClassSelect.options[intIndex].value;
	
	//Set our array to proper main array elements.
	strArray = strListArray[intValue];
	
	//Check if this function is called from OnChange event of Job Function class
	//Release 2.2 - sponnaganti, 03/24/03
	if (objClassSelect.name == 'Class_JF')
	  {
	  	//Clear all entries in our List Select box.
		objListSelect.options.length = 0;
		document.form1.elements['Job Title'].options.length = 0;
		document.form1.elements['Job Title'].options[0] = new Option;
		document.form1.elements['Job Title'].options[0].text = '-------------------';
		document.form1.elements['Job Title'].options[0].value = 0;
	  }
	else
	  {
		//Clear all entries in our List Select box.
		objListSelect.options.length = 0;
	  }
	  
	
	//Calcualte the total number of our elements which is half since we use two at a time.
	intTotal = strArray.length / 2;
	
	//Loop through our array and populate our List select box.
	for(intCounter=0;intCounter<intTotal;intCounter++) {
		//Calculate our array elements.
		intOne = intCounter * 2;
		intTwo = intOne + 1;
		
		//Add a new option and populate with our array data.
		objListSelect.options[intCounter] = new Option;
		objListSelect.options[intCounter].text = strArray[intOne];
		objListSelect.options[intCounter].value = strArray[intTwo];
	}
	
	//Make sure our first item in List select box is selected.
	objListSelect.selectedIndex = 0;
}

//Clear all our iamges.
function clearImages() {
	//Variable Declaration
	var intCounter;
	var intTotal;
	var intElement;
	var strImageName;
	
	//Calculate our total number of elements to process.
	intTotal=selectInfo.length / 3;
	
	//Set our first element.
	intElement = 1;
	
	//Loop through our select info array and clear our images.
	for(intCounter=0;intCounter<intTotal;intCounter++) {
		//Set our Image to our blank image.
		strImageName = selectInfo[intElement];
		document.images[strImageName].src = dotImage
		
		//Set our next element.
		intElement = intElement + 3;
	}
}

//Will handle the positioning of our graphic when a Class has been chosen.
function selectClass(objClassSelect) {
	//Variable Declarations.
	var intIndex;
	var intValue;
	var intCounter;
	
	//Check value of select box
	intIndex = objClassSelect.options.selectedIndex;
	intValue = objClassSelect.options[intIndex].value;
	
	//If value is not zero than set our arrow and focus to next select..
	//If it is zero than set it to the passed in object.
	if (intValue != 0) {
		//Clear our current images.
		clearImages();
		
		//Loop through our array and get our next select info.
		for (intCounter=0;intCounter<selectInfo.length;intCounter=intCounter+3) {
			//Check to see if we have a match on our name.
			if (selectInfo[intCounter] == objClassSelect.name) {
				//Set our new graphic for the next select box.
				document.images[selectInfo[intCounter + 4]].src = selectInfo[intCounter + 5];
				
				//CHANGED ON 6-28-2000 as per synapse request.
				//Set focus to next select box.
				//document.form1.elements[selectInfo[intCounter + 3]].focus();
				
				//End our loop.
				intCounter = selectInfo.length;
			}
		}
	}
	else {
		//Clear our current images.
		clearImages();
		
		//Loop through our array and get our select info.
		for (intCounter=0;intCounter<selectInfo.length;intCounter=intCounter+3) {
			//Check to see if we have a match on our name.
			if (selectInfo[intCounter] == objClassSelect.name) {
				//Set our new graphic for the select box.
				document.images[selectInfo[intCounter + 1]].src = selectInfo[intCounter + 2];
				
				//CHANGED ON 6-28-2000 as per synapse request.
				//Set focus to next select box.
				//objClassSelect.focus();
				
				//End our loop.
				intCounter = selectInfo.length;
			}
		}
	}
}

//Will dtermine which select box gets the focus.
//If everything in our select boxes are complete we set focus
//to final entry in our selectInfo array.
function setSelect(intIndex,intValue) {
	//Variable Declaration.
	var intCounter;
	var intTotal;
	var intFound=0;
	var intIndex;
	var intValue;
	
	//Clear all our images.
	clearImages();
	
	//Set our total counter which is three less than
	//array length because we do not look at our final entry.
	intTotal = selectInfo.length - 3;
	
	//Loop through our select boxes and if any of them have a value
	//of zero we set focus to it.
	for (intCounter=0;intCounter<intTotal;intCounter=intCounter+3) {
		//Get our select box value.
		intIndex = document.form1.elements[selectInfo[intCounter]].selectedIndex;
                 
                if (intIndex != -1)		
                {
                intValue = document.form1.elements[selectInfo[intCounter]].options[intIndex].value;
		
		if (intValue == 0) {
			//Set our new graphic for the select box.
			document.images[selectInfo[intCounter + 1]].src = selectInfo[intCounter + 2];
				
			//CHANGED ON 6-28-2000 as per synapse request.
			//Set focus to next select box.
			//document.form1.elements[selectInfo[intCounter]].focus();
				
			//End our loop.
			intCounter = intTotal;
				
			//Set our found boolean to true.
			intFound = 1;
			
			//Set our return to true since we set a select.
			return true;
		}
                }
	}
	
	//If no empty entries than set our graphic and focus on our
	//final entry in selectInfo.
	if (intFound == 0) {
		//Set our new graphic for the select box.
		document.images[selectInfo[intTotal + 1]].src = selectInfo[intTotal + 2];
		
		//CHANGED ON 6-28-2000 as per synapse request.		
		//Set focus to next select box.
		//document.form1.elements[selectInfo[intTotal]].focus();
		
		//Set our return to false since no select was set.
		return false;
	}
}

function fillClassList(strArray,objListSelect){
	//alert("in fill class list "+strArray.length);
	var intTotal = strArray.length/2;
	
	for(var i=0;i<intTotal;i++){
		intOne = i * 2;
		intTwo = intOne + 1;
			
		objListSelect.options[i] = new Option;
		objListSelect.options[i].text = strArray[intOne];
		objListSelect.options[i].value = strArray[intTwo];
	}
}

function GetJobTitles(objClassSelect,objListSelect)
{
//Get our index of our selected item and retrieve its value.
	intIndex = objClassSelect.selectedIndex;
	intValue = objClassSelect.options[intIndex].value;
	intCounter = 0;

	if (intIndex == 0)
	   {
		//Clear all entries in our List Select box.
		objListSelect.options.length = 0;
		objListSelect.options[0] = new Option;
		objListSelect.options[0].text = "--------Make a Selection-------";
		objListSelect.options[0].value = 0;
	   }
	else
	   {		
		//Clear all entries in our List Select box.
		objListSelect.options.length = 0;
	
		//Calculate the total number of our elements which is half since we use two at a time.
		intTotal = jfmap[intValue].length;
	
		objListSelect.options[intCounter] = new Option;
		objListSelect.options[intCounter].text = "--------Make a Selection-------";
		objListSelect.options[intCounter].value = 0;
	
		//Loop through our array and populate our List select box.
		for(intCounter=1;intCounter<intTotal;intCounter++) {
			//Add a new option and populate with our array data.
	
			objListSelect.options[intCounter] = new Option;
			objListSelect.options[intCounter].text = jtd[jfmap[intValue][intCounter]];
			objListSelect.options[intCounter].value = jfmap[intValue][intCounter];
	    }

		//Make sure our first item in List select box is selected.
		objListSelect.selectedIndex = 0; 
	  }  
}

/* Show select boxes that are hidden. Release 2.2 - sponnaganti */
function ShowSelectboxes(lyr)
{
	if (navigator.appName == "Netscape")
		br="ns";
	else
        br="";
        
	ver = navigator.appVersion.substring(0,1);
	
	if (br == "ns" && ver <= 4) 
	  {
			/*lyr = document.layers[lyr];
			lyr.position='absolute';
			lyr.visibility = 'visible';*/
      }
    else
      {
			lyr = document.getElementById(lyr);
			lyr.style.position='absolute';
			lyr.style.visibility = 'visible';
      }
}

/* Hide select boxes that are visible. Release 2.2 - sponnaganti */
function HideSelectboxes()
{
	if (navigator.appName == "Netscape")
		br="ns";
	else
        br="";
        
	ver = navigator.appVersion.substring(0,1);
	
	if (br == "ns" && ver <= 4) 
	  {
			/*document.layers['trTOB'].visibility = 'hidden';
			document.layers['trJF'].visibility = 'hidden';
			document.layers['trJT'].visibility = 'hidden';*/
      }
    else
      {
			document.getElementById('trTOB').style.visibility = 'hidden';
			document.getElementById('trJF').style.visibility = 'hidden';
			document.getElementById('trJT').style.visibility = 'hidden';
      }
}