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 SFCMS_Qian(){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", sf_index+"index.php/m/sfq/index/jsqian?random="+Math.random(), true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
           document.getElementById("sfcms_qian").innerHTML = theHttpRequest.responseText;
           } else {
           document.getElementById("sfcms_qian").innerHTML = "您请求的页面出现异常错误";
                  }
           }
     }
}

function SFCMS_Qianadd(){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", sf_index+"index.php/m/sfq/qiandao/jsqian?random="+Math.random(), true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
               var data=theHttpRequest.responseText;
               if(data=='10003'){ //用户名为空
                    do_alert('您还没登陆呢!');setTimeout('close_alert()', 2000);
               } else if(data=='10004'){ //密码为空
                    do_alert('签到成功!');setTimeout('close_alert()', 2000);
					SFCMS_Qian();
               } else if(data=='10005'){ //帐号不存在
                    do_alert('今天已经签到了!');setTimeout('close_alert()', 2000);
					SFCMS_Qian();
               } else { 
                   alert(data);
               }

           } 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 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" : "");
};