
var images = 5;
function _(o) { return document.getElementById(o); }
function fix(v) {
	for(var i = 0; i < v; i++) {
		_('vote' + (i+1)).className = 'selvote' + (i+1);
	}
}
function fixall() {
	for(var i = 0; i < images; i++) {
		_('vote' + (i+1)).className = 'vote' + (i+1);
	}
}

function setRightnow(data) {
	_('rightnow_desc').innerHTML = data[0] + (data[0] == '...' || data[0] == 'Reklam'?'':' - ' + data[1]);
	setTimeout(getRightnow, rightnow_time);
}
function getRightnow() {
	postAjax('/webbradio/rn.php?mode=bandit');
}
var rightnow_time = 30000;
var xmlGet;
function postAjax(url) {
	callback_suffix = Math.random();
	url = url + (url.indexOf('?') != -1?'&':'?') + callback_suffix;
	try {
		xmlGet = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlGet = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlGet = false;
		}
	}
	if(!xmlGet && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlGet = new XMLHttpRequest();
		} catch (e) {
			xmlGet = false;
		}
	}
	if(xmlGet) {
		xmlGet.onreadystatechange = readData;
		xmlGet.open("GET", url, true);
		xmlGet.send(null);
	} else return false;
}
function readData() {
	if(xmlGet.readyState == 4 && xmlGet.status == 200) {
		txt = unescape(xmlGet.responseText);
		txt = txt.parseJSON();
		if(typeof(txt[2]) != 'undefined')
			fill(txt[0], txt[1], txt[2]);
		else
			fill(txt[0], txt[1]);
	}
}
function fill(id, data, search) {
	switch(id) {
		case 'rightnow':
			setRightnow(data);	
		break;
	}
}
