function update_schedule(){
  $.post("ajaxHandler.ud121?trigger_event_0=getterminalnowbyslide&rand="+Math.random(),{transmission_id: transmission.oid}, function(data){
      $("#prog-name").html(data);
  });

  $.post("ajaxHandler.ud121?trigger_event_0=getterminalschedullebyslide&rand="+Math.random(),{transmission_id: transmission.oid}, function(data){

    $("#schedule *").remove();

    $("#schedule").append('<ul>');

    $("#schedule ul").html(data);

    $('#schedule').jcarousel({
      vertical: true,
      scroll: 5
    });

  });
}

$(document).ready(function() {
  
  //streaming
  if(transmission.transmission_type == 0)
  {
    update_schedule();

    setInterval("update_schedule()", 20000);

    $('#schedule').jcarousel({
      vertical: true,
      scroll: 5
    });
    
    flowplayer("player", {src: "flowplayer-3.2.4.swf", wmode: "transparent"}, {
      clip:  {
          provider: 'http',
          //url: transmission_url,
          onBeforePause : function(){
            return false;
          },
          scaling: 'fit'
      },
      canvas: {backgroundColor: "#000000"},
      plugins:  {
        content:{
          url: 'flowplayer.content-3.2.0.swf',
          backgroundColor: 'transparent',
          backgroundGradient: 'none',
          opacity: 1.0,
          border: 0,
          height:100,
          top: 5,
          left: 0,
          padding: 0,
          borderRadius: 0,
          html: '<img src="images/Marca-TV.png" hspace="0"/>'
        },
        controls: {
          all: false,
          volume: true,
          mute: true,
          fullscreen: true,
          borderRadius: '0px',
          backgroundColor: '#222222',
          tooltipColor: '#5F747C',
          sliderGradient: 'none',
          bufferColor: '#d0dbbd',
          tooltipTextColor: '#ffffff',
          backgroundGradient: [0.6,0.3,0,0,0],
          durationColor: '#d3d9d3',
          sliderColor: '#0d270c',
          bufferGradient: 'none',
          progressGradient: 'medium',
          volumeSliderGradient: 'none',
          timeBgColor: '#555555',
          buttonColor: '#878787',
          progressColor: '#97beb2',
          volumeSliderColor: '#000000',
          buttonOverColor: '#728B94',
          timeColor: '#f6f9f6',
          height: 24,
          opacity: 1.0,
          tooltips: {
            buttons: true,
            fullscreen: 'Ecr&atilde; inteiro',
            mute: 'Sem som',
            unmute: 'Com som',
            fullscreenExit: 'Sair do modo de ecr&atilde; inteiro'
          }
       }
      }//,
      //play: { opacity: 0 }
    });
  }
  //live
  else
  {
    date = new Date();
    
    if(transmission.start_transmission_date.timestamp > Math.round(date.getTime()/1000))
    {
      
      $f("player", host + "flowplayer-3.2.4.swf", {
        clip:  {
            provider: 'http',
            autoPlay: true,
            autoBuffering: true,
            scaling: 'scale',
            onFinish: function(){ 
                this.stop(); 
                this.play(); 
            } 
        },
        play: {
            replayLabel: 'Repetir'
        },
        plugins: {
          content:{
            url: host + 'flowplayer.content-3.2.0.swf',
            backgroundColor: 'transparent',
            backgroundGradient: 'none',
            opacity: 1.0,
            border: 0,
            height:100,
            top: 5,
            left: 0,
            padding: 0,
            borderRadius: 0,
            html: '<img src="'+host+'images/Marca-TV.png" hspace="0"/>'
          },
         controls: {
            backgroundColor: '#222222',
            tooltipColor: '#5F747C',
            sliderGradient: 'none',
            borderRadius: '0px',
            bufferColor: '#d0dbbd',
            tooltipTextColor: '#ffffff',
            backgroundGradient: [0.6,0.3,0,0,0],
            durationColor: '#d3d9d3',
            sliderColor: '#0d270c',
            bufferGradient: 'none',
            progressGradient: 'medium',
            volumeSliderGradient: 'none',
            timeBgColor: '#555555',
            buttonColor: '#878787',
            progressColor: '#97beb2',
            volumeSliderColor: '#000000',
            buttonOverColor: '#728B94',
            timeColor: '#f6f9f6',
            height: 24,
            opacity: 1.0
         }
        }
      });
    }
    else
    {
     
      flowplayer("player", {src: "flowplayer-3.2.4.swf", wmode: "transparent"}, {
        clip:  {
            provider: 'http',
	    bufferlength: 3,
            //url: transmission_url,
            onBeforePause : function(){
              return false;
            },
            scaling: 'scale'
        },
        canvas: {backgroundColor: "#000000"},
        plugins:  {
          content:{
            url: 'flowplayer.content-3.2.0.swf',
            backgroundColor: 'transparent',
            backgroundGradient: 'none',
            opacity: 1.0,
            border: 0,
            height:100,
            top: 5,
            left: 0,
            padding: 0,
            borderRadius: 0,
            html: '<img src="images/Marca-TV.png" hspace="0"/>'
          },
          controls: {
	    url: 'flowplayer.controls-3.2.2.swf',
            all: false,
            volume: true,
            mute: true,
            fullscreen: true,
            borderRadius: '0px',
            backgroundColor: '#222222',
            tooltipColor: '#5F747C',
            sliderGradient: 'none',
            bufferColor: '#d0dbbd',
            tooltipTextColor: '#ffffff',
            backgroundGradient: [0.6,0.3,0,0,0],
            durationColor: '#d3d9d3',
            sliderColor: '#0d270c',
            bufferGradient: 'none',
            progressGradient: 'medium',
            volumeSliderGradient: 'none',
            timeBgColor: '#555555',
            buttonColor: '#878787',
            progressColor: '#97beb2',
            volumeSliderColor: '#000000',
            buttonOverColor: '#728B94',
            timeColor: '#f6f9f6',
            height: 24,
            opacity: 1.0,
            tooltips: {
              buttons: true,
              fullscreen: 'Ecr&atilde; inteiro',
              mute: 'Sem som',
              unmute: 'Com som',
              fullscreenExit: 'Sair do modo de ecr&atilde; inteiro'
            }
         }
        },
        play: { opacity: 0 }
      });
    }
  }

});



