$(document).ready(function(){
	
	//top nav
	$("#topNav ul").superfish({
		animation : { height:"show" }				
	});
	
	//home page slideshow
	$('#homePromoContainer').innerfade({
		speed: 'slow',
		timeout: 20000,
		containerheight: '324px',
		type: 'random_start'
	});
	
	//form inputs
	$('input[@title]').example(function() {
	    return $(this).attr('title');
	});
	
	//location dropdown
	$("#locationSwitch").click(function () {
		$('#locations').slideToggle("slow", function() {
			$(document.body).one("click", function () {
				$("#locations").slideUp("slow", function() {
					$('#locationSwitch').removeClass("active");
				});
				$(this).unbind("click");
			});
			$('#locationSwitch').toggleClass("active");
		});
		return false;
	});
	
	//footernav
	$("#footerNav a:last").addClass("last");
	
	//leftnav
	$("#leftNav h6:first").addClass("first");
	
	//fix pngs
	$("img[@src$=.png],.homePromoTag").ifixpng("/img/pixel.gif");
	$("div.equipment").iunfixpng();	
		
	
	//gallery
	$('ul#galleryNav').galleria({
		insert : '#galleryImg',
		onImage   : function(image,caption,thumb) {
			if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) {
				image.css('display','none').fadeIn(1000);
			}
			var _li = thumb.parents('li');
			_li.siblings().children('img.selected').fadeTo(500,0.5);
			thumb.fadeTo('fast',1).addClass('selected');
		},
		onThumb : function(thumb) {
			var _li = thumb.parents('li');
			var _fadeTo = _li.is('.active') ? '1' : '0.5';
			thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
			thumb.hover(
				function() { thumb.fadeTo('fast',1); },
				function() { _li.not('.active').children('img').fadeTo('fast',0.5); }
			)
		}	
	});
	
	//form validation 
	
	$("#content form").validate({
		errorPlacement: function(label,element) {
			label.insertBefore( element.prev() );
		}
	});
});

