////////////////////////////////////////////////////////
// Common
////////////////////////////////////////////////////////
function serverPost(script, data, callback){
	jQuery.post( script, data, function( data ) {
		callback(true,data);
	}, "json").fail(function(){
		callback(false,{});
	});
};

////////////////////////////////////////////////////////
// MESSAGE WINDOW
////////////////////////////////////////////////////////
function waitMessage(message,title){	
	jQuery("#msgModalGeneralCloseBtn").hide();
	jQuery("#msgModalGeneralConfirmBtn").hide();
	jQuery("#msgModalGeneralCancelBtn").hide();
	jQuery("#msgModalGeneralMessage").html(message);
	jQuery("#msgModalGeneralTitle").html(title);
	jQuery("#msgModalGeneral").modal('show');
}

function showMessage(message,title,callBack,size){
	jQuery("#msgModalGeneral .modal-dialog").removeClass("modal-lg");
	jQuery("#msgModalGeneral .modal-dialog").removeClass("modal-xl");
	if (size!=undefined)
		jQuery("#msgModalGeneral .modal-dialog").addClass("modal-"+size);
	
	jQuery("#msgModalGeneralTitle").html(title);
	jQuery("#msgModalGeneralCloseBtn").show();
	jQuery("#msgModalGeneralMessage").html(message);
	jQuery("#msgModalGeneralConfirmBtn").html("Ok");
	jQuery("#msgModalGeneralConfirmBtn").show();
	jQuery("#msgModalGeneralCancelBtn").hide();
	jQuery("#msgModalGeneralConfirmBtn").off("click");
	jQuery("#msgModalGeneralConfirmBtn").on("click",function(e){
		closeMessageWindow();
		if (callBack!=undefined)
			if (callBack!=null)
				callBack();
	});
	jQuery("#msgModalGeneral").modal('show');
}

function showConfirmMessage(message,title,callBack){
	jQuery("#msgModalGeneralCloseBtn").hide();
	jQuery("#msgModalGeneralConfirmBtn").html("Ok");
	jQuery("#msgModalGeneralCancelBtn").html("Annulla");	
	
	jQuery("#msgModalGeneralTitle").html(title);
	jQuery("#msgModalGeneralMessage").html(message);
	jQuery("#msgModalGeneralConfirmBtn").show();
	jQuery("#msgModalGeneralCancelBtn").show();	
	jQuery("#msgModalGeneralConfirmBtn").off("click");
	jQuery("#msgModalGeneralCancelBtn").off("click");
	jQuery("#msgModalGeneralConfirmBtn").on("click",function(e){
		closeMessageWindow();
		callBack("Y");
	});
	jQuery("#msgModalGeneralCancelBtn").on("click",function(e){
		closeMessageWindow();
		callBack("N");
	});
	
	jQuery("#msgModalGeneral").modal('show');
}

function closeMessageWindow(){
	//jQuery("#msgModalGeneral").removeAttr("data-bs-backdrop");
	jQuery("#msgModalGeneral").modal('hide');
	//jQuery("#msgModalGeneral").css('display','none');
}