//////////
// Scripts
//////////

//Gradual Elements Fader- By Dynamic Drive at http://www.dynamicdrive.com
//Last updated: Nov 8th, 07'

var gradualFader={}

gradualFader.baseopacity=0.6 //set base opacity when mouse isn't over element (decimal below 1)
gradualFader.increment=0.1 //amount of opacity to increase after each iteration (suggestion: 0.1 or 0.2)

document.write('<style type="text/css">\n') //write out CSS to enable opacity on "gradualfader" class
document.write('.gradualfader{filter:progid:DXImageTransform.Microsoft.alpha(opacity='+gradualFader.baseopacity*100+'); -moz-opacity:'+gradualFader.baseopacity+'; opacity:'+gradualFader.baseopacity+';}\n')
document.write('</style>')

gradualFader.setopacity=function(obj, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
	var targetobject=obj
	if (targetobject && targetobject.filters && targetobject.filters[0]){ //IE syntax
		if (typeof targetobject.filters[0].opacity=="number") //IE6
			targetobject.filters[0].opacity=value*100
		else //IE 5.5
			targetobject.style.filter="alpha(opacity="+value*100+")"
		}
	else if (targetobject && typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
		targetobject.style.MozOpacity=value
	else if (targetobject && typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
		targetobject.style.opacity=value
	targetobject.currentopacity=value
}

gradualFader.fadeupdown=function(obj, direction){
	var targetobject=obj
	var fadeamount=(direction=="fadeup")? this.increment : -this.increment
	if (targetobject && (direction=="fadeup" && targetobject.currentopacity<1 || direction=="fadedown" && targetobject.currentopacity>this.baseopacity)){
		this.setopacity(obj, targetobject.currentopacity+fadeamount)
		window["opacityfader"+obj._fadeorder]=setTimeout(function(){gradualFader.fadeupdown(obj, direction)}, 50)
	}
}

gradualFader.clearTimer=function(obj){
if (typeof window["opacityfader"+obj._fadeorder]!="undefined")
	clearTimeout(window["opacityfader"+obj._fadeorder])
}

gradualFader.isContained=function(m, e){
	var e=window.event || e
	var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
	while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
	if (c==m)
		return true
	else
		return false
}

gradualFader.fadeinterface=function(obj, e, direction){
	if (!this.isContained(obj, e)){
		gradualFader.clearTimer(obj)
		gradualFader.fadeupdown(obj, direction)
	}
}

gradualFader.collectElementbyClass=function(classname){ //Returns an array containing DIVs with specified classname
	var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i") //regular expression to screen for classname within element
	var pieces=[]
	var alltags=document.all? document.all : document.getElementsByTagName("*")
	for (var i=0; i<alltags.length; i++){
		if (typeof alltags[i].className=="string" && alltags[i].className.search(classnameRE)!=-1)
			pieces[pieces.length]=alltags[i]
	}
	return pieces
}

gradualFader.init=function(){
	var targetobjects=this.collectElementbyClass("gradualfader")
	for (var i=0; i<targetobjects.length; i++){
		targetobjects[i]._fadeorder=i
		this.setopacity(targetobjects[i], this.baseopacity)
		targetobjects[i].onmouseover=function(e){gradualFader.fadeinterface(this, e, "fadeup")}
		targetobjects[i].onmouseout=function(e){gradualFader.fadeinterface(this, e, "fadedown")}
	}
}

// Cross Browser DOM
// copyright Stephen Chapman, 4th Jan 2005
// you may copy this code but please keep the copyright notice as well
var aDOM = 0, ieDOM = 0, nsDOM = 0; var stdDOM = document.getElementById;
if (stdDOM) aDOM = 1; else {ieDOM = document.all; if (ieDOM) aDOM = 1; else {
var nsDOM = ((navigator.appName.indexOf('Netscape') != -1)
&& (parseInt(navigator.appVersion) ==4)); if (nsDOM) aDOM = 1;}}
function xDOM(objectId, wS) {
if (stdDOM) return wS ? document.getElementById(objectId).style:
document.getElementById(objectId);
if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];
if (nsDOM) return document.layers[objectId];
}

// More Object Functions
// copyright Stephen Chapman, 18th Jan 2005
// you may copy these functions but please keep the copyright notice as well
function setObjVis(objectID,vis) {var objs = xDOM(objectID,1); objs.visibility = vis;} function toggleObjVis(objectID) {var objs = xDOM(objectID,1); var vis = objs.visibility;  objs.visibility = (vis == "visible" || vis == "show") ? 'hidden' : 'visible';} function moveObjTo(objectID,x,y) {var objs = xDOM(objectID,1); objs.left = x; objs.top = y;}function moveObjBy(objectID,x,y) {var obj = xDOM(objectID,0);var objs = xDOM(objectID,1); if (obj.offsetLeft != null) {var l = obj.offsetLeft; var t = obj.offsetTop; objs.left = l+x; objs.top = t+y;} else if (objs.pixelLeft != null) {objs.pixelLeft += x; objs.pixelTop += y;} else obj.moveBy(x,y);}function moveObjLayer(objectID,z) {var objs = xDOM(objectID,1); objs.zIndex = z;}

//other janky functions!

function clearInput(box) {
	document.getElementById(box).value="";
}

function submitEmail()	{
	var eAddy = document.getElementById('emailInput').value;
	var formAddy = 'mail.php';
	ajaxUpdate( "emailFeedbackDiv", formAddy, {
		params:"do=add&email=" + eAddy,
		meth:"get",
		async:true,
		startfunc:"",
		endfunc:"",
		errorfunc:"ajaxError()",
		noauthfunc:"ajaxNoAuth()" }
	);
}

function loadIt(){
	setObjVis('loadContent','visible');
	setObjVis('home','visible');
	setObjVis('homeBox', 'hidden');
	setObjVis('homeBox_active', 'visible');
	setObjVis('loading','hidden');
}

function viewTab(tab){
	if(tab=='home'){
		setObjVis('home','visible');
		setObjVis('homeBox', 'hidden');
		setObjVis('homeBox_active', 'visible');
		setObjVis('music','hidden');
		setObjVis('musicBox', 'visible');
		setObjVis('musicBox_active', 'hidden');
		setObjVis('info','hidden');
		setObjVis('infoBox','visible');
		setObjVis('infoBox_active','hidden');
		setObjVis('top10','hidden');
		setObjVis('top10Box','visible');
		setObjVis('top10Box_active','hidden');
	}else if(tab=='music'){
		setObjVis('home','hidden');
		setObjVis('homeBox', 'visible');
		setObjVis('homeBox_active', 'hidden');
		setObjVis('music','visible');
		setObjVis('musicBox', 'hidden');
		setObjVis('musicBox_active', 'visible');
		setObjVis('info','hidden');
		setObjVis('infoBox','visible');
		setObjVis('infoBox_active','hidden');
		setObjVis('top10','hidden');
		setObjVis('top10Box','visible');
		setObjVis('top10Box_active','hidden');
	}else if(tab=='info'){
		setObjVis('home','hidden');
		setObjVis('homeBox', 'visible');
		setObjVis('homeBox_active', 'hidden');
		setObjVis('music','hidden');
		setObjVis('musicBox', 'visible');
		setObjVis('musicBox_active', 'hidden');
		setObjVis('info','visible');
		setObjVis('infoBox','hidden');
		setObjVis('infoBox_active','visible');
		setObjVis('top10','hidden');
		setObjVis('top10Box','visible');
		setObjVis('top10Box_active','hidden');
	}else if(tab=='top10'){
		setObjVis('home','hidden');
		setObjVis('homeBox', 'visible');
		setObjVis('homeBox_active','hidden');
		setObjVis('music','hidden');
		setObjVis('musicBox', 'visible');
		setObjVis('musicBox_active', 'hidden');
		setObjVis('info','hidden');
		setObjVis('infoBox','visible');
		setObjVis('infoBox_active','hidden');
		setObjVis('top10','visible');
		setObjVis('top10Box','hidden');
		setObjVis('top10Box_active','visible');
	}
}

/* Preload Images*/
Image1= new Image(100,150)
Image1.src = "pic/button_home_hover.png"

Image2= new Image(100,150)
Image2.src = "pic/button_music_hover.png"

Image3= new Image(100,150)
Image3.src = "pic/button_info_hover.png"

Image4= new Image(100,150)
Image4.src = "pic/button_top10_hover.png"

Image4= new Image(100,150)
Image4.src = "pic/banner_hover.gif"

/*******************************************************************************
* Author: Justin Barlow - www.netlobo.com
* Project Netlobo Ajax v1.1
* the ajaxUpdate( ) function tries to make AJAX operations easier by performing
* many common AJAX related operations in one place. The function will request
* the data from the given "url" and inject it into the html element with the
* given "elemid" using the element's innerHTML method. This function is most
* useful when the requested "url" returns html formatted text or plain text. The
* "url" does not have to return XML.
* 
* The "options" parameter is an anonymous object which includes the following
* available options:
* 
* params:     Parameters for the requested url in the format p1=1&p2=0&p3=2
* meth:       The request method. Can be "get" or "post". Default is "post".
* async:      Toggles asynchronous mode. Default is true.
* startfunc:  A function or list of functions to be called before the AJAX
*             request is made. A list of functions must be separated by the
*             semi-colon like this: "showLoad(); animateText(); hideDiv('bob')".
*             You can pass parameters into the functions.
* endfunc:    A function or list of functions to be called after a successful
*             AJAX request. Uses the same format as "startfunc".
* errorfunc:  A function or list of functions to be called when the AJAX request
*             is unsuccessful. Uses the same format as "startfunc".
* noauthfunc: A function or list of functions to be called when the AJAX request
*             is not authenticated (http status code 403 is encountered). Uses
*             the same format as "startfunc".
* 
* Returns true on success and false on failure.
* 
* Example Usage:
* 
	ajaxUpdate( "rightdiv", "getData.jsp", {
		params:"id=12&AJAX=true",
		meth:"post",
		async:true,
		startfunc:"elemOn('loading')",
		endfunc:"elemOff('loading'); elemOn('rightdiv')",
		errorfunc:"ajaxError()",
		noauthfunc:"ajaxNoAuth()" }
	);
* 
*******************************************************************************/
function ajaxUpdate( elemid, url, options )
{
	var params = options.params || "";
	var meth = options.meth || "post";
	var async = options.async;
	if( async == null )
		async = true;
	var startfunc = options.startfunc || "";
	var endfunc = options.endfunc || "";
	var errorfunc = options.errorfunc || "";
	var noauthfunc = options.noauthfunc || "";
	var req = false;
	if( window.XMLHttpRequest )
		req = new XMLHttpRequest();
	else if( window.ActiveXObject )
		req = new ActiveXObject( "Microsoft.XMLHTTP" );
	else
	{
		alert(  "Your browser cannot perform the requested action. "+
				"Either your security settings are too high or your "+
				"browser is outdated. Try the newest version of "+
				"Internet Explorer or Mozilla Firefox." );
		return false;
	}
	if( startfunc != "" )
		eval( startfunc );
	req.onreadystatechange =
		function()
		{
			if ( req.readyState == 4 ) 
			{
				if ( req.status == 200 )
				{
					if( elemid != '' )
						document.getElementById(elemid).innerHTML = req.responseText;
					if( endfunc != "" )
						eval( endfunc );
					return true;
				}
				else
				{
					if( req.status == 403 && noauthfunc != "" )
						eval( noauthfunc );
					else
					{
						window.alert(req.status);
						if( endfunc != "" )
							eval( endfunc );
						if( errorfunc != "" )
							eval( errorfunc );
					}
					return false;
				}
			}
		};
	if( meth == "get" )
	{
		req.open( meth, url+( params != "" ? "?"+params : "" ), async );
		req.send(null);
	}
	else
	{
		req.open( meth, url, async );
		req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
		req.send( params );
	}
}

function setLoading(div)	
{
	document.getElementById(div).innerHTML = "Loading";
}

function ajaxError(div)
{
	document.getElementById(div).innerHTML = "Ajax Error";
}

function ajaxNoAuth(div)
{
	document.getElementById(div).innerHTML = "Ajax No Auth";	
}
