﻿<!--
//制作：柯培宗 2006-08-03
//修改：柯培宗 2006-08-03　解决有滚动条提示框无法居中的问题
//修改：柯培宗 2006-08-03　可自定义是否让窗口延时关闭.
//修改: 柯培宗 2006-08-04  解决多次点击关闭造成丢失对象的情况
//功能：弹出一个DIV层提示
//调用示例：AlertDiv(250,80,"评论删除成功!",1000);
//函数名称：AlertDiv(w,h,msg,time)
//参数列表：w:	窗口宽度
//			h:  窗口高度
//			title:提示框标题
//			msg:消息内容
//			time:延时时间，0为不消失
var x0=0,y0=0,x1=0,y1=0;
var offx=6,offy=6;
var moveable=false;
var hover='#FFA600',normal='#5A8642';//color;
var index=10000;//z-index;
//开始拖动;
function startDrag(obj)
{
	if(event.button==1)
	{
		//锁定标题栏;
		obj.setCapture();
		//定义对象;
		var win = obj.parentNode;
		//记录鼠标和层位置;
		x0 = event.clientX;
		y0 = event.clientY;
		x1 = parseInt(win.style.left);
		y1 = parseInt(win.style.top);
		//记录颜色;
		normal = obj.style.backgroundColor;
		//改变风格;
		obj.style.backgroundColor = hover;
		win.style.borderColor = hover;
		moveable = true;
	}
}
//拖动;
function drag(obj)
{
	if(moveable)
	{
		var win = obj.parentNode;
		win.style.left = x1 + event.clientX - x0;
		win.style.top  = y1 + event.clientY - y0;
	}
}
//停止拖动;
function stopDrag(obj)
{
	if(moveable)
	{
		var win = obj.parentNode;
		var msg = obj.nextSibling;
		win.style.borderColor     = normal;
		obj.style.backgroundColor = normal;
		msg.style.color           = normal;
		obj.releaseCapture();
		moveable = false;
	}
}
//获得焦点;
function getFocus(obj)
{
	if(obj.style.zIndex!=index)
	{
		index = index + 2;
		var idx = index;
		obj.style.zIndex=idx;
	}
}
//最小化;
function min(obj)
{
	var win = obj.parentNode.parentNode;
	var tit = obj.parentNode;
	var msg = tit.nextSibling;
	var confirmbutton=msg.nextSibling;
	var flg = msg.style.display=="none";
	if(flg)
	{
		win.style.height  = parseInt(msg.style.height) + parseInt(tit.style.height) + 2*2;
		msg.style.display = "block";
		confirmbutton.style.display = "block";
		obj.innerHTML = "0";
	}
	else
	{
		win.style.height  = parseInt(tit.style.height) + 2*2;
		obj.innerHTML = "2";
		msg.style.display = "none";
		confirmbutton.style.display = "none";
	}
}
//关闭;
function cls(obj)
{
	if(obj&&obj.parentNode&&obj.parentNode.parentNode)//防止多次点击造成丢失对象的情况2006-08-04
	{
		var win = obj.parentNode.parentNode;
		win.parentElement.removeChild(win);
	}
}
//创建一个对象;
function AlertDiv(w,h,title,msg,time)
{
	var tdiv=document.createElement("div");
	index = index+2;
	tdiv.id      = "591upmsg";
	tdiv.width   = w;
	tdiv.height  = h;
	tdiv.left    = (document.body.offsetWidth/2)-(w/2);
	tdiv.top     = (document.body.offsetHeight/2)+document.body.scrollTop-(h/2);
	tdiv.zIndex  = index;
	tdiv.title   = title;//"591UP温馨提醒：";
	tdiv.message = msg;
	tdiv.obj     = null;
	tdiv.bulid   = bulid;
	tdiv.bulid();
	if (time!="0") {
		var m_timeout=setTimeout("cls(document.getElementById('tempid'));",time)
	}
}
//初始化;
function bulid()
{
	var str = ""
		+ "<div id=" + this.id + " "
		+ "style='"
		+ "z-index:" + this.zIndex + ";"
		+ "width:" + this.width + ";"
		+ "height:" + this.height + ";"
		+ "left:" + this.left + ";"
		+ "top:" + this.top + ";"
		+ "background-color:#5499DC;"
		+ "color:" + normal + ";"
		+ "font-size:12px;"
		+ "font-family:Verdana;"
		+ "position:absolute;"
		+ "border:2px solid #5499DC;filter:progid:dximagetransform.microsoft.shadow(color=#333333,direction=120,strength=5)"
		+ "' "
		+ "onmousedown='getFocus(this)'>"
			+ "<div "
			+ "style='"
			+ "background-color:" + normal + ";"
			+ "width:" + (this.width-2*2) + ";"
			+ "height:20;"
			+ "color:white;cursor:default;"
			+ "' "
			+ "onmousedown='startDrag(this);' "
			+ "onmouseup='stopDrag(this);' "
			+ "onmousemove='drag(this);' "
			+ "ondblclick='min(this.childNodes[1])'"
			+ ">"
				+ "<span style='width:" + (this.width-36-4) + ";padding-left:3px;'>" + this.title + "</span>"
				+ "<span id=tempid style='width:18;border-width:0px;color:white;font-size:15px;font-family:webdings;cursor:hand;' onclick='min(this)' title=最小化或还原>0</span>"
				+ "<span style='width:18;border-width:0px;cursor:hand;' onclick='cls(this)' title=关闭591up><img src=skin/closeMode.gif border=0 align=absmiddle></span>"
			+ "</div>"
			+ "<div style='"
				+ "width:100%;"
				+ "height:" + (this.height-50-4) + ";"//减去上下两个Div的高度（４０）
				+ "background-color:white;"
				+ "line-height:14px;"
				+ "word-break:break-all;"
				+ "padding:3px;'>"
				+ "<div style=display:inline;float:left;padding:0px;padding-top:20px;><img src=skin/DivAlertTip.gif border=0></div><div style=display:inline;float:left;padding:0px;padding-top:40px;>" + this.message + "</div>"
			+ "</div>"
			+ "<div style='width:100%;height:30;background-color:white;text-align:center;vertical-align:middle;'>"
				+ "<input type=button name=alertconfirm value=确定 onclick='cls(this);' onmousedown='cls(this);' class=btn></div>"
			+ "</div>"
		+ "</div>"
	document.body.insertAdjacentHTML("beforeEnd",str);
}
//-->
