/// This object is used to create form elements
function createFormObject(myform){

	///use level 1 to create form for cross browser support

	this.createTextBox=function(myName,myId,mysize,myDescription){
		newArea=document.createElement('span');
		
		myform.appendChild(newArea).innerHTML=myDescription+"<input type=\"text\" name=\""+myName+
			"\" id=\""+myId+"\" size=\""+mysize+"\" />";

	}

	//// Create a text box that allows control using an event
	this.createTextBoxEvent=function(myName,myId,mysize,myDescription,myAction){
		newArea=document.createElement('span');
		
		myform.appendChild(newArea).innerHTML=myDescription+"<input type=\"text\" name=\""+myName+
			"\" id=\""+myId+"\" size=\""+mysize+"\""+myAction+" />";

	}

	
	this.createCheckbox=function(myText){
		newArea=document.createElement('span');

		myform.appendChild(newArea).innerHTML="<input type=\"checkbox\" name=\"myCheckbox\" id=\"myCheckbox\" />"+
			myText+"<br />";
	}

	this.createTextArea=function(myId,myName,width,height){
		newArea=document.createElement('span');

		myform.appendChild(newArea).innerHTML=myName+"<br /><textarea id=\""+myId+"\" name=\""+myId+"\" cols=\""+width+"\" rows=\""+height+"\" wrap=\"wrap\">"+
		"</textarea><br />";

	}

	// This method creates a selection list. The myId argument sets the name of the 
	// selection list. The myName argument is the innerHTML text to describe the
	// function of the list to the end user.The mChange argument indicates that the
	// mAction javascript function should be called. The object is to create 
	// a selection list that detects a change and performs a method.

	this.createSelectList=function(myId,myName,myList,mChange,mAction){
		newArea=document.createElement('span');

		newObject=myform.appendChild(newArea)
		

		//IE does not fully support setAttribute. It does not support
		// adding a style nor does it allow adding an event as an
		// attribute. The code below creates a selection list with
		// an onChange event. The else statement uses the later
		// approach to creating the selection list.

		var bname = navigator.appName;
		if (bname == "Microsoft Internet Explorer"){

			/// Add the options

			//create option list level 0
			var myoptlist="";

			for(opt=0;opt<myList.length;opt++){
				myoptlist=myoptlist+"<option name=\""+myList[opt]+"\" value=\""+
					myList[opt]+"\">"+myList[opt]+"</option>";
			}
	
			newObject.innerHTML=myName+"<select name=\""+myId+"\" onChange=\""+mAction+"\">"+
				myoptlist+"</select>";


   		
			
		} else {
			newObject.innerHTML=" "+myName;	
		       	var selectionList = document.createElement("select");
               		selectionList.setAttribute("name",myId);
			if(mChange !='null'){

				selectionList.setAttribute("onChange",mAction)
			}

			this.createOptions(selectionList,myList);
                        
                	newObject.appendChild(selectionList);
		}	



	}

	this.createSubSelectList=function(myId,myName,myList){
		newArea=document.createElement('span');

		newObject=myform.appendChild(newArea)
		newObject.innerHTML=" "+myName;	

                var selectionList = document.createElement("select");
                selectionList.setAttribute("name",myId);
		

		/***
		if(mChange !='null'){
			selectionList.setAttribute("onChange",mAction)
		}
		***/
                this.createSubOptions(selectionList,myList);
                        
                newObject.appendChild(selectionList);

	}

	this.createRadioButton=function(myId,myName){
		newArea=document.createElement('span');
		myform.appendChild(newArea).innerHTML="<br /><input type=\"radio\" name=\""+myId+
			"\" id=\""+myId+"\" value=\""+myName+"\" />"+myName;
			

	}

	/// Create a radio button the causes an action when checked
	this.createRadioButtonAction=function(myId,myName,myAction){
		newArea=document.createElement('span');
		myform.appendChild(newArea).innerHTML="<br /><input type=\"radio\" name=\""+myId+
			"\" id=\""+myId+"\" value=\""+myName+"\" "+
			"onclick=\"javascript: "+myAction+"\"/>"+myName;
			

	}

/////////////// Modify this method to support level 1-must assign attribute
	this.createOptions=function(sel,_options){
 		//_options is an array of strings that represent the values of
    		//a select list, as in each option of the list.
    		//sel is the select object
    		if(_options == null || _options.length==0) { return;}
    			var opt = null;
    		for(i = 0; i < _options.length; i++) {

			
        		opt =document.createElement("option");
			opt.setAttribute("value",_options[i]);
			
       			opt.appendChild(document.createTextNode(_options[i]));
        		sel.appendChild(opt);
    		}
		

	}

	this.createSubOptions=function(sel,_options){
 		//_options is an array of strings that represent the values of
    		//a select list, as in each option of the list.
    		//sel is the select object
    		if(_options == null || _options.length==0) { return;}
    			var opt = null;
		

		
    		for(i = 0; i < _options.length; i++) {
			myNum=_options[i].split(/\s/);
			myName="";
			if(myNum.length=='3'){
				myName=myNum[1]+" "+myNum[2];
			} else {
				if(myNum.length>'3'){
					myName=myNum[1]+" "+myNum[2]+" "+myNum[3];
				}
			}
        		opt =document.createElement("option");
			opt.setAttribute("value",myNum[0]);
			if(myName==""){
				opt.appendChild(document.createTextNode(myNum[0]));
			} else {
       				opt.appendChild(document.createTextNode(myName));
			}
        		sel.appendChild(opt);
    		}
		

	}

}