//-----------------------------------------------------------
// error.js
//
// This contains the central code to handle all container-based errors
//
// Version History:
// ----------------
// 20111027: Added redirection parameter and, if set, redirect to new url upon error lightbox ok click
// 20110914: Parameter mod to shadowbox to allow select boxes to display in the background as applicable
// 20110614: Message formatting changes
// 20101209: Initial version
//-----------------------------------------------------------

var errCodes = $H();                                        // Holds all error codes and user error messages

// Database error messages
errCodes.set('A100','Database connectivity failure');
errCodes.set('A101','Unsupported database');
errCodes.set('A102','Database SQL');

errCodes.set('B100','Invalid report identifier');           // This pertains to rqst_id errors, not rprt_id
errCodes.set('B101','Invalid target identifier');
errCodes.set('B102','Data formatting');
errCodes.set('B103','String parsing');
errCodes.set('B104','Unidentified data');                   // Data expected but dont know what this is
errCodes.set('B105','Unexpected data');                     // Data where it is unexpected
errCodes.set('B106','Missing data');                        // Data not where it is expected
errCodes.set('B107','Invalid data');                        // Data is invalid

errCodes.set('C100','Processing');
//-------------------------------------------------------------------------

function handleErr (eCode, eLoc, eProg, eVers, eMesg, eRedir) {

   // Purpose:   Display modal box to display error message

   // Arguments: eCode: the user error code
   //            eLoc:  code locator
   //            eProg: the "program" where the error occurred 
   //            eVers: the version of the "program" that failed
   //            eMesg: the error message
   //            eRedir: a redirection url, if available

   // Returns:   neither true or false
   //-----------------------------------------------------------

   //Html to be included in modal box
   var node = "<blockquote><p style='font-weight:bold;'><br />";
   node = node +  eMesg;
   node = node + "</p></blockquote>";
   node = node + "<p style='font-size:smaller;margin-left:10px;margin-right:10px;'>This error occurred in '<b>" + eProg;
   node = node + "'</b>, version: <b>" + eVers + "</b>&nbsp;&nbsp;[<b>" + eLoc + "</b>]";
   node = node + "<center>";
   node = node + "<input type='button' value='OK' id='OK' onClick='window.parent.Shadowbox.close(); return false;' />";
   node = node + "</center>";

   //Display modal box
   Shadowbox.open({
      content: node.valueOf(),
      title: 'System Error: ' + errCodes.get(eCode),
      player: 'html',
      height: 300,
      width: 700,
      options: {
         enableKeys: false,
         displayNav: false,
         troubleElements:["object", "embed", "canvas"],
         onFinish: function(element) { },
         onOpen: function(element) { },
         onClose: function(element){ if (eRedir != undefined && eRedir.length != 0) { window.location=eRedir } }
      }
   });
}
// ---------------------------------------------------------------------
// A-series location codes are located in functions.asp (A1043)
// B-series location codes are located in report.asp (B1066)
// C-series location codes are located in inputform.asp (C1035)
// D-series location codes are located in recovery.asp (D1008)
// E-series location codes are located in chartfunctions.asp (E1000)
// F-series location codes are located in checReportRunning.asp (F1004)
// G-series location codes are located in dashboard.asp (G1008)
// H-series location codes are located in favorites.asp (H1016)
// I-series location codes are located in login.asp (I1006)
// J-series location codes are located in main_menu.asp (J1007)
// K-series location codes are located in password.asp (K1003)
// L-series location codes are located in report2.asp (L1003)
// M-series location codes are located in retailer_menu.asp (M1007)
// N-series location codes are located in targets.asp (N1027)
// ZA-series location codes are located in favorites.js (ZA111)
// ZB-series location codes are located in main_menu_ajax.js (ZB108)
// ZC-series location codes are located in report_ajax.js (ZC111)
// ZD-series location codes are located in targets.js (ZD113)
// ---------------------------------------------------------------------

