$(document).ready(function() {
	$(".slide").hover(
	  function () {
      if($("p", this).is(':animated')) {
        $("p", this).stop();
      }
      $("p", this).fadeIn();
    },
	  function () {
      if($("p", this).is(':animated')) {
        $("p", this).stop();
      }	  
      $("p", this).fadeOut();
	  }
	);
  
  $('#content').autoPrettyphoto();
  //$('#content').generateCaption();
  //$('#content').animRolloverFade();
	
	$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'facebook', overlay_gallery: false });
	$("a[rel^='lightbox']").prettyPhoto({theme: 'facebook', overlay_gallery: false });
  
  /*$('img[name^="img"]', $('#bg_wrapper')).each(function()
  {
    var i = Image();
    i.src = $(this).attr('name');
    document.setTimeOut(function()
    {
      $(
    }, 1000);
  });*/
});

/* Slider Initializer */

$(document).ready(function() {	
	$('#bg_wrapper').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		random: true,
		timeout: 10000
	});					

	function BGresize() {
		jQuery("img#background").each(function(){
			var imgheight = jQuery(this).height();
			var imgwidth = jQuery(this).width();
			
			var windowheight = jQuery(window).height();
			var windowwidth = jQuery(window).width();
			
			var ratio = 1;
			if(windowheight/imgheight > windowwidth/imgwidth)
			{
				ratio = windowheight/imgheight;
			} else
			{
				ratio = windowwidth/imgwidth;
			}	
			
			imgheight *= ratio;
			imgwidth *= ratio;
			
			var topD = (windowheight-imgheight)/2;
			var leftD = (windowwidth-imgwidth)/2;
			
			jQuery(this).css("top", topD+"px");
			jQuery(this).css("left", leftD+"px");
			
			jQuery(this).height(imgheight);
			jQuery(this).width(imgwidth);
		});
		window.setTimeout(BGresize, 200);
	};
	BGresize();
});
