
/*
				JavaScriptova obsluha poslednich pisni z Last.fm
				(c) 2006 Tom Hnatovsky aka xom
			*/
			
			/* Definice promennych */ 
			
			/* Funkce zjistujici hudebni vkus */ 
			function getLastFmTracks (block, user) { 
				var i; 
			var x; 
			var artist; 
			var name; 
			var url; 
			var date; 
				/* Pracuje prohlizec s W3 DOM kodem? */  
				if (document.getElementById) { 
					/* Aktivace komunikacniho rozhrani */  
					var last = "http://www.pifik.com/workspaces/pifik.com-new/php/lastfm_recent.php?user="+user; 
					x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); 
					x.open("GET", last, true); 
					x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); 
					x.onreadystatechange = function () { 
						/* Vyzadany dokument je nacteny (readyState == 4) a dotaz byl vykonan v poradku (status == 200) */  
						if (x.readyState == 4 && x.status == 200) { 
							/* Ziskame data dle tagu z XML vypisu, abychom vedeli kolik pisnicek se v nem skryva */  
							var artist1 = x.responseXML.getElementsByTagName("artist"); 
							var name1 = x.responseXML.getElementsByTagName("name"); 
							var url1 = x.responseXML.getElementsByTagName("url"); 
							var date1 = x.responseXML.getElementsByTagName("date"); 
							var output = ""; 
							var n = 1; 
							/* Projizdime XML vypis dokud v nem neco je */  
							for (i=0; i < name1.length && n<6; i++) { 
								artist = (artist1.length == "0" ? "" : artist1[i].firstChild.nodeValue); 
								name = (name1.length == "0" ? "" : name1[i].firstChild.nodeValue); 
								url = (url1.length == "0" ? "" : url1[i].firstChild.nodeValue); 
								date = (date1.length == "0" ? "" : date1[i].firstChild.nodeValue); 
								output += '<li><a href="' + url + '" title="Detail o interpretovi ' + artist + ' | Hrál mi ' + date + '">' + artist + ' �&raquo; ' + name + '</a></li>\n'; 
								n++; 
							} 
							var el = document.getElementById(block); 
							el.innerHTML = output;
						} 
					} 
					x.send(null); 
				} 
			}
			
			function lastfm() {
				getLastFmTracks('lastFM', 'pifik');
				getLastFmTracks2('lastFM2', 'pifik');
			}
			
			function getLastFmTracks2 (block, user) { 
				var i; 
			var x; 
			var artist; 
			var name; 
			var url; 
			var date; 
				/* Pracuje prohlizec s W3 DOM kodem? */  
				if (document.getElementById) { 
					/* Aktivace komunikacniho rozhrani */  
					var last = "http://www.pifik.com/workspaces/pifik.com-new/php/lastfm_top.php?user="+user; 
					x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); 
					x.open("GET", last, true); 
					x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); 
					x.onreadystatechange = function () { 
						/* Vyzadany dokument je nacteny (readyState == 4) a dotaz byl vykonan v poradku (status == 200) */  
						if (x.readyState == 4 && x.status == 200) { 
							/* Ziskame data dle tagu z XML vypisu, abychom vedeli kolik pisnicek se v nem skryva */  
							var artist1 = x.responseXML.getElementsByTagName("artist"); 
							var name1 = x.responseXML.getElementsByTagName("name"); 
							var url1 = x.responseXML.getElementsByTagName("url"); 
							var date1 = x.responseXML.getElementsByTagName("date"); 
							var output = ""; 
							var n = 1; 
							/* Projizdime XML vypis dokud v nem neco je */  
							for (i=0; i < name1.length && n<11; i++) { 
								artist = (artist1.length == "0" ? "" : artist1[i].firstChild.nodeValue); 
								name = (name1.length == "0" ? "" : name1[i].firstChild.nodeValue); 
								url = (url1.length == "0" ? "" : url1[i].firstChild.nodeValue); 
								date = (date1.length == "0" ? "" : date1[i].firstChild.nodeValue); 
								output += '<li><a href="' + url + '" title="Detail o interpretovi ' + artist + ' | Hrál mi ' + date + '">' + artist + ' �&raquo; ' + name + '</a></li>\n'; 
								n++; 
								
							} 
							var el = document.getElementById(block); 
							el.innerHTML = output;
						} 
					} 
					x.send(null); 
				} 
			}