$(document).ready(
	function(){
		$("ul.sf-menu").supersubs({
			minWidth:			10,
			maxWidth:			20,
			extraWidth:		1
		}).superfish({
			autoArrows:		false
		}); 
		
		$("#carousel").jCarouselLite({
			btnNext: ".next",
    	btnPrev: ".prev",
    	/* auto: 6000, */
    	speed: 1000,
    	easing: "easeInOutQuad",
    	visible:	1,
    	btnPrev: ".carousel_prev",
    	btnNext: ".carousel_next"
		});
		
		
		carousel_nav = $(".carousel_prevxxx, .carousel_nextxxx")
		
		carousel_nav.fadeTo(3000,1).fadeTo(3000,.01);
		
		$('#carousel').hover(
			function(){
				carousel_nav.stop().fadeTo(250,.99);
			},function(){
				carousel_nav.stop().fadeTo(500,.01);
			}
		);
		
		
		$('.hb').each(
			function(){
				x = $(this).attr('pop');
				$(this).append('<span class="pop" style="opacity:0"> '+ x +' </span>');
			}
		)
		
		show_pop = function(e){
			e.children('.pop').stop().animate({
				bottom: '0px',
				opacity: '0.80'
			},700)
		}
		hide_pop = function(e){
			e.children('.pop').stop().animate({
				bottom: '-20px',
				opacity: '0'
			},100)
		}
		
		$('.hb').hoverIntent(
			function(){
				$(this).stop().animate({
					borderTopColor: "#ed1c24",
					borderRightColor: "#ed1c24",
					borderBottomColor: "#ed1c24",
					borderLeftColor: "#ed1c24"},150,'swing',show_pop($(this)))
			},function(){
				$(this).stop().animate({
					borderTopColor: "#ffffff",
					borderRightColor: "#ffffff",
					borderBottomColor: "#ffffff",
					borderLeftColor: "#ffffff"},300,'swing',hide_pop($(this)))
			}
		);
		
		
		$("#flash_notice").effect('pulsate',{ times: 2 },400).delay(5000, function(){
			$("#flash_notice").animate({
						height: "0px",
						opacity: "0",
						fontSize: "0px",
						lineHeight: "0px"},1200,"linear",function(){
				$(this).remove();
			});
		});
		
		doFck = function(){
			$('.fck_full:visible').fck({
				path:			'/fckeditor/',
				toolbar:	'RLFull',
				height:		300
			});
			$('.fck_full_tall:visible').fck({
				path:			'/fckeditor/',
				toolbar:	'RLFull',
				height:		500
			});
			$('.fck_basic:visible').fck({
				path:			'/fckeditor/',
				toolbar:	'RLBasic',
				height:		200
			});
		}
		doFck();
		
		$('#cancel_record, #delete_record').click(
			function(){
				window.location=$(this).attr('href');
			}
		)
		
		bike_tabs = $(".tab_table .tabs td a")
		bike_panels = $("#specs, #geometry, #downloads, #reviews, #share")
		
		bike_tabs.click(
			function(){
				bike_panels.hide();
				bike_tabs.removeClass('active');
				$( $(this).attr('href') ).show();
				$(this).addClass('active');
				return false;
			}
		)
		
		Cufon.replace('.coupe')
		
		$('.zoom').zoomimage({
			centered:			true,
			hideSource:		true,
			opacity:			0.5,
			controls:			false,
			duration:			500
		});
		
		$('#locator_form :text').focus(
			function(){
				if ($(this).val() == 'ENTER ZIP') {
					$(this).val('')
				}
			}
		);
		
		$('#locator_form :text').blur(
			function(){
				if ($(this).val() == '') {
					$(this).val('ENTER ZIP')
				}
			}
		);
		
		$('#locator_form').submit(
			function(){
				zip = $('#locator_form :text').val();
				window.open('http://www.sbshub.com/alldealers/results.php?s_Dealer_Zip='+zip+'&s_Dealer_Redline=ON&s_Dealer_Radius=50');
				return false;
			}
		)
		
	}
);