var pointer = new Array();
var xmlData = new Array();
var tickStatus;
$(function(){ getXML(0,3);getXML(1,2);getXML(2,4);getXML(3,5);return;});
function getXML(index,catid) {	
$.get("index.php",{ id: "182", type: "100", 'tx_ttnews[cat]': catid } , function(xml){
		xmlData[index] = $("item",xml);
		pointer[index] = 0;
		$(xmlData[index]).each(function(key) {
			if($(this).children("title").text() == $("div.on-infobox-4:eq("+index+") dl dd p b").text()) {
				pointer[index] = key;
			} 			
		});
		startTicker(index);	return;});return;}
function startTicker(index) {if(xmlData[index].length > 1) { tickStatus = setInterval( function() { tick(index) }, '6000'); }return;}
function stopTicker() { clearInterval(tickStatus); return; }
function tick(index) {if(pointer[index] + 1 == xmlData[index].length){pointer[index] = 0;} else {	pointer[index] = pointer[index] + 1;}fillTags(index);return;}
function fillTags(index) {
	$("div.on-infobox-4:eq("+index+") dl").fadeOut('slow', function() {
		var href = $(xmlData[index][pointer[index]]).children("related").contents().attr("href");
		var title = $(xmlData[index][pointer[index]]).children("related").contents().attr("title");
	    var img = $("<img />").attr("src",$(xmlData[index][pointer[index]]).children("image").contents().attr("src")).attr("alt",title);
		$(this).children("dt").empty().append($("<a></a>").attr("href",href).attr("title",title).html(img));
		$(this).children("dd").empty().append('<p><b>'+$(xmlData[index][pointer[index]]).children("title").text()+'</b></p><p>'+$(xmlData[index][pointer[index]]).children("description").text()+'</p>');
		$("div.on-infobox-4:eq("+index+") p.more a").attr("href",href);
		$("div.on-infobox-4:eq("+index+") p.more a").attr("title",title);
		$(this).fadeIn("slow");
	});
	return;
}