/**
 * Javascript for Default Theme
 */
jQuery(document).ready(function(){
    jQuery("ul.sf-menu").supersubs({
        minWidth:    12,                                // minimum width of sub-menus in em units
        maxWidth:    27,                                // maximum width of sub-menus in em units
        extraWidth:  1                                  // extra width can ensure lines don't sometimes turn over
    }).superfish({
        delay:       250,                               // delay on mouseout
        animation:   {opacity:'show',height:'show'},    // fade-in and slide-down animation
        speed:       'fast',                            // faster animation speed
        autoArrows:  true,                             // disable generation of arrow mark-up
        dropShadows: true                              // disable drop shadows
    });
});

jQuery(document).ready(function(){
			jQuery("a#example1").fancybox({
				'titleShow'		: false
			});
			jQuery("a[rel=example_group]").fancybox({
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
				'titlePosition' 	: 'over',
				'easingIn'			: 'swing',
				'easingOut'			: 'swing',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
});

jQuery(document).ready(function() {

    var button = jQuery('#ReservationPromoStatusYes');
	var button1 = jQuery('#ReservationPromoStatusNo');
	
	jQuery("#promo_container").css("display","none");
    if (jQuery.cookie('currentToggle') === 'hidden') {
        togglePanel(button, false);
    }
    else {
        togglePanel(button, true);
    }
   	button.click(function() {
            togglePanel(jQuery(this), true);
    });
	button1.click(function() {
            togglePanel(jQuery(this), false);
    });
});



function togglePanel(button, show) {
    var panel = jQuery('#promo_container');
    if (show) {
        panel.removeClass('hidden');
        button.text('-Hide');
		//jQuery('#promo_container').show();
		jQuery('#promo_container').slideDown("slow");
        jQuery.cookie('currentToggle', '', { path: '/' });
    }
    else {
        panel.addClass('hidden');
        button.text('+Show');
		jQuery('#promo_container').slideUp("slow");	
		//jQuery('#promo_container').hide();
        jQuery.cookie('currentToggle', 'hidden', { path: '/' });
    }
}



		jQuery(document).ready(function(){
		  jQuery('.ajax_loading_image').hide();
		  jQuery('.site-name').change(function() {
			
			if(jQuery(this).val().length != 0) {
			  jQuery('.ajax_loading_image').show();
			  jQuery.getJSON('http://www.clubultima.com/main/reservations/ajax_room_types',
						  {siteId: jQuery(this).val()},
						  function(rooms) {
							if(rooms !== null) {
							  populateTypeList(rooms);
							}
				});
			  }
			});
		});
		
		function populateTypeList(rooms) {
		  var options = '';
		  
		  jQuery.each(rooms, function(index, room) {
			options += '<option value="' + index + '">' + room +'</option>';
		  });
		  jQuery('#reservation_type').html(options);
		  jQuery('#room_type').show();
		  jQuery('.ajax_loading_image').hide();
		}
 
	jQuery(document).ready(function () { 
		jQuery("#ReservationCheckin").datepicker({changeMonth: true, changeYear: true, yearRange: '2009:2015',minDate: -0,dateFormat: 'yy-mm-dd'});
		jQuery("#ReservationCheckout").datepicker({changeMonth: true, changeYear: true, yearRange: '2009:2015',minDate: -0,dateFormat: 'yy-mm-dd'
});
	});
