
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 GbookList(_namea){
  var theHttpRequest = getHttpObject();
  theHttpRequest.onreadystatechange = function() {processAJAX();};
  theHttpRequest.open("GET", "ajax.php?ac=gbooklist&usera="+_namea, true);
  theHttpRequest.send(null);
    function processAJAX(){
       if (theHttpRequest.readyState == 4) {
         if (theHttpRequest.status == 200) {
                document.getElementById("cscms_book").innerHTML = unescape(theHttpRequest.responseText);
         } else {
		document.getElementById("cscms_book").innerHTML = "您请求的页面出现异常错误";
         }
       }
   }
}

function AddFriend(_name){
	 createXMLHttpRequest();
         XMLHttpReq.open("GET", "ajax.php?ac=gz&usera="+_name,true);
	 XMLHttpReq.onreadystatechange= function(){
		if(XMLHttpReq.readyState == 4){
			if(XMLHttpReq.status == 200){
	           		if(XMLHttpReq.responseText == "Err_100"){
	           	        	alert("您还没有登入！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_101"){
	           	        	alert("不能关注自己的！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_000"){
	           	        	alert("您已经关注TA了！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_102"){
	           	        	alert("关注成功！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_103"){
	           	        	alert("关注失败！");
		        	}
			}else alert("网络链接失败");
		}
	}
	 XMLHttpReq.send(null);
}


function Gbookadd(){
         var username=getObjValues("username");
         var namea=getObjValues("CS_Usera");
         if(username!='csdjcms'){
         var userpass=getObjValues("userpass");
             if(username==""){
                     alert("请输入用户名");
             } else if(userpass==""){
                     alert("请输入密码！");
             }
	      createXMLHttpRequest();
              XMLHttpReq.open("GET", "ajax.php?ac=gbook&usera="+getObjValues('CS_Usera')+"&userpass="+userpass+"&userb="+getObjValues('CS_Userb')+"&content="+getObjValues('CS_Content'),true);
         }else{
	      createXMLHttpRequest();
	      XMLHttpReq.open("GET", "ajax.php?ac=gbook&usera="+getObjValues('CS_Usera')+"&userb="+getObjValues('CS_Userb')+"&content="+getObjValues('CS_Content'),true);
         }
	 XMLHttpReq.onreadystatechange= function(){
		if(XMLHttpReq.readyState == 4){
			if(XMLHttpReq.status == 200){
	           		if(XMLHttpReq.responseText == "Err_000"){
	           	        	alert("参数错误，接收会员为空！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_100"){
	           	        	alert("请输入用户名！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_101"){
	           	        	alert("请输入密码！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_102"){
	           	        	alert("用户名或密码不正确！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_103"){
	           	        	alert("留言内容不能为空！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_104"){
	           	        	alert("刚刚留过言，先休息一下！");
		        	}
	           		if(XMLHttpReq.responseText == "Err_105"){
                                        document.getElementById('CS_Content').innerText = '';
	           	        	GbookList(namea);
		        	}
	           		if(XMLHttpReq.responseText == "Err_106"){
	           	        	alert("抱歉,留言失败！");
		        	}
			}else alert("网络链接失败");
		}
	}
	 XMLHttpReq.send(null);
}


//复制代码
function CopyUrl(url,title){ 
   window.clipboardData.setData("Text",url);
   alert(title); 
} 

function insertsmilie(sampleText) {
    var txtarea = document.getElementById('CS_Content').value;
    document.getElementById('CS_Content').innerText = txtarea+sampleText;

}
function faceadd(s) {
    if (document.getElementById(s).style.display == 'none') {
        document.getElementById(s).style.display = 'block'
        document.getElementById('face').innerHTML = '关闭表情';
    } else if (document.getElementById(s).style.display == 'block') {
        document.getElementById(s).style.display = 'none'
        document.getElementById('face').innerHTML = '插入表情';
    }
}

function addBookmark(title,url) {
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}
