//Back to Top Arrow Script

/*Browsercheck object*/
function cm_bwcheck(){
	//In theory we should use object detection, but this script needs work-arounds for almost every browser...
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.op=window.opera 
	this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
	}else if(this.moz) this.ns6 = 1
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
	}
	this.mac=(this.agent.indexOf("mac")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  this.usedom= this.ns6||this.op7//Use dom creation
  this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}
var bw=new cm_bwcheck()

function setVariables() {
	//Create Cross-Browser Pointer Variable
	if (bw.ns4) {
		arrow = "document.arrowDiv";
		arrow2 = document.arrowDiv;
	}
	if (bw.ns6 || bw.op5 || bw.op6 || bw.op7) {
		arrow = "document.getElementById('arrowDiv').style";
		arrow2 = document.getElementById('arrowDiv').style;
	}
	if (bw.ie4 || bw.ie5 || bw.ie6) {
		arrow = "arrowDiv.style";
		arrow2 = arrowDiv.style;
	}

	imgwidth= 19;  // image width, in pixels
	imgheight= 28;  // image height, in pixels
	if (bw.ns4) {
		horz = ".left";
		vert = ".top";
		innerW = "window.innerWidth";
		innerH = "window.innerHeight";
		offsetX = "window.pageXOffset";
		offsetY = "window.pageYOffset";
	} else if (bw.ns6 || bw.op5 || bw.op6 || bw.op7) {
		horz = ".left";
		vert = ".top";
		innerW = "self.innerWidth";
		innerH = "self.innerHeight";
//		offsetX = "document.body.offsetWidth";
//		offsetY = "document.body.offsetHeight";
		offsetX = "document.body.scrollLeft";
		offsetY = "document.body.scrollTop";
	} else if (bw.ie4 || bw.ie5 || bw.ie6) {
		horz = ".pixelLeft";
		vert = ".pixelTop";
		innerW = "document.body.clientWidth";
		innerH = "document.body.clientHeight";
		offsetX = "document.body.scrollLeft";
		offsetY = "document.body.scrollTop";
	}
}

//Check Location of arrowDiv
function checkLocation() {
	var availableX=eval(innerW);
	var availableY=eval(innerH);
	var currentX=eval(offsetX);
	var currentY=eval(offsetY);
	if (Math.abs(currentY) > 0) {
		showObj(arrow2);
	} else {
		hideObj(arrow2);
	}
	x=availableX-(imgwidth+40)+currentX;
	y=availableY-(imgheight+80)+currentY;
	evalMove();
	setTimeout("checkLocation()",10);
}

//Move arrowDiv
function evalMove() {
	if (bw.ns6 || bw.op5 || bw.op6 || bw.op7) {
		eval(arrow + horz + "='" + x + "px'");
		eval(arrow + vert + "='" + y + "px'");
	} else {
		eval(arrow + horz + "=" + x);
		eval(arrow + vert + "=" + y);
	}
}

// Show Object
function showObj(obj) {
	if (bw.ns4) {
		obj.visibility = "show";
	} else {
		obj.visibility = "visible";
	}
}

// Hide Object
function hideObj(obj) {
	if (bw.ns4) {
		obj.visibility = "hide";
	} else {
		obj.visibility = "hidden";
	}
}