/**
 * @author jsnyder
 */
function addHR() {
  var theForm = document.getElementById('pageForm');
  var newdiv = document.createElement('hr');
  newdiv.setAttribute('size','1');
  theForm.appendChild(newdiv);
}
function addTextBox(obj) {
	var theForm = document.getElementById('pageForm');
	var newdiv = document.createElement('div');
	newdiv.setAttribute('class', "inputElementDiv")
	var divIdName = getNextGlobalNumber();
  
	var newinput = '';
	newinput += '<label>'+obj.name+' </label>';
	newinput += '<input type="text" id="Physician" style="margin: 0px; width: 300px;" value="'+obj.value+'" autocomplete="off" />';
	
	newdiv.innerHTML = newinput;
	theForm.appendChild(newdiv);
}
function addButton(obj) {
	var theForm = document.getElementById('pageForm');
	var newdiv = document.createElement('div');
	newdiv.setAttribute('class', "inputElementDiv")
	var divIdName = getNextGlobalNumber();
  
	var newinput = '';
	newinput += '<input type="button" id="'+divIdName+'" value="'+obj.value+'" />';
   	
   	newdiv.innerHTML = newinput;
	theForm.appendChild(newdiv);
}
function addRadio(obj) {
	var theForm = document.getElementById('pageForm');
	var newdiv = document.createElement('div');
	newdiv.setAttribute('class', "inputElementDiv")
	var divIdName = getNextGlobalNumber();
	
	var newinput = "";
	var options = obj.options;
	var optLength = options.length;
	for (j=0;j<optLength;j++) {
		if (obj.options[j] == obj.value){
			newinput += '<input type="radio" name="'+divIdName+'" value="'+obj.options[j]+'" checked="checked"><label>'+obj.options[j]+'</label>';
		} else {
			newinput += '<input type="radio" name="'+divIdName+'" value="'+obj.options[j]+'"><label>'+obj.options[j]+'</label>';
		}
	}	
	newdiv.innerHTML=newinput;
	theForm.appendChild(newdiv);
}
function addCheckBox(obj) {
	var theForm = document.getElementById('pageForm');
	var newdiv = document.createElement('div');
	newdiv.setAttribute('class', "inputElementDiv");
	var divIdName = getNextGlobalNumber();
  
	var newinput = "";
	newinput += '<input type="checkbox" id="'+divIdName+'" />';
	newinput += '<label>'+obj.name+'</label>';
  
	newdiv.innerHTML = newinput;
	theForm.appendChild(newdiv);
	document.getElementById(divIdName).checked = obj.value;
}
function addToggle(obj) {
	var theForm = document.getElementById('pageForm');
	var newdiv = document.createElement('div');
	newdiv.setAttribute('class', "inputElementDiv");
	var divIdName = getNextGlobalNumber();
  
	var newinput = "";
	
	if (obj.size == "3") {
		for(j=1;j<=3;j++) {
			if (j==1) {
				optionsval = obj.option1;
			} else {
				if (j==2) {
					optionsval = obj.option2;
				} else {
					optionsval = obj.option3;
				}
			}
			if (optionsval == obj.value){
				newinput += '<input type="radio" name="'+divIdName+'" value="'+optionsval+'" checked="checked"><label>'+optionsval+'</label>';
			} else {
				newinput += '<input type="radio" name="'+divIdName+'" value="'+optionsval+'"><label>'+optionsval+'</label>';
			}
		}
	} else {
		for(j=1;j<=2;j++) {
			if (j==1) {
				optionsval = obj.option1;
			} else {
				if (j==2) {
					optionsval = obj.option2;
				} else {
					optionsval = obj.option3;
				}
			}
			if (optionsval == obj.value){
				newinput += '<input type="radio" name="'+divIdName+'" value="'+optionsval+'" checked="checked"><label>'+optionsval+'</label>';
			} else {
				newinput += '<input type="radio" name="'+divIdName+'" value="'+optionsval+'"><label>'+optionsval+'</label>';
			}
		}		
	}
	newdiv.innerHTML = newinput;
	theForm.appendChild(newdiv);
}
