$(function () {
	// clear search default text on focus
	$(".clearDefault").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	// submit forms with links
	$("a.submit").click(function( e ){
		$(this).closest("form").submit();
                e.preventDefault();
		return false;	
	});
	$('form input').keypress(function(e){
		var c = e.which ? e.which : e.keyCode;
		if(c == 13){
		    $(this).closest('form').submit();
		} 
	});
	// search reveal
	$("ul#nav li.last a").click(function(){	
		$("#search").stop().slideToggle(120);
		return false;	
	});
	$("#closeSearch").click(function(){	
		$("#search").stop().slideUp(120);
		return false;	
	});
	// .features links
	$(".features a img").css({ marginRight: '-90' })
	$(".features a").hover(
    	function () {
    		$(this).find("img").stop().animate({ marginRight: '0' }, 100)
    	}, 
    	function () {
      		$(this).find("img").stop().animate({ marginRight: '-90' }, 100)
    	}
  	);
  	// .slideshow links
  	$("#slideSwitch a").css({ backgroundPosition: '0px 0px' }, 100);
	$("#slideSwitch a").hover(
    	function () {
    		$(this).stop().animate({ backgroundPosition: '(0px 5px)' }, 100)
    	}, 
    	function () {
      		$(this).stop().animate({ backgroundPosition: '(0px 0px)' }, 100)
    	}
  	).click(function(){	
  		var target = $(this).attr("href");
  		$(".slideshow, .caption").hide();
  		$("#slideshow"+target).add("#caption"+target).show();
		$("#slideSwitch a:not(this)").removeClass("current");
		$(this).addClass("current");
		return false;	
	});
	// scroll sponsor logos
	var $prev = $("#sponsors .btn-left"); //prev button
	var $next = $("#sponsors .btn-right"); //next button
	$prev.add($next).addClass("disabled");
	$next.removeClass("disabled");
	$("#sponsors .slider").serialScroll({
		items: 'li',
		prev: '#sponsors .btn-left',
		next: '#sponsors .btn-right',
		start: 0, 
		step: 1,
		exclude: 0,
		duration: 300,
		stop: true,
		lock: false,
		force: true,
		easing: 'easeOutQuad',
		cycle: false,
		axis: 'x',
		offset: {left: -30, top: 0 },
		jump: false,
		onBefore:function( e, elem, $pane, $items, pos ){
			$prev.add($next).removeClass("disabled");
			if( pos == 0 )
				$prev.addClass("disabled");
			else if( pos >= $items.length-1 )
				$next.addClass("disabled");
		}
	});
});

