    function initListen(currentUrl)
    {
             
        /*$('body').html('');
        $('body').append('<iframe width="100%" height="0%" frameborder="no" style="border-bottom:2px solid buttonshadow" src="theme/kupreski/stream_iframe.php"></iframe>');
        $('body').append('<iframe onload="" width="100%" height="100%" frameborder="no" src="http://www.kupreskiradio.com"></iframe>');
        $('body').css('overflow', 'hidden');*/
        var w = window.open("theme/kupreski/live.php", "live", "width=500,height=80,status=no,location=no");
        if(!w)
        {
            alert("Pop-up bloker na Vasem pregledniku je blokirao otvaranje prozora!");
        }
    }

    function initPodcast(currentUrl)
    {
        var w = window.open("http://www.kupreskiradio.tk", "podcast", "width=700,height=500,scrollbars=yes,status=no,location=no");
        if(!w)
        {
            alert("Pop-up bloker na Vasem pregledniku je blokirao otvaranje prozora!");
        }
    }
    
    function getImagesFromLastFm(artistName)
    {
        $.ajax({
        type: "GET",
	    url: "theme/kupreski/lastfm_image.php?artist=" + artistName + "&m=" + Math.random(),
	    dataType: "xml",
	    success: function(xml)
	    {
            try
            {
                var img = xml.getElementsByTagName("size");
                $('#image').attr("src", $(img[2]).text() );
                setCookie("last_image", $(img[2]).text(), "10");
            }
            catch(ex)
            {
                setCookie("last_image", "theme/kupreski/images/default.jpg", "-10");
				$('#image').attr("src", "theme/kupreski/images/default.jpg");
				setCookie("last_image", "theme/kupreski/images/default.jpg", "10");
				$('#artist').text('Kupre&scaron;ki Radio');
                $('#song').text('Uvijek uz Vas!');
            }


	    },
	    error: function(er)
	    {
	        $('#image').attr("src", "theme/kupreski/images/default.jpg");
            setCookie("last_image", "theme/kupreski/images/default.jpg", "-10");
			setCookie("last_image", "theme/kupreski/images/default.jpg", "10");
			$('#artist').text('Kupre&scaron;ki Radio');
            $('#song').text('Uvijek uz Vas!');
	    }
	    
        });
    }


    function save_to_playlist()
	{
		try
		{
		  $.ajax({
			type: "POST",
			url: "theme/kupreski/save_to_playlist.php",
			data: { "artist" : $("#artist").text(), "song" : $("#song").text() }
		  });
		}
		catch(ex)
		{}
    }
    
    function getInfoFromLastFm(el)
    {
        $.ajax({
        type: "GET",
	    url: "lastfm_info.php?artist=" + document.getElementById("artist").innerHTML + "&m=" + Math.random(),
	    dataType: "xml",
	    success: function(xml)
	    {
            var img = xml.getElementsByTagName("content");
            $(el).html( $(img[0]).text() );
	    },
	    
	    error: function(er)
	    {
	    }
	    
        });
    }


    function loadCurrentArtist()
    {
        $.get("theme/kupreski/onair.php?t=" + Math.random(), function(r)
        {
                var exp = r.split("=");
                if(exp[0] != $('#artist').text() | exp[1] != $('#song').text() )
                {
                    $('#artist').text(exp[0]);
                    $('#song').text(exp[1]);
                    //$('#image').attr("src", "theme/kupreski/images/default.jpg");
                    getImagesFromLastFm(exp[0]);
                    save_to_playlist();
                    setCookie("last_artist", exp[0], "10");
                    setCookie("last_song", exp[1], "10");

                }

                setTimeout("loadCurrentArtist()", 50000);
        });


    }



