function dialog()
{
	var boxTitle = "恒初提醒您";
	var boxTitleBgImg = "http://www.hengchu.cn/Images/table_top_bg.gif";
	var blankBgImg = "http://www.hengchu.cn/Images/blank.gif";
	var closeImg_0 = "http://www.hengchu.cn/Images/dialog_Close_0.gif";
	var closeImg_1 = "http://www.hengchu.cn/Images/dialog_Close_1.gif";
	var shadowPx = 6;
	var boxWidth = 300;
	var boxHeight = 160;
	var divBg = '\
		<div id="dialogBoxBg"></div>\
	';
	var divShadow = '\
		<div id="dialogBoxShadow"></div>\
	';
	var divTitle = '\
		<div id="dialogBoxTitle" style="font-weight:bold;" onmousedown="new dialog().moveStart(event, \'dialogBox\')">\
			<span style="float:left;">' + boxTitle + '</span>\
			<img id="dialogBoxClose" title="关闭" src="' + closeImg_0 + '" onmouseover="this.src=\'' + closeImg_1 + '\';" onmouseout="this.src=\'' + closeImg_0 + '\';" style="float:right;" onclick="new dialog().close();" />\
		</div>\
	';
	var divContent = '\
	<div id="dialogBoxContent">\
		<img id="dialogBoxMsgImg" src="" style="float:left;" />\
		<div id="dialogBoxMsg" style="float:right; line-height:20px; text-align:left;"></div>\
	</div>\
	';
	var divButton = '\
	<div id="divBoxBotton" style="text-align:center;">\
		<input id="buttonOk" type="button" value=" 确定 " onclick="new dialog().close();" /> \
		 <input id="buttonCancel" type="button" value=" 取消 " onclick="new dialog().close();" />\
	</div>\
	';
	var divBox = '\
		<div id="dialogBox">\
			' + divTitle + '\
			' + divContent + '\
			' + divButton + '\
		</div>\
	';
	
	function $(_sId)
	{
		return window.top.document.getElementById(_sId);
	}
	
	//显示对话框
	this.showBox = function(_sMsg, _sImg, _sOk, _sCancel)
	{
		this.init();
		$('dialogBoxMsg').innerHTML = _sMsg;
		$('dialogBoxMsgImg') ? $('dialogBoxMsgImg').src = 'http://www.hengchu.cn/Images/' + _sImg + '.gif' : function(){};
		_sOk && _sOk != "" ? this.button('buttonOk', _sOk) : $('buttonOk').style.display = 'none';
		_sCancel && _sCancel != "" ? this.button('buttonCancel', _sCancel) : $('buttonCancel').style.display = 'none';
		//$('buttonOk').focus();
	}
	
	//对话框设置
	this.boxSet = function()
	{
		var obj = $('dialogBox');
		
		obj['style']['background']	= "#ffffff";
		obj['style']['z-index']	= 10;
		obj['style']['border']	= "1px solid #336699";
		obj['style']['width'] = boxWidth + "px";
		obj['style']['height'] = boxHeight + "px";
		obj['style']['display']	= "";
	}
	
	//对话框标题栏设置
	this.titleSet = function()
	{
		var obj = $('dialogBoxTitle');
		
		obj['style']['color'] = "#ffffff";
		obj['style']['background']	= "url(" + boxTitleBgImg +")";
		obj['style']['height'] = "14px";
		obj['style']['padding'] = "6px 8px";
		obj['style']['cursor'] = "move";
		obj['style']['display'] = "";
	}
		
	//对话框标题栏的关闭按钮设置
	this.closeSet = function()
	{
		var obj = $('dialogBoxClose');
		
		obj['style']['width']	= "14px";
		obj['style']['height'] = "14px";
		obj['style']['cursor'] = "pointer";
		obj['style']['display'] = "";
	}
		
	//对话框标题栏的确定按钮设置
	this.okSet = function()
	{
		var obj = $('buttonOk');
		
		obj['style']['cursor'] = "pointer";
		obj['style']['width']	= "50px";
		obj['style']['padding'] = "2px 0px 0px 0px";
		obj['style']['font'] = "normal 12px 宋体,Verdana";
		obj['style']['color'] = "#001037";
		obj['style']['border'] = "1px solid #245487";
		obj['style']['background'] = "#F7FCFF url(http://www.hengchu.cn/images/bg_btn.gif)";
	}
		
	//对话框标题栏的取消按钮设置
	this.cancelSet = function()
	{
		var obj = $('buttonCancel');
		
		obj['style']['cursor'] = "pointer";
		obj['style']['width']	= "50px";
		obj['style']['padding'] = "2px 0px 0px 0px";
		obj['style']['font'] = "normal 12px 宋体,Verdana";
		obj['style']['color'] = "#001037";
		obj['style']['border'] = "1px solid #245487";
		obj['style']['background'] = "#F7FCFF url(http://www.hengchu.cn/images/bg_btn.gif)";
	}
		
	//对话框内容设置
	this.contentSet = function()
	{
		var obj = $('dialogBoxContent');
		
		obj['style']['width']	= boxWidth + "px";
		obj['style']['height'] = "90px";
		obj['style']['display'] = "";
	}
	
	//对话框信息图片设置
	this.msgImgSet = function()
	{
		var obj = $('dialogBoxMsgImg');
		
		obj['style']['position'] = "relative";
		obj['style']['left'] = "10px";
		obj['style']['top'] = "15px";
		obj['style']['display'] = "";
	}
	
	//对话框信息设置
	this.msgSet = function()
	{
		var obj = $('dialogBoxMsg');
		
		obj['style']['width'] = boxWidth - 85 + "px";
		obj['style']['padding']	= "32px 0px 0px 0px";
		obj['style']['display'] = "";
	}
	
	//对话框阴影设置
	this.shadowSet = function()
	{
		var obj = $('dialogBoxShadow');
		var objDialog = $('dialogBox');
		
		obj['style']['position'] = "absolute";
		obj['style']['background']	= "#000000";
		obj['style']['z-index']	= 9;
		obj['style']['opacity']	= "0.2";
		obj['style']['filter'] = "alpha(opacity=30)";
		obj['style']['top'] = objDialog.offsetTop + shadowPx +"px";
		obj['style']['left'] = objDialog.offsetLeft + shadowPx + "px";
		obj['style']['width'] = boxWidth + "px";
		obj['style']['height'] = boxHeight + "px";
		obj['style']['display'] = "";
	}
	
	//大背景设置
	this.bgSet = function()
	{
		var obj = $('dialogBoxBg');
		
		obj['style']['position'] = "absolute";
		obj['style']['background']	= "#000000 url(" + blankBgImg + ")";
		obj['style']['z-index']	= 8;
		obj['style']['top'] = "0px";
		obj['style']['left'] = "0px";
		obj['style']['width'] = "100%";
		obj['style']['height'] = window.top.document.body.scrollHeight + "px";
		//obj['style']['height'] = "100%";
		obj['style']['display'] = "";
		obj['style']['filter'] = "alpha(opacity=30)";
	}
	
	//初始化对话框
	this.init = function()
	{
		$('dialogCase') ? $('dialogCase').parentNode.removeChild($('dialogCase')) : function(){};
		var oDiv = window.top.document.createElement('span');
		oDiv.id = "dialogCase";
		oDiv.innerHTML = divBg + divShadow + divBox;
		window.top.document.body.appendChild(oDiv);
		
		this.boxSet();
		this.titleSet();
		this.closeSet();
		this.okSet();
		this.cancelSet();
		this.contentSet();
		this.msgImgSet();
		this.msgSet();
		
		this.middle('dialogBox');
		
		this.shadowSet();
		this.bgSet();
	}
	
	//关闭对话框
	this.close = function()
	{
		$('dialogBoxBg')['style']['display'] = 'none';
		$('dialogBox')['style']['display'] = 'none';
		$('dialogBoxTitle')['style']['display'] = 'none';
		$('dialogBoxClose')['style']['display'] = 'none';
		$('dialogBoxContent')['style']['display'] = 'none';
		$('dialogBoxMsgImg')['style']['display'] = 'none';
		$('dialogBoxMsg')['style']['display'] = 'none';
		$('divBoxBotton')['style']['display'] = 'none';
		$('dialogBoxShadow')['style']['display'] = 'none';
	}
	
	//按钮的动作
	this.button = function(_sId, _sFuc)
	{
		if($(_sId))
		{
			$(_sId).style.display = '';
			if($(_sId).addEventListener)
			{
				if($(_sId).act)
				{
					$(_sId).removeEventListener('click', function(){eval($(_sId).act)}, false);
				}
				$(_sId).act = _sFuc;
				$(_sId).addEventListener('click', function(){eval(_sFuc)}, false);
			}
			else
			{
				if($(_sId).act){$(_sId).detachEvent('onclick', function(){eval($(_sId).act)});}
				$(_sId).act = _sFuc;
				$(_sId).attachEvent('onclick', function(){eval(_sFuc)});
			}
		}
	}
	
	//对话框居中
	this.middle = function(_sId)
	{
		var sClientWidth = window.top.document.body.clientWidth;
		var sClientHeight = window.top.document.body.clientHeight;
		var sScrollTop = window.top.document.documentElement.scrollTop;
		
		var obj = $(_sId);
		var left = (sClientWidth / 2) - (obj.offsetWidth / 2) - (shadowPx / 2) + "px";
		var top = sScrollTop + 180 + "px";//注意

		obj['style']['display'] = '';
		obj['style']['position'] = "absolute";
		obj['style']['left'] = left;
		obj['style']['top'] = top;
	}
	
	//移动对话框
	this.moveStart = function (event, _sId)
	{
		var oObj = $(_sId);
		oObj.onmousemove = mousemove;
		oObj.onmouseup = mouseup;
		oObj.setCapture ? oObj.setCapture() : function(){};
		oEvent = window.event ? window.event : event;
		var dragData = {x : oEvent.clientX, y : oEvent.clientY};
		var backData = {x : parseInt(oObj.style.top), y : parseInt(oObj.style.left)};
		function mousemove()
		{
			var oEvent = window.event ? window.event : event;
			var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left);
			var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top);
			oObj.style.left = iLeft + "px";
			oObj.style.top = iTop + "px";
			$('dialogBoxShadow').style.left = iLeft + shadowPx + "px";
			$('dialogBoxShadow').style.top = iTop + shadowPx + "px";
			dragData = {x: oEvent.clientX, y: oEvent.clientY};
			
		}
		function mouseup()
		{
			var oEvent = window.event ? window.event : event;
			oObj.onmousemove = null;
			oObj.onmouseup = null;
			if(oEvent.clientX < 1 || oEvent.clientY < 1 || oEvent.clientX > window.top.document.body.clientWidth || oEvent.clientY > window.top.document.body.clientHeight)
			{
				oObj.style.left = backData.y + "px";
				oObj.style.top = backData.x + "px";
				$('dialogBoxShadow').style.left = backData.y + shadowPx + "px";
				$('dialogBoxShadow').style.top = backData.x + shadowPx + "px";
			}
			oObj.releaseCapture ? oObj.releaseCapture() : function(){};
		}
	}
}

