//可以打包为js文件;
var x0=0,y0=0,x1=0,y1=0;
var offx=6,offy=6;
var moveable=false;
var hover='orange',normal='#336699';//color;
var index=10000;//z-index;
//开始拖动;
function startdrag(obj)
{
	if(event.button==1)
	{
		//锁定标题栏;
		obj.setcapture();
		//定义对象;
		var win = obj.parentnode;
		var sha = win.nextsibling;
		//记录鼠标和层位置;
		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;
		obj.nextsibling.style.color = hover;
		sha.style.left = x1 + offx;
		sha.style.top  = y1 + offy;
		moveable = true;
	}
}
//拖动;
function drag(obj)
{
	if(moveable)
	{
		var win = obj.parentnode;
		var sha = win.nextsibling;
		win.style.left = x1 + event.clientx - x0;
		win.style.top  = y1 + event.clienty - y0;
		sha.style.left = parseint(win.style.left) + offx;
		sha.style.top  = parseint(win.style.top) + offy;
	}
}
//停止拖动;
function stopdrag(obj)
{
	if(moveable)
	{
		var win = obj.parentnode;
		var sha = win.nextsibling;
		var msg = obj.nextsibling;
		win.style.bordercolor     = normal;
		obj.style.backgroundcolor = normal;
		msg.style.color           = normal;
		sha.style.left = obj.parentnode.style.left;
		sha.style.top  = obj.parentnode.style.top;
		obj.releasecapture();
		moveable = false;
	}
}
//获得焦点;
function getfocus(obj)
{
	if(obj.style.zindex!=index)
	{
		index = index + 2;
		var idx = index;
		obj.style.zindex=idx;
		obj.nextsibling.style.zindex=idx-1;
	}
}
//最小化;
function min(obj)
{
	var win = obj.parentnode.parentnode;
	var sha = win.nextsibling;
	var tit = obj.parentnode;
	var msg = tit.nextsibling;
	var flg = msg.style.display=="none";
	if(flg)
	{
		win.style.height  = parseint(msg.style.height) + parseint(tit.style.height) + 2*2;
		sha.style.height  = win.style.height;
		msg.style.display = "block";
		obj.innerhtml = "0";
	}
	else
	{
		win.style.height  = parseint(tit.style.height) + 2*2;
		sha.style.height  = win.style.height;
		obj.innerhtml = "2";
		msg.style.display = "none";
	}
}
//创建一个对象;
function xwin(id,w,h,l,t,tit,msg)
{
	index = index+2;
	this.id      = id;
	this.width   = w;
	this.height  = h;
	this.left    = l;
	this.top     = t;
	this.zindex  = index;
	this.title   = tit;
	this.message = msg;
	this.obj     = null;
	this.bulid   = bulid;
	this.bulid();
}
//初始化;
function bulid()
{
	var str = ""
		+ "<div id=xmsg" + this.id + " "
		+ "style='"
		+ "z-index:" + this.zindex + ";"
		+ "width:" + this.width +";"
		+ "height:" + this.height + ";"
		+ "left:" + this.left + ";"
		+ "top:" + this.top + ";"
		+ "background-color:" + normal + ";"
		+ "color:" + normal + ";"
		+ "font-size:8pt;"
		+ "font-family:tahoma;"
		+ "position:absolute;"
		+ "cursor:default;"
		+ "border:1px solid " + normal + ";"
		+ "' "
		+ "onmousedown='getfocus(this)'>"
			+ "<div "
			+ "style='"
			+ "background-color:" + normal + ";"
			+ "width:" + (this.width-2*2) + ";"
			+ "height:20;"
			+ "color:white;"
			+ "' "
			+ "onmousedown='startdrag(this)' "
			+ "onmouseup='stopdrag(this)' "
			+ "onmousemove='drag(this)' "
			+ "ondblclick='min(this.childnodes[1])'"
			+ ">"
				+ "<span style='width:" + (this.width-2*12-4) + ";padding-left:3px;'>" + this.title + "</span>"
				+ "<span style='width:12;border-width:0px;color:white;font-family:webdings;' onclick='min(this)'>0</span>"
				+ "<span style='width:12;border-width:0px;color:white;font-family:webdings;' onclick='showhide(\""+this.id+"\",null)'>r</span>"
			+ "</div>"
				+ "<div style='"
				+ "width:100%;"
				+ "height:" + (this.height-20-4) + ";"
				+ "background-color:white;"
				+ "line-height:14px;"
				+ "word-break:break-all;"
				+ "padding:3px;"
				+ "'>" + this.message + "</div>"
		+ "</div>"
		+ "<div id=xmsg" + this.id + "bg style='"
		+ "width:" + this.width + ";"
		+ "height:" + this.height + ";"
		+ "top:" + this.top + ";"
		+ "left:" + this.left + ";"
		+ "z-index:" + (this.zindex-1) + ";"
		+ "position:absolute;"
		+ "background-color:black;"
		+ "filter:alpha(opacity=40);"
		+ "'></div>";
	document.body.insertadjacenthtml("beforeend",str);
}
//显示隐藏窗口
function showhide(id,dis){
	var bdisplay = (dis==null)?((document.getelementbyid("xmsg"+id).style.display=="")?"none":""):dis
	document.getelementbyid("xmsg"+id).style.display = bdisplay;
	document.getelementbyid("xmsg"+id+"bg").style.display = bdisplay;
}

