/* ppFloat 漂浮插件1.0  作者：彭成刚 网站：http://www.zzcn.net/ QQ:76526211 */
/*
<script language="JavaScript" type="text/javascript" src="ppFloat.js"></script>
//Html架构代码
<DIV id=ppFloat>彭彭漂浮组件<br />这里面放漂浮的广告<br />Www.Zzcn.Net</DIV>
//调用方式
<script type="text/javascript">
var ppFloat = new ppFloat({
					objStr:"ppFloat",	//漂浮的div ID
					xPos:300,			//漂浮x坐标
					yPos:200,			//漂浮y坐标
					delay:30,			//延时
					zindex:100,			//层的位置
					IsStop:true,		//是否鼠标放到广告上就停止 true false
					IsW3c:true			//是否支持标准 true false
					});
</script>
*/
function ppFloat(a)
{
	this.objStr = a.objStr;
	this.xPos = a.xPos;
	this.yPos = a.yPos; 
	this.step = 1;
	this.delay = a.delay; 
	this.height = 0;
	this.width = 0;
	this.Hoffset = 0;
	this.Woffset = 0;
	this.yon = 0;
	this.xon = 0;
	this.pause = true;
	this.zindex = a.zindex;
	this.IsW3c = a.IsW3c;
	this.$(this.objStr).style.top = this.yPos + "px";
	/*
	alert(document.documentElement.clientWidth);
	alert(document.documentElement.clientHeight);
	alert(document.body.clientWidth);
	alert(document.body.clientHeight);
	alert(document.documentElement.scrollLeft);
	alert(document.body.scrollLeft);
	alert(window.netscape);
	
	alert(window.netscape ? document.body.clientWidth : document.documentElement.clientWidth);
	alert(window.netscape ? document.body.clientHeight : document.documentElement.clientHeight);
	alert(document.documentElement.clientHeight);
	alert(document.documentElement.clientWidth);
	alert(document.documentElement.scrollTop);
	alert(this.$(this.objStr).style.top);
	alert(this.$(this.objStr).style);
	alert(document.body.clientHeight);*/
	if(a.IsStop)
	{
		this.$(a.objStr).onmouseover=function() {eval(a.objStr+".pause_resume();");}
		this.$(a.objStr).onmouseout=function() {eval(a.objStr+".pause_resume();")}
	}
	
	this.start();
	
}

ppFloat.prototype.$ = function(Id)
{
	return document.getElementById(Id);
}

ppFloat.prototype.changePos = function()
{
	
	
	this.Hoffset = this.$(this.objStr).offsetHeight;
	this.Woffset = this.$(this.objStr).offsetWidth;
	if(this.IsW3c)
	{
		this.width = document.documentElement.clientWidth;
		this.height = document.documentElement.clientHeight;
	
		this.$(this.objStr).style.left = this.xPos + document.documentElement.scrollLeft + "px";
		this.$(this.objStr).style.top = this.yPos + document.documentElement.scrollTop + "px";
	}
	else
	{
		this.width = document.body.clientWidth;
		this.height = document.body.clientHeight;
		
		this.$(this.objStr).style.left = this.xPos + document.body.scrollLeft + "px";
		this.$(this.objStr).style.top = this.yPos + document.body.scrollTop + "px";
	}
	
	if (this.yon) 
		{this.yPos = this.yPos + this.step;}
	else 
		{this.yPos = this.yPos - this.step;}
	if (this.yPos < 0) 
		{this.yon = 1;this.yPos = 0;}
	if (this.yPos >= (this.height - this.Hoffset)) 
		{this.yon = 0;this.yPos = (this.height - this.Hoffset);}
	if (this.xon) 
		{this.xPos = this.xPos + this.step;}
	else 
		{this.xPos = this.xPos - this.step;}
	if (this.xPos < 0) 
		{this.xon = 1;this.xPos = 0;}
	if (this.xPos >= (this.width - this.Woffset)) 
		{this.xon = 0;this.xPos = (this.width - this.Woffset);   }
		
}

ppFloat.prototype.start = function()
{
	//alert(document.documentElement.clientWidth + " + " + document.documentElement.clientHeight);
	this.$(this.objStr).style.visibility = "visible";
	this.$(this.objStr).style.zindex = this.zindex;
	this.$(this.objStr).style.position = "absolute";
	this.interval = setInterval(this.objStr+".changePos();", this.delay);
}

ppFloat.prototype.pause_resume = function()
{
	if(this.pause) 
	{
		clearInterval(this.interval);
		this.pause = false;}
	else 
	{
		this.interval = setInterval(this.objStr+".changePos()",this.delay);
		this.pause = true; 
	}
}