//------------------------------------------------------
//作用：显示信息对话框
//参数：
//	   msgStr：			要显示的信息内容
//	   infoType：		信息(图片)类别: 0 为消息,1 为是否(将显示取消按钮), 2 为成功, 3 为失败, 4 为警告
//	   actType：		确定按钮返回的操作:
//						0 为无操作
//						1 为关闭窗口
//						2 为返回上一页
//						3 为转到连接地址
//						4 为新窗口打开连接地址
//						5 为框架内执行连接地址
//						6 为框架内执行连接地址(删除)
//						7 为窗口转向自定义地址
//						8 为父框架转向自定义地址
//						9 为本框架转向自定义地址
//						10 为子框架转向自定义地址
//						11 为刷新当前窗口
//						12 为刷新父窗口
//						13 为提交表单
//						其他 或者可填写其他自定义函数
//		obj:			页面上传来的对象,直接写this, 如果对象不是连接则请写连接地址
//------------------------------------------------------
var objPage

function showDialog(msgStr, infoType, actType, obj)
{
	var iconImg, cancelBtn, okBtn;
	
	msgStr = msgStr ? msgStr : "恒初提醒您";
	infoType = infoType ? infoType : 0;
	actType = actType ? actType : 0;
	obj = obj ? obj : "";
	objPage = obj;
	
	switch (infoType)
	{
		case 0:
			iconImg = 0;
			cancelBtn = "";
			break;
		
		case 1:
			iconImg = 1;
			cancelBtn = " ";
			break;
		
		case 2:
			iconImg = 2;
			cancelBtn = "";
			break;
		
		case 3:
			iconImg = 3;
			cancelBtn = "";
			break;
		
		case 4:
			iconImg = 4;
			cancelBtn = "";
			break;
		
		default:
			iconImg = 0;
			cancelBtn = "";
			break;
	}
	
	switch (actType)
	{
		case 0:
			okBtn = " ";
			break;
		
		case 1:
			okBtn = "window.top.opener = null;window.top.close();";
			break;
		
		case 2:
			okBtn = "history.go(-1);";
			break;
		
		case 3:
			okBtn = "document.location.href = '" + obj.href + "';";
			break;
		
		case 4:
			okBtn = "window.open('" + obj.href + "');";
			break;
		
		case 5:
			okBtn = "frameSrc('" + obj.href + "');"
			break;
		
		case 6:
			okBtn = "frameSrcDel('" + obj.href + "');";
			break;
		
		case 7:
			okBtn = "window.top.document.location.href = '" + obj + "';";
			break;
		
		case 8:
			okBtn = "parent.document.location.href = '" + obj + "';";
			break;
		
		case 9:
			okBtn = "document.location.href = '" + obj + "';";
			break;
		
		case 10:
			okBtn = "frameSrc('" + obj + "');"
			break;
		
		case 11:
			okBtn = "document.location.reload();";
			break;
		
		case 12:
			okBtn = "parent.document.location.reload();";
			break;
		
		case 13:
			okBtn = "formSubmit(document.getElementById('" + obj.id + "'));";
			break;
		
		default:
			okBtn = actType;
			break;
	}
	
	var dg = new dialog();
	dg.showBox(msgStr, iconImg, okBtn, cancelBtn);
	return false;
}

