// JavaScript Document

$(document).ready(function(){

	$("#jquery_jplayer").jPlayer({
	  swfPath : "http://www.radiodeinavigli.com/jquery/plugin/jplayer", 
		ready: function () {
		          
		          var action = "play";
              if ( ( $.cookie('jq_player') != null  ) && ( $.cookie('jq_player') == "false" ) )
            	{
            	  action = "stop";
              }                
			        this.element.jPlayer("setFile", "http://s1.viastreaming.net:7550/;listen.pls", "http://s1.viastreaming.net:7550/;listen.pls").jPlayer( action );
		        },
		volume: 50,
		oggSupport: false,
		nativeSupport: false
	});
	
  $("#jplayer_play").click( function(){                              
                                $.cookie("jq_player", "true");                                                           
                            } );

  $("#jplayer_pause").click( function(){                              
                                $.cookie("jq_player", "false");                                                           
                            } );

  $("#jplayer_stop").click( function(){
                              $.cookie("jq_player", "false");                            
                            } );                            
	
	
});


function getTime() 
{
  now = new Date();
  y2k = new Date("Feb 06 2009 21:00:00");
  days = (y2k - now) / 1000 / 60 / 60 / 24;
  daysRound = Math.floor(days);
  hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);
  hoursRound = Math.floor(hours);
  minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
  minutesRound = Math.floor(minutes);
  seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
  secondsRound = Math.round(seconds);
  sec = (secondsRound == 1) ? " secondo" : " secondi";
  min = (minutesRound == 1) ? " minuto" : " minuti, ";
  hr = (hoursRound == 1) ? " ora" : " ore, ";
  dy = (daysRound == 1)  ? " giorno" : " giorni, "
  //document.getElementById("counter").innerHTML = daysRound  + dy + hoursRound + hr + minutesRound + min + secondsRound + sec + " " + " al party radio!";
  document.getElementById("counter").innerHTML = daysRound  + dy + hoursRound + hr + minutesRound + min + secondsRound + sec;
  newtime = window.setTimeout("getTime();", 1000);
}


function preloader()
{

  /*
  if (top.location == location)
  {
    location.href = "http://www.radiodeinavigli.com/";
    return;
  }
  */

  // getTime();

  // Contatore
  var i = 0;

  // Crea oggetto image
  imageObj = new Image();

  // Impostiamo l'array delle foto
  images = new Array();
  images[0]="http://www.radiodeinavigli.com/template/image/winamp_press.jpg";
  images[1]="http://www.radiodeinavigli.com/template/image/wmp_press.jpg";
  images[2]="http://www.radiodeinavigli.com/template/image/real_press.jpg";
  images[3]="http://www.radiodeinavigli.com/template/image/foo_press.jpg";
  images[4]="http://www.radiodeinavigli.com/template/image/itunes_press.jpg";
  images[5]="http://www.radiodeinavigli.com/template/image/vlc_press.jpg";
  images[6]="http://www.radiodeinavigli.com/template/image/quick_press.jpg";
  images[7]="http://www.radiodeinavigli.com/template/image/aiuto_press.jpg";
        
  images[8]="http://www.radiodeinavigli.com/template/image/us_en_press.jpg";
  images[9]="http://www.radiodeinavigli.com/template/image/es_press.jpg";
  images[10]="http://www.radiodeinavigli.com/template/image/de_press.jpg";
  images[11]="http://www.radiodeinavigli.com/template/image/gr_press.jpg";
  images[12]="http://www.radiodeinavigli.com/template/image/fr_press.jpg";
  images[13]="http://www.radiodeinavigli.com/template/image/mi_press.jpg";

  // start preloading
  for(i=0; i<=13; i++) 
  {
          imageObj.src=images[i];
  }
} 

function button_press(oggetto, file )
{
  oggetto.src= file;
}

