function subNav() {
	var nav = document.getElementById('subNav');
	aTags = nav.getElementsByTagName('a');
	
	for (i = 0 ; i < aTags.length ; i ++) {
		if (aTags[i].className != 'active') {

				createEvent(aTags[i], 'mouseover', 'change('+i+', "over")');
				createEvent(aTags[i], 'mouseout', 'change('+i+', "out")');
				aTags[i].style.backgroundPosition = "-146px 0";
		}
		actions[i] = new Array();
		actions[i]['node'] = aTags[i];
		actions[i]['pos'] = -146;
		actions[i]['actions'] = null;
	}
	
	timer = setInterval("movement()", 10);
}

function change(i, mEvent) {
	if (actions[i]['actions'] == null) { 
		actions[i]['actions'] = (mEvent=='over')?10:-2;
	} else {
		if (actions[i]['actions'] == 10) { actions[i]['actions'] = -2; }
		else { actions[i]['actions'] = 10; }
	}
}

function movement() {
	for (i = 0 ; i < actions.length ; i++) {
		if (actions[i]['actions'] != null) {
			actions[i]['pos'] = actions[i]['pos'] + actions[i]['actions'];
			actions[i]['node'].style.backgroundPosition = actions[i]['pos']+"px 0";
			
			if (actions[i]['pos'] >= -11) {
				actions[i]['pos'] = -11;
				actions[i]['node'].style.backgroundPosition = "0 0";
				actions[i]['actions'] = null;
			}
			if (actions[i]['pos'] <= -146) {
				actions[i]['pos'] = -146;
				actions[i]['node'].style.backgroundPosition = "-146px 0";
				actions[i]['actions'] = null;
			}
		}  // End if not null
	}  // End for
}

function rightCol() {
	var height = heightCheck(document.getElementById("right"));

	var url = 'http://'+window.location.host+'/assets/images/';
	if (height <= 146) {
		document.getElementById('right').style.backgroundImage = "url("+url+"right_bar_146.jpg)";
	} else if (height <= 296) {
		document.getElementById('right').style.backgroundImage = "url("+url+"right_bar_296.jpg)";
	} else if (height <= 436) {
		document.getElementById('right').style.backgroundImage = "url("+url+"right_bar_436.jpg)";
	} else {
		document.getElementById('right').style.backgroundImage = "url("+url+"right_bar_596.jpg)";
	}
}

function createEvent(target, cause, effect) {
	if (document.addEventListener) { //For Everyone
		target.addEventListener(cause, function() { eval(effect); }, false);
	}  //End If
	if (document.attachEvent) { //For Internet Explorer
		target.attachEvent('on'+cause, function() { eval(effect); });
	}  //End if
}  // End function createEvent
