
$(document).ready(function() {
    $("#text a").attr("target","_blank");
    $("#text_wide a").attr("target","_blank");

    $('#slideshow').cycle({
        fx: 'scrollRight'
    });

     $('#days').click(function(event) {
        $('#hidedate').slideToggle();
    });

    $('.viewpar').bind('click', function(event) {
        event.preventDefault();
        id = $(this).attr('id');
        $('#contest'+id).toggle();
    });

    $(".deletefolder").click(function(){
        folderid = $(this).attr('folder');
        $("#dialog-detail").html("<p>Ben je zeker dat je deze map wilt verwijderen?</p><p>Alle onderliggende mappen en bestanden zullen ook verwijderd worden!</p>");
        $("#dialog-detail").dialog({
            autoOpen: false,
            title: 'Bevestiging',
            height: 160,
            width: 520,
            draggable: false,
            resizable: false,
            modal: true,
            close: function(event, ui) { },
            buttons: {
                'Verwijderen!': function() {
                    $.ajax({
                       type: "GET",
                       url: "http://www.bruggeleeft.be/ajx/ajx.php",
                       data: "action=deleteFolder&folderid="+folderid,
                       success: function(msg){
                            if(msg==1){
                                $(this).dialog('close');
                                window.location.reload();
                            }else{
                                $('#dialog-detail').dialog('close');
                                $("#dialog-detail").dialog( "option", "height", 170 );
                                $("#dialog-detail").dialog( "option", "width", 650 );
                                $("#dialog-detail").dialog( "option", "buttons", { "Ok": function() { $('#dialog-detail').dialog('close'); } } );
                                $("#dialog-detail").html("<div id='errormessages'>Er ging iets fout tijdens het verwijderen van deze folder. Probeer het nogmaals.</div>");
                                $('#dialog-detail').dialog('open');
                            }
                       }
                    });
                },
                Annuleren: function() {
                        $(this).dialog('close');
                }
            }
        });
        $('#dialog-detail').dialog('open');
        return false;
    });
    
    
    $(".deleteevent").click(function(){
        eventid = $(this).attr('event');
        $("#dialog-detail").html("<p>Ben je zeker dat je dit event wilt verwijderen?</p><p>Deze actie is definitief!</p>");
        $("#dialog-detail").dialog({
            autoOpen: false,
            title: 'Bevestiging',
            height: 160,
            width: 520,
            draggable: false,
            resizable: false,
            modal: true,
            close: function(event, ui) { },
            buttons: {
                'Verwijderen!': function() {
                    $.ajax({
                       type: "GET",
                       url: "http://www.bruggeleeft.be/ajx/ajx.php",
                       data: "action=deleteEvent&eventid="+eventid,
                       success: function(msg){
                            if(msg==1){
                                $(this).dialog('close');
                                window.location.reload();
                            }else{
                                $('#dialog-detail').dialog('close');
                                $("#dialog-detail").dialog( "option", "height", 170 );
                                $("#dialog-detail").dialog( "option", "width", 650 );
                                $("#dialog-detail").dialog( "option", "buttons", { "Ok": function() { $('#dialog-detail').dialog('close'); } } );
                                $("#dialog-detail").html("<div id='errormessages'>Er ging iets fout tijdens het verwijderen van dit event. Probeer het nogmaals.</div>");
                                $('#dialog-detail').dialog('open');
                            }
                       }
                    });
                },
                Annuleren: function() {
                        $(this).dialog('close');
                }
            }
        });
        $('#dialog-detail').dialog('open');
        return false;
    });
    

$(".deletediscount").click(function(){
        discountid = $(this).attr('discount');
        $("#dialog-detail").html("<p>Ben je zeker dat je dit voordeel wilt verwijderen?</p>");
        $("#dialog-detail").dialog({
            autoOpen: false,
            title: 'Bevestiging',
            height: 140,
            width: 400,
            draggable: false,
            resizable: false,
            modal: true,
            close: function(event, ui) { },
            buttons: {
                'Verwijderen!': function() {
                    $.ajax({
                       type: "GET",
                       url: "http://www.bruggeleeft.be/ajx/ajx.php",
                       data: "action=deleteDiscount&discountid="+discountid,
                       success: function(msg){
                            if(msg==1){
                                $(this).dialog('close');
                                window.location.reload();
                            }else{
                                $('#dialog-detail').dialog('close');
                                $("#dialog-detail").dialog( "option", "height", 170 );
                                $("#dialog-detail").dialog( "option", "width", 650 );
                                $("#dialog-detail").dialog( "option", "buttons", { "Ok": function() { $('#dialog-detail').dialog('close'); } } );
                                $("#dialog-detail").html("<div id='errormessages'>Er ging iets fout tijdens het verwijderen van het voordeel. Probeer het nogmaals.</div>");
                                $('#dialog-detail').dialog('open');
                            }
                       }
                    });
                },
                Annuleren: function() {
                        $(this).dialog('close');
                }
            }
        });
        $('#dialog-detail').dialog('open');
        return false;
    });

$(".deletetravel").click(function(){
        travelid = $(this).attr('travel');
        $("#dialog-detail").html("<p>Ben je zeker dat je deze travel wilt verwijderen?</p>");
        $("#dialog-detail").dialog({
            autoOpen: false,
            title: 'Bevestiging',
            height: 140,
            width: 400,
            draggable: false,
            resizable: false,
            modal: true,
            close: function(event, ui) { },
            buttons: {
                'Verwijderen!': function() {
                    $.ajax({
                       type: "GET",
                       url: "http://www.bruggeleeft.be/ajx/ajx.php",
                       data: "action=deleteTravel&travelid="+travelid,
                       success: function(msg){
                            if(msg==1){
                                $(this).dialog('close');
                                window.location.reload();
                            }else{
                                $('#dialog-detail').dialog('close');
                                $("#dialog-detail").dialog( "option", "height", 170 );
                                $("#dialog-detail").dialog( "option", "width", 650 );
                                $("#dialog-detail").dialog( "option", "buttons", { "Ok": function() { $('#dialog-detail').dialog('close'); } } );
                                $("#dialog-detail").html("<div id='errormessages'>Er ging iets fout tijdens het verwijderen van het voordeel. Probeer het nogmaals.</div>");
                                $('#dialog-detail').dialog('open');
                            }
                       }
                    });
                },
                Annuleren: function() {
                        $(this).dialog('close');
                }
            }
        });
        $('#dialog-detail').dialog('open');
        return false;
    });

$(".deletemessage").click(function(){
        messageid = $(this).attr('message');
        $("#dialog-detail").html("<p>Ben je zeker dat je dit bericht wilt verwijderen?</p>");
        $("#dialog-detail").dialog({
            autoOpen: false,
            title: 'Bevestiging',
            height: 140,
            width: 400,
            draggable: false,
            resizable: false,
            modal: true,
            close: function(event, ui) { },
            buttons: {
                'Verwijderen!': function() {
                    $.ajax({
                       type: "GET",
                       url: "http://www.bruggeleeft.be/ajx/ajx.php",
                       data: "action=deleteMessage&messageid="+messageid,
                       success: function(msg){
                            if(msg==1){
                                $(this).dialog('close');
                                window.location.reload();
                            }else{
                                $('#dialog-detail').dialog('close');
                                $("#dialog-detail").dialog( "option", "height", 170 );
                                $("#dialog-detail").dialog( "option", "width", 650 );
                                $("#dialog-detail").dialog( "option", "buttons", { "Ok": function() { $('#dialog-detail').dialog('close'); } } );
                                $("#dialog-detail").html("<div id='errormessages'>Er ging iets fout tijdens het verwijderen van het bericht. Probeer het nogmaals.</div>");
                                $('#dialog-detail').dialog('open');
                            }
                       }
                    });
                },
                Annuleren: function() {
                        $(this).dialog('close');
                }
            }
        });
        $('#dialog-detail').dialog('open');
        return false;
    });

$(".deletefile").click(function(){
        fileid = $(this).attr('file');
        $("#dialog-detail").html("<p>Ben je zeker dat je deze file wilt verwijderen?</p>");
        $("#dialog-detail").dialog({
            autoOpen: false,
            title: 'Bevestiging',
            height: 140,
            width: 400,
            draggable: false,
            resizable: false,
            modal: true,
            close: function(event, ui) { },
            buttons: {
                'Verwijderen!': function() {
                    $.ajax({
                       type: "GET",
                       url: "http://www.bruggeleeft.be/ajx/ajx.php",
                       data: "action=deleteFile&fileid="+fileid,
                       success: function(msg){
                            if(msg==1){
                                $(this).dialog('close');
                                window.location.reload();
                            }else{
                                $('#dialog-detail').dialog('close');
                                $("#dialog-detail").dialog( "option", "height", 170 );
                                $("#dialog-detail").dialog( "option", "width", 650 );
                                $("#dialog-detail").dialog( "option", "buttons", { "Ok": function() { $('#dialog-detail').dialog('close'); } } );
                                $("#dialog-detail").html("<div id='errormessages'>Er ging iets fout tijdens het verwijderen van het bericht. Probeer het nogmaals.</div>");
                                $('#dialog-detail').dialog('open');
                            }
                       }
                    });
                },
                Annuleren: function() {
                        $(this).dialog('close');
                }
            }
        });
        $('#dialog-detail').dialog('open');
        return false;
    });

    $(function() {
        var dates = $("#datefrom, #dateto").datepicker({
            dateFormat: 'dd/mm/yy',
            minDate: 0,
            onSelect: function( selectedDate ) {
                var option = this.id == "datefrom" ? "minDate" : "maxDate",
                    instance = $( this ).data( "datepicker" ),
                    date = $.datepicker.parseDate(
                            instance.settings.dateFormat ||
                            $.datepicker._defaults.dateFormat,
                            selectedDate, instance.settings );
                dates.not( this ).datepicker( "option", option, date );
            }
        });
    });
});

    function deleteLocation(locid){
        $("#dialog-detail").html("<p>Ben je zeker dat je deze locatie wilt verwijderen?</p>");
        $("#dialog-detail").dialog({
            autoOpen: false,
            title: 'Bevestiging',
            height: 140,
            width: 430,
            draggable: false,
            resizable: false,
            modal: true,
            close: function(event, ui) { },
            buttons: {
                'Verwijderen!': function() {
                    $.ajax({
                       type: "GET",
                       url: "http://www.bruggeleeft.be/ajx/ajx.php",
                       data: "action=deleteLocation&locationid="+locid,
                       success: function(msg){
                            if(msg==1){
                                $(this).dialog('close');
                                window.location.reload();
                            }else{
                                $('#dialog-detail').dialog('close');
                                $("#dialog-detail").dialog( "option", "height", 170 );
                                $("#dialog-detail").dialog( "option", "width", 650 );
                                $("#dialog-detail").dialog( "option", "buttons", { "Ok": function() { $('#dialog-detail').dialog('close'); } } );
                                $("#dialog-detail").html("<div id='errormessages'>Er ging iets fout tijdens het verwijderen van deze locatie. Probeer het nogmaals.</div>");
                                $('#dialog-detail').dialog('open');
                            }
                       }
                    });
                },
                Annuleren: function() {
                        $(this).dialog('close');
                }
            }
        });
        $('#dialog-detail').dialog('open');
        return false;
    }