function initialize()
{
	var a = new xwin("1",105,400,5,50,"旅游在线客服","<h2>散客旅游咨询</h2><p><a href=http://float2006.tq.cn/static.jsp?uin=8178407&ltype=0 target=_blank>龙小姐<img src=http://float2006.tq.cn/staticimg.jsp?uin=8178407&style=1 border=0></a></p><p><a href=http://float2006.tq.cn/static.jsp?uin=8178408&ltype=0 target=_blank>黄先生<img src=http://float2006.tq.cn/staticimg.jsp?uin=8178408&style=1 border=0></a></p><h2>包团旅游咨询</h2><p><a href=http://float2006.tq.cn/static.jsp?uin=8178408&ltype=0 target=_blank>黄先生<img src=http://float2006.tq.cn/staticimg.jsp?uin=8178408&style=1 border=0></a></p><h2>租车咨询</h2><p><a href=http://float2006.tq.cn/static.jsp?uin=8178408&ltype=0 target=_blank>黄先生<img src=http://float2006.tq.cn/staticimg.jsp?uin=8178408&style=1 border=0></a></p><p><a href=http://float2006.tq.cn/static.jsp?uin=8178407&ltype=0 target=_blank>龙小姐<img src=http://float2006.tq.cn/staticimg.jsp?uin=8178407&style=1 border=0></a></p><h2>景区酒店预定</h2><p><a href=http://float2006.tq.cn/static.jsp?uin=8178407&ltype=0 target=_blank>龙小姐<img src=http://float2006.tq.cn/staticimg.jsp?uin=8178407&style=1 border=0></a></p><p><a href=http://float2006.tq.cn/static.jsp?uin=8178408&ltype=0 target=_blank>黄先生<img src=http://float2006.tq.cn/staticimg.jsp?uin=8178408&style=1 border=0></a></p><h2>机票预定</h2><p><a href=http://float2006.tq.cn/static.jsp?uin=8178407&ltype=0 target=_blank>龙小姐<img src=http://float2006.tq.cn/staticimg.jsp?uin=8178407&style=1 border=0></a></p><p><a href=http://float2006.tq.cn/static.jsp?uin=8178408&ltype=0 target=_blank>黄先生<img src=http://float2006.tq.cn/staticimg.jsp?uin=8178408&style=1 border=0></a></p><a href=http://qtt.tq.cn/leavemsg.do?uin=8178290&page=&ltype=0><img src=http://www.66sc.com/files/ads/tel.jpg alt=免费电话></a>");
	showhide("1","");//隐藏窗口1
}


