var show_message_div_mtop=0;    //记录上升到的最大Y坐标
var show_message_div_ttop=0;	//记录当前的Y坐标
var show_message_div_mwidth=0;//层的宽度
var show_message_div_mheight=0;//层的高度
var show_message_div_imgs=new Array("../Images/info.png","../Images/yes.png","../Images/err.png");
var mouse_in_show_message_div=false;//判断是否鼠标存于层上
var show_message_div_showtime=0;//显示的时间


var show_message_div_timer;//设置隐藏显示的


var show_message_div_stitle;//设置提示标题
var show_message_div_msg_color;
var show_message_div_title_color;

at_msgbox_init();
initShowMessage_Div();
	//设置初始参数的


function at_msgbox_init(stitle,mwidth,mheight,showTime,title_color,msg_color){
	if(typeof(stitle)=="undefined"){
		stitle="DMS系统信息提示";
	}
	if(typeof(title_color)=="undefined"){
		title_color='#6190CD';
	}
	if(typeof(msg_color)=="undefined"){
		msg_color='#DAEEFF';
	}
	if(typeof(mwidth)=="undefined"){
		mwidth=300;
	}
	if(typeof(mheight)=="undefined"){
		mheight=130;
	}
	if(typeof(showTime)=="undefined"){
		showTime=3000;
	}

	show_message_div_mwidth=mwidth;
	show_message_div_mheight=mheight;
	show_message_div_showtime=showTime;
	show_message_div_stitle=stitle;
	show_message_div_msg_color=msg_color;
	show_message_div_title_color=title_color;
}
/////////////////输出//////////////////////////////////////
function initShowMessage_Div(){

/*
	document.write("<div align='right' id='show_message_div' onMouseOver='mouse_in_show_message_div=true;' onMouseOut='mouse_in_show_message_div=false;'");
	document.write(" style='width:"+show_message_div_mwidth+";height:"+show_message_div_mheight+";visibility=hidden;background-color:"+show_message_div_msg_color+";position:absolute;left:50;top:300;'>");
	document.write("<table border=0 style='background-color:"+show_message_div_title_color+";' width="+show_message_div_mwidth+"><tr><td><div id='show_message_div_tspan'>"+show_message_div_stitle+"</div></td><td align='right'><span style='cursor:hand' onclick=\"document.getElementById('show_message_div').style.visibility='hidden'\">[X]</span></td></tr></table><div align='center' id='div_message_show'>asd</div></div>");
*/
document.write("<div align='right' id='show_message_div' onMouseOver='mouse_in_show_message_div=true;' onMouseOut='mouse_in_show_message_div=false;' style='width:"+show_message_div_mwidth+";height:"+show_message_div_mheight+";visibility=hidden;background-color:"+show_message_div_msg_color+";position:absolute;left:50;top:300;overflow-y:hidden'>");
document.write("<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0' class='Table'><tr><td class='Table_title'>");
document.write("<table width='100%' border='0' cellspacing='0' cellpadding='4'><tr><td width='100%'>");
document.write("<div id='show_message_div_tspan'>"+show_message_div_stitle+"</div></td>");
document.write("<td><span style='cursor:hand' onclick=\"document.getElementById('show_message_div').style.visibility='hidden'\">[X]</span></td></tr></table></td></tr><tr>");
document.write("<td align='center'><table width='96%' height='100%' border='0' cellspacing='0' cellpadding='4'><tr>");
document.write("<td><img id='show_message_div_img' src='../Images/info.png' width='64' height='64'></td><td width='100%'>");
document.write("<div align='center' id='div_message_show'>asd</div></td></tr></table></td></tr></table></div>");

window.onscroll=setShowMessage_Div;
window.onresize=setShowMessage_Div;
}
/////////////////////////设置位置///////////////////////
function setShowMessage_Div(){
//设置层显示的横坐标


	document.getElementById("show_message_div").style.left=document.body.scrollLeft + document.body.clientWidth - show_message_div_mwidth;
//设置层显示的纵坐标,并重新记录位置


	var tmp=show_message_div_mtop - show_message_div_ttop;
	show_message_div_mtop=document.body.clientHeight+document.body.scrollTop-show_message_div_mheight;
	show_message_div_ttop=show_message_div_mtop-tmp;
	document.getElementById("show_message_div").style.top=show_message_div_ttop;
}

