// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
//
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// --- version date: 01/17/03 ---------------------------------------------------------

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Cross-Browser Functions

var dom = document.getElementById;
var iex = document.all;
var ns4 = document.layers;

function addEvent(event,method){
	this[event] = method;
	if(ns4) this.captureEvents(Event[event.substr(2,event.length).toUpperCase()]);
}
function removeEvent(event){
	this[event] = null;
	if(ns4) this.releaseEvents(Event[event.substr(2,event.length).toUpperCase()]);
}
function getElement(name,nest){
	nest = nest ? "document."+nest+"." : "";
	var el = dom ? document.getElementById(name) : iex ? document.all[name] : ns4 ? eval(nest+"document."+name) : false;
	el.css = ns4 ? el : el.style;
	el.hideVis = function(){el.css.visibility="hidden"};
	el.showVis = function(){el.css.visibility="visible"};
	el.getTop = function(){return parseInt(el.css.top) || 0};
	el.setTop = function(y){el.css.top = ns4 ? y: y+"px"};
	el.getHeight = function(){return ns4 ? el.document.height : el.offsetHeight};
	el.getClipHeight = function(){return ns4 ? el.clip.height : el.offsetHeight};
	el.addEvent = addEvent;
	el.removeEvent = removeEvent;
	return el;
}
function getMouse(e){
	return iex ? event.clientY : e.pageY;
}

document.addEvent = addEvent;
document.removeEvent = removeEvent;

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// ImageSwap Functions

