$(document).ready(function(){
	
	// current link
	function filterPath(string) {
		return string
		.replace(/^\//,'')
		.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
		.replace(/\/$/,'');
	} 
	$("#nav a").filter(function() {
		return filterPath(this.pathname) == filterPath(location.pathname);
	}).parent().addClass('current');
	
	
	// scrollto
	$("#nav li.current #news").click(function(){
		$.scrollTo($("#news-title"), 300);
		return false;
	});
	
	// gallery
	$('.caption').hide();
	setTimeout(function() {
	        $('.caption:first').fadeIn(2000);
	        $("#gallery").cycle({
				cleartype:  1,
				timeout: 9000,
			    pager:  '#featured',
			 	before: onBefore,
				after: onAfter,
			    next: "#next",
				prev: "#prev"
			});
	    }, 1000);
	function onAfter(curr, next, opts) {
	    $('.caption').fadeIn('fast');
	}
	function onBefore(curr, next, opts) {
		$('.caption').hide();
	}
	
	// hover
	$("#store li a").hover(
	function () {
		$(this).find(".spanbg").stop().animate( { opacity: .85 }, 100 );
	},
	function () {
		$(this).find(".spanbg").stop().animate( { opacity: 0 }, 300 );
	});
	
	// zoom
	$("#store li a").fancyZoom();
	
	// nav hover
	$("#nav li:not([class='current']) a").hover(
	function () {
		$(this).find(".nav-bg").fadeIn(50);
	},
	function () {
		$(this).find(".nav-bg").fadeOut(200);
	});
	//$("#nav li[class='current'] a .nav-bg").fadeIn(50);
	
	// swish
	$(".content a, #footer a").swish();
	$("#nav a").swish({ hoverclass: "navswish" });

});
