var http_request = false;
function send_request(url,para,callback) {
	http_request = false;
	if(window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType("text/xml");
		}
	}
	else if (window.ActiveXObject) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		window.alert("can't create XMLHttpRequest instance.");
		return false;
	}
	http_request.onreadystatechange = callback;
	//alert('url='+url+' para='+para);
	http_request.open("POST", url, true);
	http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	http_request.send(para);
}

function Browser(){
	var ua, s, i;
	this.isIE = false;
	this.isNS = false;
	this.isOP = false;
	this.isSF = false;
	ua = navigator.userAgent.toLowerCase();
	s = "opera";
	if ((i = ua.indexOf(s)) >= 0){
		this.isOP = true;
		return;
	}
	s = "msie";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isIE = true;
		return;
	}
	s = "netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		return;
	}
	s = "gecko";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		return;
	}
	s = "safari";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isSF = true;
		return;
	}
}

function gid(id){
	return document.getElementById?document.getElementById(id):null;
}

function gname(name){
	return document.getElementsByTagName?document.getElementsByTagName(name):new Array()
}

function ScreenConvert(){
	var browser = new Browser();
	var objScreen = gid("ScreenOver");
	if(!objScreen)
		var objScreen = document.createElement("div");
	var oS = objScreen.style;
	objScreen.id = "ScreenOver";
	oS.display = "block";
	oS.top = oS.left = oS.margin = oS.padding = "0px";
	if (document.body.clientHeight)	{
		var wh = document.body.clientHeight + "px";
	}else if (window.innerHeight){
		var wh = window.innerHeight + "px";
	}else{
		var wh = "100%";
	}
	oS.width = "100%";
	oS.height = wh;
	oS.position = "absolute";
	oS.zIndex = "5";
	if ((!browser.isSF) && (!browser.isOP)){
		oS.background = "#181818";
	}else{
		oS.background = "#F0F0F0";
	}
	oS.filter = "alpha(opacity=40)";
	oS.opacity = 40/100;
	oS.MozOpacity = 40/100;
	document.body.appendChild(objScreen);
	var allselect = gname("select");
	for (var i=0; i<allselect.length; i++)
		allselect[i].style.visibility = "hidden";
}

function ScreenClean(){
	var objScreen = document.getElementById("ScreenOver");
	if (objScreen) objScreen.style.display = "none";
	var allselect = gname("select");
	for (var i=0; i<allselect.length; i++)
		allselect[i].style.visibility = "visible";
}

//参数说明
// showTitle: 需要显示的窗口标题
// showText: 需要显示的提示信息内容
// align: 信息的水平对齐方式
// valign: 信息的垂直对齐方式
// ow,oh,w,h 定义弹出窗口的位置与大小
// timeout:　如果用户不做任何操作，多少毫秒自动关闭窗口,如果等于0,则必须等用户自已关闭
// closeButton: 是否显示关闭按钮
//
function ScreenBox_Text(showTitle,showText,ow,oh,w,h,align,valign,timeout,closeButton){
	ScreenConvert();
	var objDialog = document.getElementById("DialogMove");
	if (!objDialog)
		objDialog = document.createElement("div");
	t_DiglogW = ow;
	t_DiglogH = oh;
	ScreenBoxLoc();
	objDialog.id = "DialogMove";
	var oS = objDialog.style;
	oS.display = "block";
	oS.top = t_DiglogY + "px";
	oS.left = t_DiglogX + "px";
	oS.margin = "0px";
	oS.padding = "0px";
	oS.width = w + "px";
	oS.height = h + "px";
	oS.position = "absolute";
	oS.zIndex = "10";
	oS.background = "#DDDDDD";
	oS.border = "solid #003C74 1px";

	var tr_height=h-40+"px";
	if(closeButton==false)
		tr_height=h-20+"px";
	var AJAX_ReportVoteBody;
	AJAX_ReportVoteBody ="<table width=100% height=100% border=0 cellpadding=5 bgcolor=#ECE9D8>";
	AJAX_ReportVoteBody+="<tr height=15 onMouseDown='this.style.cursor=\"move\";DragIt(\"DialogMove\");' onMouseUp='this.style.cursor=\"auto\";'>";
	AJAX_ReportVoteBody+="<td align=left bgcolor=#3560AE colspan=1>";
	AJAX_ReportVoteBody+="<div style=\"float:left;font-size:12px;font-name:Arial, Helvetica, sans-serif;font-weight:bold;color:#ECE9D8;\">{replaceTitle}</div>";
	AJAX_ReportVoteBody+="<div align=right style=\"display:block;width:50px;float:right;text-align:right;\">[<span style='cursor:hand;font-size:12px;color:#FFFFFF' onclick='ScreenBox_Close();'>Close</span>]</div></td>";
	AJAX_ReportVoteBody+="</tr>";
	AJAX_ReportVoteBody+="<tr height='"+tr_height+"'>";
	AJAX_ReportVoteBody+="<td align="+align+" valign="+valign+" bgcolor=#ECE9D8>{replaceText}</td>";
	AJAX_ReportVoteBody+="</tr>";
	if(closeButton==true)
	{
		AJAX_ReportVoteBody+="<tr height=20>";
		AJAX_ReportVoteBody+="<td align=center colspan=1 bgcolor=#ECE9D8>";
		AJAX_ReportVoteBody+="<input name='closebutton' type='button' onclick='ScreenBox_Close();' value=' Close ' style=\"font-size:12px;font-name:Arial, Helvetica, sans-serif;color:#000;line-height:140%;background-color:#F8F8F6;border:1px solid #003C74;\">";
		AJAX_ReportVoteBody+="</td>";
		AJAX_ReportVoteBody+="</tr>";
	}
	AJAX_ReportVoteBody+="</table>";

	AJAX_ReportVoteBody = AJAX_ReportVoteBody.replace("{replaceTitle}",showTitle);
	AJAX_ReportVoteBody = AJAX_ReportVoteBody.replace("{replaceText}",showText);

	objDialog.innerHTML = AJAX_ReportVoteBody;
	document.body.appendChild(objDialog);
	
	ScreenBox_timeout=Math.abs(timeout);
	if(ScreenBox_timeout>0)
		set_timeOut_btnCaption();
}

