window.onresize = baiduResizeDiv;
window.onerror = function(){}
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
var px = document.doctype?"px":0;
var scrollwidth = navigator.userAgent.indexOf("Firefox")>0?16:0;
var iframeheight = navigator.userAgent.indexOf("MSIE")>0?172:225; //一行15px
String.prototype.Trim  = function(){return this.replace(/^\s+|\s+$/g,"");}
String.prototype.encode =function(){
	var s=this.replace(/&/g,"&amp;").replace(/\"/g,"&quot;").replace(/\'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
	return parent.Browser.isIE?s.replace(/&apos;/g,"&#39;"):s;
}
String.prototype.decode =function (){return this.replace(/&#92;/g,"\\").replace(/&quot;/g,"\"").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&#39;/g,"\'");}
function collapse(){
	ct = $('tab_c');
	obj = $('ioc1');
	if(ct.style.display=="none"){
		ct.style.display="";
		obj.src=obj.src.replace("b.gif","a.gif");
	} else {
		ct.style.display="none";
		obj.src=obj.src.replace("a.gif","b.gif");
	}
	baiduResizeDiv();
}
function baiduMsg(){
	try{
		divTop = parseInt($("eMeng").style.top,10);
		divLeft = parseInt($("eMeng").style.left,10);
		divHeight = parseInt($("eMeng").offsetHeight,10);
		divWidth = parseInt($("eMeng").offsetWidth,10);

		var scrollPosTop,scrollPosLeft,docWidth,docHeight;
		if (typeof window.pageYOffset != 'undefined') { 
			scrollPosTop = window.pageYOffset; 
			scrollPosLeft = window.pageXOffset; 
			docWidth = window.innerWidth; 
			docHeight = window.innerHeight; 
		} else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
			scrollPosTop = document.documentElement.scrollTop;
			scrollPosLeft = document.documentElement.scrollLeft;
			docWidth = document.documentElement.clientWidth;
			docHeight = document.documentElement.clientHeight;
		} else if (typeof document.body != 'undefined') { 
			scrollPosTop = document.body.scrollTop;
			scrollPosLeft = document.body.scrollLeft;
			docWidth = document.body.clientWidth;
			docHeight = document.body.clientHeight;
		}

		$("eMeng").style.top = parseInt(scrollPosTop,10) + docHeight + 10 + px;// divHeight
		$("eMeng").style.left = parseInt(scrollPosLeft,10) + docWidth - divWidth - scrollwidth + px;
		$("eMeng").style.visibility="visible";
		objTimer = window.setInterval("baidu_move_div()",10);
	}catch(e){}
}

function baiduResizeDiv(){
	i+=1;
	try{
		divHeight = parseInt($("eMeng").offsetHeight,10);
		divWidth = parseInt($("eMeng").offsetWidth,10);

		var scrollPosTop,scrollPosLeft,docWidth,docHeight; 
		if (typeof window.pageYOffset != 'undefined') { 
			scrollPosTop = window.pageYOffset; 
			scrollPosLeft = window.pageXOffset; 
			docWidth = window.innerWidth; 
			docHeight = window.innerHeight; 
		} else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
			scrollPosTop = document.documentElement.scrollTop;
			scrollPosLeft = document.documentElement.scrollLeft;
			docWidth = document.documentElement.clientWidth;
			docHeight = document.documentElement.clientHeight;
		} else if (typeof document.body != 'undefined') { 
			scrollPosTop = document.body.scrollTop;
			scrollPosLeft = document.body.scrollLeft;
			docWidth = document.body.clientWidth;
			docHeight = document.body.clientHeight;
		}

		$("eMeng").style.top = docHeight - divHeight + parseInt(scrollPosTop,10) + px;
		$("eMeng").style.left = docWidth - divWidth + parseInt(scrollPosLeft,10) - scrollwidth + px;
	}catch(e){}
}

function baidu_move_div(){
	var scrollPosTop,scrollPosLeft,docWidth,docHeight; 
	if (typeof window.pageYOffset != 'undefined') { 
		scrollPosTop = window.pageYOffset; 
		scrollPosLeft = window.pageXOffset; 
		docWidth = window.innerWidth; 
		docHeight = window.innerHeight; 
	} else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
		scrollPosTop = document.documentElement.scrollTop;
		scrollPosLeft = document.documentElement.scrollLeft;
		docWidth = document.documentElement.clientWidth;
		docHeight = document.documentElement.clientHeight;
	} else if (typeof document.body != 'undefined') { 
		scrollPosTop = document.body.scrollTop;
		scrollPosLeft = document.body.scrollLeft;
		docWidth = document.body.clientWidth;
		docHeight = document.body.clientHeight;
	}

	try{
		if(parseInt($("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(scrollPosTop,10)))
		{
			window.clearInterval(objTimer);
			objTimer = window.setInterval("baiduResizeDiv()",1);
		}
		divTop = parseInt($("eMeng").style.top,10);
		$("eMeng").style.top = divTop - 1 + px;
	}catch(e){}
}
function sonFocus(obj){if (obj.value == obj.defaultValue) obj.value='';}
function sonBlur(obj){obj.value=obj.value.Trim(); if (obj.value=='') obj.value=obj.defaultValue;}
function savebook(){
	var v =document.body.getElementsByTagName("*");
	var es =new Array();
	for(var i=0; i<v.length; i++){
		if (v[i].id.indexOf("Uid$")==0){
			if (v[i].che!=null) {
				if (v[i].value=="") {
					alert(v[i].che +"，请重新填写");
					return;
				}
			}
			if (v[i].type=="radio"){
				if (v[i].checked)	
					es.push(v[i].id +"=" +v[i].value);
			}
			else if (v[i].value==v[i].defaultValue)
				es.push(v[i].id +"=");
			else
				es.push(v[i].id +"=" +v[i].value);
		}
	}
	if (es.length>0){
		Notes.Gbook.Uploads($("cid").value,$("aid").value,$("nid").value,es,
		function (obj){
			if (obj.value.indexOf("成功")>0)
				document.location.reload();
			else
				alert(obj.value);
		});
	}
}
function popmsgbox(){
	var swinstr='<div id=eMeng style="VISIBILITY:hidden;">'
	+ '<div id="tab_4" onClick="collapse();"><img src=/program/notes/images/ico_1a.gif id="ioc1" >'+document.getElementById("nid").value+'</div>'
	+ '<div id="tab_c">' + document.getElementById("gbookvalue").value.decode() +'</div></div>';
	document.write(swinstr);
	window.onload = baiduMsg;
}
popmsgbox();