// jQuery Functions and other Javascript
function slideSwitch() {
		var active = $('.ngg-galleryoverview .active');
		if (active.length == 0) active = $('.ngg-galleryoverview .ngg-gallery-thumbnail-box:last');
		var next = active.next().length ? active.next() : $('.ngg-galleryoverview .ngg-gallery-thumbnail-box:first');
		active.addClass('last-active');
		next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				active.removeClass('active last-active');
			});
	}
	
$(document).ready(function(){

	if($('.ngg-galleryoverview')) {
		$('.ngg-galleryoverview').wrap('<div class="loader"></div>');
	}

  $.preloadCssImages();
  $('a[rel*=facebox]').facebox();
  $('#s').focus(function() {
  	if ($(this).val() == "Keyword(s)") { $(this).val(''); }
  });
  $('#s').blur(function() {
  	if ($(this).val() == '') { $(this).val('Keyword(s)'); }
  })
  
  $('#email').focus(function() {
  	if ($(this).val() == "Your email address") { $(this).val(''); }
  });
  $('#email').blur(function() {
  	if ($(this).val() == '') { $(this).val('Your email address'); }
  })
  
  $('#nav li.parent').hover(function() {
  	$(this).addClass('hover');
  }, function() {
  	$(this).removeClass('hover');
  });
	
}); 

$(window).bind('load', function() {
	if ($('.ngg-galleryoverview')) {
		$('.ngg-gallery-thumbnail').each(function() {
			image = $(this);
			image.prepend('<div class="overlay-background"></div><div class="overlay">'+image.find('img').attr('title')+'</div>');
		});
		$('.ngg-galleryoverview').fadeIn();
		setInterval( "slideSwitch()", 5000 );
	}
});