// Script - getTabData.js
// 
// This script assists in applying Ajax principles to tabs.php.
// The tab ID is sent to the prcessTabs.php script which will retrieve the record from MySQL database.

// Start AJAX Process Function
function getTabData(tabid) {
  // Confirm Ajax object is usable
  if (xhrObj) {
    // Call PHP script
    // Use GET method
//   var json = eval('(' + jdata + ')');
    var url = "service.php?tabid=" + tabid+"&r="+Math.random();
    var jdata = "";
    $("#load").ajaxStart(function() { $(this).show(); });
    $("#load").ajaxStop(function() { $(this).hide(); });     
    $.get(url, function(json) {
      var jdata = eval('(' + json + ')');
      $("#content").html(jdata[0].description).show('slow');
      $("#attachments").html("<h3>Attachments:</h3>"+jdata[0].attachments).show('slow');
      $("#entrylink").html(jdata[0].entry_link).show('slow');
     // $("#forums").html("<h3>Problem Set Discussion Forum - Latest Posts:</h3>"+jdata[0].forums).show('slow');
    });
   $(".active").css('background', 'url(templates/images/active.gif)'); //background BLUE for all ACTIVE tabs
    $(".closed").css('background', 'url(templates/images/onhold.gif)'); //background RED for all CLOSED tabs
    $(".upcoming").css('background', 'url(templates/images/upcoming.gif)'); //background GREEN for all COMING SOON tabs    

   var index = "#" + tabid;
   $(index).css('background', 'url(templates/images/clicked_tab.gif)'); //white background for clicked tab
  } else { // Ajax not usable
    $("#content").html('Your browser does not support Ajax calls!');
  } // end if (xhrObj)
} // end function()

