// movieName musicBox
var movieName = "musicBox";

function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return top.window[movieName]
  }	else {
    return top.document[movieName]
  }
}

// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {
    return theMovie.PercentLoaded() == 100;
  } else {
    return false;
  }
}

function playTrack(trackNum){
  if (movieIsLoaded(thisMovie(movieName))){
	  thisMovie(movieName).SetVariable("calledTrack",trackNum);
	}
}

function rw() {
    aTags = document.getElementsByTagName("a");
		// Get base URL
		var currUrl = new String(window.location);
		if (currUrl.indexOf("index.php")>=0) {
			currUrl = currUrl.slice(0,currUrl.indexOf("index.php"));
		} else if (currUrl.indexOf(".php")>=0) {
			currUrl = currUrl.slice(0,currUrl.lastIndexOf("/",currUrl.indexOf(".php")));
		}
		// alert(currUrl);
	  for (i=0;i<aTags.length;i++){
	    var currHref = aTags[i].getAttribute("href");
			// remove base URL from href, if it exists
			if (currHref.indexOf(currUrl)>=0){ currHref = currHref.slice(currHref.indexOf(currUrl)+currUrl.length);}
			// for some reason, IE is carrying the initial slash - kill it!
			if (currHref.indexOf("/")==0){ currHref = currHref.slice(1);}			
			// links to external site need target=_parent
			if (currHref.indexOf("http://")>=0) {
			  aTags[i].setAttribute("target", "_parent");
			} else if (currHref.indexOf(".mp3")>=0 && thisMovie(movieName)!="") {
			  // cancel href for music tracks - onclick will load track into music player
			  aTags[i].setAttribute("href", "#");
			} else if (currHref.indexOf("javascript:")>=0) {
			  // leave javascript calls alone
			} else  {
  			if (currHref.indexOf("?")>=0) {
  			    aTags[i].setAttribute("href", currHref+"&content=yes");
  			} else {
  			    aTags[i].setAttribute("href", currHref+"?content=yes");
  			}
  			aTags[i].setAttribute("target", "contentFrame");
  		}
		}
}
function refreshElem(id) {
    // Refresh for IE's shite CSS rendering 
    document.getElementById(id).style.visibility = "hidden";
		document.getElementById(id).style.visibility = "visible";
}

currentSubNav = null;
function showNavs(navName){
	if (currentSubNav != null) {
	    document.getElementById(currentSubNav).style.display = "none";
	}
  if (navName != "" && navName != "0") {
  	document.getElementById(navName).style.display = "block";
		currentSubNav = navName;
	}
	refreshElem("navList");
}		