function PopupCenterDiv(id,popup,timer_lenght){
		
		if (!document.all){
			
			myDIV = document.getElementById(id);
		
			myheight = document.getElementById(id).clientHeight; 
			mywidth  = document.getElementById(id).clientWidth; 
			
			//document.getElementById(id).style.top  = ( (window.innerHeight / 2 ) - ( myheight / 2 ) ) + "px";
			//document.getElementById(id).style.left = ( (window.innerWidth  / 2 )  - ( mywidth / 2 ) ) + "px";

			document.getElementById(id).style.top  = (  window.pageYOffset ) + ( (window.innerHeight - myheight ) / 2 ) + "px";
			document.getElementById(id).style.left = (  window.pageXOffset ) + ( (window.innerWidth  - mywidth  ) / 2 ) + "px";
			
			document.getElementById(id).style.cursor = 'pointer';
			document.getElementById(id).style.visibility = 'visible';
			
		}
		else if (document.all){
			
			myDIV = document.all[id];
			
			myheight = document.all[id].clientHeight; 
			mywidth  = document.all[id].clientWidth; 
			//document.all[id].style.top  = ( (document.documentElement.clientHeight / 2) - ( myheight / 2 ) ) + "px";
			//document.all[id].style.left = ( (document.documentElement.clientWidth  / 2) - ( mywidth  / 2 ) ) + "px";
			document.getElementById(id).style.top  = ( document.documentElement.scrollTop  + (document.documentElement.clientHeight - myheight ) / 2 ) + "px";
			document.getElementById(id).style.left = ( document.documentElement.scrollLeft + (document.documentElement.clientWidth  - mywidth  ) / 2 ) + "px";
			
			document.all[id].style.cursor = 'pointer';
			document.all[id].style.visibility = 'visible';
		}

		if(popup) setTimeout('CloseDIV()', timer_lenght);

		window.onresize = function (){
 						    PopupCenterDivCenterDiv(id);	
						  }

	    myDIV.onclick = function (){
						  myDIV.style.visibility = 'hidden';
						  myDIV = null;
						  }
						  
	start()					  
}
//------------------------------------------------------------------------------------------------------------------
function PopupCloseDIV(){
	myDIV.style.visibility = 'hidden';
	myDIV = null;
}	
	
//-------------------------------------------------------------------------------------------------------------------	
function ScrollLayer(){
	// TOP - BOTTOM
	//document.getElementById("MovingLayer").offsetWidth
	//if (!document.all){ top_offset = document.getElementById("Container").offsetHeight; }
	//if (document.all) { top_offset = document.all["Container"].offsetHeight; }
	//current_pageYOffset = window.pageYOffset;

	// Top
	//if (!document.all){document.getElementById("MovingLayer").style.top = window.pageYOffset + (window.innerHeight - (window.innerHeight-top_offset)) + "px";}
	//if (document.all) {document.all["MovingLayer"].style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - (document.documentElement.clientHeight-top_offset)) + "px";}
		
	//bottom
	//if (!document.all){document.getElementById("Container").style.top = window.pageYOffset + (window.innerHeight - top_offset) + "px";}
	//if (document.all) {document.all["Container"].style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - top_offset) + "px";}
	//----------------------------------------------------------------------------------------------------------------------------------------------  
	//window.onscroll = function(){
	//                     ScrollLayer();	
	//				  }
}


//################################################################SCROLLED DIV #################################################################################

window.onerror = null;

var topMargin =   0; 
var slideTime = 2000;//1200

var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);

function layerObject(id) {
	if (ns6) {
		this.obj = document.getElementById(id).style;
		return this.obj;
	}
	else if(ie4) {
		this.obj = document.all[id].style;
		return this.obj;
	}
	else if(ns4) {
		this.obj = document.layers[id];
		return this.obj;
   }
 }

function layerSetup() {

//---------


	floatLyr = new layerObject('floatLayer');
	window.setInterval("main()", 10)
}

function floatObject() {
	if (ns4 || ns6) {
		findHt = window.innerHeight;
	} else if(ie4) {
		findHt = document.body.clientHeight;
   }
}

function main() {
	if (ns4) {
		this.currentY = document.layers["floatLayer"].top;
		this.scrollTop = window.pageYOffset;
		mainTrigger();
	}
	else if(ns6) {
		this.currentY = parseInt(document.getElementById('floatLayer').style.top);
		this.scrollTop = scrollY;
		mainTrigger();
	} 
	else if(ie4) {
		this.currentY = floatLayer.style.pixelTop;
		this.scrollTop = document.body.scrollTop;
		mainTrigger();
   }
  
}

function mainTrigger() {
	var newTargetY = this.scrollTop + this.topMargin;
	if ( this.currentY != newTargetY ) {
		if ( newTargetY != this.targetY ) {
			this.targetY = newTargetY;
			floatStart();
		}
		animator();
   }
}

function floatStart() {
	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 animator() {
	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 )) {
		//if ( ie4 )document.all.floatLayer.style.pixelTop = newY;
		if ( ie4 )document.all['floatLayer'].style.pixelTop 		= newY;
		if ( ns4 )document.layers['floatLayer'].top 				= newY;
		if ( ns6 )document.getElementById('floatLayer').style.top 	= newY + "px";
   }
   
}

function start(){
	//setLeft();
	
	if(ns6||ns4) {
		pageWidth = innerWidth;
		pageHeight = innerHeight;
		layerSetup(); floatObject();
	}
	else if(ie4) {
		pageWidth = document.body.clientWidth;
		pageHeight = document.body.clientHeight;

		layerSetup(); floatObject();
   }
}

function setLeft(){
	   //------------------- SETTING LEFT ------------------
if(!document.all){
   document.getElementById('floatLayer').style.left = ( window.innerWidth / 2) + (  ( parseInt(document.getElementById('mainDiv').style.width) / 2 ) - parseInt(document.getElementById('floatLayer').style.width) ) + 26 + 'px';
}
else{
  document.all['floatLayer'].style.left = ( document.body.clientWidth / 2) + (  ( parseInt(document.all['mainDiv'].style.width) / 2 ) - parseInt(document.all['floatLayer'].style.width) ) + 26;
}
//------------------- SETTING LEFT ------------------ 
}

window.onload=start;
//window.onresize=setLeft
//##############################################################################################################################################################