/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var stimer = new Array();
var type = new Array();

$(document).ready(function(){

    //Show/Hide Recently playing
    $('.played').hide();
    $('.played_link').css("cursor", "pointer");
    $('.played_link').click(function(){
        var t = $(this);
        // toggle hidden div
        t.parent().find('.played').toggle('fast', function(){

            var imgsrc = ($(this).is(':hidden')) ? '/imagesio/down3.png' : '/imagesio/up3.png';
            // update image src
            t.attr('src', imgsrc );


        });
    })

    $('.host_lnk').colorbox({width:"750px", height:"450px"});

 //   $('.listen').click(function(){
 //       $('#current_channel').html($(this).attr('title'));
 //       goChannel(this.id);
 //   });

})

function get_current(id) {
    //clearTimeout(stimer[id]);
    $.ajax({
       type: "GET",
       url: '/scripts/current_song.php',
       data: 'id='+id,
       success: function(msg){
         //alert(msg);
          //stimer[id] = setTimeout('timer_func()', 60000);
          if(msg == 'error') {  exit; }
          $("#"+id).html(msg);
       }
     });
}

function timer_func() {
   //alert("timer");
   $('.current').each( function() {
       var id = this.id;
       //clearTimeout(stimer[id]);
       $.ajax({
           type: "GET",
           url: "/scripts/current_song.php",
           data: "id="+id,
           success: function(msg){
               //stimer[id] = setTimeout('timer_func()', 60000);
               if(msg == 'error') {  exit; }
             $("#"+id).html(msg);
              
           }
         });

         $.ajax({
           type: "GET",
           url: "/scripts/recent_update.php",
           data: "id="+id,
           success: function(msg){
               if(msg == 'error') {  exit; }
             $("#recent"+id).html(msg);
           }
         });
   })

}

function get_recent(id) {
    $.ajax({
       type: "GET",
       url: "/scripts/recent_update.php",
       data: "id="+id,
       success: function(msg){
           if(msg == 'error') {  exit; }
         $("#recent"+id).html(msg);
       }
     });
}


function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function goChannel(id)
{	
	var flashMovie=getFlashMovieObject("radioioPlayer");
	flashMovie.goChannel(id);
}

function syncBanner(cid)
{
 	document.getElementById("normal_ad").style.display = "none";
 	document.getElementById("sync_ad").style.display = "block";
 	document.getElementById("playerBoard").src = "http://adpoint.radioio.com/banners/adbuildjd.php?posID=120&cID="+cid;

}

function unloadBanner()
{
 	document.getElementById("normal_ad").style.display = "block";
 	document.getElementById("sync_ad").style.display = "none";
 	document.getElementById("playerBoard").src = "";
}


