/** Christopher M. Natan  **/


function demo(tv) {
	$(document).ready(function(){ 
		function loading(){ 
		   spinner = "<img src='/jquery/img/spinner/b.gif' class='block_loading_image' alt='loading'/>";
		   text    = " <span class='block_loading_text'>Loading...</span>";
		   $('#middle-level-1 .content .box-b').html(spinner+text); 
		 }
		loading();			   
		  $.post("/pages/index_flowplayer/"+tv, {}, function(data) {
		        $('#middle-level-1 .content .box-b').html(data); 
		  }); 
	 });
}

function fixHeight() {
 $("#content-box-c").ready(function(){ 
      h = document.getElementById("content-box-c").offsetHeight + 10;
      document.getElementById("content-box-b").style.height = h+"px";	
  });
};

function toggle(elm) {
	var links =  "/iptv/img/crm/";
	if ($('.box-'+elm + " .b").is(':visible')) {
		 $(".box-"+elm + " .b").slideUp('slow');
		 $(".box-"+elm + " .img").attr('src',links + "details-up.jpg");
	} else {
		 $(".box-"+elm + " .b").slideDown('slow');
		 $(".box-"+elm + " .img").attr('src',links + "details.jpg");	 
	}
	 
}
function clicked() {
    $(document).ready(function(){ 	
		$('#menu-packages-hover').click(function() {
			
			 $('#front-image').attr('src','/jquery/img/spinner/b.gif');	
			 var img = $('.current_sel').val();
			 var src = '/iptv/img/front/';	
			 var path = src+img+'.jpg';
			 $('#ajax_banner_middle').html("<img src='"+path+"'");	
			 $('#middle-level-1 .box-a #ajax_banner_middle').hide();
			 $('#middle-level-1 .box-a #ajax_banner_middle').fadeIn();
			 return false;
		});
  });	   		
}


function next_step(step,type) {
   /* var variable  is hard code if set topbox or pc*/
   var variable=7;
   var c=0;
   c = document.getElementById("signup_1").checked;
   if(c==1){ 
     $(".option-one").show();
     $(".option-two").hide();
	 
	 $("#next-step-2 .box-p").hide();
	 $("#next-step-2 .box-"+variable).show();
	 /* group */
	 $("#next-step-2 .box-13").show();
	 $("#next-step-2 .box-14").show();
	 $("#next-step-2 .box-15").show();
	 $("#next-step-2 .box-16").show();
	 $("#next-step-2 .box-22").show();
	 $('#box-group').show();
	 document.getElementById("product7").checked=true;
	 $("#next-step-2 .box-7 .b").show();
	 
   } 
   else { 
      $('#box-group').hide();
	  $(".option-two").show();
      $(".option-one").hide();
	  
	  $("#next-step-2 .box-p").show();
	  $("#next-step-2 .box-"+variable).hide();
	 // document.getElementById("product8").checked=true;
	  $("#next-step-2 .box-8 .b").show();
   }
	  
   if(type=='next') { c = step-1; }
   else { c = step+1; }
   var links =  "/iptv/img/crm/";
   $(".img-step").attr('src',links + "step-"+step+".jpg");
   $("#next-step-"+c).hide();
   $("#next-step-"+step).fadeIn();
   fixHeight(); 
}
function selected_product(id){
  var t = $("#span-"+id).text();	
  $("#selected-product").text(t);
  document.getElementById('product7').checked = true;
}



function saveTimezone(param){
   var t = $("input[@name='tz']:checked").val();
   $('.bt').hide();
   $('.ajax_label').show();
   $.post("/channel/timezone/"+t, function(data){
         //alert("Your time zone has been saved.");
		 $('.bt').show();
         $('.ajax_label').hide();
		 if(param==1) {
			 reload_channel(); 
		 }
   });
   
}
function tz(self) {
  $('.timez').show();
  $('ul.cc li div').removeClass('selected');
  $(self).hide();
  $('ul.cc li div.a'+self.value).addClass('selected');
  var timez = $('ul.cc li div.a'+self.value+" .tmz").text();
  $('.tz').text(timez);
 
  
}
function tzdiv(num) {
  $(".r"+num).attr("checked","checked");
  $('.timez').show();
  $('ul.cc li div').removeClass('selected');
  $('.r'+num).hide();
  $('ul.cc li div.a'+num).addClass('selected');
  var timez = $('ul.cc li div.a'+num+" .tmz").text();
  $('.tz').text(timez);
  saveTimezone(1);
}
function tz_default() {
  $('.selected .timez').hide();
  var timez = $(".selected .tmz").text();
  $('.tz').text(timez);	
}
function watch_img() {
   $(".one-c li .a img").hover(function(){
      $(this).attr("src",'/iptv/img/watch/watch-hover.jpg');
	},function(){
	  $(this).attr("src",'/iptv/img/watch/watch.jpg');
	});
   $(".one-c li .a a").click( function() { 
	  $("#start-page").hide();
	  $("#play-page").slideDown();
	  $("#"+this.id+" img").attr('src','/iptv/img/watch/nowplaying.png');
	  var title = this.title;
	  $(".cuw").text(title);
	  $('#qq').val(this.href);
	  //document.getElementById("content-box-b").style.height = 840+"px";	
	  $('.tmzx_').fadeOut();
	  watch_channel(this);
   }); 
}
function watch_channel(self) {
  var t = self.href;
  $.post(t, function(data){
       $("#player").html(data);  
   });
  
}
function reload_channel() {
  var t = $('#qq').val();
  if(t.length >=1) {
	  $.post(t, function(data){
		   $("#player").html(data);  
	   });
  }
}
	
function fullScreen() {
   var player=document.getElementById("wmplayer");
   if(player!=null) {
	   player.fullScreen=true;
	   
   } 
   
}



  
  