$(document).ready(function(){
	//Homepage 1 scrolling pods
	$(".scrollingPods .podsCenterFrame").carousel({
		btnsPosition:"outside",
		 dispItems: 4
	});
	
	//Homepage 2 scrolling pods
	$(".scrollingPodsSmall .podsCenterFrame").carousel({
		btnsPosition:"outside",
		 dispItems: 3
	});
	
	//Remove text from input buttons
	$(".carousel-previous").attr('value','');
	$(".carousel-next").attr('value','');
	
	//Homepage scrolling banner
	$('#slides').slides({
		preload: true,
		play: 10000,
		pause: 2500,
		effect: 'fade',
		
		pagination: true,
		hoverPause: true,
		generatePagination: true,
		animationStart: function(){
			$('.caption').animate({
				bottom:"-33px"
			},100);
		},
		animationComplete: function(current){
			$('.caption').animate({
				bottom:"0px"
			},200);
			if (window.console && console.log) {
				// example return of current slide number
				//console.log(current);
			};
		}
	});
	
	if( $(".bannerFrame").length > 0){
		$(".bannerFrame .caption").hide();
		$(".bannerFrame img").hide();
		$(".bannerFrame h2").hide();
		$(".bannerFrame p").hide();
		
		try{
			console.log("showing banner");
			console.log("Banner Length: "+$(".bannerFrame").length);
		}
		catch(err){
		}
		$(".bannerFrame img").delay(1000).fadeIn(1000,function(){
			$(".bannerFrame .caption").fadeIn(500,function(){
				$(".bannerFrame h2").fadeIn(1000,function(){
					$(".bannerFrame p").fadeIn(1000,function(){
					});
				});
			});
		});
	}
	
	/* this will select the 3 column staff wrapper and then find the staff panels within that element to make sure the heights are the same. */
	$(".staff-wrapper").each(function(){
		$(this).find(".staffPanel").equalHeights();
	});	

	//Image-text pod rollovers
	
	//Disabled till long description is added to the CMS
	
	/*$(".slidingPodInfoFrame").each(function(i){		
		$(this).hover(function () {		
			$(".slidingPodInfoFrame").eq(i).css("background-color","#fff");
			$(".podInfoFrame").eq(i).stop().animate({
				top: "-64px",
				height: "100px"
			}, 500, function() {
				// Animation complete.
			});
		}, function () {
			$(".podInfoFrame").eq(i).stop().animate({ 
				top: "0px",
				height: "34px"
			}, 500, function() {
				// Animation complete.
				$(".slidingPodInfoFrame").eq(i).css("background-color","transparent");
			});
		});
	});*/
	
	$('#Photos').galleryView({
		panel_width: 460,
		panel_height: 345,
		frame_width: 80,
		frame_height: 61
	});
	
	$(".map-directions").bind('keypress',function(e){
		var code = (e.keyCode ? e.keyCode : e.which);
		
		if(code == 13){
			window.open('/printmap?zipcode='+(document.directionForm.directions.value)+'', 'directions', 'width=700, \ height=600, \ directories=no, \ location=no, \ menubar=no, \ resizable=no, \   scrollbars=1, \   status=no, \   toolbar=no');
			event.preventDefault();
		}
	});
});
