﻿var dlg_def_width	= 264;
var dlg_def_height	= 157;
var dlg_def_enter	= new Image();
var dlg_def_cancel	= new Image();
var dlg_def_wait	= new Image();
dlg_def_enter.src	= "../images/dlg_enter.gif";
dlg_def_cancel.src	= "../images/dlg_cancel.gif";
dlg_def_wait.src	= "../images/sending.gif";
var dlg_time_out;
dw('<div id="dlg_back" onselectstart="return false" style="position:absolute;top:0px;left:0px;background:#DFDFDF;-moz-opacity:0.2;filter:Alpha(Opacity = 20);z-index:900;"></div>');
dw('\
<div id="dlg" onselectstart="return false" style="border:#E4E9EF 3px solid;background:#FFF;width:' + dlg_def_width + 'px;height:' + dlg_def_height + 'px;position:absolute;overflow:hidden;display:none;z-index:999;">\
	<div id="dlg_zone" style="width:100%;height:100%;position:absolute;top:0px;left:0px;display:none;">\
		<div id="dlg_title" style="height:23px;font-size:12px;width:100px;color:#013298;padding-left:15px;padding-top:5px;text-align:left;">信息提示！</div>\
		<div id="dlg_string" style="width:170px;height:50px;font-size:12px;margin:20px auto;line-height:150%;"></div>\
		<div id="dlg_button" style="width:200px;height:30px;text-align:center;margin:20px auto;"></div>\
	</div>\
	<div id="dlg_html" style="width:100%;height:100%;position:absolute;display:none;"></div>\
	<div style="border:1px #FFF solid;">\
		<div style="height:23px;border:1px #9AC2F5 solid;text-align:left;background:url(../images/dlg_title_bg.gif) repeat-x;overflow:hidden;"><img src="../images/dlg_title_bg2.gif" /></div>\
	</div>\
	<div id="dlg_move" onmousedown="dialog.dlg_move(event);" style="width:80px;height:23px;position:absolute;top:0px;right:30px;cursor:move;"><img src="../images/nopic.gif" width="100%" height="100%" /></div>\
	<div style="width:16px;height:16px;position:absolute;top:5px;right:10px;"><input type="image" src="../images/dlg_close.gif" onclick="dialog.reset();" /></div>\
</div>\
');
dw('<div id="dlg_wait" onselectstart="return false" style="position:absolute;top:0px;left:0px;width:' + dlg_def_wait.width + 'px;height:' + dlg_def_wait.height + 'px;display:none;z-index:91;"><img src="' + dlg_def_wait.src + '" border="0" alt="" /></div>');
dw('<div id="dlg_load" onselectstart="return false" style="position:absolute;top:0px;left:0px;display:none;z-index:92;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="16" height="16"><param name="wmode" value="transparent" /><param name="movie" value="../images/loading.swf" /><param name="quality" value="high" /><embed src="../images/loading.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="16" height="16"></embed></object></div>');
var dialog = new Object();
dialog.__FUNC;
dialog.alert = function(str, func, bkgrd, full){	//对话框字符串；执行语句；是否全屏;是否带透明背景
	if (isNull(func)){
		func = "";
	}
	dialog.__FUNC = "dialog.reset();" + func;
	var but = '<input type="image" src="' + dlg_def_enter.src + '" onclick="eval(dialog.__FUNC)" width="56" height="21" alt="确定" />';
	$("dlg").style.display		= "";
	$("dlg_zone").style.display	= "";
	$("dlg_string").innerHTML = str;
	$("dlg_button").innerHTML = but;
	dialog.dlg_make($("dlg"), full, bkgrd);
}
dialog.confirm = function(str, func, bkgrd, full){
	if (isNull(func)){
		func = "";
	}
	dialog.__FUNC = "dialog.reset();" + func;
	var but = '<input type="image" src="' + dlg_def_enter.src + '" onclick="eval(dialog.__FUNC)" width="56" height="21" alt="确定" /> <input type="image" src="' + dlg_def_cancel.src + '" onclick="dialog.reset();" width="56" height="21" alt="取消" />';
	$("dlg").style.display		= "";
	$("dlg_zone").style.display	= "";
	$("dlg_string").innerHTML	= str;
	$("dlg_button").innerHTML	= but;
	dialog.dlg_make($("dlg"), full, bkgrd);
}
dialog.iframe = function(sUrl, sWidth, sHeight, bkgrd, sScroll, full){
	if (isNull(sScroll)){
		sScroll = "no";
	}
	var s = '<iframe width="100%" height="100%" scrolling="' + sScroll + '" src="' + sUrl + '" frameborder="0"  allowtransparency="true"></iframe>';
	dialog.html(s, sWidth, sHeight, bkgrd, full)
}
dialog.html = function(str, sWidth, sHeight, bkgrd, full){
	$("dlg").style.display	= "";
	if (!isNull(sWidth)){
		$("dlg").style.width = sWidth + "px";
	}
	if (!isNull(sHeight)){
		$("dlg").style.height = sHeight + "px";
	}
	$("dlg_move").style.width = parseInt($("dlg").style.width) - 184 + "px";
	$("dlg_html").style.display	= "";
	$("dlg_html").innerHTML 	= str;
	dialog.dlg_make($("dlg"), full, bkgrd);
}
dialog.wait = function(){
	$("dlg_wait").style.display = "";
	dialog.dlg_make($("dlg_wait"), false, true);
	dlg_time_out = setTimeout(function(){
		dialog.reset();
		dialog.alert("连接超时，请重试！");
	}, 20000);
}
dialog.load = function(){
	$("dlg_load").style.display = "";
	dialog.dlg_make($("dlg_load"), false, true);
	dlg_time_out = setTimeout(function(){
		dialog.reset();
		dialog.alert("连接超时，请重试！");
	}, 20000);
}
dialog.title = function(tit){
	$("dlg_title").innerHTML	= tit;
}
dialog.dlg_make = function(obj, full, bkgrd){
	var sDcument	= document.documentElement ? document.documentElement : document.body;
	with (sDcument){
		if (full){
			obj.style.width		= clientWidth + "px";
			obj.style.height	= clientHeight + "px";
			obj.style.top		= "-3px";
			obj.style.left		= "-3px";
		}
		else{
			obj.style.top		= clientHeight/2 - obj.offsetHeight/2 + scrollTop + "px";
			obj.style.left		= clientWidth/2 - obj.offsetWidth/2 + scrollLeft + "px";
		}
		if(isNull(bkgrd) || bkgrd){
			$("dlg_back").style.display = "";
			$("dlg_back").style.width = scrollWidth + "px";
			$("dlg_back").style.height = scrollHeight + "px";
		}
	}
	try{
		$t("input", $("dlg_button"))[0].focus();
	}catch(E){}
}
dialog.dlg_move = function(evt){
	if ($("dlg_move").setCapture){
		$("dlg_move").setCapture();
	}
	var mLeft = evt.clientX - parseInt($("dlg").style.left);
	var mTop = evt.clientY - parseInt($("dlg").style.top);
	$("dlg").onmousemove = function(){
		$("dlg").style.left = evt.clientX - mLeft  + "px";
		$("dlg").style.top = evt.clientY - mTop + "px";
	};
	$("dlg").onmouseup =  function(){
		if ($("dlg_move").releaseCapture)
		{
			$("dlg_move").releaseCapture();
		}
		$("dlg").onmouseup = null;
		$("dlg").onmousemove = null;
	};
}
dialog.reset = function(){
	clearTimeout(dlg_time_out);
	$("dlg").style.width			= dlg_def_width + "px";
	$("dlg").style.height			= dlg_def_height + "px";
	$("dlg_html").innerHTML			= "";
	$("dlg_title").innerHTML		= "信息提示！";
	$("dlg_back").style.display		= "none";
	$("dlg_zone").style.display		= "none";
	$("dlg_html").style.display		= "none";
	$("dlg_wait").style.display		= "none";
	$("dlg_load").style.display		= "none";
	$("dlg").style.display			= "none";
}

//按照以前使用习惯封装到函数中
function reset(){
	dialog.reset();
}
function show_error(str, func){
	reset()
	dialog.alert(str, func);
}
function show_win(str, func){
	reset()
	dialog.alert(str, func, true, true);
}
function show_confirm(str, func){
	reset()
	dialog.confirm(str, func);
}
function show_send(){
	reset()
	dialog.wait();
}
function show_loading(){
	reset()
	dialog.load();
}
function show_frame(Url, sWidth, sHeight, bkgrd, sScroll, full){
	reset()
	dialog.iframe(Url, sWidth, sHeight, bkgrd, sScroll, full);
}
