$(document).ready( function(){

	$('#bg-slides').css({'display':'block', 'height':'0px'});
	$('#wrapper, footer').css({'display':'block'}).hide();
	$('#prev').css({'left':'0'});
	$('#next').css({'right':'0'});
    $('#get-directions').hide();
	
	
	$('#main-menu ul .hover ').hover( function (){
		$(this).find('.ro').stop().animate({'opacity':'0'});
		}, function(){
		$(this).find('.ro').stop().animate({'opacity':'1'});
	});
	$('#main-menu ul .apply ').hover( function (){
		$(this).find('.ro').stop().animate({'opacity':'0'});
		$('#main-menu .ro').stop().animate({'opacity':'0'});
		}, function(){
		$(this).find('.ro').stop().animate({'opacity':'1'});
		$('#main-menu .ro').stop().animate({'opacity':'1'});
	});
	
	$('#google-map-pic').hover( function (){
		$(this).find('#get-directions').stop().fadeIn(250);
		}, function(){
		$(this).find('#get-directions').stop().fadeOut(250);
	});


///////////////////////////////////////  DRIVER JOBS MENU //////////////////////////////////////
	$('#experienced-drivers-menu #btn1 ').hover( function (){
		$('.rollover-line').stop(true, true).animate({'width':'145px', 'left':'0px'}, 250);
		}, function(){
		$('.rollover-line').stop(true, true).animate({'width':'0px'}, 250);
	});

	$('#experienced-drivers-menu #btn2').hover( function (){
		$('.rollover-line').stop(true, true).animate({'width':'141px', 'left':'180px'}, 250);
		}, function(){
		$('.rollover-line').stop(true, true).animate({'width':'0px'}, 250);
	});

	$('#experienced-drivers-menu #btn3').hover( function (){
		$('.rollover-line').stop(true, true).animate({'width':'75px', 'left':'357px'}, 250);
		}, function(){
		$('.rollover-line').stop(true, true).animate({'width':'0px'}, 250);
	});
	
	$('#experienced-drivers-menu #btn4 ').hover( function (){
		$('.rollover-line').stop(true, true).animate({'width':'62px', 'left':'467px'}, 250);
		}, function(){
		$('.rollover-line').stop(true, true).animate({'width':'0px'}, 250);
	});
	$('#experienced-drivers-menu #btn5 ').hover( function (){
		$('.rollover-line').stop(true, true).animate({'width':'62px', 'left':'566px'}, 250);
		}, function(){
		$('.rollover-line').stop(true, true).animate({'width':'0px'}, 250);
	});

	$('.sub-menu .back-btn ').hover( function (){
		$('.rollover-line').stop(true, true).animate({'width':'113px', 'left':'705px'}, 250);
		}, function(){
		$('.rollover-line').stop(true, true).animate({'width':'0px'}, 250);
			
	});
////////////////////////////////////////////////////////////////////////////////////////////////


	$('.slideshow img').hover( function (){
		$(this).css({'opacity':'0.6'}).stop(true, true).animate({'opacity':'1'}, 500);
		}, function(){
		$(this).css({'opacity':'1'});
	});

    
    $('#express-search-btn').hover( function (){
		$('#search-btn-container .ro').stop(true, true).fadeIn();
		}, function(){
		$('#search-btn-container .ro').stop(true, true).fadeOut();
	});

	


	//$('#prev, #next').css({'opacity':'0.5'});
	$('#prev, #next').hover( function (){
		$(this).stop(true, true).animate({'opacity':'0.5'}, 'fast');
		}, function(){
		$(this).stop(true, true).animate({'opacity':'1'}, 'fast');
	});


	$('.link').mouseenter( function (){
		$(this).find('img').stop().css({'left':'-60px'}).animate({'left':'-30px'}, 500, 'easeOutExpo');
	});
	
	$('.link-landing').mouseenter( function (){
		$(this).find('img').stop().css({'left':'-60px'}).animate({'left':'-30px'}, 500, 'easeOutExpo');
	});
	$('.Apply-btn').mouseenter( function (){
		$(this).find('img').stop().css({'left':'-60px'}).animate({'left':'-30px'}, 500, 'easeOutExpo');
	});
	
	
	$('footer .top').click( function (){
		$('html, body').animate({scrollTop:0},1000,'easeInOutExpo');
		return false;
	});
	
	$('#hiring-map').click( function (){
		$('#pop-ups').animate({'width':'100%'},350,'easeInExpo');
		$('#hiring-map-popup').delay(300).animate({'width':'920px'},600,'easeOutExpo');
		
	});
	$('#orientation').click( function (){
		$('#pop-ups').animate({'width':'100%'},350,'easeInExpo');
		$('#orientation-popup').delay(300).animate({'width':'920px'},600,'easeOutExpo');
		
	});
	
	$('#pop-ups, #hiring-map-popup, #orientation-popup').click( function (){
		$('#pop-ups').animate({'width':'0%'},500,'easeOutExpo');
	    $('#hiring-map-popup, #orientation-popup').css({'width':'0px'});
    });


	$('.slideshow').cycle({
		prev: '#prev',
		next: '#next',
		fx: 'scrollHorz',
		speed:  350,
		easing: 'easeInExpo',
		timeout: 0
	});


	$('#messages').cycle({
		fx: 'scrollUp',
		speed:  350,
		easing: 'easeInExpo',
		timeout: 6000
	});
	
	$('#home').mousemove(function(e){
	    if(e.pageY <= 495){
		    $('#bg-slides').cycle('pause');
	    }
		else{
		    $('#bg-slides').cycle('resume');
		}	
	});
	

});

function opening() {
	
	$('#bg-slides').animate({'height':'495px'}, 1000, 'easeInOutExpo', function(){
		$('#wrapper, footer').fadeIn(500, function(){
			$('#prev').animate({'left':'-50px'},750, 'easeOutBack');
			$('#next').animate({'right':'-50px'},750, 'easeOutBack', function(){
				$('#bg-slides').cycle({fx: 'scrollHorz', speed:  500, easing: 'easeInOutExpo', timeout: 5000}); 		
			});
		});
	});
			
}

$(window).load(opening);


