    var online = 0;

	function getOnline() {
		$.getJSON('/stats/Radiostats.php', function(data) {
			online = data.online;
			song = data.song;
			name = data.name;			
		});	        
	}	      
    
    function setTitle() {
        var titletext = $('#song', window.frames[0].document).html();

	song= song.replace(/\&amp;/g,'&');
	song= song.replace(/\&lt;/g,'<');
        
        if(titletext != null) window.document.title = name + ' :: ' +song+' :: Улетное радио :: '+online+' слушателей';
    }  
	
	function getTime(shours, smin, ssec) {  
		if(ssec == 59) {
			ssec = 0;
			if(smin == 59){
				smin = 0;
				if(shours == 23) shours=0; else shours++;            
			} else smin++;        
		} else ssec++;

		if(ssec   >= 0 && ssec   <= 9) ssec =   '0' + ssec;
		if(smin   >= 0 && smin   <= 9) smin =   '0' + smin;    
		if(shours >= 0 && shours <= 9) shours = '0' + shours;    
        
        var timespan = $('#time', window.parent.frames[1].document);
        if(timespan != null) $(timespan).html(shours + ':' + smin + ':' + ssec);
		var time_timer = setTimeout('getTime(' + shours + ',' + smin + ',' + ssec + ')', 1000)

	}

	$(document).ready(function() {			           
       
		getOnline();
        $.getJSON('main/servertime', function(data) {
            getTime(data.h, data.m, data.s);
        });        
	    var online_timer = setInterval( function() { getOnline(); }, 3000);
        var title_timer = setInterval( function() { setTitle(); }, 3000);
        		
    });