janf.splitter = "97c8730aa693f60439cf3cf4558ce5ea";
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);
//~ }

janf.showNews = function() {
	if (xmlhttp.readyState != 0 && xmlhttp.readyState != 4) return;
	xmlhttp.open('get', janf.livesite + '/modules/ja_newsflash/ja-newsflashloader.php?curnews='+janf.current);
	xmlhttp.onreadystatechange = janf.handleHeadlineResponse;
	xmlhttp.send(null);
	//document.getElementById("loading-indicator").style.display = "block";
	clearTimeout(janf.timer);
}

janf.handleHeadlineResponse = function() {
	if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
			janf.text = xmlhttp.responseText;
			janf.fadeOut();
		}
	}
}

janf.div2show = "ja-newsflash";

if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
else if (document.childNodes && !document.all && !navigator.taintEnabled) window.khtml = true;
else if (document.getBoxObjectFor != null) window.gecko = true;

function janfInit() {
	//~ janf.ani = new Fx.Style(janf.div2show, 'opacity', {duration: 300, unit: ""});
	janf.ani = new janf.effect(document.getElementById(janf.div2show), {duration: 300, opacity: true});
	janf.timer = setTimeout(janf.autoRoll, janf.delaytime*1000);
}

janf.addEvent = function(obj, evType, fn){
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

janf.addEvent( window, 'load', janfInit );

janf.fadeOut = function() {
	//~ janf.ani.options.onComplete = janfFadeIn
	janf.ani.custom(janf.ani.p.scrollHeight,0);
	janf.fadeIn();
}

janf.fadeIn = function() {
	if (janf.ani.timer) {
		setTimeout(janf.fadeIn, 20);
		return;
	}
	update = [];
	update = janf.text.split(janf.splitter);
	janf.current = update[1];
	document.getElementById(janf.div2show).innerHTML = update[0];
	janf.ani.custom(0,janf.ani.p.scrollHeight);
	janf.timer = setTimeout(janf.autoRoll, janf.delaytime*1000);
}

janf.autoRoll = function() {
	janf.showNews();
}

Function.prototype.janfbind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
}

janf.effect = new Object();
janf.effect = function(p, options) {
	this.p = p;
	this.options = options;
	this.timer = null;

	this.p.style.overflow = "hidden";
	this.p.setOpacity = function(opacity){
		if (opacity == 0){
			if(this.style.visibility != "hidden") this.style.visibility = "hidden";
		} else {
			if(this.style.visibility != "visible") this.style.visibility = "visible";
		}
		if (window.ie) {
			this.style.filter = "alpha(opacity=" + opacity*100 + ")";
			this.style.zoom = 1;
		}
		this.style.opacity = opacity;
	};

	this.step = function() {
		var time = (new Date).getTime();
		if (time > this.options.duration + this.startTime) {
			this.hnow = this.to;
			if (this.options.opacity) {
				if (this.from > this.to) this.onow = 0;
				else this.onow = 1;
			}
			clearInterval(this.timer);
			this.timer = null;
		} else {
			var Tpos = (time - this.startTime) / (this.options.duration);
			this.hnow = Tpos*(this.to-this.from) + this.from;
			if (this.options.opacity) {
				if (this.from > this.to) this.onow = 1 - Tpos;
				else this.onow = Tpos;
			}
		}
		this.change();
	};

	this.custom = function(from, to) {
		if (this.timer != null) return;
		this.from = from;
		this.to = to;
		this.startTime = (new Date).getTime();
		this.timer = setInterval(this.step.janfbind(this), 13);
	};

	this.change = function() {
		// this.p.style.height = this.hnow + "px";
		this.p.setOpacity(this.onow);
	};

};

