//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//   B . C .   C O N S U L T I N G   G R O U P
//      C U S T O M   S O F T W A R E   S O L U T I O N S
//
//   W E B   B A S E D   S O L U T I O N S
//      J A V A S C R I P T   F U N C T I O N A L I T Y   D O C U M E N T   v 2 . 0 0
//
//      ( C ) 2 0 0 2 - 2 0 0 5   B . C .   C O N S U L T I N G
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//
//
//~~ Core VARs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var CrLf = unescape("%0D%0A");   //Defines the Character Return & Line Feed 10,13 for GUI uses
//~~ Global Admin Definable Switches ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var DisableRClick = true;         //Enable-Disable the Right-Click Security Option.
var enableDebug = false;          //Enable-Disable the JS Debug messages.
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                A L E R T   N O T I F I C A T I O N S
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
var unTooShort = "Username too short";
var pwTooShort = "Password too short";
var oldBrowser = "your browser is too old.";
//
//

 function doPageCtrlsSetup(){
  //If debug, show current status.
   if(enableDebug){ alert(cPage); }
   if(enableDebug){ alert(pgCount); }
  //If multi-page document
   if(cPage > 0){
     if(document.topCtrls){
       if(document.topCtrls.prvPg && cPage > 1){ document.topCtrls.prvPg.disabled = false; }
       if(document.topCtrls.nxtPg && pgCount > cPage){ document.topCtrls.nxtPg.disabled = false; }
     }
     if(document.btmCtrls){
       if(document.btmCtrls.prvPg && cPage > 1){ document.btmCtrls.prvPg.disabled = false; }
       if(document.btmCtrls.nxtPg && pgCount > cPage){ document.btmCtrls.nxtPg.disabled = false; }
     }
   } //Close multi-page check if   
 } //Close function

 function doNextPage(){
   if(enableDebug){ alert(cPage); }
  //Check if we should do anything first.
   if(cPage == pgCount){ return; }
  //Create new URL
   var newUrl = "?PageNr=" + (cPage + 1);
  //Read the current full url
   var pLoc = document.location.href;
  //Split url on page and options
   var pLocArry = pLoc.split("?");
  //Find other options to include
   if(pLocArry.length > 1){
    //Break apart options
     var oValArry = pLocArry[1].split("&");
    //For each option...
     for(n = 0; n < oValArry.length; n++){
      //Split option name from value
       tmpArry = oValArry[n].split("=");
      //If not page number, add it back to the url
       if(tmpArry[0] != "PageNr"){
         newUrl = newUrl + "&" + oValArry[n];
       } //Close not page option if
     } //Close options for
   } //Close url options split if
  //if debug, show new location before redirect
   if(enableDebug){ alert(newUrl); }
  //Direct browser to new page
   document.location = newUrl;
 } //Close function


 function doPrevPage(){
   if(enableDebug){ alert(cPage); }
  //Check if we should do anything first.
   if(cPage < 2){ return; }
  //Create new URL
   var newUrl = "?PageNr=" + (cPage - 1);
  //Read the current full url
   var pLoc = document.location.href;
  //Split url on page and options
   var pLocArry = pLoc.split("?");
  //Find other options to include
   if(pLocArry.length > 1){
    //Break apart options
     var oValArry = pLocArry[1].split("&");
    //For each option...
     for(n = 0; n < oValArry.length; n++){
      //Split option name from value
       tmpArry = oValArry[n].split("=");
      //If not page number, add it back to the url
       if(tmpArry[0] != "PageNr"){
         newUrl = newUrl + "&" + oValArry[n];
       } //Close not page option if
     } //Close options for
   } //Close url options split if
  //if debug, show new location before redirect
   if(enableDebug){ alert(newUrl); }
  //Direct browser to new page
   document.location = newUrl;
 } //Close function


 function doThisPg(pgID){
   if(enableDebug){ alert(cPage); }
  //Check if we should do anything first.
   if(pgID == cPage || pgID > pgCount || pgID < 1){ return; }
  //Create new URL
   var newUrl = "?PageNr=" + pgID;
  //Read the current full url
   var pLoc = document.location.href;
  //Split url on page and options
   var pLocArry = pLoc.split("?");
  //Find other options to include
   if(pLocArry.length > 1){
    //Break apart options
     var oValArry = pLocArry[1].split("&");
    //For each option...
     for(n = 0; n < oValArry.length; n++){
      //Split option name from value
       tmpArry = oValArry[n].split("=");
      //If not page number, add it back to the url
       if(tmpArry[0] != "PageNr"){
         newUrl = newUrl + "&" + oValArry[n];
       } //Close not page option if
     } //Close options for
   } //Close url options split if
  //if debug, show new location before redirect
   if(enableDebug){ alert(newUrl); }
  //Direct browser to new page
   document.location = newUrl;
 } //Close function


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//           C O N S T R U C T   O P E R A T I O N   F U N C T I O N S
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
 function doWinLogOut(){
   if(window.top.loadMgr.isLoggedOn){ 
     var lclURL = window.top.loadMgr.location.href;
     var lclRDR = lclURL.substring(0, lclURL.indexOf('/nav/') );
     Opening(lclRDR+'/nav/logon.php','150','300','loWin');
   }
 }
 function doFramesetCmds(){
   var cmd = document.location.href.split("?");
   if(cmd[1] == 'doAdmin'){ top.mainFrame.location = 'core/admin.php'; }
   if(cmd[1] == 'doLogon'){ top.mainFrame.location = 'nav/logon.php'; }
 }
 function doLogOut(){
   var frmObj = document.nav;
   frmObj.action = '../nav/logon.php';
   frmObj.OpMode.value = '3';
   frmObj.submit();
 }
  function doLogon(frmObj){
    if(frmObj.OpMode.value == 0){
      if(frmObj.UserName.value.length < 4){
        alert(unTooShort);
        return false;
      }
    }
    if(frmObj.OpMode.value == 1){
      if(frmObj.Passwd.value.length < 6){
        alert(pwTooShort);
        return false;
      }
      var cTime = new Date();
      var cHours = cTime.getHours();
      var cMins = cTime.getMinutes();
      var cSecs = cTime.getSeconds();
      var cTime = cHours + ":" + cMins + ":" + cSecs;
      var cSessionID = getCookie('SessionID');
      if(cSecs > 30){ cMins++; }
      var pwdToHash = cMins + cHours + frmObj.Passwd.value + cSessionID;
      frmObj.Passwd.value = "";
      frmObj.Passwd.disabled = true;
      frmObj.enc_Passwd.value = hex_md5(pwdToHash);
      frmObj.cTime.value = cTime;
    }
    frmObj.OpMode.value = parseInt(frmObj.OpMode.value) + 1;
    frmObj.Submit.value = "Please Wait...";
    frmObj.Submit.disabled = true;
    return true;
  }
 function doContentChange(fbObj){
   var frmObj = fbObj.form;
   frmObj.submit_btn.disabled = false;
 }



