

//=============================================================================
// NO RIGHT MOUSE CLICK
//=============================================================================
// Set the message for the alert box
am = "Sorry, Right Mouse Click Is Not Allowed.";
// do not edit below this line
bV  = parseInt(navigator.appVersion)
bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"
//function nrc(e) {
//   if (bNS && e.which > 1){
//      alert(am)
//      return false;
//   } else if (bIE && (event.button >1)) {
//     alert(am)
//     return false;
//   }
//   X = (bNS) ? e.x : event.offsetX;
//   Y = (bNS) ? e.y : event.offsetY;
//   return false;
//}
//document.onmousedown = nrc;
//if (document.layers) window.captureEvents(Event.MOUSEDOWN);
//if (bNS && bV<5) window.onmousedown = nrc;

//=============================================================================
//  BROWSER DETECTION VARIABLES USING OBJECT TESTING
//=============================================================================
var isDOM = (document.getElementById); 
var isIE4 = (document.all && !document.getElementById);
var isNS4 = (document.layers && !document.getElementById);

//=============================================================================
//  BLOCK JAVASCRIPT ERRORS - COMMENT OUT FOR DEBUGGING
//=============================================================================
function blockError(){
  return true;
}
window.onerror = blockError;

//=============================================================================
//  SCROLLING MESSAGE IN WINDOW STATUS BAR
//=============================================================================
introMsg = " Welcome to Edgear Student Progress Center! "
window.defaultStatus = introMsg;
i=0
endNow=0
var slideSpeed = 10; //(smaller=faster)

function scrollMsg(){
  frontPart = introMsg.substring(i,introMsg.length)
  backPart = introMsg.substring(0,i)
  window.status=frontPart + backPart
  //document.title=frontPart + backPart
  if (i < introMsg.length){
    i++
  }
  else{
    i=0
    endNow++
  }
  if(endNow < 1){setTimeout("scrollMsg()",100)}
}

