(function ( $ ) {

		$('#slider').nivoSlider({
				pauseTime:9000
		});
		
		$("#rims li a:first").addClass("active");
		
		$('#rims li a').click(function(e) {
			$('#rims li a').removeClass();
			$(this).addClass('active');
			e.preventDefault();
			ajax_content($(this).attr('name'));
			$.scrollTo('#ajax-content', "slow");
			//$('#rims li a:first').removeClass();
		});
		
		function ajax_content(rim_id) {
			$('#ajax-content').html('Loading...');
			$.ajax({	
				type: "GET",
				url: "get-info.php",
				data: ({
					id : rim_id
				}),
				success: function(data) {
					$('#ajax-content').html(data);
					//$.scrollTo('#ajax-content', "slow");
				}
			});
		}
		
		ajax_content($('#rims li a:first').attr('name'));
		
		/*doTimeout Plugin for Hover Info on Wheels - http://css-tricks.com/13638-a-really-nice-way-to-handle-popup-information/*/
		
		var li_cache, over = false;

		$( "#ajax-content" )
        .delegate( ".wheels", "mouseenter", function ( e ) {
                var $li = $( this ), speed;

                if ( li_cache === this && over ) {
                        $.doTimeout( "hoverOut" );
                        return;
                }

                if ( over ) {
                        $.doTimeout( "hoverOut", true );
                        speed = 0;
                } else {
                        $.doTimeout( "hoverOut" );
                        speed = 500;
                }

                $.doTimeout( "hoverIn", speed, function () {
                        over = true;
                        $li.find( "div" ).fadeTo( 200, 1.0 );
                });
        })
        .delegate( ".wheels", "mouseleave", function ( e ) {
                var $li = $( this );

                $.doTimeout( "hoverIn" );
                $.doTimeout( "hoverOut", 500, function () {
                        over = false;
                        $li.find( "div" ).stop( true ).fadeOut();
                });
        });
		
		$("a.facebook, a.twitter").hover(function() { 
			$(this).stop().animate({"opacity": 1}); 
		},function() { 
			$(this).stop().animate({"opacity": .4}); 
		});

}( jQuery ));
