$(function() {
	//Documentation located in special.docs.js
	
	//Booking Console
	//$('.console input.date-picker').focus(function(){
	$('.console fieldset, .console .ui-datepicker-trigger').click(function(){
		//console.log("fish");
		if(!($('#console-wrapper').hasClass("extended"))){
			$('#console-wrapper').animate({ width: 990 }, 100, function() {
				$('.console').animate({ width: 810 }, 500, function() {
					$('.focus-toggled').show();
					$('#console-wrapper').addClass("extended");
				});
			});
		};
	});
	    //Add class to datepicker when console dates are in focus, to allow for special css
	$(".date-picker")
		.focus(function (){
			if($(this).parents("form").hasClass('console')){
				$('#ui-datepicker-div').addClass("fromconsole");
			} else {
				$('#ui-datepicker-div').removeClass("fromconsole");
			}
		});

	    //Toggle reservations promo code fields
	$('#advanced-toggle').toggle(function(){
		$(this).toggleClass('active');
		$('#advanced-fields').show();
	}, function(){
		$(this).toggleClass('active');
		$('#advanced-fields').hide();
	});
	
	//Specials Pages - Property Change Select form
	$('#specials-property-qlink').submit(function(event){
		event.preventDefault();
		window.location = $('option:selected', this).val();
	});
	
	//Condo Booking Engine
	$('a.property-details').hover(function(e) {
		var offset = $(this).offset(), t = (offset.t-15);
		$(this).nextAll('.property-details-popup-thing').show().css('top', t)
	}, function(e){
		$(this).nextAll('.property-details-popup-thing').hide()
	});
	
	$("a#clear-link").click(function() { 
		$('form#search-console input#arrive').val("");
		$('form#search-console input#depart').val("");
		return false;
	});
	
	//Interactive Map JQModal 
	//var openFn=function(hash){
	//	hash.w.show();
	//	$('#dialog').css({left:($(window).width()-$('#dialog').width())/2,top:$(window).scrollTop()+10});
	//};
	//var openFnFloorplans=function(hash){
	//	hash.w.show();
	//	$('#floorplans-modal').css({left:($(window).width()-$('#floorplans-modal').width())/2,top:$(window).scrollTop()+10});
	//};
	//var openFnMap=function(hash){	
	//	hash.w.show();
	//	$('#map-modal').css({left:($(window).width()-$('#map-modal').width())/2,top:$(window).scrollTop()+10});				
	//};
	var openFnMapInd=function(hash){	
		hash.w.show();
		hashURL = hash.t;
		$('#msn-map').css({left:($(window).width()-$('#map-modal').width())/2,top:$(window).scrollTop()+10});				
	};
	var openFnMapSearch=function(hash){	
		hash.w.show();
		hashURL = hash.t;
		$('#map-modal-search').css({left:($(window).width()-$('#map-modal-search').width())/2,top:$(window).scrollTop()+10});				
	};
	var hideFnMap=function(hash){
		$('.more-info-wrapper').hide();
		hash.w.hide()
		hash.o.remove();
	};

	//var hideFn=function(hash){
	//	hash.w.hide()
	//	hash.o.remove();
	//};
	
	//$('#dialog').jqm({ closeClass:'jqmClose', onShow: openFn, onHide: hideFn});
	//$('#dialog').jqmAddTrigger('a#btn-post-entry'); 
		
	//$('#floorplans-modal').jqm({ trigger: 'a.btn-floorplans', ajax: '@href',closeClass:'jqmClose', onShow: openFnFloorplans, onHide: hideFn});

	    //var mapLoad = function(hash){  };
				
	//$('#map-modal').jqm({ajax:'/includes/map-new.php', trigger: 'a#meeting-map, #res-map, #resort-map', onShow: openFnMap, onHide: hideFnMap, target:'div#map-content' });
	$('#msn-map').jqm({ajax:'/includes/map-new.php', trigger: '#sidebar-btn-map a, #banner-map, #home-map, #header-btn-map, .condo-view-map', onShow: openFnMapInd, onHide: hideFnMap, target:'div#map-content' });

	$('#map-modal-search').jqm({ajax:'/includes/map-search.php', trigger: 'a#btn-view-on-map', onShow: openFnMapSearch, onHide: hideFnMap, target:'div#map-content' });
	$('#map-modal-search').jqmAddTrigger('a.view-map');
	
	//Condo Comparison page stuff
	$("ul#condominiums li:nth-child(odd)").css("margin-right", "20px");
	
	$('#condo-lightbox').jqm();
	$('#condo-lightbox').jqmShow();
	
	$("#holiday-modal").each(function() {
		$('#holiday-modal').jqm();
		$('#holiday-modal').jqmShow();
	});
	
});

// resizing flash sign up on expand/collapse
function resizeSwf(size) {
	if ( size == 75 ) {
		$("div#tool-sign-up-flash").css("height","74px");
	} else {
		$("div#tool-sign-up-flash").css("height","320px");
	}
}