//创建一个隐藏的框架
function createFrame()
{
	var oFrame = document.createElement("iframe");
	oFrame.id = "OptionFrame";
	oFrame.name = "OptionFrame";
	oFrame.width = "0";
	oFrame.height = "0";
	oFrame.src = "";
	document.body.appendChild(oFrame);
	document.getElementById('OptionFrame')['style']['display'] = 'none';
}

//隐藏框架内执行连接地址
function frameSrc(hrefSrc)
{
	document.getElementById('OptionFrame') ? function(){} : createFrame();
	document.getElementById('OptionFrame').src = hrefSrc;
}

//删除表格<tr>,隐藏框架内执行连接地址
function frameSrcDel(hrefSrc)
{
	if (objPage.parentNode.parentNode.tagName == 'TR')
	{
		objPage.parentNode.parentNode.parentNode.removeChild(objPage.parentNode.parentNode);
	}
	frameSrc(hrefSrc);
}

//提交表单
function formSubmit(obj)
{

//alert(obj.id);
	var objForm
	objForm = document.getElementById(obj.form.id);
	
	var objInput = document.createElement("input");
	objInput.id = "SubmitType";
	objInput.name = "SubmitType";
	objInput.value = obj.value;
	objInput.type = "hidden";

	objForm.appendChild(objInput);
	objForm.method="post";
	objForm.submit();
	
	objForm.removeChild(objInput);
}