function handleMotorCapacityID() {
  if (http.readyState == 4) {
	var objLen = document.MotorSrhFrm.MotorCapacityID.length;
	for (index=1;index<objLen;index++){
	  document.MotorSrhFrm.MotorCapacityID[1] = null;
	}
    if (http.responseText.indexOf('invalid') == -1) {
      results = http.responseText;
	  if (results != 0){
		var MotorCapacityIDArray = results.split(",");
		for (index=0;index<(MotorCapacityIDArray.length-1)/2;index++){
			var MotorCapacityIDOption = document.createElement("OPTION");
			MotorCapacityIDOption.value = MotorCapacityIDArray[index];
			MotorCapacityIDOption.text = MotorCapacityIDArray[index+(MotorCapacityIDArray.length-1)/2];
			document.MotorSrhFrm.MotorCapacityID.add(MotorCapacityIDOption);
		}
		var objLen_after = document.MotorSrhFrm.MotorCapacityID.length;
		for (index=0;index<objLen_after-1;index++){
			if(MotorSrhFrm.hdnMotorCapacityID.value == MotorCapacityIDArray[index]) document.MotorSrhFrm.MotorCapacityID[index+1].selected = true;
		}
	  }
      isWorking = false;
    }
  }
}

var isWorking = false;

function updateMotorCapacityID() {
  if (!isWorking && http) {
    var MotorTypeID = document.MotorSrhFrm.MotorTypeID.value;
    http.open("POST", 'ajax/rtnMotorCapacityID.asp?MotorTypeID=' + escape(MotorTypeID), true);
    http.onreadystatechange = handleMotorCapacityID;
    isWorking = true;
    http.send(null);
  }
}

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject();
