function emissionLoader() {
	var url = window.location.href.toLowerCase() + "/";
	url = url.replace(/http.*?\/\/(.*?)\/.*/, '$1');
	var useMain = url.indexOf("planeta.fm") == 0 || url.indexOf("www.planeta.fm") == 0 || url.indexOf("krakow") > -1;
	var requestUrl = "/emissionMain" + (useMain ? "" : "Others") + ".txt";

	$.ajax({
		type: "GET", url: requestUrl, dataType: "html",
		error: function() { setTimeout("emissionLoader()", 60000); },
		success: function(data) { if (data.toString().indexOf("<html") < 0) $("#emission").html(data); setTimeout("emissionLoader()", 10000); }
	});
}


function emissionChannelLoader() {
	$.ajax({
		type: "GET", url: "/emission.txt", dataType: "html",
		error: function() { setTimeout("emissionChannelLoader()", 120000); },
		success: function(data) {
			if (data.toString().indexOf("<html") > 0)
				return;
			var channels = data.toString().split(/[\n\r]/g);
			for (var i = 0; i < channels.length; i++) {
				var id = channels[i].split("<", 1)[0];
				if (id.length == 0) continue;
				var html = channels[i].replace(/.*?</, "<");
				$("[id=" + id + "]").html(html);
			}
			setTimeout("emissionChannelLoader()", 60000);
		}
	});
}

$(document).ready(emissionLoader);