$(document).ready(function(){
  $("#video_category_select").change(changeVideoCat);

  $("div.videoBox div.buttons img").hover(function(){
    var tmp = $(this).attr('src').split("_");
    $(this).attr('src', tmp[0] +'_over.png');
  },function(){
    var tmp = $(this).attr('src').split("_");
    $(this).attr('src', tmp[0] +'_off.png');
  });


  $("div.videoPagination a").hover(function(){
    $("#adj_"+ $(this).attr("id")).addClass("adjSelected");
  },function(){
    $("#adj_"+ $(this).attr("id")).removeClass("adjSelected");
  });

  $("div.videoCarrouselBox").hover(function(){
    $(this).addClass("adjSelected");
  },function(){
    $(this).removeClass("adjSelected");
  });

  // rate video
  if($('#videoRater').length != 0)
  {
    $(function(){
      $('#videoRater').rater({
        postHref: siteUrl +'api/rateVideo'
      });
    });
  }
});

function changeVideoCat()
{
  var mthd = $("input[name='mthd']").val();
  if(mthd == '')  mthd = 'allVideos';
  document.location.href = siteUrl +'video/'+ mthd +'/'+ $(this).val();
}

function addTrailerPlayer(id, width, height, movieUrl, movieId, imageUrl)
{
  var playerUrl = siteUrl +"assets/jw_player.swf";
  var flashvars = {};
  flashvars.t = Math.floor(Math.random()*1000000000);
  flashvars.file = movieUrl;
  flashvars.bufferlength = 2;
  flashvars.autostart = "false";
  flashvars.author = "false";
  flashvars.frontcolor = "cccccc";
  flashvars.lightcolor = "66cc00";
  flashvars.backcolor = "111111";
  flashvars.skin = siteUrl +"assets/jw_stylish.swf";
  var params = {};
  params.wmode = "opaque";
  params.allowfullscreen = "false";
  params.allowscriptaccess = "always";
  params.allownetworking = "all";
  var attributes = {};
  swfobject.embedSWF(playerUrl, id, width, height, "9.0.0", false, flashvars, params, attributes);
}

function addVideoPlayer(id, width, height, movieUrl, movieKey, movieId, imageUrl, start)
{
  var playerUrl = siteUrl +"assets/am_player_1.2.swf";
  var s1 = new SWFObject(playerUrl,'ply',height,width,"9","#111111");
  s1.addParam("allowNetworking","all");
  s1.addParam("allowfullscreen","true");
  s1.addParam("allowscriptaccess","always");
  s1.addParam("wmode","Opaque");
  s1.addParam("flashvars","t="+ Math.floor(Math.random()*1000000000) +"&file="+ movieUrl +"&videoid="+ movieKey +"&bufferlength=4&autostart=false&author=Membersarea.nl&description=Membersarea.nl&captions=Membersarea.nl&title=Membersarea.nl&frontcolor=cccccc&lightcolor=66cc00&backcolor=111111&skin="+ siteUrl +"assets/jw_stylish.swf&");
  s1.write(id);
}

function addVideoPlayer2(id, width, height, movieUrl, movieKey, movieId, imageUrl, start)
{
  var playerUrl = siteUrl +"assets/jw_player.swf";
  var flashvars = {};
  flashvars.t = Math.floor(Math.random()*1000000000);
  flashvars.file = movieUrl;
  flashvars.videoid = movieKey;
  flashvars.bufferlength = 2;
  flashvars.autostart = "false";
  flashvars.author = "false";
  flashvars.frontcolor = "cccccc";
  flashvars.lightcolor = "66cc00";
  flashvars.backcolor = "111111";
  flashvars.skin = siteUrl +"assets/jw_stylish.swf";
  var params = {};
  params.wmode = "opaque";
  params.allowfullscreen = "true";
  params.allowscriptaccess = "always";
  params.allownetworking = "all";
  var attributes = {};
  swfobject.embedSWF(playerUrl, id, width, height, "9.0.0", false, flashvars, params, attributes);
}

function closeTrailer()
{
  parent.tb_remove();
}

function goMovie()
{
  parent.location.href = this.href;
}

