var $j = jQuery.noConflict();

$j(document).ready(function(){
	//Colorbox
	$j('a.modal').colorbox();
	
	
	//Primary Nav Stuffs
	$j('#primary-nav>li').hoverIntent(primaryNavConfig);
	
	//Quote Box (Call to Action)
	$j('.quote-box').hover(function(){
		$j(this).addClass('hover');
	}, function(){
		$j(this).removeClass('hover');
	});
	
	//Form Field Stuffs
	$j('form#book-flight input, form#search input, form#quick-contact input, form#quick-contact textarea, form#rcq-form input, form#rcq-form textarea, #contact input, #contact textarea').focus(function(){
		if($j(this).val()==$j(this).attr('title')){
			$j(this).val('');
		}
		}).blur(function(){
			if($j(this).val()==''){
			$j(this).val($j(this).attr('title'));
		}
	});
		
	//Tabs Stuff
	$j("#tab-section>div").addClass('tab');
	$j('#tab-section li a').click(function($e){
		
		$e.preventDefault();
		
		$j("#tab-section>div").hide().filter(this.hash).fadeIn();
		$j('#tab-nav li a').removeClass('active');
		$j(this).addClass('active');	
		
	}).filter(':first').click();
	
	//Our Fleet Main Tab Nav
	$j('#fleetNav li a').click(function($e){
		
		$e.preventDefault();
		
		$j("#sectionWrapper>div")
			.hide()
			.filter(this.hash).fadeIn()
			.find('.fleetItemWrapper>div').hide().filter('.fleetItem:first').fadeIn();
			$j('#sectionWrapper>div').filter(this.hash).find('.nav li a').removeClass('active').filter('a:first').addClass('active');
		
		
		$j('#fleetNav li a').removeClass('active');
		$j(this).addClass('active');
		
	}).filter(':first').click();
	

$j('.nav li a').click(function($e){
		
		$e.preventDefault();
		
		$j(".fleetItemWrapper>div").hide().filter(this.hash).fadeIn()
			.find('.imgWrapper>img').hide().filter('img:first').fadeIn()
		$j(".fleetItemWrapper>div").filter(this.hash)
			.find('.imgNav li a').removeClass('active').filter('a:first').addClass('active');
		$j('.nav li a').removeClass('active');
		$j(this).addClass('active');	
		
	}).filter(':first').click();
	
$j('.imgNav li a').click(function($e){
		
		$e.preventDefault();
		
		$j(".imgWrapper img").hide().filter(this.hash).fadeIn();
		$j('.imgNav li a').removeClass('active');
		$j(this).addClass('active');	
		
	}).filter(':first').click();


	
	//RCQ (One-Way | Round-Trip | Multi-Leg)
	
	
	$j('input.roundTrip').click(function() {
		$j('.multi').hide('fast');
		$j('.round').show('fast');
		$j('input.formValue').val('2');
		$j('#insiteKey').val('actk=8odxrq-47dr12ddj2');
	});
	$j('input.multiLeg').click(function() {
		$j('.multi, .round').show('fast');
		$j('input.formValue').val('4');
		$j('#insiteKey').val('actk=8odxrq-475v3q5pbd');
	});
	$j('input.oneWay').click(function() {
		$j('.multi, .round').hide('fast');
		$j('input.formValue').val('3');
		$j('#insiteKey').val('actk=8odxrq-47dqtdn22m');
	});
	
	$j('input#ownLeaseYes').click(function() {
		$j('#ownLeaseLabel').text('Please Describe Your Fleet:');
	});
	$j('input#ownLeaseNo').click(function() {
		$j('#ownLeaseLabel').text('What type of vehicle are you considering for purchase?');
	});
	
	
	$j('#rentalCarYes').click(function(){
		$j('.carToggle').show('fast');
	});
	$j('#rentalCarNo').click(function(){
		$j('.carToggle').hide('fast');
	});
	
	$j('#hotelYes').click(function(){
		$j('.hotelToggle').show('fast');
	});
	$j('#hotelNo').click(function(){
		$j('.hotelToggle').hide('fast');
	});
	
	$j('#otherTransportYes').click(function(){
		$j('.otherToggle').show('fast');
	});
	$j('#otherTransportNo').click(function(){
		$j('.otherToggle').hide('fast');
	});
	
	
	$j('#rentalCarYes2').click(function(){
		$j('.carToggle2').show('fast');
	});
	$j('#rentalCarNo2').click(function(){
		$j('.carToggle2').hide('fast');
	});
	
	$j('#hotelYes2').click(function(){
		$j('.hotelToggle2').show('fast');
	});
	$j('#hotelNo2').click(function(){
		$j('.hotelToggle2').hide('fast');
	});
	
	$j('#otherTransportYes2').click(function(){
		$j('.otherToggle2').show('fast');
	});
	$j('#otherTransportNo2').click(function(){
		$j('.otherToggle2').hide('fast');
	});
	// Datepicker
	$j('.date-text').datepicker();
	
	//Validation Stuff
	 $j('#rcq-form').validationEngine();
	 $j('#quick-contact').validationEngine();
	 $j('#contact').validationEngine();
	 
	 $j("#social-media span#signBtn").colorbox({
		inline:true,
		href:"#signup-form",
		opacity: 0
	});


});

	
var primaryNavConfig = {    
     sensitivity: 10,     
     interval: 100,  
     over: primaryOver,   
     out: primaryOut,
     timeout: 250  
};

function primaryOver(){$j(this).find(">ul").fadeIn('fast');  $j(this).addClass("hover"); }
function primaryOut(){$j(this).find(">ul").fadeOut('fast');  $j(this).removeClass("hover"); }