$(function(){
	$('a[rel=external]').each(function(){this.target="_blank";});
	
	$('#gnav a').each(function(){if(this.href==window.location) $(this).parents('#gnav>li').addClass('indicator');}).parent().css('cursor', 'pointer').click(function(event){event.stopPropagation();window.location = $(this).children('a').get(0).href;

	});
	
	$('.lnav a').each(function(){if(this.href==window.location) $(this).parent(           ).addClass('indicator');}).parent().css('cursor', 'pointer').click(function(event){event.stopPropagation();window.location = $(this).children('a').get(0).href;});
	$('#gnav li, .lnav li').hover(function(){$(this).addClass('hover')}, function(){$(this).removeClass('hover')});
	$('.interior #ps').attr('src', 'images/ps' + Math.ceil(Math.random()*3) + '.jpg');
	rotate();
	$(".controls a").click(function(){
		$(":animated").stop();
		$(".testimonial .showing").fadeOut(500).removeClass("showing");
		$( $(this).attr("rel") ).fadeIn(500).addClass("showing");
		return false;
	});
});


var delay = 4000;
function rotate(){
	$(".testimonial .showing").fadeTo(delay,1,function(){
		delay = 4000;
		var next = $(".testimonial .showing").next().length>0?$(".testimonial .showing").next(): $(".testimonial div:first-child");

		
		$(".testimonial .showing").fadeOut(1500);
		$(".showing").removeClass("showing");
		next.addClass("showing");
		next.fadeIn(1500,rotate);
	});
}