function makeItScale() {
	var winW = $(window).width();
	if($('body').hasClass('home')) {
		$('#masthead img').css({width:winW, marginLeft: -winW/2});
		var imageW = $('#masthead img').width(); // get the current masthead height
		var ratio = .372; // orginial image aspect ratio (1600 x 595)
		var newHeight = imageW * ratio; // calc the new height of the image.
		$('.masthead-fade').css({height: newHeight}); // set the height to the div with the fade
	}
	else {
		if (winW > 1280) {
			$('#masthead img').css({width:winW, marginLeft: -winW/2});
			var imageW = $('#masthead img').width(); // get the current masthead height
			var ratio = .372; // orginial image aspect ratio (1600 x 595)
			var newHeight = imageW * ratio; // calc the new height of the image.
			$('.masthead-fade').css({height: newHeight}); // set the height to the div with the fade
		}
	}
}
$(function() {
	$('body').each(function(){
		makeItScale();
		$(window).resize(function(){		
			makeItScale();
		});
	});
	
	$('#sidebar #check-avail-wrapper h2').click(function() {
		$("#check-avail-wrapper h2").toggleClass("active");
		$("#reservations-console").slideToggle("slow");
	});
	
	$('body.home #arrival-field input, body.home #arrival-field img').one('click',function() {
		$("#check-avail-wrapper h2").toggleClass("active");
		$('#ui-datepicker-div').css('opacity','0');
		$(".console .field, .console .promo-trigger").show();
		$('#check-avail-wrapper').animate({ height:'293px'},'fast', function() {
			$('#ui-datepicker-div').css('opacity','1');
			$('#ui-datepicker-div').css('margin-top','-130px');
			$('#ui-datepicker-div').css('margin-left','-40px');
			$('#nav').css('z-index','50');
			$('#reservations-console').removeClass('inactive').removeClass('ie7-hack').addClass('active');
			$('.ui-datepicker-trigger-inactive').hide();
			$('.ui-datepicker-trigger').show();
			$('#reservations-console').initializeForm();
			$('#reservations-console .date-picker').datepicker({ disabled: false });
			$('#arrival').focus();
		});
	});

	$('body.home #check-avail-wrapper h2').toggle(function() {
		$("#check-avail-wrapper h2").addClass("active");
		$('#ui-datepicker-div').css('opacity','0');
		$(".console .field, .console .promo-trigger").show();
		$('#check-avail-wrapper').animate({ height:'293px'},'fast');
	   }, function() {
		$("#check-avail-wrapper h2").removeClass("active");
		$('#ui-datepicker-div').css('opacity','0');
		$(".console .field:not(#arrival-field), .console .promo-trigger").hide();
		$('#check-avail-wrapper').animate({ height:'150px'},'fast');
	});

	$('a.promo-trigger').click(function(e){
		e.preventDefault();
		$('#promo-code-wrapper').toggle();
	});

	$("#email-signup h2").click(function () {
		$("#email-signup h2").toggleClass("active");
		$("#email-signup-form").slideToggle("slow");
	});
	
	$('.button a, .close a').click(function(e){
		e.preventDefault();
		$('#promo-code-wrapper').hide();
	});
	
	$('.promo-trigger a').click(function(e){
		e.preventDefault();
		$('#promo-code-wrapper').show();								 
	});

	if (!CMT) {
		$("div.job-title a").click(function (e) {
			e.preventDefault();
			$(this).parent().next().slideToggle("slow");
		});
	} else {
		$("div.job-description").click(function (e) {
			$(this).show();
		});
	}

	//modified packages expand/collapse.
	/*$('.package').each(function(){
		$('.package-details').toggle(function(e){
			e.preventDefault();
			$(this).text('Hide Details').parent().addClass('active').find('.package-content').slideDown('slow');
		}, function(e){
			e.preventDefault();
			$(this).text('View Details').parent().removeClass('active').find('.package-content').slideUp('fast');
		});
	});*/





});
