//public functions
//toastsCall popup
//
//
//     'bg-success', 'bg-info', 'bg-warning',  'bg-danger',  'bg-maroon',
function toastsCall (type = 'bg-info', title = 'Info', body = 'Toast', auto = true) {
    $(document).Toasts('create', {
        class: type,
        title: title,
        body: body,
        autohide: auto,
        delay: 3000
    })
}
;

function validateIntegers(e, def) {
    var num = parseInt($(e).val());
    if (!(Number.isInteger(num) && num > 0)) {
        $(e).val(def);
        Swal.fire({
            icon: 'error',
            title: 'Error',
            text: 'Please enter integers!'
        });
    } else {
        $(e).val(num);
    }
}
function validateTime(e) {


	re=/^([0-9]|0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]|[0-9])$/;
	var time = ($(e).val());
	if(!re.test(time)){

		if(time>0 && time<=24){
			$(e).val(time.padStart(2,"0")+":00")
			return time;
		}
			$(e).val("");
			Swal.fire({
				icon: 'error',
				title: 'Error',
				text: 'Invalid Time format! (Please enter HH:MM,Max 23:59)'
			});
		return time;
	}else{
		var tm=time.split(":")
		$(e).val(tm[0].padStart(2,"0")+":"+tm[1].padStart(2,"0"));
		return time;
	}

}

function printSheet(div) {
    var printContents = document.getElementById(div).innerHTML;
    var originalContents = document.body.innerHTML;
    document.body.innerHTML = printContents;
    window.print();
    document.body.innerHTML = originalContents;
    $("#activity").keypress(function () {
        Activity_Suggestions();
    });
}

