// JavaScript Document
	$(document).ready(function(){
		 $("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal',
			padding: 40,
			opacity: .85,
			showTitle: false,
			allowresize: true,
			counter_separator_label: '/',
			theme: 'light_rounded'
						});	
		// tabs ready
		$("#tabs").tabs();
				
		// event datepicker(s)		
		$("#datepickereventstart").datepicker({
			showOn: 'button', 
			buttonImage: 'http://www.kcadventure.com/img/icons/calendar.gif', 
			buttonImageOnly: true
		});
		$("#datepickereventend").datepicker({
			showOn: 'button', 
			buttonImage: 'http://www.kcadventure.com/img/icons/calendar.gif', 
			buttonImageOnly: true
		});
		
		// begin gear div color changes
		$(".maingearblock:even").css("background-color", "#f6f5f5");
  		$(".maingearblock:odd").css("background-color", "#cadceb");
		// begin tr routes color change
		$(".routesrow:even").css("background-color", "#e9e9e9");
  		$(".routesrow:odd").css("background-color", "#fdfdfd");
		
		// copyright modal
		$("#copyright").load('/copyright.php').dialog({
         	title: "KCAdventure.com Copyright Info",
			modal: true,
			autoOpen: false,
			height: 400,
			width: 750
      	}); 
  		// click to open copyrigt modal
    	$('#showcopyright').click(
        function (){
            $("#copyright").dialog("open");
            return false;
       });
		
		// activate dogy hover pulse
		$('div.defthumb img').hoverpulse({
        size: 50,  // number of pixels to pulse element (in each direction)
        speed: 400 // speed of the animation 
    	});		
		
	}); // ***** end functions *****
	
	
	
		// begin animated scroll	
	$(document).ready(function() {
		$("a.anchorLink").anchorAnimate()
	});

	jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
		}, settings);	
	
		return this.each(function(){
		var caller = this
			$(caller).click(function (event) {	
				event.preventDefault()
				var locationHref = window.location.href
				var elementClick = $(caller).attr("href")
			
				var destination = $(elementClick).offset().top;
				$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
				});
		  		return false;
				})
			})
		} // end animated scrolling


		// start tooltips
	$(document).ready(function(){
		tooltip();
	});			
		this.tooltip = function(){			
			xOffset = 10;
			yOffset = 20;		
		
		$("a.tooltip").hover(function(e){											  
			this.t = this.title;
			this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    	},
		function(){
			this.title = this.t;		
		$("#tooltip").remove();
    	});	
		$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
		});			
		}; // end tooltips
		
		
		
		// begin gear guide filter
		(function($){
    
		$.fn.shuffle = function() {
        	var allElems = this.get(),
            getRandom = function(max) {
             return Math.floor(Math.random() * max);
            },
            shuffled = $.map(allElems, function(){
                var random = getRandom(allElems.length),
                randEl = $(allElems[random]).clone(true)[0];
                allElems.splice(random, 1);
                return randEl;
           });
        
        this.each(function(i){
        $(this).replaceWith($(shuffled[i]));
        });
        
        return $(shuffled);
    	};
		})(jQuery);
   
		$(function(){
	     // which div to filter  
   		$(".maingearblock")
        	.css("opacity","1")
       		.hover(function(){
           	$(this).css("opacity","1");
       		}, function() {
           $(this).css("opacity","1");
       	});
       	// all categories filter
   		$("#allcat").click(function(){
       		$(".maingearblock").slideDown();
       		$("#catpicker a").removeClass("current");
       		$(this).addClass("current");
       		return false;
   		});
   		// filter div
   		$(".filter").click(function(){
        	var thisFilter = $(this).attr("id");
        	$(".maingearblock").slideUp();
        	$("."+ thisFilter).slideDown();
        	$("#catpicker a").removeClass("current");
        	$(this).addClass("current");
        	return false;
   		});
   		// not sure
   		$(".discounted-item").shuffle();

		});