function oldies_head_onair(){
	var stream_win = null;
	var wnd_width = 510;
	var wnd_height = 365;
	LeftPosition = (screen.width) ? (screen.width-wnd_width)/2 : 0;
	TopPosition = (screen.height) ? (screen.wnd_height)/2 : 0;
	settings = 'height='+wnd_height+', width='+wnd_width+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no';
	stream_win = window.open('http://www.oldiesradio.cz/index.php?module=oldies_stream', 'OLDIES_STREAM', settings);
	stream_win.focus();
}

if (window.XMLHttpRequest){
	// Mozilla
	var xmlhttp_onair = new XMLHttpRequest();
} else if (window.ActiveXObject){
	// IE
	var xmlhttp_onair = new ActiveXObject("Microsoft.XMLHTTP");
}

function stream_update() {
	xmlhttp_onair.open("GET", xmlURL, true);
	xmlhttp_onair.onreadystatechange=function() {
		if (xmlhttp_onair.readyState==4) {
			// Do action...
			//alert (xmlhttp_onair.responseText);
			values = xmlhttp_onair.responseText.split("\r\n");
			oldText = document.getElementById('onair_pisnicka').innerHTML;
			newText = '<strong>' + values[0] + "</strong> - " + values[1];
			document.getElementById('onair_pisnicka').innerHTML = newText;
			document.getElementById('onair_pisnicka_url').href = song_db_baseurl + '&song_id='+values[4];
			if (newText != oldText) document.getElementById('onair_pisnicka').style.left = '0px';
			stream_refreshAfter = values[2];
			
			// DATA OK.
			stream_refreshAfter = stream_refreshAfter * 1;
			if (stream_refreshAfter > 300) { stream_refreshAfter = 300; }
			if (stream_refreshAfter < 15) { stream_refreshAfter = 15; }
			stream_refreshAfter = stream_refreshAfter * 1000;
			setTimeout('stream_update()', stream_refreshAfter);
		}
	}
	xmlhttp_onair.send(null);
}

function ScrollIt(text_scroll_speed, text_scroll_step, text_scroll_revert_wait, idOuter, idInner, idHelper) {
	var newLeft = 0;
	var scrollWait = text_scroll_speed;
	var text_scroll_revert_left = 0;
	var text_scroll_revert_right = 20;
	var curLeft = (document.getElementById(idInner).style.left).replace('px', '') * 1;
	var width_outer = document.getElementById(idOuter).clientWidth;
	var width_inner = document.getElementById(idHelper).clientWidth;
	
	document.getElementById(idHelper).innerHTML = document.getElementById(idInner).innerHTML;
	if (width_outer > width_inner) {
		document.getElementById(idInner).style.left = '0px';
		scrollWait = text_scroll_revert_wait;
	} else {
		if (curLeft < ((width_inner * -1) + width_outer - text_scroll_revert_right)) {
			text_scroll_step = text_scroll_step * -1;
			scrollWait = text_scroll_revert_wait;
		}
		if (curLeft > text_scroll_revert_left) {
			text_scroll_step = text_scroll_step * -1;
			scrollWait = text_scroll_revert_wait;
		}
		newLeft = curLeft - text_scroll_step;
		document.getElementById(idInner).style.left = newLeft + 'px';
	}
	
	setTimeout('ScrollIt('+text_scroll_speed+', '+text_scroll_step+', '+text_scroll_revert_wait+', "'+idOuter+'", "'+idInner+'", "'+idHelper+'")', scrollWait);
}

/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}

// MAIN CODE
function oldies_init(){ 
	stream_update();
	ScrollIt(40, 1, 2500, "hlavicka_onair_pisnicka", "onair_pisnicka", "ScrollIt_helper");
	P7_equalCols2(0,'oldiesuvod1','DIV','oldiesuvod2','DIV');
}

var xmlURL = "";
var song_db_baseurl = 'index.php?pageid=168261';
var stream_refreshAfter = 30;