/* Brains for RCM */
jQuery(function( $ ){
		
	// Setup the page
	if ( window.ActiveXObject ) { }
	else {
		$("#top-nav").hide();
		$("#top #top-pics img").each( function () { $(this).hide(); });

		$("body").delay(5000);
	
		$("#top #top-pics img:nth-child(1)").fadeIn('slow', function() {
			$("#top #top-pics img:nth-child(2)").fadeIn('slow', function() {
				$("#top #top-pics img:nth-child(3)").fadeIn('slow', function() {
					$("#top-nav").fadeIn('slow');
				}); 
			});
		});
	}
	
	$("#types a.gallery").fancybox({
				'titleShow'		: true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

	$("#gallery a.gallery").fancybox({
				'titleShow'		: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

	$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};
	
	$('body').scrollTo( 0 ); 	// Reset all scrollable panes to (0,0)
	$.scrollTo( 0 ); 	        // Reset the screen to (0,0)

	$('#nav-top').click(function(e){
		$.scrollTo( '#top', 2000 );
		e.preventDefault();
	});

	$('#nav-types').click(function(e){
		$.scrollTo( '#types', 2000 );
		e.preventDefault();
	});
	$('#btn-types').click(function(e){
		$.scrollTo( '#types', 2000 );
		e.preventDefault();
	});
	
	$('#nav-gallery').click(function(e){
		$.scrollTo( '#gallery', 2000 );
		e.preventDefault();
	});
	$('#btn-gallery').click(function(e){
		$.scrollTo( '#gallery', 2000 );
		e.preventDefault();
	});
		
	$('#btn-specs').click(function(e){
		$.scrollTo( '#specs', 2000 );
		e.preventDefault();
	});
	$('#nav-specs').click(function(e){
		$.scrollTo( '#specs', 2000 );
		e.preventDefault();
	});
	
	$('#btn-plan').click(function(e){
		$.scrollTo( '#plan', 2000 );
		e.preventDefault();
	});
	$('#nav-plan').click(function(e){
		$.scrollTo( '#plan', 2000 );
		e.preventDefault();
	});	
	
	$('#btn-location').click(function(e){
		$.scrollTo( '#location', 2000 );
		e.preventDefault();
	});
	$('#nav-location').click(function(e){
		$.scrollTo( '#location', 2000 );
		e.preventDefault();
	});				

});