function newImage(src){
	img = new Image();
	img.src = src;
	return img;
}
function imageSwap(img,obj,div){
	obj = eval(obj);
	if(document.layers && div != null){
		document.layers[div].document.images[img].src = obj.src;
	}else{
		document.images[img].src = obj.src;
	}
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Scroll Functions

var currentContent = null;
var docLoaded = false;
var newsOff = newImage(""+depth+"images/buttons/recent_news-off.gif");
var newsOn = newImage(""+depth+"images/buttons/recent_news-on.gif");
var tourDatesOff = newImage(""+depth+"images/buttons/tours-off.gif");
var tourDatesOn = newImage(""+depth+"images/buttons/tours-on.gif");
var songsVideosOff = newImage(""+depth+"images/buttons/featured_clips-off.gif");
var songsVideosOn = newImage(""+depth+"images/buttons/featured_clips-on.gif");

var songsOff = newImage(""+depth+"images/buttons/songs_off.gif");
var songsOn = newImage(""+depth+"images/buttons/songs_on.gif");
var videosOff = newImage(""+depth+"images/buttons/videos_off.gif");
var videosOn = newImage(""+depth+"images/buttons/videos_on.gif");

var newsBandOff = newImage(""+depth+"images/buttons/news_band-off.gif");
var newsBandOn = newImage(""+depth+"images/buttons/news_band-on.gif");
var newsDateOff = newImage(""+depth+"images/buttons/news_date-off.gif");
var newsDateOn = newImage(""+depth+"images/buttons/news_date-on.gif");

var catalogBandOff = newImage(""+depth+"images/buttons/catalog_band-off.gif");
var catalogBandOn = newImage(""+depth+"images/buttons/catalog_band-on.gif");
var catalogNumberOff = newImage(""+depth+"images/buttons/catalog_number-off.gif");
var catalogNumberOn = newImage(""+depth+"images/buttons/catalog_number-on.gif");
/*
var wideDistributionOff = newImage(""+depth+"images/buttons/distribution_off.gif");
var wideDistributionOn = newImage(""+depth+"images/buttons/distribution_on.gif");
var wideBookingOff = newImage(""+depth+"images/buttons/booking_agents_off.gif");
var wideBookingOn = newImage(""+depth+"images/buttons/booking_agents_on.gif");
var wideRetailersOff = newImage(""+depth+"images/buttons/online_retailers_off.gif");
var wideRetailersOn = newImage(""+depth+"images/buttons/online_retailers_on.gif");
*/
var narrowInfoOff = newImage(""+depth+"images/buttons/info-off.gif");
var narrowInfoOn = newImage(""+depth+"images/buttons/info-on.gif");
var narrowAboutOff = newImage(""+depth+"images/buttons/about_off.gif");
var narrowAboutOn = newImage(""+depth+"images/buttons/about_on.gif");
var narrowFaqOff = newImage(""+depth+"images/buttons/faq_off.gif");
var narrowFaqOn = newImage(""+depth+"images/buttons/faq_on.gif");

var album_contentOff = newImage(""+depth+"images/buttons/album_info_off.gif");
var album_contentOn = newImage(""+depth+"images/buttons/album_info_on.gif");
var purchase_contentOff = newImage(""+depth+"images/buttons/purchase_off.gif");
var purchase_contentOn = newImage(""+depth+"images/buttons/purchase_on.gif");



function initMultiScroller(){
	scrollSpeed = 6; // scrolling speed
	dragHeight = 28; // Height of scrollbar drag
	trackHeight = 119; // Height of scrollbar track
	trackObj = getElement("track"); // Reference to the scrollbar track div
	upObj = getElement("up"); // Reference to the up arrow div
	downObj = getElement("down"); // Reference to the down arrow div
	dragObj = getElement("drag"); // Reference to the scrollbar drag div
	contentMaskObj = getElement("quick_access_mask"); // Reference to the content mask div
	trackTop = dragObj.getTop(); // Scrollbar top contraint
	trackLength = trackHeight-dragHeight; // Adjusted track height
	trackBottom = trackTop+trackLength; // Scrollbar bottom contraint
	contentMaskHeight = contentMaskObj.getClipHeight();// Height of the div that masks the content div
	scrollTimer = null;
	trackObj.addEvent("onmousedown",scrollJump);
	upObj.addEvent("onmousedown", function(){scroll(scrollSpeed);return false});
	upObj.addEvent("onmouseup", stopScroll);
	upObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmousedown", function(){scroll(-scrollSpeed);return false});
	downObj.addEvent("onmouseup", stopScroll);
	downObj.addEvent("onmouseout", stopScroll);
	dragObj.addEvent("onmousedown", startDrag);
	if(iex) dragObj.addEvent("ondragstart", function(){return false});
	docLoaded = true;
	loadContent("news");
}

function initNewsScroller(){
	scrollSpeed = 6; // scrolling speed
	dragHeight = 28; // Height of scrollbar drag
	trackHeight = 354; // Height of scrollbar track
	trackObj = getElement("body_track"); // Reference to the scrollbar track div
	upObj = getElement("body_up"); // Reference to the up arrow div
	downObj = getElement("body_down"); // Reference to the down arrow div
	dragObj = getElement("body_drag"); // Reference to the scrollbar drag div
	contentMaskObj = getElement("body_mask"); // Reference to the content mask div
	trackTop = dragObj.getTop(); // Scrollbar top contraint
	trackLength = trackHeight-dragHeight; // Adjusted track height
	trackBottom = trackTop+trackLength; // Scrollbar bottom contraint
	contentMaskHeight = contentMaskObj.getClipHeight();// Height of the div that masks the content div
	scrollTimer = null;
	trackObj.addEvent("onmousedown",scrollJump);
	upObj.addEvent("onmousedown", function(){scroll(scrollSpeed);return false});
	upObj.addEvent("onmouseup", stopScroll);
	upObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmousedown", function(){scroll(-scrollSpeed);return false});
	downObj.addEvent("onmouseup", stopScroll);
	downObj.addEvent("onmouseout", stopScroll);
	dragObj.addEvent("onmousedown", startDrag);
	if(iex) dragObj.addEvent("ondragstart", function(){return false});
	docLoaded = true;
	loadContent("newsDate");
}

function initMediaScroller()
{	scrollSpeed = 6; // scrolling speed
	dragHeight = 28; // Height of scrollbar drag
	trackHeight = 354; // Height of scrollbar track
	trackObj = getElement("body_track"); // Reference to the scrollbar track div
	upObj = getElement("body_up"); // Reference to the up arrow div
	downObj = getElement("body_down"); // Reference to the down arrow div
	dragObj = getElement("body_drag"); // Reference to the scrollbar drag div
	contentMaskObj = getElement("body_mask"); // Reference to the content mask div
	trackTop = dragObj.getTop(); // Scrollbar top contraint
	trackLength = trackHeight-dragHeight; // Adjusted track height
	trackBottom = trackTop+trackLength; // Scrollbar bottom contraint
	contentMaskHeight = contentMaskObj.getClipHeight();// Height of the div that masks the content div
	scrollTimer = null;
	trackObj.addEvent("onmousedown",scrollJump);
	upObj.addEvent("onmousedown", function(){scroll(scrollSpeed);return false});
	upObj.addEvent("onmouseup", stopScroll);
	upObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmousedown", function(){scroll(-scrollSpeed);return false});
	downObj.addEvent("onmouseup", stopScroll);
	downObj.addEvent("onmouseout", stopScroll);
	dragObj.addEvent("onmousedown", startDrag);
	if(iex) dragObj.addEvent("ondragstart", function(){return false});
	docLoaded = true;
	loadContent("songs");
}

function initCatalogScroller(){
	scrollSpeed = 6; // scrolling speed
	dragHeight = 28; // Height of scrollbar drag
	trackHeight = 354; // Height of scrollbar track
	trackObj = getElement("full_width_track"); // Reference to the scrollbar track div
	upObj = getElement("full_width_up"); // Reference to the up arrow div
	downObj = getElement("full_width_down"); // Reference to the down arrow div
	dragObj = getElement("full_width_drag"); // Reference to the scrollbar drag div
	contentMaskObj = getElement("full_width_mask"); // Reference to the content mask div
	trackTop = dragObj.getTop(); // Scrollbar top contraint
	trackLength = trackHeight-dragHeight; // Adjusted track height
	trackBottom = trackTop+trackLength; // Scrollbar bottom contraint
	contentMaskHeight = contentMaskObj.getClipHeight();// Height of the div that masks the content div
	scrollTimer = null;
	trackObj.addEvent("onmousedown",scrollJump);
	upObj.addEvent("onmousedown", function(){scroll(scrollSpeed);return false});
	upObj.addEvent("onmouseup", stopScroll);
	upObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmousedown", function(){scroll(-scrollSpeed);return false});
	downObj.addEvent("onmouseup", stopScroll);
	downObj.addEvent("onmouseout", stopScroll);
	dragObj.addEvent("onmousedown", startDrag);
	if(iex) dragObj.addEvent("ondragstart", function(){return false});
	docLoaded = true;
	loadContent("catalogBand");
}

function initNarrowInfoScroller(){
	scrollSpeed = 6; // scrolling speed
	dragHeight = 28; // Height of scrollbar drag
	trackHeight = 325; // Height of scrollbar track
	trackObj = getElement("narrow_track"); // Reference to the scrollbar track div
	upObj = getElement("narrow_up"); // Reference to the up arrow div
	downObj = getElement("narrow_down"); // Reference to the down arrow div
	dragObj = getElement("narrow_drag"); // Reference to the scrollbar drag div
	contentMaskObj = getElement("narrow_mask"); // Reference to the content mask div
	trackTop = dragObj.getTop(); // Scrollbar top contraint
	trackLength = trackHeight-dragHeight; // Adjusted track height
	trackBottom = trackTop+trackLength; // Scrollbar bottom contraint
	contentMaskHeight = contentMaskObj.getClipHeight();// Height of the div that masks the content div
	scrollTimer = null;
	trackObj.addEvent("onmousedown",scrollJump);
	upObj.addEvent("onmousedown", function(){scroll(scrollSpeed);return false});
	upObj.addEvent("onmouseup", stopScroll);
	upObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmousedown", function(){scroll(-scrollSpeed);return false});
	downObj.addEvent("onmouseup", stopScroll);
	downObj.addEvent("onmouseout", stopScroll);
	dragObj.addEvent("onmousedown", startDrag);
	if(iex) dragObj.addEvent("ondragstart", function(){return false});
	docLoaded = true;
	loadContent("narrowInfo");
}

/*
function initWideInfoScroller(){
	scrollSpeed = 6; // scrolling speed
	dragHeight = 28; // Height of scrollbar drag
	trackHeight = 341; // Height of scrollbar track
	trackObj = getElement("wide_track"); // Reference to the scrollbar track div
	upObj = getElement("wide_up"); // Reference to the up arrow div
	downObj = getElement("wide_down"); // Reference to the down arrow div
	dragObj = getElement("wide_drag"); // Reference to the scrollbar drag div
	contentMaskObj = getElement("wide_mask"); // Reference to the content mask div
	trackTop = dragObj.getTop(); // Scrollbar top contraint
	trackLength = trackHeight-dragHeight; // Adjusted track height
	trackBottom = trackTop+trackLength; // Scrollbar bottom contraint
	contentMaskHeight = contentMaskObj.getClipHeight();// Height of the div that masks the content div
	scrollTimer = null;
	trackObj.addEvent("onmousedown",scrollJump);
	upObj.addEvent("onmousedown", function(){scroll(scrollSpeed);return false});
	upObj.addEvent("onmouseup", stopScroll);
	upObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmousedown", function(){scroll(-scrollSpeed);return false});
	downObj.addEvent("onmouseup", stopScroll);
	downObj.addEvent("onmouseout", stopScroll);
	dragObj.addEvent("onmousedown", startDrag);
	if(iex) dragObj.addEvent("ondragstart", function(){return false});
	docLoaded = true;
	loadContent("wideDistribution");
}
*/


function initAlbumInfoScroller(){
	scrollSpeed = 6; // scrolling speed
	dragHeight = 28; // Height of scrollbar drag
	trackHeight = 354; // Height of scrollbar track
	trackObj = getElement("album_content_track"); // Reference to the scrollbar track div
	upObj = getElement("album_content_up"); // Reference to the up arrow div
	downObj = getElement("album_content_down"); // Reference to the down arrow div
	dragObj = getElement("album_content_drag"); // Reference to the scrollbar drag div
	contentMaskObj = getElement("album_content_mask"); // Reference to the content mask div
	trackTop = dragObj.getTop(); // Scrollbar top contraint
	trackLength = trackHeight-dragHeight; // Adjusted track height
	trackBottom = trackTop+trackLength; // Scrollbar bottom contraint
	contentMaskHeight = contentMaskObj.getClipHeight();// Height of the div that masks the content div
	scrollTimer = null;
	trackObj.addEvent("onmousedown",scrollJump);
	upObj.addEvent("onmousedown", function(){scroll(scrollSpeed);return false});
	upObj.addEvent("onmouseup", stopScroll);
	upObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmousedown", function(){scroll(-scrollSpeed);return false});
	downObj.addEvent("onmouseup", stopScroll);
	downObj.addEvent("onmouseout", stopScroll);
	dragObj.addEvent("onmousedown", startDrag);
	if(iex) dragObj.addEvent("ondragstart", function(){return false});
	docLoaded = true;
	loadContent("album_content");
}


function initAlbumMultiScroller(){
	scrollSpeed = 6; // scrolling speed
	dragHeight = 28; // Height of scrollbar drag
	trackHeight = 119; // Height of scrollbar track
	trackObj = getElement("album_multi_track"); // Reference to the scrollbar track div
	upObj = getElement("album_multi_up"); // Reference to the up arrow div
	downObj = getElement("album_multi_down"); // Reference to the down arrow div
	dragObj = getElement("album_multi_drag"); // Reference to the scrollbar drag div
	contentMaskObj = getElement("album_multi_mask"); // Reference to the content mask div
	trackTop = dragObj.getTop(); // Scrollbar top contraint
	trackLength = trackHeight-dragHeight; // Adjusted track height
	trackBottom = trackTop+trackLength; // Scrollbar bottom contraint
	contentMaskHeight = contentMaskObj.getClipHeight();// Height of the div that masks the content div
	scrollTimer = null;
	trackObj.addEvent("onmousedown",scrollJump);
	upObj.addEvent("onmousedown", function(){scroll(scrollSpeed);return false});
	upObj.addEvent("onmouseup", stopScroll);
	upObj.addEvent("onmouseout", stopScroll);
	downObj.addEvent("onmousedown", function(){scroll(-scrollSpeed);return false});
	downObj.addEvent("onmouseup", stopScroll);
	downObj.addEvent("onmouseout", stopScroll);
	dragObj.addEvent("onmousedown", startDrag);
	if(iex) dragObj.addEvent("ondragstart", function(){return false});
	docLoaded = true;
	loadContent("news");
}


function loadContent(name){
	if(!docLoaded) return;
	if(currentContent!=null){
		imageSwap(currentContent, currentContent+"Off", "nav");
		contentObj.setTop(0);
		contentObj.hideVis();
	}
	currentContent = name;
	imageSwap(name, name+"On", "nav");
	contentObj = getElement(currentContent+"Content","contentMask");
	contentHeight = contentObj.getHeight(); // Height of the content div
	contentLength = contentHeight-contentMaskHeight; // Adjusted content height
	scrollLength = trackLength/contentLength; // Height difference between the scrollbar track and the content
	contentObj.showVis();
	dragObj.setTop(trackTop);
	if(contentHeight<=contentMaskHeight){
		trackObj.showVis();
		upObj.showVis();
		downObj.showVis();
		dragObj.hideVis();
	}else{
		trackObj.showVis();
		upObj.showVis();
		downObj.showVis();
		dragObj.showVis();
	}
}
function startDrag(e){
	dragStartMouse = getMouse(e); // Holds the starting y mouse position
	dragStartOffset = dragObj.getTop(); // Holds the starting top position of the scrollbar drag
	document.addEvent("onmousemove", drag);
	document.addEvent("onmouseup", stopDrag);
	return false;
}
function stopDrag(){
	document.removeEvent("onmousemove");
	document.removeEvent("onmouseup");
}
function drag(e){
	var currentMouse = getMouse(e);
	var mouseDifference = currentMouse-dragStartMouse;
	var dragDistance = dragStartOffset+mouseDifference;
	var dragMovement = (dragDistance<trackTop) ? trackTop : (dragDistance>trackBottom) ? trackBottom : dragDistance;
	dragObj.setTop(dragMovement);
	var contentMovement = -(dragMovement-trackTop)*(1/scrollLength);
	contentObj.setTop(contentMovement);
	return false;
}
function scroll(speed){
	var contentMovement = contentObj.getTop()+speed;
	var dragMovement = trackTop-Math.round(contentObj.getTop()*(trackLength/contentLength));
	if(contentMovement > 0){
		contentMovement = 0;
	}else if(contentMovement < -contentLength){
		contentMovement = -contentLength;
	}
	if(dragMovement < trackTop){
		dragMovement = trackTop;
	}else if(dragMovement > trackBottom){
		dragMovement = trackBottom;
	}
	contentObj.setTop(contentMovement);
	dragObj.setTop(dragMovement);
	scrollTimer = window.setTimeout("scroll("+speed+")",25);
}
function stopScroll(){
	if(scrollTimer){
		window.clearTimeout(scrollTimer);
		scrollTimer = null;
	}
}
function scrollJump(e){
	var currentMouse = getMouse(e);
	var dragDistance = currentMouse-(dragHeight/2);
	var dragMovement = (dragDistance<trackTop) ? trackTop : (dragDistance>trackBottom) ? trackBottom : dragDistance;
	dragObj.setTop(dragMovement);
	var contentMovement = -(dragMovement-trackTop)*(1/scrollLength);
	contentObj.setTop(contentMovement);
	return false;
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Utility Functions

/*function hideScrollbars(){
	if(document.getElementsByTagName){
		document.getElementsByTagName("body")[0].style.overflow = "hidden";
	}
}*/
function fixNetscape4(){
	if(ns4origWidth != window.innerWidth || ns4origHeight != window.innerHeight){
		window.location.reload();
	}	
}
if(document.layers){
	ns4origWidth = window.innerWidth;
	ns4origHeight = window.innerHeight;
	window.onresize = fixNetscape4;
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||