//=============================================================================
//  TABLE SORTER
//=============================================================================
//function setDataType(cValue)
//  {
//    // THIS FUNCTION CONVERTS DATES AND NUMBERS FOR PROPER ARRAY
//    // SORTING WHEN IN THE SORT FUNCTION
//    var isDate = new Date(cValue);
//    if (isDate == "NaN")
//      {
//        if (isNaN(cValue))
//          {
//            // THE VALUE IS A STRING, MAKE ALL CHARACTERS IN
//            // STRING UPPER CASE TO ASSURE PROPER A-Z SORT
//            cValue = cValue.toUpperCase();
//            return cValue;
//          }
//        else
//          {
//            // VALUE IS A NUMBER, TO PREVENT STRING SORTING OF A NUMBER
//            // ADD AN ADDITIONAL DIGIT THAT IS THE + TO THE LENGTH OF
//            // THE NUMBER WHEN IT IS A STRING
//            var myNum;
//            myNum = String.fromCharCode(48 + cValue.length) + cValue;
//            return myNum;
//          }
//        }
//  else
//      {
//        // VALUE TO SORT IS A DATE, REMOVE ALL OF THE PUNCTUATION AND
//        // AND RETURN THE STRING NUMBER
//        //BUG - STRING AND NOT NUMERICAL SORT .....
///       // ( 1 - 10 - 11 - 2 - 3 - 4 - 41 - 5  etc.)
//        var myDate = new String();
//        myDate = isDate.getFullYear() + " " ;
//        myDate = myDate + isDate.getMonth() + " ";
//        myDate = myDate + isDate.getDate(); + " ";
//        myDate = myDate + isDate.getHours(); + " ";
//        myDate = myDate + isDate.getMinutes(); + " ";
//        myDate = myDate + isDate.getSeconds();
//        //myDate = String.fromCharCode(48 + myDate.length) + myDate;
//        return myDate ;
//      }
//  }
//
//function sortTable(col, tableToSort)
//  {
//    var iCurCell = col + tableToSort.cols;
//    var totalRows = tableToSort.rows.length;
//    var bSort = 0;
//    var colArray = new Array();
//    var oldIndex = new Array();
//    var indexArray = new Array();
//    var bArray = new Array();
//    var newRow;
//    var newCell;
//    var i;
//    var c;
//    var j;
//    // ** POPULATE THE ARRAY colArray WITH CONTENTS OF THE COLUMN SELECTED
//    for (i=1; i < tableToSort.rows.length; i++)
//      {
//        colArray[i - 1] = setDataType(tableToSort.cells(iCurCell).innerText);
//        iCurCell = iCurCell + tableToSort.cols;
//      }
//    // ** COPY ARRAY FOR COMPARISON AFTER SORT
//    for (i=0; i < colArray.length; i++)
//      {
//        bArray[i] = colArray[i];
//      }
//    // ** SORT THE COLUMN ITEMS
//    //alert ( colArray );
//    colArray.sort();
//    //alert ( colArray );
//    for (i=0; i < colArray.length; i++)
//      { // LOOP THROUGH THE NEW SORTED ARRAY
//        indexArray[i] = (i+1);
//        for(j=0; j < bArray.length; j++)
//          { // LOOP THROUGH THE OLD ARRAY
//            if (colArray[i] == bArray[j])
//              {  // WHEN THE ITEM IN THE OLD AND NEW MATCH, PLACE THE
//                // CURRENT ROW NUMBER IN THE PROPER POSITION IN THE
//                // NEW ORDER ARRAY SO ROWS CAN BE MOVED ....
//                // MAKE SURE CURRENT ROW NUMBER IS NOT ALREADY IN THE
//                // NEW ORDER ARRAY
//                for (c=0; c<i; c++)
//                  {
//                    if ( oldIndex[c] == (j+1) )
//                    {
//                      bSort = 1;
//                    }
//                      }
//                      if (bSort == 0)
//                        {
//                          oldIndex[i] = (j+1);
//                        }
//                          bSort = 0;
//                        }
//          }
//    }
//  // ** SORTING COMPLETE, ADD NEW ROWS TO BASE OF TABLE ....
//  for (i=0; i<oldIndex.length; i++)
//    {
//      newRow = tableToSort.insertRow();
//      newRow.align = tableToSort.rows(oldIndex[i]).getAttribute('align');
//      for (c=0; c<tableToSort.cols; c++)
//        {
//          newCell = newRow.insertCell();
//          newCell.innerHTML = tableToSort.rows(oldIndex[i]).cells(c).innerHTML;
//          newCell.style.background = tableToSort.rows(oldIndex[i]).cells(c).style.background;
//          newCell.style.color = tableToSort.rows(oldIndex[i]).cells(c).style.color;
//          newCell.width = tableToSort.rows(oldIndex[i]).cells(c).getAttribute('width');
//          newCell.align = tableToSort.rows(oldIndex[i]).cells(c).getAttribute('align');
//        }
//        
//      }
//  //MOVE NEW ROWS TO TOP OF TABLE ....
//  for (i=1; i<totalRows; i++)
//    {
//      tableToSort.moveRow((tableToSort.rows.length -1),1);
//    }
//  //DELETE THE OLD ROWS FROM THE BOTTOM OF THE TABLE ....
//  for (i=1; i<totalRows; i++)
//    {
//      tableToSort.deleteRow();
//    }
//  }

//=============================================================================
//  NEW TABLE SORTER
//=============================================================================
var dateRE = /^(\d{2})[\/\- ](\d{2})[\/\- ](\d{4})/;
var isNumber;
var isADate;
var isAscending = false;
function mdyOrdA(a, b){
    a = a.replace(dateRE,"$3$1$2");
    b = b.replace(dateRE,"$3$1$2");
    if (a > b) return 1;
    if (a < b) return -1;
    return 0;
}
function mdyOrdD(a, b){
    a = a.replace(dateRE,"$3$1$2");
    b = b.replace(dateRE,"$3$1$2");
    if (a > b) return -1;
    if (a < b) return 1;
    return 0;
} 
function numOrdA(a,b){ return (a-b); }
function numOrdD(a,b){ return (b-a); }
function setDataType(cValue)
  {
    // THIS FUNCTION CONVERTS DATES AND NUMBERS FOR PROPER ARRAY
    // SORTING WHEN IN THE SORT FUNCTION
    isNumber = false;
    isADate = false;
    var isDate = new Date(cValue);
    if (isDate == "NaN")
      {
        if (isNaN(cValue))
          {
            // THE VALUE IS A STRING, MAKE ALL CHARACTERS IN
            // STRING UPPER CASE TO ASSURE PROPER A-Z SORT
            cValue = cValue.toUpperCase();
            return cValue;
          }
        else
          {
            // VALUE IS A NUMBER
            isNumber = true;
            return cValue;
          }
        }
  else
      {
        // VALUE TO SORT IS A DATE
        isADate = true;
        return cValue;
      }
  }

