/**
 * AjaxTools
 * 简单Ajax工具js文件
 * sorc
 */
//0提交url，1提交方式，2数据显示位置，3form名，4表单名，5提示位置，6提示内容，7请求参数
var p = new Array("","POST","","","","","<font color=\"#00FF00\">数据加载中...</font>","","false","<font color=\"#00FF00\">数据加载完毕！</font>");
function ajax(){
    var l = arguments.length;
    if(l>10){
        l=10;
    }
    for (var i = 0; i < l; i++)
    {
        var t = arguments[i];
        p[i] = t;
        if(i==5&&!c(t)){
            p[i] = p[2];
        }
    }
    sr();
}
function lc(s){
  return s.toLowerCase();
}
function uc(s){
  return s.toUpperCase();
}
function c(o){
  if(!o){
  return false;
  }else if(o.length==0){
      return false;
  }
    return true;
}
function gio(i){
    return document.getElementById(i);
}
function gr() {
  if (window.XMLHttpRequest) {
      return new XMLHttpRequest();
  }else if (window.ActiveXObject) {
      try {
          return new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e1) {
          try {
              return new ActiveXObject("Microsoft.XMLHTTP");
          } catch (e2) {
          }
      }
  }
}
function sr() {
    if(c(p[3])){
        alert(p[3]);
        var t = p[3].split(",");
        for(var i=0;i<t.length;i++)
        addf(t[i]);
    }
    if(c(p[4])){
        var t = p[4].split(",");
        for(var i=0;i<t.length;i++)
        add(t[i]);
    }
    if(!c(p[7])){
        p[7] = "sorc=sorc";
    }
    var u = p[0];
    if(uc(p[1])=="GET"){
        if(u.indexOf("?")<0){
        u += ("?"+p[7]);}
        p[7] = null;
    }
    var x;
    x = gr();
    x.onreadystatechange = function (){pr(x);};
    x.open(uc(p[1]), u, true);
    if(lc(p[8])=="true"){
        x.setrequestheader("cache-control","no-cache");
    }
  //  x.setrequestheader("Content-Type","application/x-www-form-urlencoded");
    x.send(p[7]);
}
function pr(x) {
  if (x.readyState == 4) {
    if (x.status == 200) {
        gio(p[2]).innerHTML = x.responseText;
//        if(p[2]!=p[5]){
//          gio(p[5]).innerHTML = p[9];
//        }
    } else {
        gio(p[5]).innerHTML = '<font color="#FF5151">您所请求的页面有异常!</font>';
    }
  }
  else{
      gio(p[5]).innerHTML = p[6];
  }
}
function addf(f){
    var e = gio(f).elements;
    var s = toQS(e);
    if(p[7]==""){
        p[7] = s;
    }else{
        p[7] = p[7] + "&" + s;
    }
}
function add(n){
    var e = null;
    e=gio(n)
    var s = n+"="+e.value;
    if(p[7]==""){
        p[7] = s;
    }else{
        p[7] = p[7] + "&" + s;
    }
}
function toQS(e){
    var d = null;
    var q = "";
    var n = "";
    var t = "";
    for(var i=0;i<e.length;i++){
        t = "";
        d = e[i];
        n = d.getAttribute("name");
        if(lc(d.tagName)=="input"){
            if(lc(d.type)=="radio"||lc(d.type)=="checkbox"){
                if(d.checked){
                    t = n + "=" + d.value;
                }
            }
            else if(lc(d.type)=="text"||lc(d.type)=="hidden"){
                t = n + "=" + decodeURIComponent(d.value);
            }
        }
        else if(lc(d.tagName)=="select"){
            t = getSO(d);
        }
        if(t != ""){
            if(q==""){
                q = t;
            }else{
                q = q + "&" + t;
            }
        }
    }
    return q;
}
function getSO(s){
    var o = s.sptions;
    var e = null;
    var q = "";
    var t = "";
    for(var i=0;x<o.length;i++){
        t = "";
        e = o[i];
        if(e.selected){
            t = s.name + "=" + e.value;
        }
        if(t != ""){
            if(q==""){
                q = t;
            }else{
                q = q + "&" + t;
            }
        }
    }
    return q;
}

function setdisplay(id,display,border,i){
    setfilter(id,i);
    gio(id).style.borderBottom=border;
    gio(id).style.borderRight=border;
    gio(id).style.borderTop=border;
    gio(id).style.borderLeft=border;
    gio(id).style.display=display;
}
function setstyle(id,font,border){
    gio(id).style.fontWeight=font;
    gio(id).style.borderRight=border;
    gio(id).style.borderLeft=border;
    gio(id).style.borderTop=border;
}
function setmouse(id,mouse){
    gio(id).style.cursor=mouse;
}
function setfilter(id,i){
    gio(id).style.position="absolute";
    gio(id).style.width="500";
    if(i=="2"){
    gio(id).style.visibility="visible";
    }
    else{
    gio(id).style.visibility="hidden";
    }
    gio(id).style.zIndex=i;
    gio(id).style.filter="Alpha(opacity=0)";
    gio(id).style.opacity="0.0";
}

function setalpha(id){
  opa=Number(gio(id).style.opacity);
  opa=opa+(5/100);
  gio(id).style.visibility="visible";
  gio(id).style.filter="Alpha(opacity="+opa*100+")";
  gio(id).style.opacity=opa;
  if(opa<=90/100){
    setTimeout("setalpha('"+id+"')",100);
  }
}
