function check_inputs(popup_if_false, checkin_field, checkout_field) {
    popup_if_false = typeof(popup_if_false) != 'undefined' ? popup_if_false : true;
    checkin_field = typeof(checkin_field) != 'undefined' ? checkin_field : 'checkin';
    checkout_field = typeof(checkout_field) != 'undefined' ? checkout_field : 'checkout';

    if (calendar_is_not_set_date($(checkin_field))) {
        if(popup_if_false){
            calendar_show_cal($(checkin_field)); 
        }
        return false;
    }
    if (calendar_is_not_set_date($(checkout_field))) {
        if(popup_if_false){
            calendar_show_cal($(checkout_field)); 
        }
        return false;
    }
    return true;
}

function copy_checkin_checkout_fields(){
    var ok = check_inputs(false);
    if(ok){
        $('message_checkin').value = $('checkin').value;
        $('message_checkout').value = $('checkout').value;
        $('message_number_of_guests').value = $('number_of_guests').value;
        check_availability_of_dates();
    }
}

function copy_message_fields_to_book_it(){
    $('checkin').value = $('message_checkin').value;
    $('checkout').value = $('message_checkout').value;
    $('number_of_guests').value = $('message_number_of_guests').value;
}


function refresh_subtotal(){
    $("book_it_button").disabled = '';
    if(calendar_is_not_set_date($('checkin')) || calendar_is_not_set_date($('checkout'))) {
        return false;
    }

    jQuery('#subtotal').html("<img src='../images/spinner_999999.gif' alt='' />");

    var current_req = new Ajax.Request('/rooms/ajax_refresh_subtotal', {asynchronous:true, evalScripts:true, parameters: $('book_it_form').serialize(true)});
}

function action_link() {
    lwlb_show('lwlb_link');
}

function action_facebook() {
    var fbshare = {
   method: 'stream.share',
        display: 'popup'
 };
 FB.ui(fbshare, function(response) {});
}