function sortTable(col, target)
  {
    //tableToSort = (isDOM) ? document.getElementById(target) : eval("document." + target);
    var tableToSort = (bIE) ? target : document.getElementById(target);
    //tableToSort = target;
    isAscending = (!isAscending);
    var iCurCell = col + tableToSort.cols;
    var totalRows = tableToSort.rows.length;
    var bSort = 0;
    var colArray = new Array();
    var oldIndex = new Array();
    var indexArray = new Array();
    var bArray = new Array();
    var newRow;
    var newCell;
    var i;
    var c;
    var j;
    // ** POPULATE THE ARRAY colArray WITH CONTENTS OF THE COLUMN SELECTED
    for (i=1; i < tableToSort.rows.length; i++)
      {
        colArray[i - 1] = setDataType(tableToSort.cells(iCurCell).innerText); 
        iCurCell = iCurCell + tableToSort.cols;
      }
    // ** COPY ARRAY FOR COMPARISON AFTER SORT
    for (i=0; i < colArray.length; i++)
      {
        bArray[i] = colArray[i];
      }

    // ** SORT THE COLUMN ITEMS
    //alert (isAscending + colArray );
    if (isAscending){
      if (isADate){ colArray.sort(mdyOrdA); }
      else if (isNumber) {colArray.sort(numOrdA);}
      else {colArray.sort();}
    }
    else{
      if (isADate){ colArray.sort(mdyOrdD); }
      else if (isNumber) {colArray.sort(numOrdD);}
      else {colArray.reverse();}
    }
    //alert ( isAscending + colArray );

    for (i=0; i < colArray.length; i++)
      { // LOOP THROUGH THE NEW SORTED ARRAY
        indexArray[i] = (i+1);
        for(j=0; j < bArray.length; j++)
          { // LOOP THROUGH THE OLD ARRAY
            if (colArray[i] == bArray[j])
              {  // WHEN THE ITEM IN THE OLD AND NEW MATCH, PLACE THE
                // CURRENT ROW NUMBER IN THE PROPER POSITION IN THE
                // NEW ORDER ARRAY SO ROWS CAN BE MOVED ....
                // MAKE SURE CURRENT ROW NUMBER IS NOT ALREADY IN THE
                // NEW ORDER ARRAY
                for (c=0; c<i; c++)
                  {
                    if ( oldIndex[c] == (j+1) )
                    {
                      bSort = 1;
                    }
                      }
                      if (bSort == 0)
                        {
                          oldIndex[i] = (j+1);
                        }
                          bSort = 0;
                        }
          }
    }
  // ** SORTING COMPLETE, ADD NEW ROWS TO BASE OF TABLE ....
  for (i=0; i<oldIndex.length; i++)
    {
      newRow = tableToSort.insertRow();
      newRow.align = tableToSort.rows(oldIndex[i]).getAttribute('align');
      for (c=0; c<tableToSort.cols; c++)
        {
          newCell = newRow.insertCell();
          newCell.innerHTML = tableToSort.rows(oldIndex[i]).cells(c).innerHTML;
          newCell.style.background = tableToSort.rows(oldIndex[i]).cells(c).style.background;
          newCell.style.color = tableToSort.rows(oldIndex[i]).cells(c).style.color;
          newCell.width = tableToSort.rows(oldIndex[i]).cells(c).getAttribute('width');
          newCell.align = tableToSort.rows(oldIndex[i]).cells(c).getAttribute('align');
        }
        
      }
  //MOVE NEW ROWS TO TOP OF TABLE ....
  for (i=1; i<totalRows; i++)
    {
      tableToSort.moveRow((tableToSort.rows.length -1),1);
    }
  //DELETE THE OLD ROWS FROM THE BOTTOM OF THE TABLE ....
  for (i=1; i<totalRows; i++)
    {
      tableToSort.deleteRow();
    }
  }

