jahl.splitter = "5bd713552b1db9d703aa2e2963cc3733";
var xmlhttp;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
	try {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp=false;
		}
	}
@else
	xmlhttp=false;
@end @*/

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

//~ function myXMLHttpRequest() {
	//~ var xmlhttplocal;
	//~ try {
		//~ xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP");
	//~ } catch (e) {
		//~ try {
			//~ xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP");
		//~ } catch (E) {
			//~ xmlhttplocal=false;
		//~ }
	//~ }

	//~ if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
		//~ try {
			//~ var xmlhttplocal = new XMLHttpRequest();
		//~ } catch (e) {
			//~ var xmlhttplocal=false;
			//~ alert('couldn\'t create xmlhttp object');
		//~ }
	//~ }

	//~ return(xmlhttplocal);
//~ }

function jahlShowNews(news, total) {
	if (xmlhttp.readyState != 0 && xmlhttp.readyState != 4) return;
	xmlhttp.open('get', jahl.livesite + '/modules/ja_news/headlineloader.php?news=' + news + '&total=' + total);
	xmlhttp.onreadystatechange = handleHeadlineResponse;
	xmlhttp.send(null);
	document.getElementById("loading-indicator").style.display = "block";
	jahl.current = news;
	clearTimeout(jahl.timer);
}

function handleHeadlineResponse() {
	if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
			jahl.text = xmlhttp.responseText;
			jahlFadeOut();
		}
	}
}

jahl.div2show = "jahl-newsitem";
function jahlInit() {
	jahl.ani = new Fx.Style(jahl.div2show, 'opacity', {duration: 300, unit: ""});
	if (jahl.autoroll) jahl.timer = setTimeout(jahlAutoRoll, jahl.delaytime*1000);
}
window.addEvent( 'load', jahlInit );

function jahlFadeOut() {
	//~ jahl.ani.options.onComplete = jahlFadeIn
	jahl.ani.custom(1,0);
	jahlFadeIn();
}

function jahlFadeIn() {
	if (jahl.ani.timer) {
		setTimeout(jahlFadeIn, 20);
		return;
	}
	update = new Array();
	update = jahl.text.split(jahl.splitter);
	
	$(jahl.div2show).innerHTML = update[0];
	jahl.ani.custom(0,1);
	$("loading-indicator").style.display = "none";
	$("jahl-indicator").innerHTML = "" + jahl.current + "/" + jahl.total;
	$("jahl-next").title = "Next: " + update[1];
	$("jahl-prev").title = "Previous: " + update[2];
	if (jahl.autoroll) jahl.timer = setTimeout(jahlAutoRoll, jahl.delaytime*1000);
}

function jahlSwitchRoll () {
	switcher = document.getElementById("jahl-switcher");
	if (jahl.autoroll) {
		switcher.src = jahl.livesite + "/modules/ja_news/play.png";
		switcher.alt = "Play";
		switcher.title = "Play";
		jahl.autoroll = false;
		clearTimeout(jahl.timer);
	} else {
		switcher.src = jahl.livesite + "/modules/ja_news/pause.png";
		switcher.alt = "Pause";
		switcher.title = "Pause";
		jahl.autoroll = true;
		jahl.timer = setTimeout(jahlAutoRoll, jahl.delaytime*1000);
	}
	
	Cookie.set("JAHL-AUTOROLL", jahl.autoroll ? 1 : 0, {duration: 1, path: "/"});
}

function jahlAutoRoll() {
	if (jahl.current == jahl.total) next = 1;
	else next = jahl.current+1;
	
	jahlShowNews(next, jahl.total);
}