var DomainUrl = top.location.hostname;
var AuthUrl = top.location.hostname;

function Trim(){
	return this.replace(/\s+$|^\s+/g,"");
}
String.prototype.Trim=Trim;

function getObjValues(id){
	if(getObjects(id).value!=undefined)
		return getObjects(id).value.Trim();
	else
		return "";
}
function getObjects(id) { 	
	if (document.getElementById) { 
		return document.getElementById(id); 
	} else if (document.all) { 
		return document.all[id]; 
	} else if (document.layers) { 
		return document.layers[id]; 
	} 
}


function createXMLHttpRequest(){
       	if (window.XMLHttpRequest) {//wwww.chshcms.com
		XMLHttpReq=new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {//IE 浏览器
	     try {
			    XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
	     } catch (e) {
		        try{
					XMLHttpReq=new ActiveXObject("Micrsost.XMLHTTP");
				} catch(e){}
	     }
        }
}
var cache = new Array();
function getHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

function CSCMS_Login(){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", cscms_loginlink+"?random="+Math.random(), true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
           document.getElementById("cscms_login").innerHTML = theHttpRequest.responseText;
           } else {
           document.getElementById("cscms_login").innerHTML = "您请求的页面出现异常错误";
                  }
           }
     }
}

function CSCMS_Logadd(){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", cscms_loginaddlink+"?username="+getObjValues("cscms_name")+"&userpass="+getObjValues("cscms_pass")+"&random="+Math.random(), true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
               var data=theHttpRequest.responseText;
               if(data=='10001'){ //用户名为空
                    do_alert('帐号不能为空!');setTimeout('close_alert()', 2000);
               } else if(data=='10002'){ //密码为空
                    do_alert('密码不能为空!');setTimeout('close_alert()', 2000);
               } else if(data=='10003'){ //帐号不存在
                    do_alert('您的帐号不存在!');setTimeout('close_alert()', 2000);
               } else if(data=='10004'){ //密码错误
                    do_alert('您的密码错误!');setTimeout('close_alert()', 2000);
               } else if(data=='10005'){ //帐号被锁定
                    do_alert('您的帐号被锁定!');setTimeout('close_alert()', 2000);
               } else if(data=='10006'){ //登入成功
                    CSCMS_Login();
               } else if(data=='10007'){ //邮件未激活
                    do_alert('您的帐号未激活，请去邮箱激活!');setTimeout('close_alert()', 2000);
               } else { 
                   alert(data);
               }

           } else {
           do_alert('网络故障，连接失败!');setTimeout('close_alert()', 2000);
                  }
           }
     }
}

function CSCMS_Logout(){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", cscms_logoutlink, true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
                  CSCMS_Login();
           } else {
           do_alert('网络故障，连接失败!');setTimeout('close_alert()', 2000);
                  }
           }
     }
}
document.writeln("<style>#alert {display:block; color:#fff;padding-top:9px; width:280px; height:80px;line-height:80px; font-size:14px; padding:1px; background:#000; }</style>");
function do_alert( msg ){
    var n=0;
    x=(document.body.scrollTop||document.documentElement.scrollTop)+n;
    var _height = document.documentElement.clientHeight||document.body.clientHeight;
    var _top = (_height) ? (_height - 39)/2 + x : 0;
    var msgObj=document.createElement('div');
    msgObj.setAttribute('id', 'msgInfo');
    msgObj.setAttribute('align', 'center');
    msgObj.style.position = 'absolute';
    msgObj.style.top = _top + 'px';
    msgObj.style.left = '0';
    msgObj.style.width = '100%';
    msgObj.style.height = '33px';
    msgObj.style.zIndex = '999';
    msgObj.innerHTML = '<span id="alert">'+ msg +'</span>';
    document.body.appendChild(msgObj);
};

function close_alert(){
    document.body.removeChild(document.getElementById('msgInfo'));
};

function bfq(){
   document.writeln("<iframe marginwidth=\"0\" marginheight=\"0\" src=\""+web_url+"csdj/real/index.php\" frameborder=\"0\" width=\"100%\" scrolling=\"no\" height=\"35\" leftmargin=\"0\" topmargin=\"0\"></iframe>");
}

function SetCookie(name, value){
	var expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))+((secure == true) ? "; secure" : "");
};