﻿$(function() {
  $("#bgright").animate({ opacity: 0 });
  $("#imageContainer").css('width', $("#overlay")[0].scrollWidth.toString() + "px");
  $("#imageContainer").css('height', ($("#overlay")[0].scrollHeight - 28).toString() + "px");
  $("#textContainer").css('zoom', 1);

  $(".hoverImage").mouseenter(
        function() {
          $(this).animate({ opacity: 0.4 }, 500).animate({ opacity: 0.8 }, 1000);
        }).mouseleave(function() {
          $(this).stop(true).animate({ opacity: 1 }, 0);
        }
			);

  window.setTimeout(function() {
    AnimateImage();
  }, 1000);
});

// The following plugin may be removed, when jQuery 1.4 is available with its delay efect..
$.fn.pause = function(duration) {
  $(this).animate({ dummy: 1 }, duration);
  return this;
};

function AnimateImage() {
  $("#bgright").
			pause().
			css("visibility", "visible").
			animate({ opacity: 0.5 }, 1000).
			pause(2000).
			animate({ opacity: 0 }, 1000, function() {
			  window.setTimeout(function() {
			    AnimateImage();
			  }, 15000);
			});
}
