var ie = (navigator.appVersion.indexOf("MSIE")!=-1);//IE
var ff = (navigator.userAgent.indexOf("Firefox")!=-1);//Firefox
document.write("<div id=\"msgbox\"></div>");
document.write("<div id=\"msgboxbg\"></div>");
Array.prototype.c = Array.prototype.concat;
function buffer(msg,url)
{
	var s = "<div style=\"background:#6A6A6A;width:100%;height:18px;\"><div id=\"msgTitle\" style=\"float:left;text-align:left;padding-left:6px;color:#fff\">信息提示框</div><div style=\"float:right\"><a href=\"javascript:;\" title=\"关闭\"><img onclick=\"hidemsgbox();\" src=\"http://images.9hy.com/blog/common/msgbox/close.gif\" onmouseover=\"this.src='http://images.9hy.com/blog/common/msgbox/closea.gif'\" onmouseout=\"this.src='http://images.9hy.com/blog/common/msgbox/close.gif'\"></a></div></div><div id=\"theMsgBox\" style='width:90%;padding: 6px 6px 6px 6px;float:center;text-align:left;background:#fff;'><div id=\"mainMsgBox\"><div id=\"theMsgIcon\" style=\"height:100%;width:68px;float:left\"><img id=\"MsgIcon\" src=\"http://images.9hy.com/blog/common/msgbox/succeed.gif\"></div><div id=\"theMsg\">"+msg+"</div></div></div>"; 
	document.getElementById("msgbox").innerHTML = s;
}

var msgbox = document.getElementById("msgbox");
var msgboxbg = document.getElementById("msgboxbg");
var body = document.body;
var ex=0,ey=0;
function showmsgbox(evt,msg,url)
{
	ex = evt.clientX;ey = evt.clientY;
	buffer(msg,url);
	rxy();
	msgbox.style.display = "block";
	msgboxbg.style.display = "block";
	evt.cancelBubble = true;
	return false;
}

function rxy()
{
	var step=3;
	if(ie){step=1}
	if(ff){step=6}
	
	if(ex+150>body.clientWidth)
	{
		msgbox.style.left = ex - 150;
		msgboxbg.style.left = ex - 150 + step;
	}
	else
	{
		msgbox.style.left = ex;
		msgboxbg.style.left = ex + step;
	}
	if(ey+200>body.clientHeight)
	{
		msgbox.style.top = ey - 160;
		msgboxbg.style.top = ey - 160 + step;
	}
	else
	{
		msgbox.style.top = ey;
		msgboxbg.style.top = ey + step;
	}
	
	//middle("msgbox");
	//middle("msgboxbg");
}
function hidemsgbox()
{
	msgbox.style.display = "none";
	msgboxbg.style.display = "none";
}
function middle(sId)
{
	document.getElementById(sId)['style']['display'] = '';
	document.getElementById(sId)['style']['position'] = "absolute";
	document.getElementById(sId)['style']['left'] = (document.body.clientWidth / 2) - (document.getElementById(sId).offsetWidth / 2);
	document.getElementById(sId)['style']['top'] = (document.body.clientHeight / 2 + document.body.scrollTop) - (document.getElementById(sId).offsetHeight / 2);
}

function msgstat(theStat)
{
	if (theStat=='fail')
	{
		$('MsgIcon').src='http://images.9hy.com/blog/common/msgbox/fail.gif';
	}
	else
	{
		$('MsgIcon').src='http://images.9hy.com/blog/common/msgbox/succeed.gif';
	}
}