var init=false;
var strhtmlcontent=GetObj("tracqfloater").innerHTML;

self.onError=function(){return ture;};

lastScrollX = 0; lastScrollY = 0;

NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;

var FloatIsClose=false;	
function GetObj(id)
{
     if (document.getElementById)
         return document.getElementById(id);
     else
	{
        if (document.all)
			return document.all(id);
	}
}


//===============================================================//
//==============07.06.12加了能让用户设置飘浮框距右边多远=========//
//===============================================================//
var IE=((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >=4));
var FF=(navigator.appName=="Netscape");
function GetWinWidth()
{
	if(IE)//增加了对xhtml的支持 ，当不是用xhtml时,用document.body.clientHeight，而用document.documentElement.clientHeight会取值永远为0
	{
		if(document.documentElement.clientHeight==0)//html
		{
			winH=document.body.clientHeight;
			winW=document.body.clientWidth;
		}
		else
		{
			winH=document.documentElement.clientHeight-2;//xhtml
			winW=document.documentElement.clientWidth-2;
		}
	}
	if(FF)
	{
		winH=(document.documentElement.clientHeight);//在firefox下无法判断是否是xhtml了，只能取个最小的让浮动框能显示就行啦，晕死了，标准太混乱啊
		winW=(document.documentElement.clientWidth);
	}
	return winW;
}
/*
function resetPos()
{
	GetObj("tracqfloater").style.left=(GetWinWidth()-parseInt(GetObj("tracqfloater").style.width)-parseInt(rightX))+"px";
}

if(typeof(rightX)!="undefined")
{
	resetPos();
	window.onresize=function(){resetPos()};
}
*/
//如果飘浮框服务器不加rightX这个参数，那么就根据GetObj("tracqfloater").style.left是正数还是负数来判定是距左还是距右，负数时为距右多少
var rightX=0;
if(parseInt(GetObj("tracqfloater").style.left)<0)
{
	rightX=-parseInt(GetObj("tracqfloater").style.left);
	resetPos();
	window.onresize=function(){resetPos()};
}
function resetPos()
{
	//GetObj("tracqfloater").style.left=(GetWinWidth()-parseInt(GetObj("tracqfloater").style.width)-rightX)+"px";
	GetObj("tracqfloater").style.left=(GetWinWidth()-118-rightX)+"px";
}

//===============================================================//
//===============================================================//
//===============================================================//


	function hidenbox(o)
	{
		if(o.style.visibility == "hidden")
		{
			o.style.visibility = "visible";
		}
		else
		{
			o.style.visibility = "hidden";
		}
		document.all.tracqfloater1.style.visibility ="hidden";
                o.style.visibility = "hidden";
	}
	function hidenbox1(o,p)
        {
        				FloatIsClose=true;
                o.style.visibility = "hidden";
                p.style.visibility = "hidden";
        }

	function heartBeat()
	{

		diffY = getScrollTop();
		diffX = getScrollLeft(); 
		if(diffY != lastScrollY) 
		{
			percent = .1 * (diffY - lastScrollY);
			if(percent > 0)	
				percent = Math.ceil(percent);
			else 
				percent = Math.floor(percent);
			
			if(NS)
				document.tracqfloater.top += percent; 
			temptop=parseInt(GetObj("tracqfloater").style.top);
			GetObj("tracqfloater").style.top = percent+temptop+"px";
			lastScrollY = lastScrollY + percent;
		}
		if(diffX != lastScrollX)
		{
			percent = .1 * (diffX - lastScrollX);
			if(percent > 0)
				percent = Math.ceil(percent);
			else
				percent = Math.floor(percent);
			if(NS) 
				document.tracqfloater.left += percent;
			templeft=parseInt(GetObj("tracqfloater").style.left);
			GetObj("tracqfloater").style.left = percent+templeft+"px";
			lastScrollX = lastScrollX + percent;
		}
}

window.setInterval("heartBeat()",20);





ImageTimer();
function ImageTimer()
{
	if(GetObj('tracqfloater') != null)
	{
	   if(!FloatIsClose)
       {
			floatHtml=GetObj('tracqfloater').innerHTML;
			if(floatHtml.indexOf('images')==-1)
			{
				 GetObj('tracqfloater').innerHTML=strhtmlcontent;
			}
        }
		if(!FloatIsClose&&GetObj('tracqfloater').style.visibility=="hidden")
		{GetObj('tracqfloater').style.visibility = "visible";}
	}
	timer1=setTimeout('ImageTimer()', 250)
}

Drag.init(GetObj("tracqfloater"));
