
                var dialogs = new Array();

                function bind_popup_maps(selector) {
                    if (typeof(selector) == 'undefined') selector = '.popup_map';
                    $(selector).click(function(event){
                        href = $(this).attr('href');
                        title = $(this).attr('title');

                        loader = $('<div />').addClass('loader_big');

                        dialog = $('<div />').addClass('popup').addClass('loader_big').attr('title', title).appendTo('body').dialog({
                            autoOpen: true,
                            minWidth: 200,
                            minHeight: 300,
                            resizable: false,
                            modal: true,
                            draggable: false
                        }).append(loader).load(
                            href, {content_only: 1}, function() {
                                map_width = $(this).find('img.map').outerWidth();
                                google_map_width = $(this).find('div').outerWidth();
                                $(this).dialog('option', 'width', Math.max(map_width, google_map_width)+25);
                                $(this).dialog('option', 'position', 'center');
                                $(this).removeClass('loader_big');
                            }
                        ).bind( "dialogclose", function(event, ui) {
                            $(this).remove();
                        });

                        event.preventDefault();
                    });
                }


                $(document).ready(function(){

                    bind_popup_maps();

                    $('.events_calendar li a, #event_calendar a.event').click(function(event) {

                        var href = $(this).attr('href');

                        var re = /id=([0-9]*)/i;
                        var result = re.exec(href);

                        if (typeof(result[1]) == 'undefined') return;
                        var id = result[1];

                        var dialog;

                        if (typeof(dialogs[id]) != 'undefined') {
                            dialog = dialogs[id];
                            dialog.dialog('open');
                        }
                        else {
                            var title = $(this).html();

                            dialog = $('<div><div class="loader_big"><\/div><\/div>').attr('title', title).appendTo('body');

                            $(dialog).dialog({
                                autoOpen: true,
                                width: 600,
                                resizable: false,
                                buttons: {
                                    "Close": function() {
                                        $(this).dialog("close");
                                    }
                                }
                            });


                            $.get(href, {content_only: 1}, function(data){
                                dialog.html(data);
                            });

                            dialogs[id] = dialog;
                        }

                        event.preventDefault();

                        dialog.parents('.ui-dialog').find('button').each(function(){
                            $(this).children('span').html($(this).attr('text'));
                        });
                    });


                });



$(document).ready(function(){
    $('input[name="search_check_date"]').click(searchCheckDateClick);
    searchCheckDateClick();
});

function searchCheckDateClick() {
    if($('input[name="search_check_date"]').is(':checked')) {
        $('input[name="search_begin_date"]').removeAttr('disabled');
        $('input[name="search_end_date"]').removeAttr('disabled');
    }
    else {
        $('input[name="search_begin_date"]').attr('disabled', 'true');
        $('input[name="search_end_date"]').attr('disabled', 'true');
    }
}

