
function openDialog() {
   $("#modal-dialog").dialog({
      modal: true,
      closable: false,
      closeOnEscape: false,
      resizable: false,
      draggable: false,
      height: 100,
      open: function(event, ui) { $(this).prev('.ui-dialog-titlebar').children('.ui-dialog-titlebar-close').hide(); }
   });
}
function closeDialog() {
   $("#modal-dialog").dialog("close");
}

function createLoadingDiv(divSelector) {
   var html = '<div class="loading"><img src="' + URL_ROOT + 'images/loading.gif" /></div>';
   $(divSelector).html(html);
}

function loadAsync(divSelector, url, data, callback) {
   //createLoadingDiv(divSelector);
   $(divSelector).load(url, data, callback);
}

function savePrediction (elPrediction, idMatch) {
   var matchResult = $("#" + elPrediction + " option:selected").val();
   openDialog();
   $.ajax({
      url: URL_ROOT + 'webservices/ws_league.php',
      data: {action: 'predict', IdMatch: idMatch, MatchResult: matchResult},
      type: 'POST',
      success: function(result) {
         if (result != "1")
            $("#" + elPrediction).attr('selectedIndex', '-1').children("option:selected").removeAttr("selected");
         closeDialog();
      }
   })
}
