(function($){
  sharedfunctions = function() {
  
  $("li", "#featuredNews").hover(
    function() {
      var headline = $(".headline", this);
      headline.hide();
      headline.next().animate({top: "0"}, 'fast');
    }, function() {
      var details = $(".details", this);
      var headline = $(".headline", this);
      details.animate({top: 198}, "fast");
      headline.show();
    });
  $(".menuitem", "#menu").append('<div class="hover"></div>');
  $(".menuitem", "#menu").hover(
    function() {
      $("img", this).fadeTo("slow", 0.01);
      $(".hover", this).fadeIn("slow").show();
    }, function() {
      $(".hover", this).fadeOut("slow");
      $("img", this).fadeTo("slow", 1);
    });
  $(".clickable").click(
    function(event) {
      event.preventDefault();
      var elementURL = $("a", this).attr("href");
      window.location = elementURL;
    });
  $(".clickableNew").click(
    function(event) {
      event.preventDefault();
      var elementURL = $("a", this).attr("href");
      window.open(elementURL);
    });
  $(".cboxAvatar").click(
    function(event) {
      event.preventDefault();
      var elementURL = $("a", this).attr("href");
      $.colorbox({href: elementURL, transition:"fade"});
    });
  $(".cboxScreenshot").click(
    function(event) {
      event.preventDefault();
      var elementURL = $("a", this).attr("href");
      $.colorbox({innerWidth: 900, innerHeight: 506, href: elementURL, transition:"fade", fullsize: true});
    });
  $("#videoFront").addClass("cboxVideo");
  $("#videoFront").hover(
    function() {
      $(".playVideo", this).fadeTo(300, 1);
    }, function() {
      $(".playVideo", this).fadeTo(300, 0.35);
    });
  $("#videoFront").click(
    function(event) {
      if($(this).hasClass("cboxVideo")) {
        event.preventDefault();
        var elementURL = $("a", this).attr("href");
        $.colorbox({iframe: true, href: elementURL, innerWidth: 645, innerHeight: 509});
      }
      else {
        event.preventDefault();
        // Move behind UP and infront DOWN
        $(this).animate({top: 155}, 300,
          function() {
            $(this).css("z-index", "20");
          });
        $("#videoBack").animate({top: -95}, 300,
          function() {
            $("#videoBack").css("z-index", "10");
          });
        // Move behind DOWN and infront UP
        $(this).animate({top: 62}, 300);
        $("#videoBack").animate({top: -3}, 300);
        $("#videoBack").removeClass("cboxVideo");
        $(this).addClass("cboxVideo");
      }
    });
  $("#videoBack").hover(
    function() {
      $(".playVideo", this).fadeTo(300, 1);
    }, function() {
      $(".playVideo", this).fadeTo(300, 0.35);
    });
  $("#videoBack").click(
    function(event) {
      if($(this).hasClass("cboxVideo")) {
        event.preventDefault();
        var elementURL = $("a", this).attr("href");
        $.colorbox({iframe: true, href: elementURL, innerWidth: 645, innerHeight: 509});
      }
      else {
        event.preventDefault();
        // Move behind UP and infront DOWN
        $(this).animate({top: -95}, 300,
          function() {
            $(this).css("z-index", "20");
          });
        $("#videoFront").animate({top: 155}, 300,
          function() {
            $("#videoFront").css("z-index", "10");
          });
        // Move behind DOWN and infront UP
        $(this).animate({top: -3}, 300);
        $("#videoFront").animate({top: 62}, 300);
        $("#videoFront").removeClass("cboxVideo");
        $(this).addClass("cboxVideo");
      }
    });
  $(".cboxScreenshot", "#screenshots").append('<div class="screenshotsHover"></div>');
  $(".cboxScreenshot", "#screenshots").hover(
    function() {
      $(".screenshotsHover", this).fadeIn(300).show();
    }, function() {
      $(".screenshotsHover", this).fadeOut(300);
    });
  $(".cboxAvatar", "#avatars").append('<div class="avatarsHover"></div>');
  $(".cboxAvatar", "#avatars").hover(
    function() {
      $(".avatarsHover", this).fadeIn(300).show();
    }, function() {
      $(".avatarsHover", this).fadeOut(300);
    });
  $(".clickableMenu", "#wallpapers").append('<div class="wallpapersHover"></div>');
  $(".clickableMenu", "#wallpapers").hover(
    function() {
      $(".wallpapersHover", this).fadeIn(300).show();
    }, function() {
      $(".wallpapersHover", this).fadeOut(300);
    });
  $("#wallpapers .clickableMenu").click(
    function() {
      $(".wallpapersHover", this).fadeOut(300);
      $(".resolutions", this).fadeIn(300).show();
      $(this).hover(
        function() {
          // Do nothing
        }, function() {
          $(".resolutions", this).fadeOut(300);
        });
    });
  $("img", "#networks").hover(
    function() {
      $(this).fadeTo(300, 0.35);
    }, function() {
      $(this).fadeTo(300, 1);
    });
  $("#webshop").hover(
    function() {
      $("a", this).css("color", "#BBBBBB");
    }, function() {
      $("a", this).css("color", "#582A0A");
    });
  
  };
})(jQuery);
