var postStr="";

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 load_div = '';
var http;

function loadDiv (div_id, url) {
  http = getHTTPObject(); // We create the HTTP Object
  http.open("GET", url, false);
  load_div = div_id;
  http.onreadystatechange = http2Div;
  http.send(null);
  document.getElementById(load_div).innerHTML = http.responseText;
}

function postDiv (div_id, url, formname, async) {
  http = getHTTPObject(); // We create the HTTP Object
  postStr="";
  sendVal = "&"+getStr(document.getElementById(formname))
//  alert(sendVal);
//  alert(div_id+"-"+url+"-"+formname+"-"+async);
  http.onreadystatechange = http2Div;
  if (!async) {
    http.open("POST", url, true);
  } else {
    http.open("POST", url, false);
  }
  load_div = div_id;
//  document.write(sendVal);
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", postStr.length);
  http.setRequestHeader("Connection", "close");
  http.send(sendVal);
//  alert(2)
}

function http2Div () {
//  alert(http.readyState);
  if (http.readyState == 1) {
//    dispProc(1);
//    alert (http.readyState);
  }
  if (http.readyState == 4) {
    results = http.responseText;
    document.getElementById(load_div).innerHTML = results;
//    setTimeout ("dispProc(0)", 10);
//    alert (http.readyState);
  }
}

function dispProc(sh) {
//  alert ("xxxx_"+sh);
  if (document.getElementById('prcimg')){
    if (sh != 1) {
      document.getElementById('prcimg').style.display="none";
    } else {
      document.getElementById('prcimg').style.display="block";
    }
  }
}

function getStr(obj) {
  for (var i=0; i<obj.childNodes.length; i++) {
    if (obj.childNodes[i].tagName == "INPUT") {
      if (obj.childNodes[i].type == "text") {
        postStr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
      }
      if (obj.childNodes[i].type == "password") {
        postStr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
      }
      if (obj.childNodes[i].type == "hidden") {
        postStr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
      }
      if (obj.childNodes[i].type == "checkbox") {
        if (obj.childNodes[i].checked) {
          postStr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
        } else {
          postStr += obj.childNodes[i].name + "=&";
        }
      }
      if (obj.childNodes[i].type == "radio") {
        if (obj.childNodes[i].checked) {
          postStr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
        }
      }
    }
    if (obj.childNodes[i].tagName == "SELECT") {
      var sel = obj.childNodes[i];
      postStr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
    }
    if (obj.childNodes[i].tagName == "TEXTAREA") {
      myString = obj.childNodes[i].value.replace(/\r\n/g, "<br>")
      postStr += obj.childNodes[i].name + "=" + myString + "&";
    }
    if(obj.childNodes[i].hasChildNodes()) {
      getStr(obj.childNodes[i])
    }
  }
  return postStr;
}


