jQuery(document).ready(function($) {

	$( '.rotator' ).jCarouselLite({
        btnNext: ".next-slide",
        btnPrev: ".previous-slide",
		afterEnd: function(a) {
			var next_href = $( a.children( 'a' ) ).attr( 'rel' );
			$( '.visit-site' ).attr( 'href', next_href );
			
			var current_num = $( a ).attr( 'id' );
			$( '.current' ).html( current_num );
		}
    });
	
	$(document).keyup(function(e) {
		var code = (e.keyCode ? e.keyCode : e.which);
		
		switch(code) {
			case 37: $( '.previous-slide' ).trigger( 'click' ); break;
			case 39: $( '.next-slide' ).trigger( 'click' ); break;
		}
	});

});


jQuery.fn.offsetSlider = function() {
	var windowWidth = jQuery(window).width();
	
	jQuery( '.rotator' ).css({
		padding : '0 0 0 ' + ( ( windowWidth ) / 2.25 ) + 'px'
	});
	
	jQuery( '#stage .tag' ).css({
		left : ( windowWidth / 2.25 ) + 'px'
	});
	
	jQuery( '#stage .slider-navigation' ).css({ 
		right : Math.round( ( windowWidth / 2 ) - 339 ) + 'px'
	});
}
