


//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
// Open the Date Range Picker dialog
//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
var bDateRangePickerDialogIsOpen = false;
function OpenDateRangePickerDialog() {

    // Open the dialog
    // igniteui.com/help/igdialog-property-reference
    $("#igDialogDateRangePicker").igDialog({ modal: true, headerText: "Choose Date Range", height: 250, width: 350, resizable: true, showCloseButton: true, showMaximizeButton: false, closeOnEscape: true, openAnimation: "", closeAnimation: "fade"/*, openAnimation: "fade"*/ });
    $("#igDialogDateRangePicker").igDialog("open");

    CenterDialog("igDialogDateRangePicker");

    // Set up controls
    bDateRangePickerDialogIsOpen = true;
}


var DateRangePickerCallback = null;

//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
// Close the dialog
//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
function CloseDateRangePickerDialog() {

    // Callback when selection is made
    if (DateRangePickerCallback != null) {
        var StartDate = $('#DateRangePickerStartDate').val();
        var EndDate = $('#DateRangePickerEndDate').val();
        if (!StartDate)
            return;
        if (!EndDate)
            return;

        // Ugly and unreliable date parsing
        var StartDateParts = StartDate.split('-');
        var EndDateParts = EndDate.split('-');
        var StartDateObject = new Date(StartDateParts[0], StartDateParts[1] - 1, StartDateParts[2]);
        var EndDateObject = new Date(EndDateParts[0], EndDateParts[1] - 1, EndDateParts[2]);
        DateRangePickerCallback(StartDateObject, EndDateObject);
    }

    $("#igDialogDateRangePicker").igDialog("close");
    bDateRangePickerDialogIsOpen = false;
}

function IsDateRangePickerDialogOpen() {
    return bDateRangePickerDialogIsOpen;
}
