$(document).ready(function(){

// Homepage slideshow
if ( jQuery('#pghome').length > 0 ) {

	$('#slider').nivoSlider({
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:3,
        animSpeed:500, //Slide transition speed
        pauseTime:6000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:true, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:false, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
	
	
	
} // end



// form validation for subscribe page
	// if there is a number in any birthdate field, then the associated birthname is required
	// if the date field is empty, is a string or has spaces, then the associate birthname is not required 
	// after form submit, if there are hidden error messages, show all hidden
	// custom error message for birthday rewards
	$("#mc-embedded-subscribe-form").validate({
		rules: 
		{
			RESTAURANT: 
			{
				required: true
			},
			EMAIL: 
			{
				required: true,
				email: true
			},
			SPOUSENAME:
			{
				required: function(element) 
				{
					if ( (isNaN( parseInt ( $("#mce-SPOUSEBDAY-month").val() ) )) && (isNaN( parseInt ( $("#mce-SPOUSEBDAY-day").val() ) )) && (isNaN( parseInt ( $("#mce-SPOUSEBDAY-year").val() ) )) )
					{
					 return "true";
					}
				}
			},
			CHILDNAME1:
			{
				required: function(element) 
				{
					if ( (isNaN( parseInt ( $("#mce-CHILDBDAY1-month").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY1-day").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY1-year").val() ) )) )
					{
					 return "true";
					}
				}
			},
			CHILDNAME2:
			{
				required: function(element) 
				{
					if ( (isNaN( parseInt ( $("#mce-CHILDBDAY2-month").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY2-day").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY2-year").val() ) )) )
					{
					 return "true";
					}
				}
			},
			CHILDNAME3:
			{
				required: function(element) 
				{
					if ( (isNaN( parseInt ( $("#mce-CHILDBDAY3-month").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY3-day").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY3-year").val() ) )) )
					{
					 return "true";
					}
				}
			},
			CHILDNAME4:
			{
				required: function(element) 
				{
					if ( (isNaN( parseInt ( $("#mce-CHILDBDAY4-month").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY4-day").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY4-year").val() ) )) )
					{
					 return "true";
					}
				}
			},
			CHILDNAME5:
			{
				required: function(element) 
				{
					if ( (isNaN( parseInt ( $("#mce-CHILDBDAY5-month").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY5-day").val() ) )) && (isNaN( parseInt ( $("#mce-CHILDBDAY5-year").val() ) )) )
					{
					 return "true";
					}
				}
			}			
		}, // end of rules
		messages: 
		{
			SPOUSENAME:	{ required: "Name is required for birthday rewards." },
			CHILDNAME1:	{ required: "Name is required for birthday rewards." },
			CHILDNAME2:	{ required: "Name is required for birthday rewards." },
			CHILDNAME3:	{ required: "Name is required for birthday rewards." },
			CHILDNAME4:	{ required: "Name is required for birthday rewards." },
			CHILDNAME5:	{ required: "Name is required for birthday rewards." }			
		}, // end of messages
		invalidHandler: function(form, validator) 
		{
			if ( $(".error:hidden") ) // if there is a hidden error, show all hidden
			{
				$("#mc-embedded-subscribe-form .form-toggle.active-toggle").trigger('click');
			}
		} // end of invalidHandler	   
	});	
				

// subscribe page: hide/show birthdays inputs and birthday 8 day message
	$("#bday-msg").hide();
	$("#mc-embedded-subscribe-form .form-toggle").each(function() {
		$(this).addClass("active-toggle");
		$(this).next('div.form-group').hide();
	}); 
	$("#mc-embedded-subscribe-form .form-toggle").hover(
      function () {
        $(this).addClass("active-toggle-hover");
      }, 
      function () {
        $(this).removeClass("active-toggle-hover");
      }
    );
    $("#mc-embedded-subscribe-form .form-toggle").toggle(
      function () {
		$(this).removeClass("active-toggle");
		$(this).addClass("inactive-toggle");
		$(this).next('div.form-group').show(400);
		$("#bday-msg").show(400);
      },
      function () {
		$(this).addClass("active-toggle");
		$(this).removeClass("inactive-toggle");
		$(this).next('div.form-group').hide(400);
      }
    );

// subscribe page: hide/show interest group descrip
	$('<span class="form-toggle-descrip">What\'s this?</span>').insertBefore("span.descrip");
	$("#mc-embedded-subscribe-form .checkbox-label span.descrip").hide();
	$("#mc-embedded-subscribe-form .form-toggle-descrip").hover(
      function (evt) {
        $(this).addClass("form-toggle-descrip-hover");
        evt.preventDefault();
      }, 
      function (evt) {
        $(this).removeClass("form-toggle-descrip-hover");
        evt.preventDefault();
      }
    );
	$("#mc-embedded-subscribe-form .form-toggle-descrip").toggle(
      function () {
        $(this).next().show(400);
      },
      function () {
        $(this).next().hide(400); 
      }
    );
    
    
// New Menu Promo - Izzy's New Save on What You Crave Menu
if ( $('#pgnewcravemenu').length > 0 ) {

	// number nav setup
	$('.details:gt(0)').hide();
	$('#nav-details a:first').addClass('active');
	
	// number nav click behavior
	$('#nav-details a').click(function(evt){
	
		$('#nav-details a').removeClass('active');
		$(this).addClass('active');
		
		$('.details').hide();
		var Target = $(this).attr('href');
		$(Target).show();
		
		evt.preventDefault();
		
	});

}// end New Menu Promo


});
