	
	//set variables:
	var coversLeft = ["coverLeft0","coverLeft1","coverLeft2","coverLeft3","coverLeft4","coverLeft5","coverLeft6","coverLeft7","coverLeft8","coverLeft9"];
	var copyLeft = ["copyLeft0","copyLeft1","copyLeft2","copyLeft3","copyLeft4","copyLeft5","copyLeft6","copyLeft7","copyLeft8","copyLeft9"];
	var albumsLeft = ["leftAlbum0","leftAlbum1","leftAlbum2","leftAlbum3","leftAlbum4","leftAlbum5","leftAlbum6","leftAlbum7","leftAlbum8","leftAlbum9"];
	var albumsCoversLeft = ["leftAlbum0Big","leftAlbum1Big","leftAlbum2Big","leftAlbum3Big","leftAlbum4Big","leftAlbum5Big","leftAlbum6Big","leftAlbum7Big","leftAlbum8Big","leftAlbum9Big"]
	
	var coversRight = ["coverRight1","coverRight2","coverRight3"];
	var copyRights = ["copyRight1","copyRight2","copyRight3"];
	var albumsRight = ["rightAlbum1","rightAlbum2","rightAlbum3"];
	var albumsCoversRight = ["rightAlbum1Big","rightAlbum2Big","rightAlbum3Big"]

	var bkbtnsL = ["leftBackBtn0","leftBackBtn1","leftBackBtn2","leftBackBtn3","leftBackBtn4","leftBackBtn5","leftBackBtn6","leftBackBtn7","leftBackBtn8","leftBackBtn9"];
	var bkbtnsR = ["rightBackBtn1","rightBackBtn2","rightBackBtn3"];	
	
	
	window.onload = function() {
		preloader();
	}
	
	function preloader() {
     imageObj = new Image();

     images = new Array();
     images[0]="http://nikeplus.nike.com/nikeplus/emea/lastfm/en/images/box-left-tab.png"
     images[1]="http://nikeplus.nike.com/nikeplus/emea/lastfm/en/images/box-left-tab.png"
     images[2]="http://nikeplus.nike.com/nikeplus/emea/lastfm/en/images/box-right-tab.png"
     images[3]="http://nikeplus.nike.com/nikeplus/emea/lastfm/en/images/box-right-tab-on.png"

	     for(i=0; i<=3; i++) {
	          imageObj.src=images[i];
	     }
	} 
	
	
	function setBackBtns() {
		// assigns back function to all backButtons
		for (i=0; i<bkbtnsL.length; i++) {
			document.getElementById(bkbtnsL[i]).onclick = resetLeftTab;
		}
		for (j=0; j<bkbtnsR.length;j++) {
			document.getElementById(bkbtnsR[j]).onclick = resetRightTab;
		}
	}
	
	function initialiseBox() {
	// initialises visibility for the box with the album covers
		var origTab = document.getElementById("originalRunTab");
	
		for (i=0;i<coversLeft.length;i++){
			document.getElementById(coversLeft[i]).style.display = "none";
		}
		for (i=0;i<copyLeft.length;i++){
			document.getElementById(copyLeft[i]).style.display = "none";
		}
		
		for (i=0;i<albumsCoversLeft.length;i++) {
			document.getElementById(albumsCoversLeft[i]).style.display = "block";
		}
		if (origTab != null) {
			origTab.style.display = "none";
		}
//		changecss('.topBoxBody','height','132px');
	}
	
	function initialiseTabs() {
		// assigns event to the tabs
		document.getElementById("tabLeftTab").onclick = switchTab;
		document.getElementById("tabRightTab").onclick = switchTab;
		document.getElementById("tabLeftTab").className = "tabLeftOn";
	}

	function resetLeftTab() {
		// resets the left tab
		for (i=0;i<coversLeft.length;i++){
			document.getElementById(coversLeft[i]).style.display = "none";
		}
		
		for (i=0;i<copyLeft.length;i++){
			document.getElementById(copyLeft[i]).style.display = "none";
		}		
		
		for (i=0;i<albumsCoversLeft.length;i++){
			document.getElementById(albumsCoversLeft[i]).style.display = "block";
		}
		
		showAllNav();
	}
	
	function resetRightTab() {
		// resets the right tab
		for (i=0;i<coversRight.length;i++){
			document.getElementById(coversRight[i]).style.display = "none";
		}
		
		for (i=0;i<copyRights.length;i++){
			document.getElementById(copyRights[i]).style.display = "none";
		}		
		
		for (i=0;i<albumsCoversRight.length;i++){
			document.getElementById(albumsCoversRight[i]).style.display = "block";
		}		
			
	}
	
	function openDetails (dir, coverDiv, detailDiv) {
		document.getElementById(coverDiv).style.display = "block";
		document.getElementById(detailDiv).style.display = "block";	
		
		if (dir=="left") {
			for (i=0;i<albumsCoversLeft.length;i++){
				document.getElementById(albumsCoversLeft[i]).style.display = "none";	
			}
			hideAllNav();
		} else {
			for (i=0;i<albumsCoversRight.length;i++){
				document.getElementById(albumsCoversRight[i]).style.display = "none";
			}
		}
	}
		
	function switchTab(e) {
		// switch between tabs
		var tabLeftCont = document.getElementById("coachRunTab");
		var tabRightCont = document.getElementById("originalRunTab");
		var targ;
		var tid;
			// check clicked target
			if (!e) {
  				var e=window.event;
  			}
			if (e.target){
  				targ=e.target;
		 	}
			else if (e.srcElement){
  				targ=e.srcElement;
			}
			if (targ.nodeType==3) // defeat Safari bug 
			{  targ = targ.parentNode;
  			}

			tid = targ.id;
	
		if (tid == "tabLeftTab" || tid == "tabLeftTabTitle"){
			tabLeftCont.style.display = "block";
			document.getElementById("tabLeftTab").className = "tabLeftOn";
			tabRightCont.style.display = "none";
			document.getElementById("tabRightTab").className = "tabRight";		
		} else {
			tabLeftCont.style.display = "none";
			document.getElementById("tabLeftTab").className = "tabLeft";
			tabRightCont.style.display = "block";
			document.getElementById("tabRightTab").className = "tabRightOn";
		}
			resetLeftTab();
			resetRightTab();
	}
	
	
	
//	function changecss (myclass,element,value) {
//		// function to change class properties
//		var CSSRules;
//		if (document.all) {
//			CSSRules = "rules";
//		}
//		else if (document.getElementById) {
//			CSSRules = "cssRules";
//		}
//		for (var i = 0; i < document.styleSheets[0][CSSRules].length; i++) {
//			if (document.styleSheets[0][CSSRules][i].selectorText == myclass) {
//				document.styleSheets[0][CSSRules][i].style[element] = value;
//			}
//		}
//	}