var KXT_NOW_PLAYING_REFRESH_INTERVAL = 20000;

//jQuery.noConflict();

jQuery(document).ready(function() {
	setTimeout('kxtReloadNowPlaying()', 100); //KXT_NOW_PLAYING_REFRESH_INTERVAL);
});

function kxtReloadNowPlaying() {
	//alert(jQuery('#nowplaying-yes').length);
	var srcURL = 'http://api.yes.com/1/station?name=KKXT&callback=yes';
	try {
	if(!jQuery('#NowOn').length) return;
	
	var v = jQuery('div');
	v.css('position', 'relative');
	jQuery('#NowOn > div:first > a').before('<div id="kxt_nowplaying_status_indicator" style="position:absolute;left:-5px;top:11px;width:2px;height:2px;background-color:black;"></div>');
	
	jQuery.ajax({
		url: srcURL,
		dataType: 'jsonp',
		data: {},
		success: function(data) {
			if(!data.now) return;
			var now = data.now;
			var id = now.id;
			var song = now.song;
			var artist = now.artist;
			
			jQuery('#NowOn > div:first > a').attr('href', 'http://www.yes.com/i' + id).html(artist + ' - ' + song);
			jQuery('#kxt_nowplaying_status_indicator').animate({opacity: 0.0}, 400, 'linear', function(){jQuery('#kxt_nowplaying_status_indicator').remove()});
		}
	});
	
	setTimeout('kxtReloadNowPlaying()', KXT_NOW_PLAYING_REFRESH_INTERVAL);
	} catch(ex) { };
}

function submitform( theform )
{
	if(theform.onsubmit())
	{
    		//this check triggers the validations
		theform.submit();
	}
}