
var sprytextfield1=new Spry.Widget.ValidationTextField("sprytextfield1","email");
var sprytextfield2=new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield3=new Spry.Widget.ValidationTextField("sprytextfield3","none");
var sprytextfield4=new Spry.Widget.ValidationTextField("sprytextfield4","none",{isRequired:false})
var sprytextfield5=new Spry.Widget.ValidationTextField("sprytextfield5");
var sprytextfield6=new Spry.Widget.ValidationTextField("sprytextfield6");
var sprytextfield7=new Spry.Widget.ValidationTextField("sprytextfield7");
function numBtZero(evt){var charCode = (evt.which) ? evt.which : event.keyCode;if (charCode > 31 && (charCode < 48 || charCode > 57)){return false;}return true;}
function calcEcc(){
	var noOfRows = document.getElementsByName('count[]').length;
	var sum=0;
		for(i=1;i<=noOfRows;i++){
		sum+=document.getElementById('noofitems'+i+'').value*document.getElementById('watts'+i+'').value;
		}
	if(sum==0){sum='';}
	document.getElementById('total').value=sum;
}
function systType(obj){
	document.getElementById('selsystem').value=obj.value;
}
function updateDOMForFields(id) {
  elem=document.getElementById(id);
  i=elem.getElementsByTagName('input');
  s=elem.getElementsByTagName('select');
  t=elem.getElementsByTagName('textarea');
  field_sets=Array(i,s,t);
  for(x=0;x<field_sets.length;x++){
    set=field_sets[x];
    for(y=0;y<set.length;y++){    	
      updateDOM(field_sets[x][y]);
    }
  }
}
function updateDOM(inputField) {
    // if the inputField ID string has been passed in, get the inputField object
    if (typeof inputField == "string") {
        inputField = document.getElementById(inputField);
    }
    
    if (inputField.type == "select-one") {
        for (var i=0; i<inputField.options.length; i++) {
            if (i == inputField.selectedIndex) {    
                inputField.options[inputField.selectedIndex].setAttribute("selected","selected");
            }
        }
    } else if (inputField.type == "select-multiple") {
        for (var i=0; i<inputField.options.length; i++) {
            if (inputField.options[i].selected) {
                inputField.options[i].setAttribute("selected","selected");
            } else {
                inputField.options[i].removeAttribute("selected");
            }
        }
    } else if (inputField.type == "text") {
        inputField.setAttribute("value",inputField.value);
    } else if (inputField.type == "textarea") {
        inputField.setAttribute("value",inputField.value);
        inputField.innerHTML = inputField.value;
    } else if (inputField.type == "checkbox") {
        if (inputField.checked) {
            inputField.setAttribute("checked","checked");
        } else {
            inputField.removeAttribute("checked");
        }
    } else if (inputField.type == "radio") {
        var radioNames = document.getElementsByName(inputField.name);
        for(var i=0; i < radioNames.length; i++) {
            if (radioNames[i].checked) {
                radioNames[i].setAttribute("checked","checked");
            } else {
                radioNames[i].removeAttribute("checked");
            }
        }
    }
}
function getdivHTML(objId,inputId){	
	document.getElementById(inputId).value='';
	var html='';
	var domArray = document.getElementById(objId);
 document.getElementById(inputId).value=domArray.innerHTML;
}
