var AdvertScroll$BTD = 
{
	counterPlus : 10,
	timer : null,
	oSpan_Left : null,
	oSpan_Right : null,
	heightScreen : screen.height - 300,
	totalWidth : 200,
	resolutionWidth : 800,
	isStop : false,
	
	ini : function(elLeft, elRight)
	{
		if (elLeft != undefined || elLeft != null) this.createSpanLeft(elLeft);
		else this.createSpanLeft();
		if (elRight != undefined || elRight != null) this.createSpanRight(elRight);
		else this.createSpanRight();
		this.onResize();
		this.changePosSpan();
		var self = this;
		utilObj.addEvent(utilObj.wd, "resize", function(e) { self.onResize(); });
		utilObj.addEvent(window, "scroll", function(e) { self.onScroll(); });
	},
	
	appendElementToLeft : function(el)
	{
		this.oSpan_Left.innerHTML = "";
		if (el != null) this.oSpan_Left.appendChild(el);
	},
	
	appendElementToRight : function(el)
	{
		this.oSpan_Right.innerHTML = "";
		if (el != null) this.oSpan_Right.appendChild(el);
	},
	
	createSpanLeft : function(el)
	{
		if (this.oSpan_Left != null) return;
		this.oSpan_Left = utilObj.createEl("SPAN");
		this.oSpan_Left.id = "spanAdvert_Left";
		this.oSpan_Left.style.position = "absolute";
		this.oSpan_Left.style.display = "block";
		this.oSpan_Left.style.left = (utilObj.isFF ? 2 : 0) + "px";
		this.oSpan_Left.style.top = this.returnScrollTop() + "px";
		if (typeof(el) != "undefined") this.oSpan_Left.appendChild(el);
		utilObj.addChildToBody(this.oSpan_Left);
	},
	
	createSpanRight : function(el)
	{
		if (this.oSpan_Right != null) return;
		this.oSpan_Right = document.createElement("SPAN");
		this.oSpan_Right.id = "spanAdvert_Right";
		this.oSpan_Right.style.position = "absolute";
		this.oSpan_Right.style.display = "block";
		this.oSpan_Right.style.left = (utilObj.getDocument().clientWidth - this.totalWidth / 2) + "px";
		this.oSpan_Right.style.top = this.returnScrollTop() + "px";
		if (typeof(el) != "undefined") this.oSpan_Right.appendChild(el);
		utilObj.addChildToBody(this.oSpan_Right);
	},
	
	changePosSpan : function()
	{
		if (this.isStop)
		{
			clearTimeout(this.timer);
			this.counterPlus = 10;
			return;
		}
		if (this.oSpan_Left == null) return;
		if (this.counterPlus < 10) this.counterPlus -= 1;
		var posNeed = this.returnScrollTop();
		if (posNeed <= 20)	posNeed = 100;
		var posDiv = parseInt(this.oSpan_Left.style.top);
		var valAdd = 0;
		var distance = (posNeed - posDiv > 0) ? posNeed - posDiv : posDiv - posNeed;
		if ( distance > 30 ) valAdd = this.counterPlus;
		else if ( distance > 20 && distance <= 30 ) valAdd = 3;
		else if ( distance > 10 && distance <= 20 ) valAdd = 2;
		else if ( distance > 0 && distance <= 10 ) valAdd = 1;
		if ( posDiv != posNeed )
		{
			if ( posDiv < posNeed )
			{
				this.oSpan_Left.style.top =  posDiv + valAdd + "px";
				if (this.oSpan_Right != null) this.oSpan_Right.style.top =  posDiv + valAdd + "px";
			}
			else
			{
				this.oSpan_Left.style.top =  posDiv - valAdd + "px";
				if (this.oSpan_Right != null) this.oSpan_Right.style.top =  posDiv - valAdd + "px";
			}
			var self = this;
			this.timer = setTimeout(function() { self.changePosSpan(); }, 10);
			return;
		}
		else
		{
			clearTimeout(this.timer);
			this.counterPlus = 10;
		}
	},
	
	onScroll : function()
	{
		if (this.oSpan_Left == null) return;
		var scrollTop = this.returnScrollTop();
		if ( parseInt(this.oSpan_Left.style.top) < scrollTop - 300 )
		{
			this.oSpan_Left.style.top = scrollTop - 300 + "px";
			if (this.oSpan_Right != null) this.oSpan_Right.style.top = scrollTop - 300 + "px";
		}
		else if ( parseInt(this.oSpan_Left.style.top) > utilObj.getDocument().height + scrollTop )
		{
			this.oSpan_Left.style.top = this.heightScreen + scrollTop + 300 + "px";
			if (this.oSpan_Right != null) this.oSpan_Right.style.top = this.heightScreen + scrollTop + 300 + "px";
		}
		this.changePosSpan();
	},
	
	onResize : function()
	{
		var isResize = false;
		var clientWidth = utilObj.getDocument().clientWidth;
		var delta = (utilObj.isFF || utilObj.isSafari ? 0 : (utilObj.isIE ? 4 : 1));
		if (screen.width >= this.resolutionWidth + this.totalWidth)
		{
			if (clientWidth >= this.resolutionWidth + this.totalWidth - delta - 16)
			{
				isResize = true;
			}
		}
		if (!isResize)
		{
			this.isStop = true;
			if (this.oSpan_Left != null)
			{
				this.oSpan_Left.style.display = "none";
			}
			if (this.oSpan_Right != null)
			{
				this.oSpan_Right.style.display = "none";
			}
		}
		else
		{
			this.isStop = false;
			this.oSpan_Left.style.display = "block";
			this.oSpan_Left.style.left = (utilObj.isFF ? 2 : 0) + "px";
			this.oSpan_Right.style.display = "block";
			this.oSpan_Right.style.left = (clientWidth - this.totalWidth / 2) + "px";
			this.onScroll();
		}
	},

	returnScrollTop : function()
	{
		return utilObj.getDocumentScroll().scrollTop;
	}
};