<?xml version="1.0" encoding="utf-8"?>
<window screenLeft="0" screenTop="0" width="140" height="40" titleBar="false" resizeMargins="0,0,0,0" maximizable="false" onload="BalloonLoad();windowOnload();" onclose="windowOnClose();BalloonClose();" onsize="OnWindowSize();" layered="true">
<script src="../common.js" />
<script src="../BalloonCommon.js" />	
<script src="../Balloons.js" />
<script>
<![CDATA[
	var timerShow = 0;
	var timerMove = 0;

	var indexShow = 0;
	var numShow = 5;

	var wa = 0.0;
	var ha = 0.0;

	var iOrgX = 0;
	var iOrgY = 0;
	var iOrgWide = 0;
	var iOrgHigh = 0;
	var iOrgAX = 0;
	var iOrgBX = 0;

	var curX = 0;
	var curY = 0;
	var curW = 0.0;
	var curH = 0;
	var curAX = 0.0;
	var curBX = 0.0;
	//------------------------------------
	var lastAX = 0;
	var lastBX = 0;
	var lastPosX = 0;
	var lastWidth = 0.0;

	var iPWinLeft = 0;

	var g_WorkLeft = 0;
	var g_WorkRight = 0;

	function MY_DEBUG(strDebug)
	{
		if (!window.debug)
		{
			window.debug = Components.GetObject2("@pplive.com/outputdebug;1");
		}
		if(window.debug)window.debug.DebugString(strDebug);
	}

	function ShowTimer()
	{
		if(indexShow == 0)
		{
			wa = (iOrgWide)/(numShow*2.0);
			ha = (iOrgHigh)/(numShow*2.0);
			curX = iOrgX+iOrgWide/2.0;
			curY = iOrgY+iOrgHigh/2.0;	
			curW = 0;
			curH = 0;

			window.moveSizeTo(curX, curY, curW, curH);
			var balloonMgr = Components.GetObject("@pplive.com/BalloonManager;1");
			if(balloonMgr)		balloonMgr.ShowBalloon(window.hwnd, true);
		}
		curX -= wa;
		curY -= ha;
		curW += 2.0*wa;
		curH += 2.0*ha;
		window.moveSizeTo(curX, curY, curW, curH);
		++indexShow;
		if(indexShow>=numShow)
		{
			if(timerShow)		window.clearInterval(timerShow);
			timerShow = 0;
			window.moveSizeTo(iOrgX, iOrgY, iOrgWide, iOrgHigh);
			lastPosX = iOrgX;
			lastWidth = iOrgWide;

			lastBX = iOrgWide/2.0;
			indexShow = 0;
		}
	}
	
	var g_tmp = 0.0;
	function OnWindowSize()
	{
		window.setTimeout("$('subwin5').moveSizeTo(g_tmp-4, 34, 9, 6);", 1);
		$("subwin5").moveSizeTo(g_tmp-4, 34, 9, 6);
	}

	function UpdateAnchor(bIsFixPos)
	{
		var left = iPWinLeft + window.xAnchor - window.x;
		var balloonMgr = Components.GetObject("@pplive.com/BalloonManager;1");
		if(left < g_WorkLeft)
		{
			g_tmp = window.xAnchor + iPWinLeft-g_WorkLeft;
			if(balloonMgr)
				balloonMgr.BalloonAnchor(window.hwnd, g_tmp, window.y, window.owner, window.xAnchor, window.yAnchor, window);
			if(bIsFixPos)
			{
				lastAX = window.xAnchor;
				lastBX = g_tmp;
			}
			window.moveSizeTo(g_WorkLeft, window.screenTop, 2*window.x, iOrgHigh);
			$("subwin5").moveSizeTo(g_tmp-4, 34, 9, 6);
		}
		else if(left+2*window.x > g_WorkRight)
		{
			g_tmp = 2*window.x - g_WorkRight + window.xAnchor + iPWinLeft;
			if(balloonMgr)
				balloonMgr.BalloonAnchor(window.hwnd, g_tmp, window.y, window.owner, window.xAnchor, window.yAnchor, window);
			if(bIsFixPos)
			{
				lastAX = window.xAnchor;
				lastBX = g_tmp;
			}
			window.moveSizeTo(g_WorkRight-2*window.x, window.screenTop, 2*window.x, iOrgHigh);
			$("subwin5").moveSizeTo(g_tmp-4, 34, 9, 6);
		}
		else
		{
			if(balloonMgr)
				balloonMgr.BalloonAnchor(window.hwnd, window.x, window.y, window.owner, window.xAnchor, window.yAnchor, window);
			g_tmp = window.x;
			if(bIsFixPos)
			{
				lastAX = window.xAnchor;
				lastBX = g_tmp;
				window.moveSizeTo(iOrgX, window.screenTop, iOrgWide, iOrgHigh);
			}
			else
				window.moveSizeTo(left, window.screenTop, 2*window.x, iOrgHigh);
			window.setTimeout("$('subwin5').moveSizeTo(window.x-4, 34, 9, 6);", 1);
			$("subwin5").moveSizeTo(window.x-4, 34, 9, 6);
		}
	}

	var indexMove = 0;
	var numMove = 20;
	var blnaa = 0.0;
	var blnxa = 0.0;
	//	iOrgX:原始位置
	//	curX:当前位置
	//	lastPosX:上次位置
	//  lastWidth:上次宽度
	function MoveToTimer()
	{
		if(indexMove == 0)
		{
			blnaa = (iOrgAX - lastAX)/670.0;
			blnxa = (iOrgBX - lastBX)/670.0;
			curBX = lastBX;	
			curAX = lastAX;
			window.x = curBX;
			window.xAnchor = curAX;
			UpdateAnchor(0);
		}
		++indexMove;
		var a = ((indexMove>10)?(20-indexMove):indexMove);
		curBX += blnxa*a*a;
		curAX += blnaa*a*a;
		window.x = curBX;
		window.xAnchor = curAX;
		UpdateAnchor(0);
		if(indexMove>=numMove)
		{
			if(timerMove)		window.clearInterval(timerMove);
			timerMove = 0;
			curBX = iOrgBX;	
			curAX = iOrgAX;
			window.x = curBX;
			window.xAnchor = curAX;
			UpdateAnchor(1);
			lastBX = iOrgBX;
			lastAX = iOrgAX;
			indexMove = 0;
		}
	}
	//----------------------------------------------------------------------------
	function windowOnload()
	{
		window.timeClose = 0;
	//----------------------------------------------------------------------------
		window.SetTextAndShow = function(tm, ds, hwndparent, ax, ay, winleft, WorkLeft, WorkRight)
		{
			g_WorkLeft = (WorkLeft<=0)?WorkLeft:0;
			g_WorkRight = (WorkRight<=0)?(window.screen.width):WorkRight;

			iPWinLeft = winleft;
			$("time").value = tm;
			$("depiction").value = ds;
			var maxlen = $("time").textWidth > $("depiction").textWidth ? $("time").textWidth : $("depiction").textWidth;
			iOrgWide = (maxlen+16-(maxlen+6)%10);
			iOrgHigh = 40;
			iOrgX = window.screenLeft - iOrgWide/2.0;
			iOrgY = window.screenTop;
			lastAX = ax;
			var balloonMgr = Components.GetObject("@pplive.com/BalloonManager;1");

			var tmp = 0;
			if(iOrgX<g_WorkLeft)
			{
				tmp = winleft+ax-g_WorkLeft;
				iOrgX = g_WorkLeft;
			}
			else if(iOrgX+iOrgWide>g_WorkRight)
			{
				tmp = iOrgX+iOrgWide-g_WorkRight+iOrgWide/2.0;
				iOrgX = g_WorkRight-iOrgWide;
			}
			else
			{
				tmp = iOrgWide/2.0;
			}
			lastBX = tmp;
			g_tmp = tmp;
			if(balloonMgr)	balloonMgr.BalloonAnchor(window.hwnd, tmp, iOrgHigh, hwndparent, ax, ay, window);
			window.moveSizeTo(iOrgX, iOrgY, iOrgWide, 40);

			SizeTo(iOrgWide, iOrgHigh);
			//-----------------------------
			window.ResetTip();
			//删掉showtimer
			if(timerShow)
			{
				window.clearInterval(timerShow);	timerShow = 0;
				indexShow = 0;
			}
			timerShow = window.setInterval("ShowTimer();", 15);
		}
	//----------------------------------------------------------------------------
		window.SetTextAndMoveTo = function(tm, ds, hwndparent, ax, ay, winleft)
		{
			iPWinLeft = winleft;
			$("time").value = tm;
			$("depiction").value = ds;
			var maxlen = $("time").textWidth > $("depiction").textWidth ? $("time").textWidth : $("depiction").textWidth;
			iOrgWide = (maxlen+16-(maxlen+6)%10);
			iOrgX = winleft+ax-iOrgWide/2;
			//-----------------------------
			iOrgAX = ax;
			iOrgBX = iOrgWide/2;
			SizeTo(iOrgWide, iOrgHigh);
			//-----------------------------
			//先删掉timerShow
			if(timerShow)
			{
				window.clearInterval(timerShow);		timerShow = 0;
				if(indexShow!=0)
				{
					window.moveSizeTo(iOrgX, iOrgY, iOrgWide, iOrgHigh);
					lastPosX = iOrgX;
					lastWidth = iOrgWide;
					lastHigh = iOrgHigh;
					lastAX = iOrgAX;
					lastBX = iOrgWide/2.0;
					window.moveSizeTo(iOrgX, iOrgY, iOrgWide, iOrgHigh);
					UpdateAnchor(0);
					indexShow = 0;
				}
			}
			window.ResetTip();
			//删掉MoveToTimer
			if(timerMove)
			{
				window.clearInterval(timerMove);	timerMove = 0;
				if(indexMove!=0)
				{
					lastWidth = curW;	
					lastBX = window.x;
					lastAX = window.xAnchor;
					indexMove = 0;
				}
			}
			timerMove = window.setInterval("MoveToTimer();", 17);
		}
	//----------------------------------------------------------------------------
		window.ResetTip = function()
		{
			//重置timeClose
			if(window.timeClose)
			{
				window.clearTimeout(window.timeClose);
				window.timeClose = 0;
			}
		}
	//----------------------------------------------------------------------------
		window.CloseTip = function()
		{
			//重置timeClose
			if(window.timeClose)
			{
				window.clearTimeout(window.timeClose);
				window.timeClose = 0;
			}
			window.timeClose = window.setTimeout("window.close();", 2*1000);
		}
	//----------------------------------------------------------------------------
		window.ShutDownTip = function()
		{
			window.close();
		}
	}
	function windowOnClose()
	{
		if(timerShow && indexShow != 0)		window.clearInterval(timerShow);
		if(timerMove && indexMove != 0)		window.clearInterval(timerMove);
	}

	function SizeTo(wt, ht)
	{
		$("time").moveSizeTo(5, 5, wt-10, ht-25);
		$("depiction").moveSizeTo(5, 20, wt-10, ht-25);	
	}
]]>
</script>
	<subwindow id="subwin1" left="0" top="0" width="140" height="40"  passThrough="false" horizontalAlignment="stretch" verticalAlignment="stretch" >
		<subwindow id="subwin2" left="0" top="0" width="3" height="35" backgroundImage="mark_tips_l.png" clippingColor="#FF00FF" passThrough="false" horizontalAlignment="left"/>
		<subwindow id="subwin3" left="137" top="0" width="3" height="35" backgroundImage="mark_tip_r.png" clippingColor="#FF00FF" passThrough="false" horizontalAlignment="right"/>
		<subwindow id="subwin4" left="3" top="0" width="134" height="35" backgroundImage="mark_tip_m.png"  backgroundImageStretchMode="stretch" passThrough="false" horizontalAlignment="stretch" backgroundColor="rgba(0x00,0x00,0x00,0x00)"/>

		<subwindow id="subwin5" left="65" top="34" width="9" height="6" backgroundImage="mark_tip_arrow.png" passThrough="false" clippingColor="#FF00FF" horizontalAlignment = "left"/>

		<label id="time" left="5" top="5" width="130" height="15" wordWrap="false" value="00:00:00" fontFace="宋体"  fontSize="12" foregroundColor="rgba(0x15,0x15,0x15,0.999)" horizontalAlignment="left"/>
		<label id="depiction" left="5" top = "20" width="130" height="15" wordWrap="false" value="" fontFace="宋体"  fontSize="12" foregroundColor="rgba(0x15,0x05,0x15,0.999)" horizontalAlignment="left"/>
	</subwindow>
</window>