//window.onerror = null;
var slideTime = 1200;
var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);
var topMargin = 0;
var leftMargin =0;
function layerObject(id) {
	this.obj = document.getElementById(id).style;
	return this.obj;
}
function layerSetup(name, topMargin, leftMargin) {
floatLayer = new layerObject(name);
window.setInterval("main('"+name+"',"+topMargin+","+leftMargin+")", 10)
}
function floatObject() {
	findHt = window.innerHeight;
} 
function main(name, topMargin, leftMargin) {
	this.currentY = parseInt(document.getElementById(name).style.top);
	this.currentX = parseInt(document.getElementById(name).style.left);
	this.scrollTop = document.body.scrollTop;
	this.scrollLeft = document.body.scrollLeft;
	mainTrigger(name, topMargin, leftMargin);
}
function mainTrigger(name, topMargin, leftMargin ) {
	var newTargetY = this.scrollTop + topMargin;
	if ( this.currentY != newTargetY ) {
		if ( newTargetY != this.targetY ) {
			this.targetY = newTargetY;
			floatYStart();
		}
	animatorY(name);
   }
   var newTargetX = this.scrollLeft + leftMargin;
	if ( this.currentX != newTargetX ) {
		if ( newTargetX != this.targetX ) {
			this.targetX = newTargetX;
			floatXStart();
		}
	animatorX(name);
   }
}
function floatYStart() {
	var now = new Date();
	this.A = this.targetY - this.currentY;
	this.B = Math.PI / ( 2 * this.slideTime );
	this.C = now.getTime();
	if (Math.abs(this.A) > this.findHt) {
		this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
		this.A = this.A > 0 ? this.findHt : -this.findHt;
	}
	else {
		this.D = this.currentY;
	}
}

function floatXStart() {
	var now = new Date();
	this.AX = this.targetX - this.currentX;
	this.BX = Math.PI / ( 2 * this.slideTime );
	this.CX = now.getTime();
	if (Math.abs(this.AX) > this.findHt) {
		this.DX = this.AX > 0 ? this.targetX - this.findHt : this.targetX + this.findHt;
		this.AX = this.AX > 0 ? this.findHt : -this.findHt;
	}
	else {
		this.DX = this.currentX;
	}
}

function animatorY(name) {
	var now = new Date();
	var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
	newY = Math.round(newY);
	if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
		document.getElementById(name).style.top = newY + "px";
	}
}

function animatorX(name) {
	var now = new Date();
	var newX = this.AX * Math.sin( this.BX * ( now.getTime() - this.CX ) ) + this.DX;
	newX = Math.round(newX);
	if (( this.AX > 0 && newX > this.currentX ) || ( this.AX < 0 && newX < this.currentX )) {
		document.getElementById(name).style.left = newX + "px";
	}
}


function floatingBanner_Start(name, topMargin, leftMargin) {
	document.getElementById(name).style.visibility='visible';
		pageWidth = document.body.clientWidth;;
		pageHeight = document.body.clientHeight;
		layerSetup(name, topMargin, leftMargin);
		floatObject();
	
}
