/*
Localtone Radio Scrolling Script. Librarlly hacked to work in my context, but originally based on a version by Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/

//Specify the marquee's width (in pixels)
var marqueewidth="250px";
//Specify the marquee's height
var marqueeheight="25px";
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=1;
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=1;

marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1); //slow speed down by 1 for NS
var copyspeed=marqueespeed;
var pausespeed=(pauseit==0)? copyspeed: 0;
var iedom=document.all||document.getElementById;

var actualwidth='';
var cross_marquee;

var initMe = function(t) {
	cross_marquee.innerHTML = t.responseText;
}
function populate() {
	
	if ( iedom ) {
		cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee;
		cross_marquee.style.left=parseInt(marqueewidth)+"px";
		new Ajax.Request('/public/current_audio', { onSuccess:initMe, asynchronous:false });
		actualwidth=document.all? iemarquee.offsetWidth : document.getElementById("iemarquee").offsetWidth;
	}
	lefttime=setInterval("scrollmarquee()",20);
}
window.onload=populate

function scrollmarquee() {
	if (iedom){
		if (parseInt(cross_marquee.style.left)>(actualwidth*(-1))) {
		cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px";
		}
		else {
		new Ajax.Request('/public/current_audio', { onSuccess:initMe, asynchronous:false });
		cross_marquee.style.left=parseInt(marqueewidth)+"px";
		actualwidth=document.all? iemarquee.offsetWidth : document.getElementById("iemarquee").offsetWidth;
		}
	}
}
