$(document).ready(function(){
	
	// Map loader
	$('#quote_badge').hide();
	$('#map_wrapper').hide();
	$(window).load(function(){
		$("#loading").remove();
		$("#map_wrapper").fadeIn("slow");
		$('#quote_badge').fadeIn('slow');
	});
	
	// Scrollable
	$(".dribbble").scrollable({
		autoplay:	true,
        loop:		true,
        clickable:	false,
		keyboard:	true,
		steps:		1
    }).autoscroll({interval:2500, speed:4000, autoplay:true, steps:1}).circular();
	
	// Load these links in a new window
	$('a.ext').click(function(){
        window.open(this.href);
        return false;
    });
	
	$('.skipto a.offers').click(function() {
		$('html,body').animate({scrollTop : 900},'slow');
		return false;
	});
	
	$('#nav_about a, .skipto .about').click(function() {
		$('html, body').animate({scrollTop: $("#home_about").offset().top}, 1000);
		return false;
	});
	/*$('#nav_portfolio a, .skipto .work, #feature .work').click(function() {
		$('html, body').animate({scrollTop: $("#expeditions").offset().top}, 1000);
		return false;
	});*/
	
	
	// Code borrowed from http://workshops.fivesimplesteps.com
	var msie6 = $.browser == 'msie' && $.browser.version < 7;
	if (!msie6) {
		var top = $('#nav').offset().top - parseFloat($('#nav').css('margin-top').replace(/auto/, 0));
		$(window).scroll(function (event) {
			// what the y position of the scroll is
			var y = $(this).scrollTop();
			// whether that's below the form
			if (y >= top) {
				// if so, ad the fixed class
				$('#nav').addClass('fixed');
				$('body').css('margin-top','110px');
			}
			else {
				// otherwise remove it
				$('#nav').removeClass('fixed');
				$('body').css('margin-top','0');
			}
		});
	}
	
});
