var track=0;

function showLayer(id){
	if(ie)
	{
		document.all[id].style.visibility = "visible";
		document.all.myChaser.style.clip = "rect(0px, 145px, 70px, 0px)";
	}
	if(ns)
	{
		document.layers.myChaser.document.layers.menuPopup.visibility = "show";
		//document.layers.myChaser.clip = "rect(0px, 145px, 94px, 0px)";
		document.layers["myChaser"].clip.top = 0;
		document.layers["myChaser"].clip.right = 145;
		document.layers["myChaser"].clip.bottom = 70; 
		document.layers["myChaser"].clip.left = 0;
    
	}
	if(moz)
	{
		document.getElementById(id).style.visibility = "visible";
		document.getElementById("myChaser").style.clip="rect(0px 145px 70px 0px)";
	}
}
function hideLayer(id){
	if(ie)
	{
	document.all[id].style.visibility = "hidden";
	document.all.myChaser.style.clip = "rect(50px, 145px, 70px, 0px)";
	}
	if(ns)
	{
	document.layers.myChaser.document.layers.menuPopup.visibility = "hide";
	//document.layers.myChaser.clip = "rect(75px, 145px, 94px, 0px)";
	document.layers["myChaser"].clip.top = 50;
	document.layers["myChaser"].clip.right = 145;
	document.layers["myChaser"].clip.bottom = 70; 
	document.layers["myChaser"].clip.left = 0;
	}
	if(moz)
	{
	document.getElementById(id).style.visibility = "hidden";
	document.getElementById("myChaser").style.clip="rect(50px 145px 70px 0px)";
	}
}

function showHideLayer(id){
	if(ie){
		if (track == 0) {
			showLayer(id);
			track=1;
		}
		else
		{
			hideLayer(id);
			track=0;
		}
	}
	if(ns){
		if (track == 0) {
			showLayer(id);
			track=1;
		}
		else
		{
			hideLayer(id);
			track=0;
		}
	}
	if(moz){
		if (track == 0) {
			showLayer(id);
			track=1;
		}
		else
		{
			hideLayer(id);
			track=0;
		}
	}
}


oChaser = new Object
oChaser.topMargin = document.all ? document.body.clientHeight-115 : window.innerHeight-115
oChaser.callRate = 10
oChaser.slideTime = 1200
oChaser.maxDiff	= document.all ? document.body.clientHeight : window.innerHeight
oChaser.isIE = document.all ? true : false
oChaser.isMoz = document.getElementById && navigator.appName == "Netscape" || navigator.appName == "Mozilla" ? true : false

//alert(oChaser.isMoz);

if (ie) { 
	oChaser.chaserDiv = document.all.myChaser
	document.all.myChaser.style.clip = "rect(50px, 145px, 70px, 0px)";
}
if (moz) {
	oChaser.chaserDiv = document.getElementById("myChaser");
	document.getElementById("myChaser").style.clip="rect(50px 145px 70px 0px)";
	//alert(oChaser.chaserDiv);
}
if (ns) {
	oChaser.chaserDiv = document.layers.myChaser
	document.layers["myChaser"].clip.top = 50;
	document.layers["myChaser"].clip.right = 145;
	document.layers["myChaser"].clip.bottom = 70; 
	document.layers["myChaser"].clip.left = 0;
	//document.layers.myChaser.clip = "rect(75px, 145px, 94px, 0px)";
	//cument.layers.myChaser.document.layers.menuPopup.style.top = '19px';
}

window.setInterval("oChaser.main( )", oChaser.callRate)

oChaser.main = function( )
{
	if(ie) {	
		this.currentY	= this.chaserDiv.style.pixelTop
	}
	if(moz) {
		this.currentY	= this.chaserDiv.style.pixelTop
	}
	if(ns) {
		this.currentY	= this.chaserDiv.top
	}
	
	//alert(this.currentY);
	
	if(ie) {	
		this.scrollTop	= document.body.scrollTop
	}
	if(moz) {
		this.scrollTop	= document.body.scrollTop
	}
	if(ns) {
		this.scrollTop	= window.pageYOffset
	}

	var newTargetY	= this.scrollTop + this.topMargin
	
	if ( this.currentY != newTargetY ) {

		if ( newTargetY != this.targetY ) {

			this.targetY = newTargetY
			this.slideInit( )
	
		}

		this.slide( )
		
	}
}


oChaser.slideInit = function( )
{
	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.maxDiff) {
		this.D = this.A > 0 ? this.targetY - this.maxDiff : this.targetY + this.maxDiff
		this.A = this.A > 0 ? this.maxDiff : -this.maxDiff
	} else {
		this.D = this.currentY
	}
}




oChaser.slide = function( )
{
	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(ie) {
				this.chaserDiv.style.pixelTop = newY
			}
			if(moz) {
				this.chaserDiv.style.pixelTop = newY
			}
			if(ns) {
				this.chaserDiv.top = newY
			}
			
	}
}
