// JavaScript Document
function validate_zip (suffix) {
	$('#search' + suffix).hide();
	$('#spinner' + suffix).show();
	if ($('#zip' + suffix).val() == '') {
		alert ("Please enter a 5 digit zip code.");
		$('#spinner' + suffix).hide();
		$('#search' + suffix).show();
		$('#zip' + suffix).focus();
		return false;
	} else {
		return true;
	}
}

$(document).ready(function() {	

	$("#slides").slides({
		next: 'next',
		prev: 'prev',
		play: 7000,
		animationStart: function(current){
			$('.caption').animate({
				bottom:-35
			},100);
		},
		animationComplete: function(current){
			$('.caption').animate({
				bottom:0
			},200);
		},
		slidesLoaded: function() {
			$('.caption').animate({
				bottom:0
			},200);
		}
	});

	// scroll to top
	$('a[href*=#]').click(function() {
		var duration=1000; // duration in ms
		var easing='swing'; // easing values: swing | linear
		var newHash=this.hash; // get / set parameters
		var target=$(this.hash+', a[name='+this.hash.slice(1)+']').offset().top;
		var oldLocation=window.location.href.replace(window.location.hash, '');
		var newLocation=this;
		if (oldLocation+newHash==newLocation) { // make sure it's the same location
			// set selector
			if($.browser.safari) var animationSelector='body:not(:animated)';
			else var animationSelector='html:not(:animated)';
			// animate to target and set the hash to the window.location after the animation
			$(animationSelector).animate({ scrollTop: target }, duration, easing, function() {				
				window.location.href=newLocation;// add new hash to the browser location
			});
			return false; // cancel default click action
		}
	});

});
