
function checkBrowser () {
	this.ver = navigator.appVersion
	this.agent = navigator.userAgent
	this.dom =document.getElementById ? 1 : 0
	this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0;
	this.ie6 = (this.ver.indexOf("MSIE 6") > -1 && this.dom) ? 1 : 0;
	this.ie4 = (document.all && !this.dom) ? 1 : 0;
	this.ie = this.ie4 || this.ie5 || this.ie6
	this.mac = this.agent.indexOf("Mac") > -1
	this.opera5 = this.agent.indexOf("Opera 5") > -1
	this.opera6 = this.agent.indexOf("Opera 6") > -1
	this.ns5 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0; 
	this.ns4 = (document.layers && !this.dom) ? 1 : 0;
	this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
bw = new checkBrowser()

//If you want it to move faster you can set this lower:
var speed = 5

//Sets variables to keep track of what's happening
var loop, timer, loaded

//Preloads up and down images
//preUp1 = new Image(); preUp1.src = "images/arrow_up.gif"
//preDown1 = new Image(); preDown1.src = "images/arrow_down.gif"
//preUp2 = new Image(); preUp2.src = "images/arrow_up_red.gif"
//preDown2 = new Image(); preDown2.src = "images/arrow_down_red.gif"

m_band = new Image(); m_band.src = "images/m_band.gif"
m_band_h = new Image(); m_band_h.src = "images/m_band_h.gif"
m_news = new Image(); m_news.src = "images/m_news.gif"
m_news_h = new Image(); m_news_h.src = "images/m_news_h.gif"
m_live = new Image(); m_live.src = "images/m_live.gif"
m_live_h = new Image(); m_live_h.src = "images/m_live_h.gif"
m_bio = new Image(); m_bio.src = "images/m_bio.gif"
m_bio_h = new Image(); m_bio_h.src = "images/m_bio_h.gif"
m_music = new Image(); m_music.src = "images/m_music.gif"
m_music_h = new Image(); m_music_h.src = "images/m_music_h.gif"
m_media = new Image(); m_media.src = "images/m_media.gif"
m_media_h = new Image(); m_media_h.src = "images/m_media_h.gif"
m_gallery = new Image(); m_gallery.src = "images/m_gallery.gif"
m_gallery_h = new Image(); m_gallery_h.src = "images/m_gallery_h.gif"
m_shop = new Image(); m_shop.src = "images/m_shop.gif"
m_shop_h = new Image(); m_shop_h.src = "images/m_shop_h.gif"
m_misc = new Image(); m_misc.src = "images/m_misc.gif"
m_misc_h = new Image(); m_misc_h.src = "images/m_misc_h.gif"
m_guestbook = new Image(); m_guestbook.src = "images/m_guestbook.gif"
m_guestbook_h = new Image(); m_guestbook_h.src = "images/m_guestbook_h.gif"
m_contact = new Image(); m_contact.src = "images/m_contact.gif"
m_contact_h = new Image(); m_contact_h.src = "images/m_contact_h.gif"
m_links = new Image(); m_links.src = "images/m_links.gif"
m_links_h = new Image(); m_links_h.src = "images/m_links_h.gif"

// Swaps menu images
function swap (obj, img) {
	if(loaded) {
		if (bw.ns4) {
			//alert(eval("document.divAllCont.document."+obj))
			eval("document.divAllCont.document.divMenu.document."+obj+".src="+img+".src")
		} else if (bw.ns5) {
			eval("document.getElementById('"+obj+"').src="+img+".src")
		} else {
			eval(obj+".src="+img+".src")
		}
	}
}

var curElement;
var curElementClickY;

function doMouseMove(e) {
	if (curElement != null) {
		if (bw.ns4 || bw.ns5) {
			MoveThaScrollBar(e.pageY)
		} else {
			MoveThaScrollBar(event.clientY)
			event.returnValue = false
			event.cancelBubble = true
		}
	}
}

function MoveThaScrollBar(clientY) {
	var newTop = 0
	newtop = clientY - oAllCont.y - 112 - curElementClickY
	//if (bw.dom) document.getElementById('divDebug').innerHTML = "clientY: "+clientY+"<br>oAllCont.y: "+oAllCont.y+"<br>oTrack.y: "+oTrack.y+" (112)<br>curElementClickY: "+curElementClickY
	if (newtop<1) {
		newtop = 1
		oScrollBar.value = oScrollBar.minValue
	} else if (newtop > 263 - curElement.offsetHeight ) {
		newtop = 263 - curElement.offsetHeight
		oScrollBar.value = oScrollBar.maxValue
	} else {
		oScrollBar.value = (newtop - 1) / oScrollBar.step
	}
	oScroll.moveIt (0, -oScrollBar.value)
	oScrollBar.moveIt(0)
}
	
//function doDragStart() {
//	// Don't do default drag operation.
//	if ("divScrollBar"==event.srcElement.id)
//	event.returnValue=false;
//}
	
function doMouseDown(e) {
var startdrag
	if (bw.ns4 || bw.ns5) {
		if ((e.which==1) && (e.target.id=="divScrollBar")) {
			curElement = e.target
			curElementClickY = e.layerY
			startdrag = 1
		}
		if ((e.which==1) && (e.target.id=="divTrack")) {
			curElement = bw.ns4 ? document.layers("divScrollBar") : document.getElementById("divScrollBar")
			curElementClickY = oScrollBar.size / 2
			MoveThaScrollBar(e.pageY)
			startdrag = 1
		}
	} else {
		if ((event.button==1) && (event.srcElement.id=="divScrollBar")) {
			curElement = event.srcElement
			curElementClickY = event.offsetY
			startdrag = 1
		}
		if ((event.button==1) && (event.srcElement.id=="divTrack")) {
			curElement = document.all.divScrollBar
			curElementClickY = oScrollBar.size / 2
			MoveThaScrollBar(event.clientY)
			startdrag = 1
		}
	}
	if (startdrag) {
		if (document.layers) document.captureEvents(Event.MOUSEMOVE)
		document.onmousemove = doMouseMove
	}
}

function doMouseUp (e) {
	if (document.layers) document.releaseEvents(Event.MOUSEMOVE)
	document.mousemove = null
	curElement = null
}

//Object constructor
function makePageObject () {
	this.x = 0;
	this.x2 = (bw.ns4 || bw.ns5) ? innerWidth : document.body.offsetWidth-20;
	this.y = 0;
	this.y2 = (bw.ns4 || bw.ns5) ? innerHeight : document.body.offsetHeight-4;
	this.x50 = this.x2 / 2;
	this.y50 = this.y2 / 2;
	this.x10 = (this.x2 * 10) / 100
	this.y10 = (this.y2 * 10) / 100
	this.x15 = (this.x2 * 15) / 100
	this.y15 = (this.y2 * 15) / 100
	return this;
} 

function makeObj (obj, nest) {
	nest = (!nest) ? '' : 'document.'+nest+'.'
	this.el = bw.dom ? document.getElementById(obj) : bw.ie4 ? document.all[obj] : bw.ns4 ? eval(nest+'document.'+obj) : 0;
	this.css = bw.dom ? document.getElementById(obj).style : bw.ie4 ? document.all[obj].style : bw.ns4 ? eval(nest+'document.'+obj) : 0;
	this.ref = bw.dom || bw.ie4 ? document : bw.ns4 ? this.css.document : 0;
	this.scrollHeight = bw.ns4 ? this.css.document.height : this.el.offsetHeight
	this.clipHeight = bw.ns4 ? this.css.clip.height : this.el.offsetHeight
	this.up = goUp;
	this.down = goDown;
	this.hideIt = hideIt;
	this.showIt = showIt; 
	this.moveIt = moveIt;
	this.x;
	this.y;
	this.obj = obj + "Object"
	eval(this.obj + "=this")
	return this
}

function makeScrollBarObj (obj, trackObj, nest) {
	oTrack = new makeObj(trackObj, nest)
	nest = (!nest) ? '' : 'document.'+nest+'.'
	this.css = bw.dom ? document.getElementById(obj).style : bw.ie4 ? document.all[obj].style : bw.ns4 ? eval(nest+'document.'+trackObj+'.document.'+obj) : 0;
	this.minValue = 0;
	this.maxValue = oScroll.scrollHeight - oCont.clipHeight;
	this.value = oScroll.y * -1;
	this.moveIt = moveScrollBar;
	this.hideIt = hideIt;
	this.showIt = showIt;
	this.size = Math.round(oTrack.clipHeight * (oCont.clipHeight / oScroll.scrollHeight))
	this.step = (oTrack.clipHeight - this.size - 2) / (1+this.maxValue)
	this.obj = obj + "Object";
	eval(this.obj + "=this");
	this.css.height = this.size;
	this.css.clip = "rect(0,7,"+this.size+",0)";
	this.css.clip.height = this.size;
	return this;
}

function moveScrollBar (move) {
	this.value += move;
	if (this.value < this.minValue)
		{ this.value = 0; this.css.top = 1; }
	else if (this.value > this.maxValue)
		{ this.value = this.maxValue; this.css.top = oTrack.clipHeight - this.size - 1; }
	else
		{ this.css.top = 1 + this.value * this.step }
}

function moveIt (x,y) {
	this.x = x; this.y = y
	this.css.left = this.x
	this.css.top = this.y
}

function showIt () {
	this.css.visibility = "visible"
}

function hideIt () {
	this.css.visibility = "hidden"
}

//Makes the object go up
function goDown (move) {
	if (this.y >- this.scrollHeight + oCont.clipHeight) {
		this.moveIt(0, this.y-move)
		//oDown.ref.arrowDown.src = preDown2.src
		oScrollBar.moveIt(move)
		timer = setTimeout(this.obj+".down("+move+")", speed)
	}
}
//Makes the object go down
function goUp (move) {
	if (this.y < 0){
		this.moveIt (0, this.y-move)
		//oUp.ref.arrowUp.src = preUp2.src
		oScrollBar.moveIt(move)
		timer = setTimeout(this.obj+".up("+move+")", speed)
	}
}

//Calls the scrolling functions. Also checks whether the page is loaded or not.
function scroll (speed) {
	if (loaded) {
		loop = true;
		if (speed > 0) oScroll.down(speed)
		else oScroll.up(speed)
	}
}

//Stops the scrolling (called on mouseout)
function noScroll () {
	loop = false
	if (timer) clearTimeout(timer)
	//oUp.ref.arrowUp.src = preUp1.src
	//oDown.ref.arrowDown.src = preDown1.src
}

//Scrolls to top of page
function scrollToTop () {
	noScroll()
	if (loaded) {
		oScroll.moveIt(0,0)
		oScrollBar.moveIt(-oScrollBar.maxValue)
	}
}

//Scrolls to bottom of page
function scrollToBottom() {
	noScroll()
	if (loaded)
		if (oScroll.scrollHeight > oCont.clipHeight) {
			oScroll.moveIt (0, -oScroll.scrollHeight + oCont.clipHeight)
			oScrollBar.moveIt(oScrollBar.maxValue)
		}
}

function resized() {
	page2 = new makePageObject()
	if (page2.x2 != page.x2 || page2.y2 != page.y2) {
		location.reload() //If the width or height have changed we reload the page.
	}
}

function init() {
	scrollInit();
	
	if(document.layers) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEMOVE)
	//document.ondragstart = doDragStart;
	document.onmousedown = doMouseDown;
	//document.onmousemove = doMouseMove;
	document.onmouseup = doMouseUp;
}

function gta (divid) {
	ypos = bw.dom || bw.ie4 ? document.all[divid].offsetTop : oScroll.ref.anchors[divid].y
	if (ypos > oScrollBar.maxValue) ypos = oScrollBar.maxValue
	if (oScrollBar.maxValue > 0) {
		oScroll.moveIt(0, -ypos)
		oScrollBar.value = ypos
		oScrollBar.moveIt(0)
	}
}

function WheelScroll () {
	scroll(-event.wheelDelta/10);
	noScroll();
}

onload = init;

