
	

	
	function printNotMACIE(){

		var agt=navigator.userAgent.toLowerCase();
		this.major = parseInt(navigator.appVersion);
		this.mac    = (agt.indexOf("mac")!=-1);
		this.ie   = (agt.indexOf("msie") != -1);

		if (this.mac && this.ie){
			alert("Sorry, your browser doesn't support this feature. Please use the file menu to print this window.");
		}else{
			window.print();
		}//end if-else

	}// end printNotMACIE
	
	
	
	//Created by Javier Castillo
	//Rexoxox@aol.com
	function doMessageForSelect(TheQuestion){
		if(!(reloadedPage)){
			//nothing
		}else{
			if(String(Parameters[("SELECT" + TheQuestion.getNum())]) == "undefined"){//If option left blank, dont write anything and exits
				//nothing
			}else if (String(Parameters[("SELECT" + TheQuestion.getNum())]) == ""){//If option left blank, dont write anything and exits
				//nothing
			}else{
				//Answered, now compare to see if its right
				//Check all Option until you get the answer
				for(oCount=0;oCount<TheQuestion.getOptions().length; oCount++){
					if(TheQuestion.getOptions()[oCount].getAns() == true){
						//Found the right answer, nwo compare to what they choose
						if (returnNiceString(String(Parameters[("SELECT" + TheQuestion.getNum())])) == TheQuestion.getOptions()[oCount].getTitle()){
							//They choose the right answer
							return String("<FONT COLOR=\"#037550\">" + TheQuestion.getMessagePos() + "</FONT>");
						}else{
							//They choose the wrong answer
							return String("<FONT COLOR=\"#FF0000\">" + TheQuestion.getMessageNeg() + "</FONT>");
						}// end if
					}// end if
				}// end for
			}// end if-else
		}// end if-else
		return String("");
	}// end function
	
	function doMessageForFillIn(TheQuestion){
		if(!(reloadedPage)){
			//nothing
		}else{
			//Repeat through each option.
			InpCount = 0;	//Number of InputBoxes
			AnsCount = 0;	//Number with stuff in them
			for(oCount=0;oCount<TheQuestion.getOptions().length; oCount++){
				//If Option FilledIn then continues to next and eventually spit out message.
				if(TheQuestion.getOptions()[oCount].getTitle() == ""){ 
					//Get Input Box
					if(String(Parameters[TheQuestion.getNum() + TheQuestion.getOptions()[oCount].getNum()]) == "undefined"){//If option left blank, dont write anything and exits
						InpCount++;
					}else if (String(Parameters[TheQuestion.getNum() + TheQuestion.getOptions()[oCount].getNum()]) == ""){//If option left blank, dont write anything and exits
						InpCount++;
					}else{
						AnsCount++;
						InpCount++;
					}// end if
				}// end if
			}// end for
			
			if (AnsCount == InpCount){
				//All Options must be filled.
				document.write("<FONT COLOR=\"#037550\">");
				document.write(TheQuestion.getMessagePos());
				document.write("</FONT>");
			}else if(AnsCount > 0 && AnsCount < InpCount){
				document.write("<FONT COLOR=\"#FF0000\">");
				document.write(TheQuestion.getMessageNeg());
				document.write("</FONT>");
			}else{
				//Didn't Answer any
			}// end if-else
			
		}// end if
	}// end doMessageForFillIn

	function doCheckMarksCheckBox(ParamName, TheOption) {
		if(!(reloadedPage) || String(Parameters[ParamName]) == "undefined"){
			document.write("<IMG SRC=\"../../images/spacer.gif\" BORDER=\"0\" WIDTH=\"20\" HEIGHT=\"20\"><BR>");
			return true;
		}else{
			if (TheOption.getAns() == true) {
				//The choice is the right one
				document.write("<IMG SRC=\"../images/main/check.gif\" BORDER=\"0\" WIDTH=\"21\" HEIGHT=\"20\" ALT=\"*\"><BR>");
				return true;
			}else{
				//The choice is wrong
				for(var q=0; q<Params.length; q++){
					//alert(Params[q].name);
					if(Params[q].name == ParamName && Params[q].value == TheOption.getNum()){
						//Was selected
						document.write("<IMG SRC=\"../images/main/x.gif\" BORDER=\"0\" WIDTH=\"21\" HEIGHT=\"21\" ALT=\"X\"><BR>");
						return false;
					}// end if
				}// end for
				document.write("<IMG SRC=\"../../images/spacer.gif\" BORDER=\"0\" WIDTH=\"20\" HEIGHT=\"20\"><BR>");
				return true;
			}//end if
		}//end if-else	
	}// end doCheckMarksRadio
	
	
	
	
	
	function doMessageForCheckBox(BoxName, TheQuestion) {
		//alert(BoxName);
		if(!(reloadedPage) || String(Parameters[BoxName]) == "undefined"){
			//nothing
		}else{
			//Fill array of answers
			ansArray = new Array();
			for(var pCount=0; pCount<Params.length; pCount++){
				if(Params[pCount].name == BoxName){
					ansArray[ansArray.length] = Params[pCount].value;
				}// end if
			}//end for
			
			opArray = new Array();
			for(var oCount=0; oCount<TheQuestion.getOptions().length; oCount++){
				TheOption = TheQuestion.getOptions()[oCount];
				if(TheOption.getAns()){
					opArray[opArray.length] = TheOption.getNum();
				}// end if
			}//end for
			
			ansArray.sort();
			opArray.sort();
			
			
			if(ansArray.length != opArray.length){
				document.write(TheQuestion.getMessageNeg());
			}else{
				for(var ai=0; ai<ansArray.length; ai++){
					if(ansArray[ai] != opArray[ai]){
						document.write(TheQuestion.getMessageNeg());
						return false;
					}// end if
				}// end for
				document.write(TheQuestion.getMessagePos());
				return true;
			}// end if
			
		}// end if-else	
	}// end doCheckMarksRadio
	
	
	
	
	
	
	
	function doCheckMarksRadio(ParamName, TheOption) {
		if(!(reloadedPage) || String(Parameters[ParamName]) == "undefined"){
			document.write("<IMG SRC=\"../../images/spacer.gif\" BORDER=\"0\" WIDTH=\"20\" HEIGHT=\"20\"><BR>");
		}else{
			if (TheOption.getAns() == true) {
				//The choice is the right one
				document.write("<IMG SRC=\"../images/main/check.gif\" BORDER=\"0\" WIDTH=\"21\" HEIGHT=\"20\" ALT=\"*\"><BR>");
			}else{
				//The choice is wrong
				if (String(Parameters[ParamName]) == TheOption.getNum()){
					document.write("<IMG SRC=\"../images/main/x.gif\" BORDER=\"0\" WIDTH=\"21\" HEIGHT=\"21\" ALT=\"X\"><BR>");
				}else{
					document.write("<IMG SRC=\"../../images/spacer.gif\" BORDER=\"0\" WIDTH=\"20\" HEIGHT=\"20\"><BR>");
				}//end if
			}//end if
		}//end if-else	
	}// end doCheckMarksRadio
	
	
	//Dave function modified
	//Created by: Javier Castillo
	//Rexoxox@aol.com
	function doCheckMarksRadioNoChecks(ParamName, TheOption) {
		if(!(reloadedPage) || String(Parameters[ParamName]) == "undefined"){
			document.write("<IMG SRC=\"../../images/spacer.gif\" BORDER=\"0\" WIDTH=\"20\" HEIGHT=\"20\"><BR>");
		}else{
			if (TheOption.getAns() == true) {
				//The choice is the right one
				if (String(Parameters[ParamName]) == TheOption.getNum()){//ANSWERED CORRECTLY
					document.write("<IMG SRC=\"../images/main/check.gif\" BORDER=\"0\" WIDTH=\"21\" HEIGHT=\"20\" ALT=\"*\"><BR>");
				}else{//ANSWERED WRONG
					document.write("<IMG SRC=\"../../images/spacer.gif\" BORDER=\"0\" WIDTH=\"20\" HEIGHT=\"20\"><BR>");
				}// end if-else
				
			}else{
				//The choice is wrong
				if (String(Parameters[ParamName]) == TheOption.getNum()){
					document.write("<IMG SRC=\"../images/main/x.gif\" BORDER=\"0\" WIDTH=\"21\" HEIGHT=\"21\" ALT=\"X\"><BR>");
				}else{
					document.write("<IMG SRC=\"../../images/spacer.gif\" BORDER=\"0\" WIDTH=\"20\" HEIGHT=\"20\"><BR>");
				}//end if
			}//end if
		}//end if-else	
	}// end doCheckMarksRadio
	
	function doMessageForRadio(RInput, TheQuestion){
		if(!(reloadedPage) || String(Parameters[("RADIO"+TheQuestion.getNum())]) == "undefined"){
			//nothing
		}else{
				for(rCount=0; rCount<RInput.length; rCount++){
					if(RInput[rCount].checked){
						//Find the answer and then compare
						for(oCount=0;oCount<TheQuestion.getOptions().length; oCount++){
							if(TheQuestion.getOptions()[oCount].getAns()){//IF this is the Answer then compare
								//Found Answer
								if(TheQuestion.getOptions()[oCount].getNum() == RInput[rCount].value){
									//Matches so: Answered Correctly
									document.write("<FONT COLOR=\"#037550\">");
									document.write(TheQuestion.getMessagePos());
									document.write("</FONT>");
								}else{
									//Doesn't Match so: Answered Wrong
									document.write("<FONT COLOR=\"#FF0000\">");
									document.write(TheQuestion.getMessageNeg());
									document.write("</FONT>");
								}// end if
								return true; // did compare, now exit the function	
							}// end if
						}// end for
						//No Answer has been defined....
						return false; // exit the function
					}// end if
				}// end for
		}//end if
	}// end doMessageForRadio
	
	//Comments: This is a contructor for the Question Object
	//Parameters: TheNum is the Number (or letter) to be displayed for this Question.
	//Parameters: TheType is used to store teh type of question this is (radio, fillIn, pullDown)
	//Parameters: TheTitle is the title of the question.
	//Parameters: TheOptions is an array of Options for this Question Object.
	function Question(TheNum, TheType, TheTitle, TheMessagePos, TheMessageNeg){
		//Properties
		this.Num = TheNum; //number or letter to be displayed before the question.
		this.TypeOf = TheType; //radio, fillIn, or pullDown
		this.Title = TheTitle; // The Question Title
		this.QOptions = new Array(); //array of Option objects
		this.MessagePos = TheMessagePos;
		this.MessageNeg = TheMessageNeg;
		//Methods
		this.addOptToQues = addOptToQues;
		this.getTitle = getTitle;
		this.getNum = getNum;
		this.getOptions = getOptions;
		this.getTypeOf = getTypeOf;
		this.getMessagePos = getMessagePos;
		this.getMessageNeg = getMessageNeg;
	}// end Question object
	
	function QOption(TheNum, TheTitle, TheAnswer, TheMessagePos, TheMessageNeg){																																																												//Created by: Javier Castillo//Rexoxox@aol.com
		//Properties
		this.Num = TheNum; //The Option Number
		this.Title = TheTitle; // The Option text
		this.IsAns = TheAnswer; // true, false (for type: radio) or string for type: pullDown
		//this.TypeOf = TheType; //void, Text or Inputbox (used for FillIn questions)
		this.MessagePos = TheMessagePos;
		this.MessageNeg = TheMessageNeg;
		//Methods
		this.getTitle = getTitle;
		this.getNum = getNum;
		this.getAns = getAns;
		this.getMessagePos = getMessagePos;
		this.getMessageNeg = getMessageNeg;
		//this.getTypeOf = getTypeOf;
	}// end Option object
	
	//Created by - Javier Castillo
	//Rexoxox@aol.com
	
	//Used for Both Question and Option
	function getTitle(){
		return this.Title;
	}
	function getNum(){
		return this.Num;
	}
	function getTypeOf(){
		return this.TypeOf;
	}
	function getMessagePos(){
		return this.MessagePos;
	}
	function getMessageNeg(){
		return this.MessageNeg;
	}
	
	//Used for only Question
	function getOptions(){
		return this.QOptions;
	}
	function addOptToQues(TheOption){
		this.QOptions[this.QOptions.length] = TheOption;
	}// end addOptToQues
	
	
	//Used for only Option
	function getAns(){
		return this.IsAns;
	}

	function writeCheckBox(TheQuestion, TheOptionObj){
			if (String(Parameters[("CHECKBOX"+TheQuestion.getNum())]) == "undefined"){
				document.write("<INPUT TYPE=\"CHECKBOX\" NAME=\"CHECKBOX" + TheQuestion.getNum() + "\" VALUE=" + TheOptionObj.getNum() +"> "+TheOptionObj.getNum()+".<BR>");
				return true;
			}else{
				//alert("length = " + sNameValuePairs.length);
				for(var q=1; q<Params.length; q++){
					if(Params[q].name == String("CHECKBOX"+TheQuestion.getNum()) && Params[q].value == TheOptionObj.getNum()){
						//alert("boo option = " + TheOptionObj.getNum());
						document.write("<INPUT TYPE=\"CHECKBOX\" NAME=\"CHECKBOX" + TheQuestion.getNum() + "\" VALUE=" + TheOptionObj.getNum() +" CHECKED> "+TheOptionObj.getNum()+".<BR>");		
						return true;
					}// end if
				}// end for
				document.write("<INPUT TYPE=\"CHECKBOX\" NAME=\"CHECKBOX" + TheQuestion.getNum() + "\" VALUE=" + TheOptionObj.getNum() +"> "+TheOptionObj.getNum()+".<BR>");
				return true;
			}// end if
			//Answer did not match
	}// end writeCheckBox
	
	//The naming convetion for Radio buttons is: 
	//Question Number
	//Example name: RADIO1, RADIO2...
	function writeRadioBox(TheQuestion, TheOptionObj){
			if (String(Parameters[("RADIO"+TheQuestion.getNum())]) == "undefined"){
				document.write("<INPUT TYPE=\"RADIO\" NAME=\"RADIO" + TheQuestion.getNum() + "\" VALUE=" + TheOptionObj.getNum() +"> "+TheOptionObj.getNum()+".<BR>");
			}else if(String(Parameters[("RADIO"+TheQuestion.getNum())]) == TheOptionObj.getNum()){
				document.write("<INPUT TYPE=\"RADIO\" NAME=\"RADIO" + TheQuestion.getNum() + "\" VALUE=" + TheOptionObj.getNum() +" CHECKED> "+TheOptionObj.getNum()+".<BR>");
			}else{		
				document.write("<INPUT TYPE=\"RADIO\" NAME=\"RADIO" + TheQuestion.getNum() + "\" VALUE=" + TheOptionObj.getNum() +"> "+TheOptionObj.getNum()+".<BR>");
			}// end if
	}// end writeRadioBox
	
	//The naming convetion for Select boxes is: 
	//Question Number + Option Number or Name
	//Example name: 2a, 2b, 2c, 2d 
	function writeSelectBox(TheQuestion){
		//Write Select Box
		theSString = "<select name=\"SELECT" + TheQuestion.getNum() + "\">";
		//alert(theSString); //For Debugging
		document.write(theSString);
		document.write("<option value=\"\"></option>");
		
		//Loop through each option	
		for(var i=0; i<TheQuestion.getOptions().length; i++){
			//alert(String(Parameters[(TheQuestion.getNum() + TheOptionObj.getNum())]));
			if(String(Parameters[("SELECT" + TheQuestion.getNum())]) == "undefined"){//If option left blank, dont write anything and exits
				theOptionString = "<option value=\"" + TheQuestion.getOptions()[i].getTitle() + "\">" + TheQuestion.getOptions()[i].getTitle() + "</option>";
			}else if (returnNiceString(String(Parameters[("SELECT" + TheQuestion.getNum())])) == TheQuestion.getOptions()[i].getTitle()){
				theOptionString = "<option value=\"" + TheQuestion.getOptions()[i].getTitle() + "\" selected>" + TheQuestion.getOptions()[i].getTitle() + "</option>";
			}else{
				theOptionString = "<option value=\"" + TheQuestion.getOptions()[i].getTitle() + "\">" + TheQuestion.getOptions()[i].getTitle() + "</option>";
			}//end if
			document.write(theOptionString);
		}// end for
												
		document.write("</select>");
	}// end writeSelectBox
	

	//The naming convetion for Input boxes is: 																																									
	//Question Number + Option Number or Name
	//Example name: 3fillIn1, 3fillIn2 
	function writeInputBox(TheQuestion, TheOptionObj){
		if (TheOptionObj.getTitle() == ""){
			//Input box
			if (String(Parameters[(TheQuestion.getNum()+TheOptionObj.getNum())]) == "undefined"){
					theIBoxString = "<input type=\"text\" name=\"" + TheQuestion.getNum() + TheOptionObj.getNum() + "\"> ";
					//alert((TheQuestion.getNum()+TheOptionObj.getNum()));
			}else if (String(Parameters[(TheQuestion.getNum()+TheOptionObj.getNum())]) == ""){
					theIBoxString = "<input type=\"text\" name=\"" + TheQuestion.getNum() + TheOptionObj.getNum() + "\"> ";
			}else{
					var theString = returnNiceString(String(Parameters[(TheQuestion.getNum()+TheOptionObj.getNum())]));
					theIBoxString = "<input type=\"text\" name=\"" + TheQuestion.getNum() + TheOptionObj.getNum() + "\" VALUE=\"" + theString + "\"> ";																									//Created by: Javier Castillo //Rexoxox@aol.com
			}// end if-else
			//alert(theIBoxString); //For Debugging
			document.write(theIBoxString);	
		}else{
			//Text
			document.write(TheOptionObj.getTitle());
		}// end if-else
	}// end writeInputBox
	
	function writeInputBoxFixedSize(TheQuestion, TheOptionObj, theSize){
		if (TheOptionObj.getTitle() == ""){
			//Input box
			if (String(Parameters[(TheQuestion.getNum()+TheOptionObj.getNum())]) == "undefined"){
					theIBoxString = "<input size= \"" + theSize + "\" type=\"text\" name=\"" + TheQuestion.getNum() + TheOptionObj.getNum() + "\"> ";
					//alert((TheQuestion.getNum()+TheOptionObj.getNum()));
			}else if (String(Parameters[(TheQuestion.getNum()+TheOptionObj.getNum())]) == ""){
					theIBoxString = "<input size= \"" + theSize + "\" type=\"text\" name=\"" + TheQuestion.getNum() + TheOptionObj.getNum() + "\"> ";
			}else{
					var theString = returnNiceString(String(Parameters[(TheQuestion.getNum()+TheOptionObj.getNum())]));
					theIBoxString = "<input size= \"" + theSize + "\" type=\"text\" name=\"" + TheQuestion.getNum() + TheOptionObj.getNum() + "\" VALUE=\"" + theString + "\"> ";																									//Created by: Javier Castillo //Rexoxox@aol.com
			}// end if-else
			//alert(theIBoxString); //For Debugging
			document.write(theIBoxString);	
		}else{
			//Text
			document.write(TheOptionObj.getTitle());
		}// end if-else
	}// end writeInputBox

	function writeTextAreaFixedSize(TheQuestion, TheOptionObj, theSizeCol, theSizeRow){
		if (TheOptionObj.getTitle() == ""){
			//Input box
			if (String(Parameters[(TheQuestion.getNum()+TheOptionObj.getNum())]) == "undefined"){
					theIBoxString = "<textarea cols= \"" + theSizeCol + "\" rows= \"" + theSizeRow + "\" type=\"text\" name=\"" + TheQuestion.getNum() + TheOptionObj.getNum() + "\"></textarea>";
					//alert((TheQuestion.getNum()+TheOptionObj.getNum()));
			}else if (String(Parameters[(TheQuestion.getNum()+TheOptionObj.getNum())]) == ""){
					theIBoxString = "<textarea cols= \"" + theSizeCol + "\" rows= \"" + theSizeRow + "\" type=\"text\" name=\"" + TheQuestion.getNum() + TheOptionObj.getNum() + "\"></textarea>";
			}else{
					var theString = returnNiceString(String(Parameters[(TheQuestion.getNum()+TheOptionObj.getNum())]));
					theIBoxString = "<textarea cols= \"" + theSizeCol + "\" rows= \"" + theSizeRow + "\" type=\"text\" name=\"" + TheQuestion.getNum() + TheOptionObj.getNum() + "\">" + theString + "</textarea>";																									//Created by: Javier Castillo //Rexoxox@aol.com
			}// end if-else
			//alert(theIBoxString); //For Debugging
			document.write(theIBoxString);	
		}else{
			//Text
			document.write(TheOptionObj.getTitle());
		}// end if-else
	}// end writeInputBox
	
	function returnNiceString(daString){
		stringArray = daString.split("+");
		daString = stringArray.join(" ");
		stringArray = daString.split("%28");
		daString = stringArray.join("(");
		stringArray = daString.split("%29");
		daString = stringArray.join(")");
		return daString;
	}// end returnNiceString
	//Created by Javier Castillo
	//Rexoxox@aol.com