//参数说明
// showTitle: 需要显示的窗口标题
// showName: 需要显示的提示信息内容
// align: 信息的水平对齐方式
// valign: 信息的垂直对齐方式
// ow,oh,w,h 定义弹出窗口的位置与大小
// timeout:　如果用户不做任何操作，多少毫秒自动关闭窗口,如果等于0,则必须等用户自已关闭
//
function ScreenBox_HtmlFile(showTitle,fileName,ow,oh,w,h,align,valign,timeout,closeButton){
	if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load(fileName);
		if (xmlDoc.parseError.errorCode != 0) {//如果打开文件出错
			var myErr = xmlDoc.parseError;
			alert("my fault：" + myErr.reason+"("+xmlDoc.parseError.errorCode+")");
		}
		else
		{
			strxml="<div>"+xmlDoc.documentElement.xml+"</div>";
			ScreenBox_Text(showTitle,strxml,ow,oh,w,h,align,valign,timeout,closeButton);
		}
	}
	else
	{
		alert("your browser doesn't support xmlDoc operation！");
	}
}

var ScreenBox_timeout=0;
function set_timeOut_btnCaption()
{
	var obj=document.getElementsByTagName("input");
	//alert(obj.length);
	for (n=0;n<obj.length;n++)
	{
		if(obj[n].name=='closebutton')
		{
			var s=Math.ceil(ScreenBox_timeout/1000);
			obj[n].value=' Close ('+s+') ';

			if(s>0)
			{
				ScreenBox_timeout=ScreenBox_timeout-1000;
				window.setTimeout(set_timeOut_btnCaption, 1000);
			}else
				ScreenBox_Close();
		}
	}
}

function ScreenBoxLoc(){
	var dde = document.documentElement;
	if (window.innerWidth){
		var ww = window.innerWidth;
		var wh = window.innerHeight;
		var bgX = window.pageXOffset;
		var bgY = window.pageYOffset;
	}else{
		var ww = dde.offsetWidth;
		var wh = dde.offsetHeight;
		var bgX = dde.scrollLeft;
		var bgY = dde.scrollTop;
	}
	t_DiglogX = (bgX + ((ww - t_DiglogW)/2));
	t_DiglogY = (bgY + ((wh - t_DiglogH)/2));
}

function ScreenBox_Close(){
	ScreenClean();
	var objDialog = document.getElementById("DialogMove");
	if (objDialog)
		objDialog.style.display = "none";
}

var  dragDiv=0;  
function  DragIt(obj){  
	dragDiv=obj;  
	event.srcElement.setCapture();  
	x=document.all(dragDiv).style.pixelLeft-event.x;  
	y=document.all(dragDiv).style.pixelTop-event.y;  
}  

function document.onmousemove(){  
	if(dragDiv){  
		document.all(dragDiv).style.pixelLeft=x+event.x;  
		document.all(dragDiv).style.pixelTop=y+event.y;  
	}  
}  

function document.onmouseup(){  
	if(dragDiv){  
		event.srcElement.releaseCapture();  
		dragDiv=0;  
	}  
}  

