function Browser()
{
	var ua, s, i;
	this.isIE    = false;
	this.isNS    = false;
	this.version = null;
	ua = navigator.userAgent;
	s = "MSIE";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isIE = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	s = "Netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	// Treat any other "Gecko" browser as NS 6.1.
	s = "Gecko";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = 6.1;
		return;
	}
}
var browser = new Browser();
var dDE=document.documentElement;
function HideDLG(DialogID){
	var objMsg=document.getElementById(DialogID);
	document.body.removeChild(objMsg);
	StopMask();
}
function CallBack(response){
	if (response.error != null){
		MessageBox("网站提示", response.error);
		return;
	}
	var ds=response.value;
	var result=ds[0];
	var resultstr=ds[1];
	if(result=="True")sobj.style.display="none";
	MessageBox("网站提示", resultstr);
}
function createMsgBox(){
	if(objMsg==null) {
		objMsg=document.createElement("div");
		objMsg.id="divMsgBox";
		document.body.appendChild(objMsg);
	}
	var objMsg=document.getElementById("divMsgBox");
	objMsg.style.display="";
	objMsg.onselectstart=function(){return false};
	StartMask();
}
function MessageBox(title,msgText,cmd){
	var sHtml = "<h2 onmousedown=\"handleMouseDown()\">";
	sHtml += title;
	sHtml += "<span title=\"关闭\" onclick=\"HideDLG('divMsgBox');"+ cmd +"\"></span></h2>";
	sHtml += "<div class=\"outer\"><div class=\"inner\"><div>";
	sHtml += msgText;
	sHtml += "</div></div></div>";
	sHtml += "<div class=\"msgButtonContainer\"><input type=\"button\" value=\"确　定\" onclick=\"HideDLG('divMsgBox');"+ cmd +"\" /></div>";
	sHtml += "<div class=\"png\"></div>";
	createMsgBox();
	var objMsg=document.getElementById("divMsgBox");
	//objMsg.style.left=(dDE.offsetWidth-400+dDE.scrollLeft*2)/2 + "px";
	//objMsg.style.top=(dDE.offsetHeight-216+dDE.scrollTop*2)/2 + "px";
	objMsg.style.left="50%";
	objMsg.style.top="50%";
	objMsg.style.margin="-108px 0 0 -200px";
	objMsg.innerHTML=sHtml;
	objMsg.focus();
}
function LoadBox(title,msgText){
	var sHtml = "<h2 onmousedown=\"handleMouseDown()\">";
	sHtml += title;
	sHtml += "<span title=\"关闭\" onclick=\"HideDLG('divMsgBox');\"></span></h2>";
	sHtml += "<div class=\"outer\"><div class=\"inner\"><div>";
	sHtml += msgText;
	sHtml += "</div></div></div>";
	sHtml += "<div class=\"png\"></div>";
	createMsgBox();	
	var objMsg=document.getElementById("divMsgBox");
	//objMsg.style.left=(dDE.offsetWidth-400+dDE.scrollLeft*2)/2 + "px";
	//objMsg.style.top=(dDE.offsetHeight-216+dDE.scrollTop*2)/2 + "px";
	objMsg.style.left="50%";
	objMsg.style.top="50%";
	objMsg.style.margin="-108px 0 0 -200px";
	objMsg.innerHTML=sHtml;
	objMsg.focus();
}
//	var str="alert('测试')";
//	ConfirmBox('网站提示','您确定要测试吗?','确定',str,'取消','') ;
function ConfirmBox(title,body){
	var sBody = body;
	if(arguments.length % 2 != 0 || arguments.length < 4) {
		alert("Invoke error!");
		return false;
	}
	var sHtml = "<h2 onmousedown=\"handleMouseDown()\">";
	sHtml += title;
	sHtml += "<span title=\"关闭\" onclick=\"HideDLG('divMsgBox');\"></span></h2>";
	sHtml += "<div class=\"outer\"><div class=\"inner\"><div>";
	sHtml += sBody;
	sHtml += "</div></div></div>";
	sHtml += "<div class=\"msgButtonContainer\">";
	for(var i = 2; i < arguments.length; i += 2) {
		var sButton = "<input type=\"button\"";
		sButton += " value=\"" + arguments[i] + "\"";
		sButton += " onclick=\"HideDLG('divMsgBox');" + arguments[i + 1] + "\" />　";
		sHtml += sButton;
	}
	sHtml += "</div>";
	sHtml += "<div class=\"png\"></div>";   
	createMsgBox();   
	var objMsg=document.getElementById("divMsgBox");
	objMsg.style.left=(dDE.offsetWidth-400+dDE.scrollLeft*2)/2 + "px";
	objMsg.style.top=(dDE.offsetHeight-216+dDE.scrollTop*2)/2 + "px";
	objMsg.style.margin=0;
	objMsg.innerHTML=sHtml; 
	objMsg.focus();
}
function StartMask(){
	showMask = true;
	oVeil=document.createElement("div");
	oVeil.id="veil";
	//oVeil.scrolling="no";
	//oVeil.frameBorder="0";
	document.body.appendChild(oVeil);
	var veil=document.getElementById("veil");
	veil.style.height=dDE.scrollHeight+"px";
	debugSelect();
}
function StopMask(){
	showMask = false;
	debugSelect();
}
function debugSelect(){
	var veil=document.getElementById("veil");
	var oSelect=document.getElementsByTagName("select");
	if(showMask){
		for(i=0;i<oSelect.length;i++)
			oSelect[i].style.visibility="hidden";
	}else{
		for(i=0;i<oSelect.length;i++)
			oSelect[i].style.visibility="";
		document.body.removeChild(veil);
	 } 
}
var showMask = false;
var iDiffx=0,iDiffy=0;
function handleMouseMove(){
	var oEvent=EventUtil.getEvent();
	var oDiv=document.getElementById("divMsgBox");
	oDiv.style.left=oEvent.clientX-iDiffx+"px";
	oDiv.style.top=oEvent.clientY-iDiffy+"px";
}
function handleMouseDown(){
	var oEvent=EventUtil.getEvent();
	var oDiv=document.getElementById("divMsgBox");
	iDiffx=oEvent.clientX-oDiv.offsetLeft;
	iDiffy=oEvent.clientY-oDiv.offsetTop;
	EventUtil.addEventHandler(dDE,"mousemove",handleMouseMove);
	EventUtil.addEventHandler(dDE,"mouseup",handleMouseUp);
}
function handleMouseUp(){
	EventUtil.removeEventHandler(dDE,"mousemove",handleMouseMove);
	EventUtil.removeEventHandler(dDE,"mouseup",handleMouseUp);
}


