$(document).ready(function() {
	// For all pages
	globalScripts();
	//initialize slideshow
	$('.preloadPhoto').hide();
	$('#slideshow').removeClass('hideGallery').cycle({
		fx:     'fade', 
	    speed:  'fast', 
	    timeout: 0, 
	    before: function(){
           var thisheight = $(this).height();
           var offset = 0 - thisheight / 2;
           $(this).css("margin-top",offset);
	   	},
	    pager:  '#slideNav', 		     
	    // callback fn that creates a thumbnail to use as pager anchor 
	    pagerAnchorBuilder: function(idx, slide) { 
	        return '<li><a href="#"><img src="' + slide.src + '" height="80" /></a></li>'; 
	    }
	});	
	//declare carousel nav as products slideshow pager
	function mycarousel_initCallback(carousel) {
	    $('#slideNav li').bind('click', function() {
	        carousel.scroll(jQuery.jcarousel.intval($(this).attr("jcarouselindex")));
	        return false;
	    });
	    var slidewidth = $('#slideNav').css('width');
	    
	    $('.jcarousel-container').css({'width' : slidewidth, 'padding-left' : 20, 'max-width' : 600});
	};
	//set up carousel nav for homepage right product area slideshow
	$('#slideNav').jcarousel({
		initCallback: mycarousel_initCallback,
	    scroll: 1,
	    visible: 5
	});
	$('.jcarousel-next, .jcarousel-prev').css('opacity',.7).hover(function(){
		$(this).css('opacity',1); },
		function() {
		$(this).css('opacity',.7); }
	);
	
	$(".tipsubmit").show();	
	
	$(".tipsubmit[rel]").overlay({
		mask: {
			color: '#ffffff',
			loadSpeed: 200,
			opacity: 0.5
		},		
		closeOnClick: true,
		effect: 'apple'}
	);
	
	$("#tipoverlay form").validate({
		rules: {
			email: {
				required: true,
				email: true
			},
			tip: {
				required: true,
			    maxlength: 3000
			}
		},
		messages: {
			email: "Please enter a valid email address"
		}
	});
	
	$('#tipoverlay form').ajaxForm({
		target: '.notify'
	});

});