//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                S I T E   O P E R A T I O N   F U N C T I O N S
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//---------------------------------------------------------------------------
// noRClicker - This function disables the RightClick control to help
//              prevent users from accessing certain properties.
//              ... or at least make it a bit more difficult.  :-)
//---------------------------------------------------------------------------
function noRClicker(){
  //If the onmousedown event is still available...
  if (document.onmousedown == null) {
    //set the onmousedown event to the MTM function for the document
    document.onmousedown = MTMcatchRight
  }
  //set the onmousedown event to the MTM function for the window
  window.onmousedown = MTMcatchRight;
}
//
//---------------------------------------------------------------------------
// FtimeDirect - This is the timer script to delay a Form Submit call.
//               This allows the user to hold on a page for n Seconds.
//             * sObj defines the Form Object to be submitted.
//             * Timeout defines number of seconds to wait before executing.
//---------------------------------------------------------------------------
function FtimeDirect(sObj,Timeout) {
  // (C)2002-05, BCConsulting Group
  // WebWare Development Team
  //    by Peter Brunnengraeber
  // v2.00  16.November.2004
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if (Timeout == 0) {
    sObj.submit(); //Submit the Object
    return true; //Exit the Loop
  }else{
    Timeout--;  //countdown timeout var...
  }
  //Set 1K milisecond (1 second) loop counter
  // function method used to define setTimeout's
  // Cmd value with the function passing an object
  setTimeout(function(){FtimeDirect(sObj, Timeout);}, 1000);
}
//
//---------------------------------------------------------------------------
// PtimeDirect - This is the timer script to delay a Page Redirect call.
//               This allows the user to hold on a page for n Seconds.
//             * pObj defines the new Location Obj to be set on document.
//             * Timeout defines number of seconds to wait before executing.
//---------------------------------------------------------------------------
function PtimeDirect(pObj,Timeout) {
  // (C)2002-05, BCConsulting Group
  // WebWare Development Team
  //    by Peter Brunnengraeber
  // v2.01  16.November.2004
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if (Timeout == 0) {
    document.location = pObj; //Change the Location Object value
    return true; //Exit the Loop
  }else{
    Timeout--;  //countdown timeout var...
  }
  //Set 1K milisecond (1 second) loop counter
  // function method used to define setTimeout's
  // Cmd value with the function passing an object
  setTimeout(function(){PtimeDirect(pObj,Timeout);}, 1000);
}
//
//---------------------------------------------------------------------------
// CtimeDirect - This is the timer script to delay a Window close call.
//               This allows the user to hold on a page for n Seconds.
//             * pObj defines the new Location Obj to be set on document.
//             * Timeout defines number of seconds to wait before executing.
//---------------------------------------------------------------------------
function CtimeDirect(Timeout) {
  // (C)2002-05, BCConsulting Group
  // WebWare Development Team
  //    by Peter Brunnengraeber
  // v2.02  19.November.2004
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if (Timeout == 0) {
    //Close the Window
    var objloc = window;
    objloc.opener = objloc; objloc.close();
    return true; //Exit the Loop
  }else{
    Timeout--;  //countdown timeout var...
  }
  //Set 1K milisecond (1 second) loop counter
  // function method used to define setTimeout's
  // Cmd value with the function passing an object
  setTimeout(function(){CtimeDirect(Timeout);}, 1000);
}
//
//---------------------------------------------------------------------------
//  Opening - Called to open new windows set top left of screen w/ optional settings
//            *IMPORTANT* Returns hte child window ID for later use.
//---------------------------------------------------------------------------
function Opening(what,opth,optw,winNme,sbarsflag) {
  // (C)2003-05 BCConsulting
  // Information Computing Services Department
  //   by Peter Brunnengraeber
  // v2.20  11.Marz.2006
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  // Find if scrollbars are to be on or off
  if(sbarsflag){ var sbars = "yes"; }else{ var sbars = "no"; }
  // Base Options used
  var opts= "scrollbars=" + sbars + ",resizable=no,top=0,left=0,";
  // Check for optional width var, else use default
  if (optw > 0) {
    opts= opts + "width=" + optw + ",";
  }else{
    opts= opts + "width=1016,";
  }
  // Check for optional height var, else use default
  if (opth > 0) {
    opts= opts + "height=" + opth;
  }else{
    opts= opts + "height=740";
  }
  // Check if optional window name var not exist and need default
  if (!winNme) {
    winNme = 'ChldlessWin';
  }
  // Open the new window
  lessWin=window.open(what,winNme,opts);
  // Return the child windows ID for use by the perl script
  return lessWin;
}
//
//---------------------------------------------------------------------------
// setCookie - This function uses the browsers document . cookie attribute
//             to save local cookies. These are session only cookies, and
//             will be erased as soon as the client browser is closed.
//             This is simply due to the fact that no expires= value is set.
//---------------------------------------------------------------------------
function setCookie(cookNme,cookVal){
  // (C)2002-05, BCConsulting Group
  // WebWare Development Team
  //    by Peter Brunnengraeber
  // v1.00  07.May.2005
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  var cookieStr = cookNme + "=" + cookVal + "; path=/";
  document.cookie = cookieStr;
}
//
//---------------------------------------------------------------------------
// getCookie - This function uses the browsers document . cookie attribute
//             to read local cookies. The function then parses through the
//             cookies, until the requested cookie name is found. At that
//             point, the value of requested cookie is returned.
//---------------------------------------------------------------------------
function getCookie(cookNme){
  // (C)2002-05, BCConsulting Group
  // WebWare Development Team
  //    by Peter Brunnengraeber
  // v1.00  07.May.2005
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  var cookies = document.cookie.split(';');
  for(n = 0; n < cookies.length; n++){
  //Trim whitespaces
    while (cookies[n].charAt(0)==' '){
      cookies[n] = cookies[n].substring(1,cookies[n].length);
    }
  //If this cookie is the one we want...
    if (cookies[n].indexOf(cookNme) == 0){
    //Strip the value
      var cookIs = cookies[n].substring((cookNme.length + 1), cookies[n].length);
    //Return its value and exit
      return cookIs;
    } //Otherwise, keep trucking!
  }
  //Nothing found by requested name. Exit in shame. :-P
  return null;
}
//
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//        D E B U G   &   E R R O R   M A N A G E M E N T   F U N C T I O N S
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//

//---------------------------------------------------------------------------
// dumpProps - This function recursively takes properties that are objects
//             themselves and shows their properties. This function provides
//             a couple of advantages for debugging. First, it allows you to
//             verify what object you are working with during your script.
//             It also allows you to verify the properties of that object
//             It is also good if you are working with a heirarchy of
//             properties.
// Copyright 1999,2005 Breaking Par Consulting Inc. (www.breakingpar.com)
//---------------------------------------------------------------------------
function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object 
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to 
      // build the message. Message includes i (the object's property name) 
      // then the object's property value on a new line 
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they 
      // click "CANCEL" then quit this level of recursion 
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object 
      if (typeof obj[i] == "object") { 
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}
//

//---------------------------------------------------------------------------



//
//---------------------------------------------------------------------------
//             * * * *   E N D   O F   F I L E   * * * *
//---------------------------------------------------------------------------