function show_message_div_show(){//显示层的函数
	if(show_message_div_mtop<show_message_div_ttop^show_message_div_mtop<show_message_div_ttop-4){
		show_message_div_ttop=show_message_div_mtop;
		document.getElementById("show_message_div").style.top=show_message_div_mtop;
		document.getElementById("show_message_div").style.height=show_message_div_mheight;//显示层的高度
		show_message_div_timer=setTimeout("show_message_div_hidden()",show_message_div_showtime);
	}
	else{
		show_message_div_ttop=show_message_div_ttop-4;
		document.getElementById("show_message_div").style.top=show_message_div_ttop;
		document.getElementById("show_message_div").style.height=parseInt(document.getElementById("show_message_div").style.height)+4;
		show_message_div_timer=setTimeout("show_message_div_show()",5);
	}
}
function show_message_div_hidden(){//隐藏层的函数
	if(mouse_in_show_message_div){//当前鼠标在div上则退出
		show_message_div_timer=setTimeout("show_message_div_hidden()",20);
		return;
	}
	if(show_message_div_mtop+show_message_div_mheight>show_message_div_ttop^show_message_div_mtop+show_message_div_mheight>show_message_div_ttop+4){
		document.getElementById("show_message_div").style.visibility="hidden";
		//把层设置到上方，避免因层出现滚动条
		document.getElementById("show_message_div").style.top=0;
		document.getElementById("show_message_div").style.height=0;
		show_message_div_mtop=0;
		show_message_div_ttop=0;
	}
	else{
		document.getElementById("show_message_div").style.height=parseInt(document.getElementById("show_message_div").style.height)-4;
		show_message_div_ttop=show_message_div_ttop+4;
		document.getElementById("show_message_div").style.top=show_message_div_ttop;
		show_message_div_timer=setTimeout("show_message_div_hidden()",5);
	}
}

///////用来显示消息的函数

/*
 * 参数1： 提示基本信息
 * 参数2： 提示图标类型 【0-普通信息 1-操作成功 2-操作失败】默认值是0
 * 参数3： 提示信息的标题 默认是 "DMS系统信息提示"
*/
function at_msgbox(msg,iImagType,stitle){ 
	document.getElementById("show_message_div").style.visibility="hidden";
	document.getElementById("show_message_div").style.height=0;
	document.getElementById("show_message_div").style.top=0;
	document.getElementById("show_message_div").style.left=0;
	if(typeof(msg)=="undefined" || msg=="null" || msg==""){
		
		return;
	}
	if(typeof(iImagType)=="undefined"){
		iImagType=0;
	}
	if(typeof(stitle)=="undefined"){
		stitle=show_message_div_stitle;
	}
	document.getElementById("show_message_div_tspan").innerHTML=stitle;
	document.getElementById("show_message_div_img").src=show_message_div_imgs[iImagType];
	//显示值并显示层


	clearTimeout(show_message_div_timer);
	document.getElementById("div_message_show").innerHTML=msg;
	document.getElementById("show_message_div").style.height=0;
	document.getElementById("show_message_div").style.visibility="visible";
	show_message_div_ttop=document.body.clientHeight+document.body.scrollTop;
	show_message_div_mtop=show_message_div_ttop-show_message_div_mheight;
	document.getElementById("show_message_div").style.top=show_message_div_ttop;
	document.getElementById("show_message_div").style.left=document.body.scrollLeft+document.body.clientWidth-show_message_div_mwidth;
	show_message_div_show();
}