jQuery(document).ready(function($){

		$('ul.sf-menu').superfish({
			 autoArrows:  false,
			 animation:   {height:'show'},
			 speed: 0,


			 onBeforeShow: function(){
				 	var theImg =  $(this).parent().children('a').children('img');
					if (theImg.length) {
						if (!theImg.attr("src").match(/-over/) ) {
							theImg.attr( "src", theImg.attr("src").replace(/\./, "-over.") );
						}
					}

				},
			 onHide: function(){
					
					var theImg =  $(this).parent().children('a').children('img');
					theImg.each(function(){
						if ($(this).attr("src").match(/-over/) ) {
								$(this).attr( "src", $(this).attr("src").replace(/-over\./, ".") );
						}
					});

						
			 	}

			 
		});

	$(".galleryThumbs a, .rates .thumb").lightBox({
		imageLoading: '/images/lightbox/ico-loading.gif',
		imageBtnClose: '/images/lightbox/btn-close.gif',
		imageBtnPrev: '/images/lightbox/btn-prev.gif',
		imageBtnNext: '/images/lightbox/btn-next.gif',
		imageBlank: '/images/lightbox/blank.gif'
	 });
	 
});



function submitCookbook() {

	if (!document.cookbookForm.name.value)
		{
			alert('Please enter your Name.');
			document.cookbookForm.name.focus();
			return false;
		}	

	if (!document.cookbookForm.email.value)
		{
			alert('Please enter your Email.');
			document.cookbookForm.email.focus();
			return false;
		}	

	if (!document.cookbookForm.phone.value)
		{
			alert('Please enter your Phone Number.');
			document.cookbookForm.phone.focus();
			return false;
		}
		
	 var params = $("#cookbookForm").serialize();
	$.post("/cgi-bin/cookbook_order.cgi", params,
	   	function(data){
			if (data == 'ok') {
				$("#submitButton").fadeOut('slow', function(){
					$("#cookbookComplete").fadeIn('slow');
				});

				setTimeout(function(){
					document.cookbookForm.reset()
					$("#cookbookComplete").fadeOut('slow', function(){
						$("#submitButton").fadeIn('slow');
					});
				}, 10000);

			}
	});
	
	return false;
}

function submitBook() {

	if (!document.bookForm.name.value)
		{
			alert('Please enter your Name.');
			document.bookForm.name.focus();
			return false;
		}	

	if (!document.bookForm.email.value)
		{
			alert('Please enter your Email.');
			document.bookForm.email.focus();
			return false;
		}	

	if (!document.bookForm.phone.value)
		{
			alert('Please enter your Phone Number.');
			document.bookForm.phone.focus();
			return false;
		}
		
	 var params = $("#bookForm").serialize();
	$.post("/cgi-bin/book_order.cgi", params,
	   	function(data){
			if (data == 'ok') {
				$("#submitButton").fadeOut('slow', function(){
					$("#bookComplete").fadeIn('slow');
				});

				setTimeout(function(){
					document.bookForm.reset()
					$("#bookComplete").fadeOut('slow', function(){
						$("#submitButton").fadeIn('slow');
					});
				}, 10000);

			}
	});
	
	return false;
}

function submitNewsletter() {

	if (!document.newsletterForm.name.value)
		{
			alert('Please enter your Name.');
			document.newsletterForm.name.focus();
			return false;
		}	

	if (!document.newsletterForm.email.value)
		{
			alert('Please enter your Email.');
			document.newsletterForm.email.focus();
			return false;
		}	

		
	 var params = $("#newsletterForm").serialize();
	$.post("/cgi-bin/newsletter.cgi", params,
	   	function(data){
			if (data == 'ok') {
				$("#submitButton").fadeOut('slow', function(){
					$("#newsletterComplete").fadeIn('slow');
				});

				setTimeout(function(){
					document.newsletterForm.reset()
					$("#newsletterComplete").fadeOut('slow', function(){
						$("#submitButton").fadeIn('slow');
					});
				}, 10000);

				_gaq.push(['_trackPageview', '/action/email_subscribe/']);
				
			}
	});
	
	return false;
}


window.onload = function() {
	// PRELOAD

	$(".sf-menu > li").each(
		function() {
			var theImg = $(this).find('img:first');
			if (!theImg.attr("src").match(/-over/) ) {
				$("<img>").attr( "src", theImg.attr("src").replace(/\./, "-over.") );
			}
		}
	);

}
