﻿firstrun=1;
total_news=2;
time_out=10000;
if(window.ActiveXObject) { 
	xml=new ActiveXObject("Microsoft.XMLDOM");
	nd=new Array(0,1,2,3);
} else if(document.implementation.createDocument) {
	xml=document.implementation.createDocument("", "", null);
	nd=new Array(1,3,5,7);
} else {
	//return false; 
}

xml.async=false;
xml.load("/cb/files/citiblue/aktualnosci.xml");

function show_news(nid) {
	if(firstrun==1) {
		news_replace(nid);
		nid++;
	}
	setTimeout("news_hide2(1,"+nid+",0)",time_out);
}

function write_news(nid) {
	items=xml.getElementsByTagName('item');
	ul=document.createElement('DIV');
	ul.setAttribute('id','all_content');
	if(items) {
		li=document.createElement('P');
		li.setAttribute('id','content_'+nid); 

		Bh=document.createElement('B');

		mnts=new Array();
		mnts['Jan']='Stycznia';
		mnts['Feb']='Lutego';
		mnts['Mar']='Marca';
		mnts['Apr']='Kwietnia';
		mnts['May']='Maja';
		mnts['Jun']='Czerwca';
		mnts['Jul']='Lipca';
		mnts['Aug']='Sierpnia';
		mnts['Sep']='Września';
		mnts['Oct']='Października';
		mnts['Nov']='Listopada';
		mnts['Dec']='Grudnia';

		datka=items[nid].childNodes[nd[2]].firstChild.nodeValue.split(" ");;

		pubdate=document.createTextNode(datka[1]+' '+mnts[datka[2]]+' '+datka[3]);
		var tresc=document.createTextNode(items[nid].childNodes[nd[3]].firstChild.nodeValue);

		Bh.appendChild(pubdate);
		li.appendChild(Bh);

		var Ah=document.createElement('A');
		Ah.setAttribute('href',items[nid].childNodes[nd[1]].firstChild.nodeValue);
		Ah.appendChild(tresc);
		li.appendChild(Ah);

		ul.appendChild(li);
	}
	return ul;
}

function news_replace(nid) {
	firstrun=0;
	time_out=4000;
	aktualny=write_news(nid);
	document.getElementById('news').innerHTML=' ';
	document.getElementById('news').appendChild(aktualny); 
}

function news_hide2(gol,nid,col) {
	var dcol=document.getElementById('news').style;
	var opak=250-col;

	if(col<250&&gol==1) {
		col=col+30;
		dcol.opacity=(opak/250);
		dcol.filter='alpha(opacity='+(opak/2.50)+')';
		setTimeout("news_hide2(1,"+nid+","+col+")",100);
	} else {
		if(col==250) {
			news_replace(nid);
			nid++;
			if(nid+1>total_news)nid=0;
		}
		
		if(col>5 && gol>=1) {
			col=col-20;
			dcol.opacity=(opak/250);
			dcol.filter='alpha(opacity='+(opak/2.55)+')';
			setTimeout("news_hide2(2,"+nid+","+col+")",100);
		} else {
			gol=0;
			show_news(nid);
		}
	}
}
