function OpenMiastoMuzykiPlayer(s) {
   var w = window.open('http://www.rmfon.pl/play,'+s, "RMFplayerWindow2", 'width=820,height=710,menubar=no,toolbar=no,location=no,scrollbars=no,resizable=no,status=no');
	if (window.focus) {if (w) w.focus()};
}

var NowPlayingHead = {
	url: '/inc/playlista_18.json.txt',
	data: null,
	executer: null,
	now: null,
	next: null,
	currentCover: '',
	fetchInterval: 20,
	fetch: function() {
	  new Ajax.Request(NowPlayingHead.url+'?'+Math.random(), {
		  method: 'get',
		  onSuccess: function (transport) {
			try {
				NowPlayingHead.data = eval('('+transport.responseText+')');
				NowPlayingHead.display();
			} catch (e) {
			}
		  }
      }); 
	},
	display: function() {
		try {
			NowPlayingHead.now = NowPlayingHead.data.find(function(s) { return s.order==0; });
			NowPlayingHead.next = NowPlayingHead.data.find(function(s) { return s.order==1; });

			if (NowPlayingHead.now && !Object.isUndefined(NowPlayingHead.now)) {
				var auth1 = NowPlayingHead.now.author;
				if (!!NowPlayingHead.now.bio) auth1 = '<a href="http://www.rmfon.pl/artysci/'+NowPlayingHead.now.bio+'.html" target="_blank">' + auth1 + '</a>';
				$('tg-teraz-artysta').update(auth1);
				$('tg-teraz-tytul').update(NowPlayingHead.now.title);

				if (NowPlayingHead.now.coverUrl) {
					if (NowPlayingHead.currentCover!=NowPlayingHead.now.coverUrl) {
						NowPlayingHead.currentCover = NowPlayingHead.now.coverUrl;
						$('tg-cover').update('<img src="'+NowPlayingHead.now.coverUrl+'">');
					}
				} else {
					NowPlayingHead.currentCover = '<img src="/img/np-zaslepka.jpg">';
					$('tg-cover').update(NowPlayingHead.currentCover);
				}
			} else {
				$('tg-teraz-artysta').update('');
				$('tg-teraz-tytul').update('');
				$('tg-cover').update('');
			}
			if (NowPlayingHead.next && !Object.isUndefined(NowPlayingHead.next)) {
				var auth2 = NowPlayingHead.next.author;
				if (!!NowPlayingHead.next.bio) auth2 = '<a href="http://www.rmfon.pl/artysci/'+NowPlayingHead.next.bio+'.html" target="_blank">' + auth2 + '</a>';
				$('tg-zachwile-artysta').update(auth2);
				$('tg-zachwile-tytul').update(NowPlayingHead.next.title);
			} else {
				$('tg-zachwile-artysta').update('');
				$('tg-zachwile-tytul').update('');
			} 
		} catch (e) {
		}
	},
	
	start: function() {
		if (NowPlayingHead.executer!==null) NowPlayingHead.executer.stop();
		NowPlayingHead.fetch();
		NowPlayingHead.executer = new PeriodicalExecuter(NowPlayingHead.fetch, NowPlayingHead.fetchInterval);
	},
	stop: function() {
		if (NowPlayingHead.executer) {
			NowPlayingHead.executer.stop();
			NowPlayingHead.executer = null;
		}
	}
}; 

function sendForm() {
  $('errormsg').hide();
  var elems = $A($('xform').getElements());
  elems.each( function(s) { $(s).removeClassName('err'); } );
  var errors = $A();
  if ($F('imie')=='') errors.push('imie');
  if ($F('telefon')=='') errors.push('telefon');
  if ($F('dlakogo')=='') errors.push('dlakogo');
  if ($F('kawalek')=='') errors.push('kawalek');
  if (errors.length>0) {
    errors.each( function(s) { $(s).addClassName('err'); });
	$('errormsg').update('Popraw zaznaczone pola!').show();
    return;
  }
  $('btnwyslij').hide();
  $('errormsg').update('Trwa wysyłanie...').show();

  new Ajax.Request('/ajax_muzokracja.php', {
       method: 'POST',
       parameters: {
          'save' : 1,
          'imie' : $F('imie'),
          'telefon' : $F('telefon'),
          'dlakogo' : $F('dlakogo'),
		  'kawalek': $F('kawalek')
        },
   onComplete: function(transport) {
        $('xform').reset();
        var ret = transport.responseJSON;
		$('errormsg').update().hide();
        $('xform').update('<DIV style="margin-top:60px;margin-bottom:50px;text-align:center;color:#004fb6;font-weight:bold;">Zgłoszenie przyjęte - dziękujemy!</DIV>');
     }
 });
}




