var ie5=(document.all && document.getElementById);
var ns6=(!document.all && document.getElementById);

var isPressed = false;

   function highlightLink(index){
      linkObj = getObject("link" + index);
      //linkObj.color = "#adff2f";
      linkObj.color = "#000000";
      linkObj.textDecoration = "underline";   
   }
   
   function unHighlightLink(index){
      linkObj = getObject("link" + index);
      linkObj.color = "#ffffff";
      linkObj.textDecoration = "none";   
   }

   function highlightButton(table, index){
     //newBrdProperty = "2px solid #adff2f";
     newBrdProperty = "2px solid #000000";
      object =  table.rows[index].cells[0];
      object.style.borderTop = newBrdProperty;
      object.style.borderLeft = newBrdProperty;
      object.style.borderBottom = newBrdProperty;
      object.style.borderRight = newBrdProperty;
     
      object.style.cursor = "pointer";
   }//end highlight

   function unHighlightButton(table, index){
     orgBrdProperty = "2px solid silver";
     object = table.rows[index].cells[0];

      object.style.color = "silver";
      object.style.borderTop = orgBrdProperty;
      object.style.borderLeft = orgBrdProperty;
      object.style.borderBottom = orgBrdProperty;
      object.style.borderRight = orgBrdProperty;
      
      object.style.cursor = "default";
   }//end unHighlight

   function highlightBg(table, row, col, sColor){
     newBgProperty = sColor;
      object =  table.rows[row].cells[col];
      object.OriginBgColor = object.style.backgroundColor;
      object.style.backgroundColor = newBgProperty;
     
      object.style.cursor = "pointer";
   }//end highlightBg
   
   function unHighlightBg(table, row, col){
     object = table.rows[row].cells[col];
     object.style.backgroundColor = object.OriginBgColor;
      
      object.style.cursor = "default";
   }//end unHighlightBg
   
   function gotoURL(url){
     window.location.href = url;
   }
   
   function setStatus(strText){
      window.status = strText;
   }
   
   function clearStatus(){
      window.status = "";
   }

   
   function getObject(objectId) {
      // cross-browser function to get an object's style object given its id
      if(document.getElementById && document.getElementById(objectId)) {
         // W3C DOM
       return document.getElementById(objectId).style;
      }
      else if (document.all && document.all(objectId)) {
       // MSIE 4 DOM
       return document.all(objectId).style;
      }
      else if (document.layers && document.layers[objectId]) {
       // NN 4 DOM.. note: this won't find nested layers
       return document.layers[objectId];
      }
      else {
       return false;
      }
   }// getObject

   function slideY (id, y, step) {
      //step = 5;
      obj = getObject(id)
      obj.ypos = parseInt(obj.top);
      if (Math.abs(obj.ypos - y) > Math.abs(step)) {
         if (y < 0) step = - step;
         obj.ypos += step;
         obj.top = obj.ypos;
         setTimeout("slideY('" + id + "'," + y + "," + step + ")", 30);
      }
   }

   /**
    Slide the object on the x axis
    id    : id of the object to be slided
    x     : destination x to move the object to
    step  : the movement speed
   *** condition ***: 
      negative value: slide to the left => x should be less than obj.left
      position value: slide to the right => x should be greater than obj.left 
   **/

   function slideX (id, x, step) {
      obj = getObject(id)
      obj.xpos = parseInt(obj.left);
      
      //alert("dest x = " + x + "\nstep = " + step + "\n obj.xpos =" + obj.xpos + "\nobj.left = " + obj.left + "\nMath.abs(obj.xpos - x) = " + Math.abs(obj.xpos - x));
      //alert("dest x = " + x + "\nstep = " + step + "\nobj.xpos =" + obj.xpos + "\nobj.left = " + obj.left + "\n" + obj.xpos + " - " + x + " = " + (obj.xpos - x));
      if (Math.abs(obj.xpos - x) > Math.abs(step)) {
      //if (obj.xpos - x > step) {
         //alert("dest x = " + x + "\nstep = " + step + "\nobj.xpos =" + obj.xpos + "\nobj.left = " + obj.left + "\nMath.abs(obj.xpos - x) = " + Math.abs(obj.xpos - x));
         if (x < 0) step = - step;
         obj.xpos += step;
         obj.left = obj.xpos;
         setTimeout("slideX('" + id + "'," + x + "," + step + ")", 30);
      }
      else if( Math.abs(obj.xpos - x)!=0 ){
         obj.left = obj.xpos - (obj.xpos - x);      
      }
   }  
      
   /*** return a string containing the color of today ***/
   function getTodayColor(){
       var now = new Date();
       var day = now.getDate();

       if (day<7){
         return "orange";
      }
      else if (day>=7 && day<=14){
         return "green";
      }
      else if (day>=14 && day<=21){
         return "darkBlue";
      }
      else if (day>=21 && day<=28){
         return "darkRed";
      }
      else{
         return "lightBlue";
      }   
   }   