document.observe('dom:loaded', function() {
	$('search_btn').observe('click', open_reservation_window);
});

function hide_block(block)
{
	if ($(block).getStyle('display') != 'none') new Effect.SwitchOff(block);
}

function show_block(block)
{
	if ($(block).getStyle('display') == 'none')	new Effect.BlindDown(block);					
}

function err(t)
{
	alert('Error ' + t.status + ' -- ' + t.statusText);
}

function open_reservation_window(ev)
{
    if(ev != null) ev.stop();

    var hotel_id    = 210949;
    var arrival     = $('arrival').value;
    var departure   = $('departure').value;

    if (arrival.empty() || departure.empty()) return;

    // screen size
    var width   = screen.width;
    var height  = screen.height;

    // window size
    var w_width = (width * 0.81);
    var w_height = (height * 0.6);

    // window position
    var left    = (width - w_width) / 2;
    var top     = (height - w_height) / 2;

    window.open(reservation_url + 'frame/serve/redirection/' + hotel_id + '/' + arrival + '/' + departure,'reservation_window','width=' + w_width + ',height=' + w_height  + ',left=' + left + ',top=' + top + ',screenX=' + left + ',screenY=' + top + ',status=yes,scrollbars=yes,resizable=yes');
}

/*
window.reservation_window.onunload = function(e)
{
    //alert(reservation_url + 'frame/xhr/cleanup');
    alert('item');

    new Ajax.Request(reservation_url + 'frame/xhr/cleanup', {
                    onFailure: err
    });
}
*/
