$(document).ready(function() {

    $("#id_start_date").datepicker();
    $("#id_end_date").datepicker();

    $("div#sponsor-dialog").dialog({
        bgiframe: true,
        height: 520,
        width: 375,
        modal: true,
        resizable: false,
        autoOpen: false,
        close: function(event, ui){
           window.location.href=window.location.href;
        }
    });
    
    $("div#volunteer-dialog").dialog({
        bgiframe: true,
        height: 550,
        width: 400,
        modal: true,
        resizable: false,
        autoOpen: false,
        close: function(event, ui){
           //window.location.href=window.location.href;
        }
    });

    $("div#event-delete-dialog").dialog({
        bgiframe: true,
        resizable: false,
        autoOpen: false,
        height:140,
        modal: true,
        overlay: {
            backgroundColor: '#000',
            opacity: 0.5
        },
        buttons: {
            'Delete this event?': function() {
                window.location.href="/admin/delete/"+$("input#admin-delete-event").attr("alt")+"/return/events"
            },
            Cancel: function() {
                $(this).dialog('close');
            }
        }
    });
    

    $("div.month .sponsor-button").click(function() {
        var key = $(this).attr("id").substring(4,$(this).attr("id").length)
        $("iframe#sponsor-frame").attr({
            src: "/schedule/"+key+"/type/sponsor/"
        });
        $("div#sponsor-dialog").dialog("open");
    });
    
    $("div.month .volunteer-button").click(function() {
        var key = $(this).attr("id").substring(4,$(this).attr("id").length)
        $("iframe#volunteer-frame").attr({
            src: "/schedule/"+key+"/type/volunteer/"
        });
        $("div#volunteer-dialog").dialog("open");
    });
    
    $("input#admin-delete-event").click(function() {
        $("div#event-delete-dialog").dialog("open");
    });
    
    $("input#add-co-sponsor").click(function() {
        $("tr.add-sponsor-c").css("display","table-row");
        $("tr.add-sponsor-btn").css("display","none");
    });
       

});



 

