$(document).ready(function() {
    $('#book_now_button').click(function(e){
        e.preventDefault();
        var yolo_warning_content = $('#id-yolo-warning-container').html();
        jQuery.facebox(yolo_warning_content);
        
        // hide the close button - force users to use our controls.
        $('.close').each(function(){
            $(this).hide();
        });
        
        $('#facebox_overlay').unbind('click');
    });
    
    $('#book_now_button_yolo').live('click', function(e) {
        $('#book_now_form').submit();
    });
    
    $('#cancel').live('click', function(e) {
        jQuery(document).trigger('close.facebox');
        e.preventDefault();
        $('.close').each(function(){
            $(this).show('slow');
        });
    });
    
    $("input[id^='book_now_button-']'").live('click', function(e) {
        e.preventDefault();
        var yolo_warning_content = $('#id-yolo-warning-container').html();
        jQuery.facebox(yolo_warning_content);
        
        // hide the close button - force users to use our controls.
        $('.close').each(function(){
            $(this).hide();
        });
        
        $('#facebox_overlay').unbind('click');
        
        var id = parseInt(this.id.replace('book_now_button-',''));
        // replace the main book now form data with this data.
        $('#departure_id').attr('value', id);
    });
});