/* Author | Developer: Christopher Natan */


/* home */
function h()
{ $(".a1 img").attr("src",app_root+"/theme/enterprise/img/common/tab-a1-h.jpg");
  $(".a2 img").attr("src",app_root+"/theme/enterprise/img/common/tab-a2.jpg");
  $(".tab-wrap .content-b").hide();
  $(".tab-wrap .content-a").fadeIn("slow");
}
function nh()
{ $(".a1 img").attr("src",app_root+"/theme/enterprise/img/common/tab-a1.jpg");
  $(".a2 img").attr("src",app_root+"/theme/enterprise/img/common/tab-a2-h.jpg");
  $(".tab-wrap .content-a").hide();
  $(".tab-wrap .content-b").fadeIn("slow");
 
}

/* movies */
function searches(elm)
{  val = $(elm+" .t-searches").val();
   if(val==''){return false;}
   
   if(elm=="#jq_3") { 
     ajax_      = ".list-cont .list" ;  
     controller = "watch";
   }
   else { 
     ajax_ = "#ajax_content";
     controller = "movies"; 
   }
   
   $(ajax_ ).fadeOut('fast');
   $.post(app_root+"/"+controller+"/search/"+val,{},
	   function(data)
	   {  $(ajax_ ).html(data);
		  $(ajax_ ).fadeIn('slow');
	});

}

function switchParts(movie_name_us) {
  val  = $("#parts").val();
  pt   = $("#player-type").val();
 
  $.post(app_root+"/watch/switchparts/"+movie_name_us+"/"+val+"/"+pt,{},
  function(data)
  {  $(".block-a #player").html(data);
  });
}


function fs()
{   
	var player=document.getElementById("wmplayer");
	player.displaysize=3;
	if (player.playState ==2) 
	{ player.displaysize=3;
	  player.fullScreen=true;
	}
	else
	{}
}
function sorts() {
  val = $("#s-sorts").val();
  if(val ==0){return false;}
  $("#ajax_content").fadeOut('fast');
   $.post(app_root+"/movies/sort/"+val,{},
	   function(data)
	   {  $("#ajax_content").html(data);
		  $("#ajax_content").fadeIn('slow');
	});	
}

function sections(elm) {
  if(elm=="#jq_2") { 
     ajax_      = ".list-cont .list" ;  
     controller = "watch";
   }
   else { 
     ajax_ = "#ajax_content";
     controller = "movies"; 
   }
   
  val = $(elm+" .s-sections").val();
  if(val ==0){return false;}
  $(ajax_).fadeOut('fast');
   $.post(app_root+"/"+controller+"/section/"+val,{},
	   function(data)
	   {  $(ajax_).html(data);
		  $(ajax_).fadeIn('fast');
	});	
   
    obj = document.getElementById('sections-x');
	selIndex = obj.selectedIndex;
	value = obj.options[selIndex].text;
    $(".h3-title").text(value);
}

function changePlayer(id,movie_name,p) {
   $(".p").removeClass("selx");
   $("."+p).addClass("selx");
   $.post(app_root+"/player/"+id+"/"+movie_name,{},
     function(data)
	 {  $("#player").html(data);
	 });   	
}

function addFavorite(id) {
   $("#img_"+id).fadeOut('fast');	
   $("#ajax_favorite").fadeOut('fast');
   $.post(app_root+"/movies/addFavorite/"+id,{},
     function(data)
	 {  $("#img_"+id).fadeIn('fast');
	    $("#ajax_favorite").fadeIn('fast');
	    $("#ajax_favorite").html(data);
	});
   return false;
}
function delFavorite(id) {
   ans = confirm("Are you sure you want to delete this movie from your favorite?");
   if(ans) {
	   $.post(app_root+"/movies/delFavorite/"+id,{},
		 function(data)
		 {  $(".li_"+id).fadeOut('fast');
		});
   }
   return false;
}

/* tab */
function tab(option) {
	if(option==1) {
	  	$(".block-b .tab .ta").attr("src",app_root+"/theme/enterprise/img/movies/tab-a-h.jpg");
		$(".block-b .tab .tb").attr("src",app_root+"/theme/enterprise/img/movies/tab-b.jpg");
		$(".block-b .tab .tc").attr("src",app_root+"/theme/enterprise/img/movies/tab-c.jpg");
		$("#jq_2").hide();
		$("#jq_3").hide();
		$("#jq_1").fadeIn("fast");
	}
	else if(option==2) {
	  	$(".block-b .tab .tb").attr("src",app_root+"/theme/enterprise/img/movies/tab-b-h.jpg");
		$(".block-b .tab .ta").attr("src",app_root+"/theme/enterprise/img/movies/tab-a.jpg");
		$(".block-b .tab .tc").attr("src",app_root+"/theme/enterprise/img/movies/tab-c.jpg");
	    $("#jq_1").hide();
		$("#jq_3").hide();
		$("#jq_2").fadeIn("fast");
	}
	else if(option==3) {
	  	$(".block-b .tab .tc").attr("src",app_root+"/theme/enterprise/img/movies/tab-c-h.jpg");
		$(".block-b .tab .ta").attr("src",app_root+"/theme/enterprise/img/movies/tab-a.jpg");
		$(".block-b .tab .tb").attr("src",app_root+"/theme/enterprise/img/movies/tab-b.jpg");
		$("#jq_1").hide();
		$("#jq_2").hide();
		$("#jq_3").fadeIn("fast");
	}
}

function keypress(e,elm) {
   if(e && e.which){ 
      e = e;
	  characterCode = e.which;
    } else{
      e = event;
      characterCode = e.keyCode;
    }
   if(characterCode == 13) { 
      searches(elm);
      return false
   }
}

/* video specuial */
function observe_vs(){
	$("#video-special li a img").mouseover( function() 
    {   f = this.className;
	    t =  $("."+f).attr("title");
	    i = $("."+f).attr("src","/theme/enterprise/img/common/"+t);
		
	});	
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
