﻿var Server={
    http:function(){
	    try	{
		    if(window.XMLHttpRequest)return new XMLHttpRequest();
		    if (window.ActiveXObject){
			    try{return new ActiveXObject("MSXML2.XMLHTTP")}
			    catch(e){ 
				    try{return new ActiveXObject("Microsoft.XMLHTTP")}
				    catch(e){location="http.html";}
			    }
		    }
	    }catch(e){location="http.html";}
    },
	load:function(url){
		var h=this.http();
		h.open("GET",url,false);
		h.send(null);
		return h.responseText;
	},
    queue:[],
    call:function(a,p,c){
		//try{
			if(!a)return;
			if(c&&typeof(c)=="object")c.busy=true;
			if(this.busy){return this.queue.push({a:a,p:p,c:c})}
			this.busy=true;
			var s=p==null?"":(typeof(p)=="object"?F.toXml(p):p),i=a.lastIndexOf('.'),h=this.http(),d;
			if(i>-1){d=a.substring(0,i);a=a.substring(i+1);} else d=F.urlhead();
			if(c)h.onreadystatechange=function(){if(h.readyState<4)return;Server.analyse(h,a,c);};
			h.open("POST",d+".ashx",c?true:false);
			h.setRequestHeader("SOAPAction", a);
			h.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
			h.send("<?xml version='1.0'?><"+a+">"+s+"</"+a+">");
			if(!c) return this.analyse(h,a,c);
		//}catch(e){alert(e.message);}
    },
    analyse:function(h,a,c){
	    try{
			if(!h.responseXML) throw{message:Lang.service};
			var T={};//alert(h.responseText);
			eval(h.responseText);
			if(T.logout)Login.before(T);else if(T.login)Login.after(T);
			if(T.script)eval(T.script);
			if(T.alert)alert(T.alert);
			if(c){if(typeof(c)=="object")c.set(T);else c(T);}
			return T;
		}
		catch(e){if(typeof(c)=="object")c.abort(e);else alert(e.message);}
    	finally{this.busy=false;if(this.queue.length>0){var q=this.queue.shift();this.call(q.a,q.p,q.c);}}
    }
};
var Xml={
    In:function(s){if(s==null)return "";return s.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"\\r").replace(/\n/g,"\\n");},
    Out:function(s){if(s==null)return "";return s.replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ")}
};

function selArea(obj)
{
    var o = document.getElementById("area");
    var ol = o.getElementsByTagName("ol")[0];
    var tl= o.getElementsByTagName("li");
    var index =0;
    for(var i=0;i<tl.length;i++){
        tl[i].className="";
        if(tl[i]==obj) index=i;
    }
    
    var uls = o.getElementsByTagName("ul");
    for(var i=0;i<uls.length;i++) uls[i].style.display="none";
    
    obj.className="focus";
    uls[index].style.display="block";
    
}

function key()
{
    var v = document.getElementById("key").value;
    location.assign("http://www.zjjgyb.com/line_index.htm?"+escape(v).replace(/\+/g,"%2B").replace(/\-/g,"%2D"));
    return false;
}

function subkey()
{
    var v = document.getElementById("subkey").value;
    location.assign("http://www.zjjgyb.com/line_index.htm?"+escape(v).replace(/\+/g,"%2B").replace(/\-/g,"%2D"));
    return false;
}

function login()
{
    var acc=$("acc").value.trim();
    var pwd=$("pwd").value.trim();
    //var t = $("validcode");
    //var code = t?t.value.trim():null;
    if(acc.length==0||pwd.length==0){alert("请您填写必要的登陆信息!");return false;};
    var p = {user_acc:acc,user_pwd:pwd};
    //if(t) p.validcode=code;
    var s=[];
	for(var e in p) s.push(" "+e+"=\""+Xml.In(p[e])+"\"");
	Server.call("/index.login","<data><row"+s.join('')+"/></data>",logined);
	return false;
}


