$("#contentBlock div.content").ready(function () {

  //Loading Fade
  var fadeloading = setInterval(function (){
    $("div.rotater div.whitemat span").fadeOut(500);
    clearInterval(fadeloading);
  });

  //Whitemat Fade
  var fadewhite = setInterval(function (){
    $("div.rotater div.whitemat").fadeOut(500);
    clearInterval(fadewhite);
  }, 500);

  //Rotation Start
  var fadetitle = setInterval(function () {
    $("div.rotater div.information span").fadeOut(500);
    clearInterval(fadetitle);

    //Whitemat Fade
    var fadewhite = setInterval(function (){
      $("div.rotater div.information").fadeOut(500);
      clearInterval(fadewhite);
    }, 300);

    //Flag Values
    var banner  = $("div.slider li").length;
    var toside  = 1;
    var current = 1;

    //Default Attributes
    $("div.rotater div.thumbnail li:eq(0)").addClass("current");
    $("div.rotater div.thumbnail li.current span").css("opacity", "0");

    //Auto Rotation
    var rotation = setInterval(function() {
      if (current != banner) {
        axis   = "-";
        toside = 1;
        fade($("div.rotater div.thumbnail li.current span"), 1);
        $("div.rotater div.thumbnail li:eq(" + (current - 1) + ")").removeClass();
        $("div.rotater div.thumbnail li:eq(" + current + ")").addClass("current");
        fade($("div.rotater div.thumbnail li.current span"), 0);
        current = current + 1;
        animation();
      } else {
        axis    = "+";
        toside  = current - 1;
        current = 1;
        fade($("div.rotater div.thumbnail li.current span"), 1);
        $("div.rotater div.thumbnail li:eq(" + (banner - 1) + ")").removeClass();
        $("div.rotater div.thumbnail li:eq(" + (current - 1) + ")").addClass("current");
        fade($("div.rotater div.thumbnail li.current span"), 0);
        animation();
      }
    }, 5000);

    //Thumbnail Hover
    $("div.rotater div.thumbnail li span img").hover(
      function () {
        fade($(this), 0);
      },
      function () {
        fade($(this), 1);
      }
    );

    //Thumbnail Click
    $("div.rotater div.thumbnail li").click(function() {
      if (!$(this).hasClass("current")) {
        clearInterval(rotation);
        flag    = $("div.rotater div.thumbnail li").index($("div.rotater div.thumbnail li.current")) + 1;
        current = $("div.rotater div.thumbnail li").index(this) + 1;
        fade($("div.rotater div.thumbnail li.current span"), 1);
        $("div.rotater div.thumbnail li.current").removeClass("current");
        $(this).addClass("current");
        fade($("div.rotater div.thumbnail li.current span"), 0);
        if (current - flag < 1) {
          axis   = "+";
          toside = flag - current;
        } else {
          axis   = "-";
          toside = current - flag;
        }
        animation();
      } else {
        clearInterval(rotation);
      }
    });

    //Banner Click
    $("div.rotater div.slide li a").click(function() {
      clearInterval(rotation);
    });

    //Fade Thumbnail
    function fade (selector, value) {
      selector.fadeTo(244, value);
    }

    //Banner Animation
    function animation () {
      $("div.rotater div.slider ul").animate(
        { marginTop: axis + "=" + (244 * toside) + "px" }, 886, "easeOutExpo"
      );
    }
  }, 2500);
});
