var Site = {
	
	init : function()
	{
		$(document).pngFix();
		
		$('#gallery a').lightBox({fixedNavigation:true});
		
		
		// init audio players
		$('.audioplayer').each(function(){
			audio_file = $(this).children('a').attr('href'); 
			$(this).html('').flash(
				{
					swf: '/swf/player.swf',
					width:290,
					height:40,
					flashvars:
					{
						soundFile: audio_file
					}
				}
			);
		});
		
	},
	
	validate_form : function(form)
	{
		if(!form) form = document.forms[0];
		var submit_it = true;
		var email_pattern = new RegExp(/[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i);

		$(form).find(".REQUIRED").each(function(req)
		{
			if(($(this).attr('type')!='checkbox' && this.value == '') || 
				($(this).attr('type')=='checkbox' && !this.checked) || 
				($(this).hasClass('email') && !email_pattern.test($(this).val()))) 
			{
				$(this).parents("div.form").addClass('error');
				submit_it = false;
			}
			else
			{
				$(this).parents("div.form").removeClass('error');
			}			
		});
		if( !submit_it ) 
		{
			$('#error_message').html('Please review the highlighted, required fields and resubmit.').fadeIn(250);
			$.scrollTo('#error_message', 800, {easing:'easeInOutCubic'});
		}
		return submit_it;
	}
}

$(document).ready(function() {
	Site.init();
});

