externalLinks();

if (typeof jQuery != 'undefined') {
	$(document).ready(function() {

		if ( $("#photogallery").size()) { // Check if the div exists
			$('#photogallery a').lightBox({
				fixedNavigation: true
			});
		}

		if ($("#photocontainer").size()){ // Check if the div exists
			 $('#photocontainer').cycle({
				fx:     'fade',
				timeout: 5000,
				delay:  -2500,
				next:   '#next',
				prev:   '#prev'
			});
		}

		// Fancybox
		if($("a.zoom").size()) {
			$("a.zoom").fancybox({
						'overlayOpacity'	:	0.7,
						'overlayColor'		:	'#000'
			});
		}

		// Validation
		if($('.validate').size()) {
			$(".validate").validate({
				errorLabelContainer: $("#errorContainer")
			});
			
			// Add error title
			$('#errorContainer').html('<h3 class="error">The following errors occured:</h3>');
			
			// add an * after required fields
			$('input.required, select.required, textarea.required').each(function(){
				$('label[for='+$(this).attr('id')+']').append(' *');
			});
		}

	});
}