$(document).ready(function(){
  //Fix mask on right upper side (Subscriptions)
  $("#spotlightMask").css({
      'height' : parseInt($("#spotlightContent").height()) + parseInt($("#spotlightContent").css('paddingTop')) + parseInt($("#spotlightContent").css('paddingBottom')) + 'px',
      'display' : 'block'
  });

  //Init wrShadow
  performerWRShadow.init();
  //Make button-like links to all links with class .button
  $("a.button").wrButton();

  $().vidOpinion();
  $().vidWebshop();
  $().vidBlog();
  //$().vidComment();
  $("#mostCommonTags a").vidTag();

  $("#menu .search a").live('click', function(ev){
      ev.preventDefault();
      vidSpotlight.changeContent('search');
  });

  $("#spotlight_search_close").live('click', function(ev){
      ev.preventDefault();
      vidSpotlight.changeContent('normal');
  });

  $("#menu .login a").live('click', function(ev){
      ev.preventDefault();
      vidSpotlight.changeContent('login');
  });

  $("#spotlight_login_close").live('click', function(ev){
      ev.preventDefault();
      vidSpotlight.changeContent('normal');
  });

  $("#spotlight_logout_close").live('click', function(ev){
      ev.preventDefault();
      vidSpotlight.changeContent('normal');
  });

  $("#searchSubmit").live('click', function(ev){
      ev.preventDefault();
      $("#spotlightSearch").submit();
  });

  //Init login-stuff
  performerFrontUser.init();

  //Init Facebook-stuff
  performerFacebook.init();

  if($("#wr_noAccess").val()){
    vidSpotlight.changeContent('login');
  }

  bindLinksBlank();
});

$(window).load(function(){
    
});

var vidSpotlight = {
    changeContent : function(showItem){
        $("#spotlightContent").css({
            height : parseInt($("#spotlightContent").height()) + 'px'
        });

        $(".spotlightBox:visible").fadeOut(500, function(){
            $("#spotlightContent").animate({
                height : parseInt($("#spotlight_" + showItem).css('height')) + 'px'
            }, 500, function(){
                $("#spotlight_" + showItem).fadeIn();
            });

            $("#spotlightMask").animate({
                'height' : parseInt($("#spotlight_" + showItem).height()) + parseInt($("#spotlightContent").css('paddingTop')) + parseInt($("#spotlightContent").css('paddingBottom')) + 'px'
            }, 500);

            $("#spotlightMask .line").animate({
                'height' : parseInt($("#spotlight_" + showItem).height()) + parseInt($("#spotlightContent").css('paddingTop')) + parseInt($("#spotlightContent").css('paddingBottom')) - parseInt($("#spotlightMask .line").css('marginTop')) - parseInt($("#spotlightMask .line").css('marginBottom')) + 'px'
            }, 500);
        });
    }
}

