﻿function RequestInfo(ids) {
  openJQueryDialog('Dialogs/RequestInfo.aspx?CS=' + ids, 'Make an Enquiry', 530, 410);
}

function AddCentreToRucksack(centreId, control) {
  $.ajax({    
    type: "POST",
    url: rootUrl + "WebServices/Rucksack.asmx/AddCentre",
    data: "{ centreId: " + centreId + "}",
    contentType: "application/json",
    dataType: "json",
    success: function(response) {
      var data = response.d;
      $(control).attr("disabled", "disabled");
      $(control).addClass("disabled");
      $(control).attr("onclick", "return false;");
      $(control).text("The Centre has been added to your Rucksack");
      $("#spanRucksackItemsCount").text(data.Count);
      $(".rucksackItemAdded").stop(true, true).hide();
      $(".rucksackItemNotAdded").stop(true, true).hide();
      if (data.Added)
        $(".rucksackItemAdded").slideDown(1000).delay(3000).slideUp(1000);
      else
        $(".rucksackItemNotAdded").slideDown(1000).delay(3000).slideUp(1000);        
    },
    error: function(req, msg, err) {
    }
  });
}
function AddCentresToRucksack(centreIds) {
  $.ajax({    
    type: "POST",
    url: rootUrl + "WebServices/Rucksack.asmx/AddCentres",
    data: "{ centreIds: [" + centreIds + "] }",
    contentType: "application/json",
    dataType: "json",
    success: function(response) {
      var data = response.d;
      $("#spanRucksackItemsCount").text(data.Count);
      $(".rucksackItemsAdded").stop(true, true).hide();
      $(".rucksackItemsNotAdded").stop(true, true).hide();
      if (data.Added)
        $(".rucksackItemsAdded").slideDown(1000).delay(3000).slideUp(1000);
      else
        $(".rucksackItemsNotAdded").slideDown(1000).delay(3000).slideUp(1000);        
    },
    error: function(req, msg, err) {
    }
  });
}

function RemoveCentreFromRucksack(centreId) {
  $.ajax({
    type: "POST",
    url: rootUrl + "WebServices/Rucksack.asmx/RemoveCentre",
    data: "{ centreId: " + centreId + "}",
    contentType: "application/json",
    dataType: "json",
    success: function(response) {
      var data = response.d;
      $("#spanRucksackItemsCount").text(data.Count);
    },
    error: function(req, msg, err) {
    }
  });
}
