function MyElement(){
	this.id='';
	this.name='';
}



function formElement(){
	this.id='';
	this.name='';
	this.type='';
	this.value='';
	this.onclick='';
		this.onchange='';
 }

formElement.prototype=new MyElement;


 function formField(){
//	this.id='';
//	this.name='';
//	this.type='';
	
 }
 formField.prototype=new formElement;
 
function ButtonCtl() {
	
//	alert('ButtonCtl')
this.onClick='';
//alert('ButtonCtl')
this.types=new Array('button', 'submit');
//alert('ButtonCtl')
this.type=this.types[0];
//alert('ButtonCtl')
}
 
 
 ButtonCtl.prototype=new MyElement;


ButtonCtl.prototype.getHtml = function () {

//alert('btn htm')
return "<input type='"
+this.type+"' value='"+this.value+"' name='B3' onclick='"
+this.onClick
+"' id='"
+this.id
+"'>";
}


 
 
 
function txtFld() {

//this.value='';
this.types=new Array('text','hidden');
//this.typeNum=0;
this.type=this.types[0];

this.size=20;

//this.id=id;


 }
 
 txtFld.prototype=new formField;
 
 txtFld.prototype.getHTML = function () {
 
 var html="<input type='"
  +this.type
  +"' id='"+this.id
  +"' name='"+this.name
  +"' value='"+ this.value  
  +"' onchange='"+this.onchange
   +"' onclick='"+this.onclick
+  "' size='"+this.size+"'>";
 
// alert(html)
  return html;
};

txtFld.prototype.setAsHidden = function () {
 
this.type=this.types[1];
};





function selectBoxOption(value, text) {
this.value=value;
this.text=text;
this.selected=false;
}
 
selectBoxOption.prototype.select = function () {
this.selected=true;
}

selectBoxOption.prototype.getSelectedText = function () {
 if (this.selected==true) {
 	return 'selected'}
 	 else {return '';}
}











function selectBox() {

//this.value='';
//alert ('val='+value)

this.options=new Array();
 }
 
selectBox.prototype=new formField;

//selectBox.prototype.checkForSelected = function (option) {
// if (option.selected==true) {
// 	return 'selected'}
// 	 else {return '';}
//}







selectBox.prototype.selectOptByVal = function (val) {
for(var index=0; index<this.options.length; index++) {

if (this.options[index].value==val){
	this.options[index].select()
}

	
}


};









selectBox.prototype.getHTML = function () {
 
// alert(this.name)
var startTag="<select id='"
+this.id
+"' size='1' name='"
+this.name
+"' onchange='"
+this.onchange
+"'>";
var endTag="</select>";

var optionsTxt='';
for(var index=0; index<this.options.length; index++) {
	optionsTxt=optionsTxt+"<option value='"+
	this.options[index].value+
	"' "+
	(this.options[index].getSelectedText())
	
	+" >"+this.options[index].text+"</option>";
}

var slctHtml=startTag+optionsTxt +endTag;

//alert (slctHtml)
  return slctHtml
								

};


















 
function selectBox_gender() {

this.selectBox= new selectBox();
this.selectBox.name='gender';
this.name='';
this.id='';
this.onchange='';
//alert('sb md')
var opt=new selectBoxOption('M', 'Male')
//opt.select()
//alert('sb md')
this.selectBox.options[0]=opt
//alert('sb md')
var opt=new selectBoxOption('F', 'Female')
//alert('sb md')
this.selectBox.options[1]=opt

}
 
 
selectBox_gender.prototype.selectMale = function () {
//	alert('selectBox_gender> sel mal')
this.selectBox.options[0].select();
}
 

selectBox_gender.prototype.selectFemale = function () {
this.selectBox.options[1].select();
}



selectBox_gender.prototype.getHtml = function () {
this.selectBox.name=this.name;
this.selectBox.id=this.id;
this.selectBox.onchange=this.onchange;

return this.selectBox.getHTML()
}
