var IsShowISMS=false;
var http_request_isms = false;
var MemberID_ISMS=0;
var dNowHISMS=0;
var dHeightISMS=0;
var dTopISMS=0;
var dObjISMS;
var dStrISMS="";
var isFirstISMS=0;
var dLoginIDISMS='';
function makeRequestISMS(url) {
	http_request_isms = false;
	if (window.XMLHttpRequest) {
		http_request_isms = new XMLHttpRequest();
		if (http_request_isms.overrideMimeType) {
			http_request_isms.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) {
		try {
			http_request_isms = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request_isms = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request_isms) {
		alert('Giving up :(无法创建一个XMLHTTP实例');
		return false;
	}
	http_request_isms.onreadystatechange = proessHttpRequestISMS;
	http_request_isms.open('POST', url, true);
	http_request_isms.send(null);
}
function proessHttpRequestISMS(){
	try{
		if (http_request_isms.readyState == 4) {
			if (http_request_isms.status == 200)
			{
				var result=trim(http_request_isms.responseText);
				shouISMS(parseInt(result))
			}
		}
	}catch(e){}
}
function showDivISMS(str,width,height){
	if($("isms_div").style.visibility == "visible"){
		hidDivISMS();
	}else{
		$("isms_div").style.width = width + "px";
		$("isms_div").style.visibility = "visible";
		var top_str = document.body.scrollTop+(document.body.clientHeight - height);///2 ;
		//alert(document.body.scrollTop+":"+top_str);
		var left_str = document.body.scrollLeft+(document.body.clientWidth-$("isms_div").offsetWidth)-5;
		//alert(document.body.clientWidth+":"+$("isms_div").offsetWidth+":"+width+"="+left_str);
		$("isms_div").style.marginLeft = left_str+ "px";
		slowShowSetISMS($("isms_div"),parseInt(""+top_str),parseInt(""+height),str);
		slowShowISMS();
	}
}
function shouISMS(NewSMSNum){
	if(NewSMSNum>0){
		var html="<h2><span onClick=\"hidDivISMS();\" style='cursor:hand'>关闭</span>"+dLoginIDISMS+"的小纸条</h2>";
		html += "<p>您有未阅读小纸条： <font color='red'>"+NewSMSNum+"</font> 条</p>"
		html += "<p><input name=\"btLogin\" value=\"查看\" type=\"button\" onClick=\"window.open('/personal/?key=0&menu=1');hidDivISMS();\" class=\"bt2\">&nbsp;&nbsp;"+
			"<input name=\"btCancle\" value=\"取消\" type=\"button\" onClick=\"hidDivISMS();\" class=\"bt2\"></p>"
		showDivISMS(html,220,120);
		IsShowISMS=true;
	}else{
		window.setTimeout("loadISMS("+MemberID_ISMS+")",10000);
	}
}
function loadISMS(MID,LID){
	if(MID=='')MID=0;
	if(LID){
		dLoginIDISMS=LID;
	}
	if(isFirstISMS<1){
		isFirstISMS++;
		window.setTimeout("loadISMS("+MID+")",1000);
		return;
	}
	if(IsShowISMS || MID<1){

	}else{
		MemberID_ISMS=MID;
		//makeRequestISMS("/pub/ajax/ISMSNewNum.jsp?MID="+MID);
		makeRequestISMS("/pub/ajax/ISMSNewNum.jsp");
	}
}
function slowShowSetISMS(obj,top,h,s){
	dObjISMS=obj;
	dTopISMS=top;
	dNowHISMS=0;
	dHeightISMS=h;
	dStrISMS=s;
}
function tiaozhengTop(){
	if($("isms_div").style.visibility != "hidden"){
		var top_str = document.body.scrollTop+(document.body.clientHeight - dHeightISMS);///2 ;
		var left_str = document.body.scrollLeft+(document.body.clientWidth-$("isms_div").offsetWidth)-5;
		$("isms_div").style.marginLeft = left_str+ "px";
		dObjISMS.style.marginTop = top_str+"px";
		window.setTimeout("tiaozhengTop();",88);
	}
}
function slowShowISMS(){
	if(dNowHISMS<dHeightISMS){
		dObjISMS.style.marginTop = (dTopISMS+(dHeightISMS/2)-(dNowHISMS/2))+"px";
		dObjISMS.style.height = dNowHISMS + "px";
		//window.status=dNowHISMS+"px";
		dNowHISMS=dNowHISMS+6;
		window.setTimeout("slowShowISMS();",10);
	}else{
		dObjISMS.style.height = dHeightISMS + "px";
		dObjISMS.style.marginTop = dTopISMS+"px";
		dObjISMS.innerHTML = dStrISMS;
		dNowHISMS=0;
		tiaozhengTop();
	}
}
function hidDivISMS(){
	setDivISMS("");
	$("isms_div").style.visibility = "hidden";
}
function setDivISMS(html){$("isms_div").innerHTML = html;}
function $(id){return document.getElementById(id);}
