// Copyright 2007, Nick Malyon, All Rights Reserved.

// Set up a loop to auto-refresh titles...
window.onload = function() {
	xajax_updateTitle();
	setInterval("xajax_updateTitle()", 20000);
}

var titleChanging = false;
var prevSong = "";

// Called when the current track changes...
function scrollTitle(what) {
	if (prevSong != what) {
		titleChanging = true;
		if (prevSong == "") {
			// Don't scroll the title for the first update - it's annoying...
			document.title = "Axon: Hard Rock, 24/7  >  " + what;
			prevSong = what;
		} else {
			// Scroll mofo!
			prepend = ">>>  " + what + "  >  ";
			newTitle = prepend + "Axon: Hard Rock, 24/7  >  " + what;
			document.title = newTitle;
			prevSong = what;
			setTimeout("scrollTitleFrame(0, "+(prepend.length)+", \""+newTitle+"\")", 3000);
		}
	}
}

function scrollTitleFrame(position, max, newTitle) {
	if (position == 0) titleChanging = false;
	if ((position < max) && (!titleChanging)) {
		newTitle = newTitle.substring(1)
		document.title = newTitle;
		setTimeout("scrollTitleFrame("+(position+1)+","+max+", \""+newTitle+"\")", 400);
	}
}