/* Trans Menu Functions {{{ */
  TransMenu.shadowSize               = 2;
  TransMenu.shadowOffset               = 3;
  TransMenu.shadowColor               = "#DEDEDE";
  TransMenu.backgroundColor             = "#FFFFFF";
  TransMenu.hideDelay               = 350;
  TransMenu.slideTime               = 380;
  TransMenu.reference               = {topLeft:1, topRight:2, bottomLeft:3, bottomRight:4};
  TransMenu.direction               = {down:1, right:2, left:3};
  TransMenu.registry                 = [];
  TransMenu._maxZ                 = 999;


  TransMenu.isSupported               = function() {
    var ua                    = navigator.userAgent.toLowerCase();
    var pf                    = navigator.platform.toLowerCase();
    var an                    = navigator.appName;
    var r                     = false;
      
    if((ua.indexOf("gecko") >- 1) && (navigator.productSub >= 20020605)) {
        r                   = true;
    } else if(an == "Microsoft Internet Explorer") { 
      if(document.getElementById) {
        if(pf.indexOf("mac") == 0) {
          r                 = /msie (\d(.\d*)?)/.test(ua) && Number(RegExp.$1) >= 5.1;
        } else {
          r                 = true;
        }
      }
    }
    return r;
  }

  TransMenu.initialize               = function(){
    for(var i = 0, menu = null; menu = this.registry[i]; i++) {
      menu.initialize();
    }
  }
  
  TransMenu.renderAll               = function(){
    var aMenuHtml                = [];
    for(var i = 0, menu = null; menu = this.registry[i]; i++) {
      aMenuHtml[i]               = menu.toString();
    }
    document.write(aMenuHtml.join(""));
  }
  
  
  
  function TransMenu(oActuator,iDirection,iLeft,iTop,iReferencePoint,parentMenuSet) {
  //alert('s');
    this.addItem                = addItem;
    this.addMenu                = addMenu;
    this.addMenuLeft                            = addMenuLeft;
    this.toString                = toString;
    this.initialize                = initialize;
    this.isOpen                  = false;
    this.show                  = show;
    this.hide                  = hide;
    this.items                  = [];
    this.onactivate                = new Function();
    this.ondeactivate              = new Function();
    this.onmouseover              = new Function();
    this.onqueue                = new Function();
    this.ondequeue                = new Function();
    this.index                  = TransMenu.registry.length;
    TransMenu.registry[this.index]        = this;
    var id                    = "TransMenu" + this.index;
    var contentHeight              = null;
    var contentWidth              = null;
    var childMenuSet              = null;
    var childMenuSetDefault            = null;
    var animating                = false;
    var childMenus                = [];
    var slideAccel                = -1;
    var elmCache                = null;
    var ready                  = false;
    var _this                  = this;
    var a                    = null;
    
    var pos;
    var animateLeft = false;
    if(iDirection == TransMenu.direction.down) { //(value: 1)
        pos = "top";
    } else if (iDirection == TransMenu.direction.left) { //Newly created (value: 3)
    animateLeft = true;
        pos = "left";
    
    } else { //if (iDirection == TransMenu.direction.right) //(value: 2)
        pos = "left";
    }
                      
    var dim                    = null;
    
    function addItem(sText,sUrl,sTarget){
      var item                = new TransMenuItem(sText,sUrl,sTarget,this);
      item._index                = this.items.length;this.items[item._index]=item;
    }
    var isLastMenu;
    function addMenu(oMenuItem) {
    
    //alert(document.getElementById('TransMenu16').innerHTML);
    //return;
    /*alert(oMenuItem + "     =>       \n" + oMenuItem.parentMenu);*/
    //alert(oMenuItem.text + "\n" + oMenuItem.text.indexOf("Reports"));
    isLastMenu = false;
    if (oMenuItem.text.toLowerCase().indexOf("reports") > 0)
    {
        isLastMenu = true;
    }

      if(!oMenuItem.parentMenu == this) {
        throw new Error("Cannot add a menu here");
      }
      if(childMenuSet == null) {
      if(isLastMenu) {
      childMenuSet            = new TransMenuSet(TransMenu.direction.left, -200, 2, TransMenu.reference.topLeft);
      }
      else {
      childMenuSet            = new TransMenuSet(TransMenu.direction.right, 0, 2, TransMenu.reference.topRight);
      }
        
      }
      
      var m                  = childMenuSet.addMenu(oMenuItem);
      childMenus[oMenuItem._index]      = m;
      m.onmouseover              = child_mouseover;
      m.ondeactivate              = child_deactivate;
      m.onqueue                = child_queue;
      m.ondequeue                = child_dequeue;
      return m;
    }

    function addMenuLeft(oMenuItem) {
      if(!oMenuItem.parentMenu == this) {
        throw new Error("Cannot add a menu here");
      }
      if(childMenuSet == null) {
        childMenuSet            = new TransMenuSet(TransMenu.direction.right, -200, 2, TransMenu.reference.topLeft);
      }
      
      var m                  = childMenuSet.addMenuLeft(oMenuItem);
      childMenus[oMenuItem._index]      = m;
      m.onmouseover              = child_mouseover;
      m.ondeactivate              = child_deactivate;
      m.onqueue                = child_queue;
      m.ondequeue                = child_dequeue;
      return m;
    }
    
    function initialize() {
      initCache();
      initEvents();
      initSize();
      ready                  = true;
    }
    
    function show() {
      if(ready) {
        _this.isOpen            = true;
        animating              = true;
        setContainerPos();
        elmCache["clip"].style.visibility  = "visible";
        elmCache["clip"].style.zIndex    = TransMenu._maxZ++;
        slideStart();
        _this.onactivate();
      }
    }
    
    function hide() {
      if(ready) {
        _this.isOpen             = false;
        animating               = true;
        for(var i = 0, item = null; item = elmCache.item[i]; i++) {
          dehighlight(item);
        }
        if(childMenuSet) {
          childMenuSet.hide();
        }
        slideStart();
        _this.ondeactivate();
      }
    }
    
/*    function init() {

    
    if (TransMenu.isSupported()) {
      TransMenu.initialize();
      
      menu101.onactivate                         = function() {
        document.getElementById("m101").className       = "hover";
      };
      
      menu101.ondeactivate                         = function() {
        document.getElementById("m101").className       = "release";
      };
      
      menu102.onactivate                         = function() {
        document.getElementById("m102").className       = "hover";
      };
      
      menu102.ondeactivate                         = function() { 
        document.getElementById("m102").className       = "release";
      };
      
      menu103.onactivate                         = function() {
        document.getElementById("m103").className          = "hover";
      };
      
      menu103.ondeactivate                         = function() {
        document.getElementById("m103").className         = "release";
      };
      
      menu104.onactivate                         = function() {
        document.getElementById("m104").className          = "hover";
      };
      
      menu104.ondeactivate                         = function() {
        document.getElementById("m104").className         = "release";
      };
                
      menu105.onactivate                         = function() {
        document.getElementById("m105").className       = "hover";
      };
      
      menu105.ondeactivate                         = function() {
        document.getElementById("m105").className       = "release";
      };
      
      menu106.onactivate                         = function() {
        document.getElementById("m106").className       = "hover";
      };
      
      menu106.ondeactivate                         = function() {
        document.getElementById("m106").className       = "release";
      };

      menu107.onactivate                         = function() {
        document.getElementById("m107").className       = "hover";
      };
      
      menu107.ondeactivate                         = function() {
        document.getElementById("m107").className       = "release";
      };

      menu108.onactivate                         = function() {
        document.getElementById("m108").className          = "hover";
      };
      
      menu108.ondeactivate                         = function() {
        document.getElementById("m108").className         = "release";
      };
      
      
    
    }
  }
*/
    function setContainerPos() {
      var sub                  = oActuator.constructor == TransMenuItem;
      var act                  = sub ? oActuator.parentMenu.elmCache["item"][oActuator._index] : oActuator;
      var el                  = act;
      var x                  = -2;
      var y                  = 0;
      var minX                = 0;
      var maxX                = (window.innerWidth ? window.innerWidth : document.body.clientWidth) - parseInt(elmCache["clip"].style.width);
      var minY                = 0;
      var maxY                = (window.innerHeight ? window.innerHeight : document.body.clientHeight) - parseInt(elmCache["clip"].style.height);
      
      while(sub?el.parentNode.className.indexOf("transMenu") == -1 : el.offsetParent) {
        x                  += el.offsetLeft;
        y                  += el.offsetTop;
        if(el.scrollLeft) {
          x                -= el.scrollLeft;
        }
        if(el.scrollTop){
          y                -= el.scrollTop;
        }
        el                  = el.offsetParent;
      }
      
      if(oActuator.constructor==TransMenuItem) {
        x                  += parseInt(el.parentNode.style.left);
        y                  += parseInt(el.parentNode.style.top);
      }
      

      switch(iReferencePoint) {
        case TransMenu.reference.topLeft : break;
        case TransMenu.reference.topRight : x += act.offsetWidth; break;
        case TransMenu.reference.bottomLeft:y += act.offsetHeight; break;
        case TransMenu.reference.bottomRight:x += act.offsetWidth; y += act.offsetHeight; break;
      }
      
      x                    += iLeft;
      y                    += iTop;
      x                    = Math.max(Math.min(x,maxX), minX);
      y                    = Math.max(Math.min(y,maxY), minY);
      elmCache["clip"].style.left        = x + "px";
      elmCache["clip"].style.top        = y + "px";
    }
    
    function slideStart() {
    
      var x0                  = parseInt(elmCache["content"].style[pos]);
      var x1                  = _this.isOpen?0:-dim;
      if(a != null){
        a.stop();
      }
      a                     = new Accelimation(x0,x1,TransMenu.slideTime,slideAccel);
      a.onframe                = slideFrame;
      a.onend                  = slideEnd;
      
      a.start();
    }
    
    function slideFrame(x) {
      elmCache["content"].style[pos]      = x+"px";
    }
    
    function slideEnd() {
      if(!_this.isOpen) {
        elmCache["clip"].style.visibility  = "hidden";
      }
      animating                = false;
    }
    
    function initSize() {
      var ow                  = elmCache["items"].offsetWidth;
      var oh                  = elmCache["items"].offsetHeight;
      var ua                  = navigator.userAgent.toLowerCase();
      elmCache["clip"].style.width      = ow+TransMenu.shadowSize + 2 + "px";
      elmCache["clip"].style.height      = oh+TransMenu.shadowSize + 2 + "px";
      elmCache["content"].style.width      = ow+TransMenu.shadowSize + "px";
      elmCache["content"].style.height    = oh+TransMenu.shadowSize + "px";
      elmCache["content"].style.left=0;

      contentHeight              = oh+TransMenu.shadowSize;
      contentWidth              = ow+TransMenu.shadowSize;
      dim                    = iDirection == TransMenu.direction.down?contentHeight:contentWidth;
      
      elmCache["content"].style[pos]      =- dim - TransMenu.shadowSize + "px";
      
      elmCache["clip"].style.visibility    = "hidden";
      
      elmCache["background"].style.width = (ow + 1) + "px";
      elmCache["background"].style.height  = oh + "px";
      elmCache["background"].style.backgroundColor = TransMenu.backgroundColor;
      elmCache["shadowRight"].style.left = (ow + 2) + "px";
      elmCache["shadowRight"].style.height = oh - (TransMenu.shadowOffset - TransMenu.shadowSize) + "px";
      elmCache["shadowRight"].style.backgroundColor = TransMenu.shadowColor;
      elmCache["shadowBottom"].style.top = oh + "px";
      elmCache["shadowBottom"].style.width = (ow + 2) - TransMenu.shadowOffset + "px";
      elmCache["shadowBottom"].style.backgroundColor = TransMenu.shadowColor;
    }
    
    function initCache() {
      var menu                = document.getElementById(id);
      var all                  = menu.all ? menu.all : menu.getElementsByTagName("*");
      elmCache                = {};
      elmCache["clip"]            = menu;
      elmCache["item"]            = [];
      
      for(var i = 0, elm = null; elm = all[i]; i++) {
        switch(elm.className){
          case"items":
          case"content":
          case"background":
          case"shadowRight":
          case"shadowBottom":
            elmCache[elm.className]    = elm;
            break;
            case"item":
            elm._index          = elmCache["item"].length;
            elmCache["item"][elm._index]= elm;
            break;
        }
      }
      _this.elmCache              = elmCache;
    }
    
    function initEvents() {
      for(var i = 0, item = null; item = elmCache.item[i]; i++) {
        item.onmouseover          = item_mouseover;
        item.onmouseout            = item_mouseout;
        item.onclick            = item_click;
      }
      
      if(typeof oActuator.tagName != "undefined") {
        oActuator.onmouseover         = actuator_mouseover;
        oActuator.onmouseout        = actuator_mouseout;
      }
      elmCache["content"].onmouseover      = content_mouseover;
      elmCache["content"].onmouseout      = content_mouseout;
    }
    
    function highlight(oRow) {
      oRow.className              = "item hover";
      if(childMenus[oRow._index]) {
        oRow.className            = "sub_on";
      }
    }
    
    function dehighlight(oRow) {
      oRow.className              = "item";
      if(childMenus[oRow._index]) {
        oRow.className            = "sub_off";
      }
    }
    
    function item_mouseover() {
      if(!animating){
        highlight(this);
        if(childMenus[this._index]) {
          childMenuSet.showMenu(childMenus[this._index]);
        } else if(childMenuSet) {
          childMenuSet.hide();
        }
      }
    }
    
    function item_mouseout() {
      if(!animating) {
        if(childMenus[this._index]) {
          childMenuSet.hideMenu(childMenus[this._index]);
        } else {
          dehighlight(this);
        }
      }
    }
    
    function item_click() {
      if(!animating) {
        if(_this.items[this._index].url.cible) {
          location.href           = _this.items[this._index].url.cible;
        }
      }
    }
    
    function actuator_mouseover() {
      parentMenuSet.showMenu(_this);
    }
    
    function actuator_mouseout() {
      parentMenuSet.hideMenu(_this);
    }
    
    function content_mouseover() {
      if(!animating) {
        parentMenuSet.showMenu(_this);
        _this.onmouseover();
      }
    }
    
    function content_mouseout() {
      if(!animating) {
        parentMenuSet.hideMenu(_this);
      }
    }
    
    function child_mouseover() {
      if(!animating) {
        parentMenuSet.showMenu(_this);
      }
    }
    
    function child_deactivate() {
      for(var i = 0; i < childMenus.length; i++) {
        if(childMenus[i] == this) {
          dehighlight(elmCache["item"][i]);
          break;
        }
      }
    }
    
    function child_queue() {
      parentMenuSet.hideMenu(_this);
    }
    
    function child_dequeue() {
      parentMenuSet.showMenu(_this);
    }
    
    function toString() {
      var aHtml                 = [];
      var sClassName               = "transMenu" + (oActuator.constructor != TransMenuItem ? " top" : "");
      for(var i = 0, item = null; item = this.items[i]; i++) {
        aHtml[i]              = item.toString(childMenus[i]);
      }

      return                  '<div id="'+id+'" class="'+sClassName+'">'+
                            '<div class="content">' + 
                              '<div class="items">' + aHtml.join('') + '</div>' +
                              '<div class="shadowBottom">&#160;</div>' +
                              '<div class="shadowRight">&#160;</div>'+
                              '<div class="background">&#160;</div>'+
                            '</div>' +
                          '</div>';
    }
  }
  
  TransMenuSet.registry              = [];
  function TransMenuSet(iDirection,iLeft,iTop,iReferencePoint) {
  
    this.addMenu                = addMenu;
    this.addMenuLeft              = addMenuLeft;
    this.showMenu                = showMenu;
    this.hideMenu                = hideMenu;
    this.hide                  = hide;
    this.hideCurrent              = hideCurrent;
    var menus                  = [];
    var _this                  = this;
    var current                  = null;
    this.index                  = TransMenuSet.registry.length;
    TransMenuSet.registry[this.index]      = this;
    
    function addMenu(oActuator) {
      var m                   = new TransMenu(oActuator,iDirection,iLeft,iTop,iReferencePoint,this);
      menus[menus.length]            = m;
      return m;
    }
      function addMenuLeft(oActuator) {
      var m                   = new TransMenu(oActuator,iDirection,iLeft,iTop,iReferencePoint,this);
      menus[menus.length]            = m;
      return m;
    }
    
    function showMenu(oMenu) {
      if(oMenu != current) {
        if(current != null) {
          hide(current);
        }
      current                  = oMenu;
      oMenu.show();
      } else {
        cancelHide(oMenu);
      }
    }
    
    function hideMenu(oMenu) {
      if(current == oMenu&&oMenu.isOpen) {
        if(!oMenu.hideTimer) {
          scheduleHide(oMenu);
        }
      }
    }
    
    function scheduleHide(oMenu) {
      oMenu.onqueue();
      oMenu.hideTimer              = window.setTimeout("TransMenuSet.registry["+_this.index+"].hide(TransMenu.registry["+oMenu.index+"])",TransMenu.hideDelay);
    }
    
    function cancelHide(oMenu) {
      if(oMenu.hideTimer) {
        oMenu.ondequeue();
        window.clearTimeout(oMenu.hideTimer);
        oMenu.hideTimer            = null;
      }
    }
    
    function hide(oMenu) {
      if(!oMenu&&current) {
        oMenu                = current;
      }
      if(oMenu&&current==oMenu&&oMenu.isOpen) {
        hideCurrent();
      }
    }
    
    function hideCurrent() {
      if(null != current) {
        cancelHide(current);
        current.hideTimer          = null;
        current.hide();
        current                = null;
      }
    }
  }
  
  function TransMenuItem(sText,sUrl,sTarget,oParent) {
    this.toString                = toString;
    this.text                   = sText;
    this.url                  = sUrl;
    this.cible                = sTarget;
	this.parentMenu           = oParent;
    function toString(bDingbat){
      return                   '<a href="' + sUrl + '" target="' + sTarget + '" class="item">' + sText + '</a>';
    }
  }
  
  function Accelimation(from,to,time,zip) {
    if(typeof zip == "undefined") {
      zip                    = 0;
    }
    if(typeof unit == "undefined"){
      unit                  = "px";
    }
    this.x0                    = from;
    this.x1                    = to;
    this.dt                    = time;
    this.zip                  = -zip;
    this.unit                  = unit;
    this.timer                  = null;
    this.onend                  = new Function();
    this.onframe                = new Function();
  }
  
  Accelimation.prototype.start          = function() {
    this.t0                    = new Date().getTime();
    this.t1                    = this.t0 + this.dt; // *** Change minus for plus for animation ***
    var dx                    = this.x1 - this.x0;
    this.c1                    = this.x0 - ((1 + this.zip) * dx / 3);
    this.c2                    = this.x0 + ((2 + this.zip) * dx / 3);
    Accelimation._add(this);
  }
  
  Accelimation.prototype.stop            = function() {
    Accelimation._remove(this);
  }
  
  Accelimation.prototype._paint          = function(time) {
    if(time<this.t1){
      var elapsed                = time - this.t0;
      this.onframe(Accelimation._getBezier(elapsed/this.dt, this.x0, this.x1, this.c1, this.c2));
    } else {
      this._end();
    }
  }
    
  Accelimation.prototype._end            = function() {
    Accelimation._remove(this);
    this.onframe(this.x1);
    this.onend();
  }
  
  Accelimation._add                = function(o) {
    var index                  = this.instances.length;
    this.instances[index]            = o;
    if(this.instances.length == 1) {
      this.timerID              = window.setInterval("Accelimation._paintAll()",this.targetRes);
    }
  }
  
  Accelimation._remove              = function(o) {
    for(var i = 0; i < this.instances.length; i++) {
      if(o == this.instances[i]) {
        this.instances            = this.instances.slice(0,i).concat(this.instances.slice(i + 1));
        break;
      }
    }
  
    if(this.instances.length == 0) {
      window.clearInterval(this.timerID);
      this.timerID              = null;
    }
  }
  
  Accelimation._paintAll              = function() {
    var now                    = new Date().getTime();

    for(var i = 0;i < this.instances.length; i++) {
      this.instances[i]._paint(now);
    }
  }
  
  Accelimation._B1                = function(t) {
    return                     t*t*t;
  }
  
  Accelimation._B2                = function(t) {
    return                     3*t*t*(1-t);
  }
  
  Accelimation._B3                = function(t) {
    return                     3*t*(1-t)*(1-t);
  }
  
  Accelimation._B4                = function(t) {
    return                    (1-t)*(1-t)*(1-t);
  }
  
  Accelimation._getBezier              = function(percent,startPos,endPos,control1,control2) {
  var bzzz = endPos*this._B1(percent) + control2 * this._B2(percent) + control1 * this._B3(percent) + startPos * this._B4(percent);
  
    return bzzz;                
  }
  
  Accelimation.instances              = [];
  Accelimation.targetRes              = 10;
  Accelimation.timerID              = null;
  
  if(window.attachEvent) {
    var cearElementProps            = ['data','onmouseover','onmouseout','onmousedown','onmouseup','ondblclick','onclick','onselectstart','oncontextmenu'];
    window.attachEvent("onunload", function() {
      var el;
      for(var d = document.all.length; d--;) {
        el                  = document.all[d];
        for(var c = cearElementProps.length; c--;) {
          el[cearElementProps[c]]     = null;
        }
      }
    }
    );
  }
/*}}}*/
          
/* Trans Menu Init {{{ */
  

/*}}}*/

/* Style Switcher {{{ */
  function setActiveStyleSheet(title) {
    var i;
    var a;
    var main;
    for(i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
      if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
        a.disabled                         = true;
        if(a.getAttribute("title") == title) {
          a.disabled                       = false;
        }
      }
    }
  }

  function getActiveStyleSheet() {
    var i;
    var a;
    for(i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
      if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) {
        return a.getAttribute("title");
      }
    }
    return null;
  }

  function getPreferredStyleSheet() {
    var i;
    var a;
    for(i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
      if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")) {
        return a.getAttribute("title");
      }
    }
    return null;
  }

  function createCookie(name,value,days) {
    if (days) {
      var date                           = new Date();
      date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
      var expires                         = "; expires=" + date.toGMTString();
    } else {
      expires                           = "";
    }
    document.cookie                         = name + "=" + value + expires + "; path=/";
  }

  function readCookie(name) {
    var nameEQ                             = name + "=";
    var ca                               = document.cookie.split(';');
    for(var i = 0; i < ca.length; i++) {
      var c                             = ca[i];
      while (c.charAt(0) == ' ') {
        c = c.substring(1,c.length);
      }
      if (c.indexOf(nameEQ) == 0) {
        return c.substring(nameEQ.length,c.length);
      }
    }
    return null;
  }

  function windowStatus(t) {
    window.status                           = t;
    return true;    
  }

  var xm_off;
  var xmr_off;
  function switchMenu() {
    if(xm_off != 'off') {
      if(document.getElementById('leftMenuContent').style.display == 'none') {
        if(xmr_off != 'off') {
          document.getElementById('containerMainColumn').className   = 'containerMainColumnSM';
          document.getElementById('leftMenuButton').className     = 'hide';
          document.getElementById('leftMenuContent').style.display   = 'inline';
        }
        menuCookie = 'inline';
      } else {

        if(xmr_off != 'off') {
          document.getElementById('containerMainColumn').className   = 'containerMainColumnHM';
          document.getElementById('leftMenuButton').className     = 'show';
          document.getElementById('leftMenuContent').style.display   = 'none';
        }
        menuCookie = 'none';
      }
    }
  }
  
  function setPreferredMenu(menu) {
    if(xm_off != 'off') {
      if(menu == 'none') {
        if(xmr_off != 'off') {
          document.getElementById('containerMainColumn').className     = 'containerMainColumnHM';
          document.getElementById('leftMenuButton').className     = 'show';
          document.getElementById('leftMenuContent').style.display   = 'none';
        }
        menuCookie = 'none';
      } else {
        if(xmr_off != 'off') {
          document.getElementById('containerGlobal').className   = 'bodyContainerMB';
          document.getElementById('leftMenuButton').className     = 'hide';
          document.getElementById('leftMenuContent').style.display   = 'inline';
        }
        menuCookie = 'inline';    
      }
    }  
  }

  function SortableTable(oTable, oSortTypes) {
    this.sortTypes                           = oSortTypes || [];
    this.sortColumn                         = null;
    this.descending                         = null;
    var oThis                             = this;
    this._headerOnclick                       = function (e) {
      oThis.headerOnclick(e);
    };
    if (oTable) {
      this.setTable(oTable);
      this.document                         = oTable.ownerDocument || oTable.document;
    } else {
      this.document                         = document;
    }
    var win                             = this.document.defaultView || this.document.parentWindow;
    this._onunload                           = function () {
      oThis.destroy();
    };
    if (win && typeof win.attachEvent != "undefined") {
      win.attachEvent("onunload", this._onunload);
    }
  }

  SortableTable.gecko                         = navigator.product == "Gecko";
  SortableTable.msie                           = /msie/i.test(navigator.userAgent);
  SortableTable.removeBeforeSort                     = SortableTable.gecko;
  SortableTable.prototype.onsort                     = function () {};
  SortableTable.prototype.defaultDescending               = true;
  SortableTable.prototype._sortTypeInfo                 = {};
  SortableTable.prototype.setTable                   = function (oTable) {
    if (this.tHead) {
      this.uninitHeader();
    }
    this.element                           = oTable;
    this.setTHead(oTable.tHead);
    this.setTBody(oTable.tBodies[0]);
  };


  SortableTable.prototype.setTHead                   = function (oTHead) {
    if (this.tHead && this.tHead != oTHead) {
      this.uninitHeader();
    }
    this.tHead                             = oTHead;
    this.initHeader(this.sortTypes);
  };
  
  SortableTable.prototype.setTBody                   = function (oTBody) {
    this.tBody                             = oTBody;
  };
  
  SortableTable.prototype.setSortTypes                 = function (oSortTypes) {
    if (this.tHead) {
      this.uninitHeader();
    }
    this.sortTypes                           = oSortTypes || [];
    if (this.tHead) {
      this.initHeader(this.sortTypes);
    }
  };

  SortableTable.prototype.initHeader = function (oSortTypes) {
    if (!this.tHead) {
      return;
    }
    var cells                             = this.tHead.rows[0].cells;
    var doc                             = this.tHead.ownerDocument || this.tHead.document;
    this.sortTypes                           = oSortTypes || [];
    var l                               = cells.length;
    var img, c;
    for (var i = 0; i < l; i++) {
      c                               = cells[i];
      if (this.sortTypes[i] != null && this.sortTypes[i] != "None") {
        if (this.sortTypes[i] != null) {
          c._sortType = this.sortTypes[i];
        }
        if (typeof c.addEventListener != "undefined") {
          c.addEventListener("click", this._headerOnclick, false);
        } else if (typeof c.attachEvent != "undefined") {
          c.attachEvent("onclick", this._headerOnclick);
        } else {
          c.onclick                       = this._headerOnclick;
        }
      } else {
        c.setAttribute( "_sortType", oSortTypes[i] );
        c._sortType                       = "None";
      }
    }
  };

  SortableTable.prototype.uninitHeader = function () {
    if (!this.tHead) {
      return;
    }
    var cells                             = this.tHead.rows[0].cells;
    var l                               = cells.length;
    var c;
    for (var i = 0; i < l; i++) {
      c                               = cells[i];
      if (c._sortType != null && c._sortType != "None") {
        c.removeChild(c.lastChild);
        if (typeof c.removeEventListener != "undefined") {
          c.removeEventListener("click", this._headerOnclick, false);
        } else if (typeof c.detachEvent != "undefined") {
          c.detachEvent("onclick", this._headerOnclick);
        }
        c._sortType                       = null;
        c.removeAttribute( "_sortType" );
      }
    }
  };

  SortableTable.prototype.headerOnclick                 = function (e) {
    var el                               = e.target || e.srcElement;
    while (el.tagName != "TD") {
      el                               = el.parentNode;
    }  
    this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex);
  };

  SortableTable.getCellIndex                       = function (oTd) {
    var cells                             = oTd.parentNode.childNodes
    var l                               = cells.length;
    var i;
    for (i = 0; cells[i] != oTd && i < l; i++)
      ;
    return i;
  };

  SortableTable.prototype.getSortType                 = function (nColumn) {
    return this.sortTypes[nColumn] || "String";
  };

  SortableTable.prototype.sort                     = function (nColumn, bDescending, sSortType) {
    if (!this.tBody) {
      return;
    }
    if (sSortType == null) {
      sSortType                           = this.getSortType(nColumn);
    }
    if (sSortType == "None") {
      return;
    }
    if (bDescending == null) {
      if (this.sortColumn != nColumn) {
        this.descending                     = this.defaultDescending;
      } else {
        this.descending                     = !this.descending;
      }
    } else {
      this.descending                       = bDescending;
    }
    this.sortColumn = nColumn;
    if (typeof this.onbeforesort == "function") {
      this.onbeforesort();
    }  
    var f                               = this.getSortFunction(sSortType, nColumn);
    var a                               = this.getCache(sSortType, nColumn);
    var tBody                             = this.tBody;
    a.sort(f);
    if (this.descending) {
      a.reverse();
    }
    if (SortableTable.removeBeforeSort) {
      var nextSibling                       = tBody.nextSibling;
      var p                             = tBody.parentNode;
      p.removeChild(tBody);
    }
    var l                               = a.length;
    for (var i = 0; i < l; i++) {
      tBody.appendChild(a[i].element);
    }  
    if (SortableTable.removeBeforeSort) {
      p.insertBefore(tBody, nextSibling);
    }
    this.destroyCache(a);
    if (typeof this.onsort == "function") {
      this.onsort();
    }
  };

  SortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) {
    var oThis                             = this;
    this._asyncsort                         = function () {
      oThis.sort(nColumn, bDescending, sSortType);
    };
    window.setTimeout(this._asyncsort, 1);
  };

  SortableTable.prototype.getCache                   = function (sType, nColumn) {
    if (!this.tBody) {
      return [];
    }
    var rows                             = this.tBody.rows;
    var l                               = rows.length;
    var a                               = new Array(l);
    var r;
    for (var i = 0; i < l; i++) {
      r = rows[i];
      a[i] = {value: this.getRowValue(r, sType, nColumn),
            element: r};
    };
    return a;
  };

  SortableTable.prototype.destroyCache                 = function (oArray) {
    var l                               = oArray.length;
    for (var i = 0; i < l; i++) {
      oArray[i].value                       = null;
      oArray[i].element                       = null;
      oArray[i]                           = null;
    }
  };

  SortableTable.prototype.getRowValue                 = function (oRow, sType, nColumn) {
    if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue) {
      return this._sortTypeInfo[sType].getRowValue(oRow, nColumn);
    }
    var s;
    var c                               = oRow.cells[nColumn];
    if (typeof c.innerText != "undefined") {
      s                               = c.innerText;
    } else {
      s                               = SortableTable.getInnerText(c);
    }
    return this.getValueFromString(s, sType);
  };

  SortableTable.getInnerText                       = function (oNode) {
    var s                               = "";
    var cs                               = oNode.childNodes;
    var l                               = cs.length;
    for (var i = 0; i < l; i++) {
      switch (cs[i].nodeType) {
        case 1:
          s                           += SortableTable.getInnerText(cs[i]);
          break;
        case 3:
          s                           += cs[i].nodeValue;
          break;
      }
    }
    return s;
  };
  
  SortableTable.prototype.getValueFromString               = function (sText, sType) {
    if (this._sortTypeInfo[sType]) {
      return this._sortTypeInfo[sType].getValueFromString( sText );
    }
    return sText;
  };
  
  SortableTable.prototype.getSortFunction               = function (sType, nColumn) {
    if (this._sortTypeInfo[sType]) {
      return this._sortTypeInfo[sType].compare;
    }
    return SortableTable.basicCompare;
  };

  SortableTable.prototype.destroy                   = function () {
    this.uninitHeader();
    var win                             = this.document.parentWindow;
    if (win && typeof win.detachEvent != "undefined") {
      win.detachEvent("onunload", this._onunload);
    }
    this._onunload                           = null;
    this.element                           = null;
    this.tHead                             = null;
    this.tBody                             = null;
    this.document                           = null;
    this._headerOnclick                       = null;
    this.sortTypes                           = null;
    this._asyncsort                         = null;
    this.onsort                           = null;
  };

  SortableTable.prototype.addSortType                 = function (sType, fGetValueFromString, fCompareFunction, fGetRowValue) {
  
    this._sortTypeInfo[sType]                     = {
      type:                            sType,
      getValueFromString:                      fGetValueFromString || SortableTable.idFunction,
      compare:                          fCompareFunction || SortableTable.basicCompare,
      getRowValue:                        fGetRowValue
    };
  };

  SortableTable.prototype.removeSortType                 = function (sType) {
    delete this._sortTypeInfo[sType];
  };

  SortableTable.basicCompare                       = function compare(n1, n2) {
    if (n1.value < n2.value) {
      return -1;
    }
    if (n2.value < n1.value) {
      return 1;
    }

    return 0;
  };

  SortableTable.idFunction                       = function (x) {
    return x;
  };

  SortableTable.toUpperCase                       = function (s) {
    return s.toUpperCase();
  };

  SortableTable.toDate                         = function (s) {
    var parts                             = s.split("-");
    var d                               = new Date(0);
    d.setFullYear(parts[0]);
    d.setDate(parts[2]);
    d.setMonth(parts[1] - 1);
    return d.valueOf();
  };

  function usCurrencyConverter(s) {
    var n                               = s;
    var i                               = s.indexOf("$");
    if (i == -1) {
      i                               = s.indexOf(",");
    }
    if (i != -1) {
      var p1                             = s.substr(0, i);
      var p2                             = s.substr(i + 1, s.length);
      return usCurrencyConverter(p1 + p2);
    }
    return parseFloat( n );
  }

  function replace8a8(str) {
    str                               = str.toUpperCase();
    var splitstr                           = "____";
    var ar                               = str.replace(/(([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?)(.*)/, "$1"+splitstr+"$4").split(splitstr);
    var num                             = Number(ar[0]).valueOf();
    var ml                               = ar[1].replace(/\s*([KMGB])\s*/, "$1");
    if (ml == "K") {
      num                             *= 1024;
    } else if(ml == "M") {
      num                             *= 1024 * 1024;
    } else if (ml == "G") {
      num                             *= 1024 * 1024 * 1024;
    } else if (ml == "T") {
      num                             *= 1024 * 1024 * 1024 * 1024;
    }  
    return num;
  }
/*}}}*/

/* Event Handlers {{{ */
  window.onload                             = function(e) {
    var cookie                             = readCookie("style");
    var menuCookie                           = readCookie("menu");
    var optionsCookie                        = readCookie("options");
    var title                             = cookie ? cookie : getPreferredStyleSheet();
    setActiveStyleSheet(title);
    c_init();                            //Initialize the checkbox alteration.
  }
  
  window.onunload                           = function(e) {
    var title                             = getActiveStyleSheet();
    createCookie("style", title, 365);
    createCookie("menu", menuCookie, 365);
    createCookie("options", optionsCookie, 365);
  }
  
  var cookie                               = readCookie("style");
  var menuCookie                            = readCookie("menu");
  var optionsCookie                          = readCookie("options");
  var title                               = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);

  SortableTable.prototype.addSortType("Percent", replace8a8 );
  SortableTable.prototype.addSortType("Money", usCurrencyConverter );
  SortableTable.prototype.addSortType("Number", Number);
  SortableTable.prototype.addSortType("CaseInsensitiveString", SortableTable.toUpperCase);
  SortableTable.prototype.addSortType("Date", SortableTable.toDate);
  SortableTable.prototype.addSortType("String");
/*}}}*/


function uncheckall() {
  checkAll('off');
  img['allbox'].className  = 'blueCheckOff';
  document.getElementById('allbox').checked   = '';
  
}

/* Show-Hide Boxes {{{ */
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// LIST ALL SHOW/HIDE ELEMENT IDS HERE
menus_array = new Array ('dd1', 'dd2');
menus_status_array = new Array ();// remembers state of switches
img_close = 'graphics/icon_closebox.gif';
img_open = 'graphics/icon_openbox.gif';

function showHideSwitch (theid) {
  if (document.getElementById) {
    var switch_id = document.getElementById(theid);
    var imgid = theid+'Button';
    var button_id = document.getElementById(imgid);
    if (menus_status_array[theid] != 'hide') {
      button_id.setAttribute ('src', img_open);
      switch_id.className = 'hideSwitch';
    menus_status_array[theid] = 'hide';
    document.cookie = theid+'=hide';
    }else{
      button_id.setAttribute ('src', img_close);
      switch_id.className = 'showSwitch';
    menus_status_array[theid] = 'show';
    document.cookie = theid+'=show';
    }
  }
}
function resetDropBoxes () { // read cookies and set menus to last visited state
  if (document.getElementById) {

    for (var i=0; i<menus_array.length; i++) {
      var idname = menus_array[i];
      var switch_id = document.getElementById(idname);
      var imgid = idname+'Button';
      var button_id = document.getElementById(imgid);
      if (getCookie(idname) == 'hide') {
      button_id.setAttribute ('src', img_open);
        switch_id.className = 'hideSwitch';
      menus_status_array [idname] = 'hide';
    }else{
      button_id.setAttribute ('src', img_close);
        switch_id.className = 'showSwitch';
      menus_status_array [idname] = 'show';
    }
    }
  }
}
/*}}}*/

/* Checkbox-radiobut styler {{{ */

function styleCheckboxesAndRadiobuttons() {
  var elements = document.getElementsByTagName('input');
  for (i = 0; i < elements.length; i++) {
    if (elements[i].type == 'checkbox' || elements[i].type == 'radio') {  
      switch (elements[i].className) {
        // Add other cases here for other symbols. Just remember 
        // to change in your css too.
        // The case is the same as the class you use when calling on the
        // input.
        case 'radioButStyle':
          createAlternateCheckboxOrRadiobutton(elements[i], i);
        break;
        case 'checkBoxStyle':
          createAlternateCheckboxOrRadiobutton(elements[i], i);
        break;
      }
    }
  }
}

function createAlternateCheckboxOrRadiobutton(element, num) {
  var defaultClass = element.className + '-default';
  // Hide the original checkbox.
  element.style.display='none';
  // creates the new alternate checkbox
  var altElement = document.createElement('div');
  if (element.checked == true) {
    altElement.className = element.className;
  } else {
    altElement.className = defaultClass;
  }
  altElement.id = 'alt-' + element.id;
  element.parentNode.appendChild(altElement);

  // Handles onclick event.
  altElement.onclick = function(){
    if (element.checked != true) {
      if (element.type == 'radio') {
        handleOnClickForRadiobuttons(element.name);
      }
      altElement.className = element.className;
      element.checked = true
    } else {
      if (element.type == 'radio') {
        handleOnClickForRadiobuttons(element.name);
      }
      altElement.className = defaultClass;
      element.checked = false;
    }
  }
}

function handleOnClickForRadiobuttons(name) {
  var radiobuttons = document.getElementsByName(name);
  for (i = 0; i < radiobuttons.length; i++) {
      if (radiobuttons[i].type == 'radio') {
      var altRadiobutton = document.getElementById('alt-' + radiobuttons[i].id);
      altRadiobutton.className = radiobuttons[i].className + '-default';
    }
  }
}
/*}}}*/

/* Left Menu {{{ */
var timeout = null;
var Delay = 10;

function TreeNavigator(clientId, plus, minus)
{
  this.Container = document.getElementById(clientId);
    this.plus = plus;
    this.minus = minus;
    var instance = this;
    var uls = this.Container.getElementsByTagName("ul");
    for(var i=0; i < uls.length; i++)
    {
    /* skip the product list (if present) */
    if (uls[i].id && uls[i].id == "categoryList")
      continue;
        if (i>0)
        {
            var img = document.createElement("img");
            uls[i].parentNode.insertBefore(img, uls[i].parentNode.firstChild);
            if (uls[i].parentNode.className == "expanded")
            {
                img.src = this.minus;
            }
            else
            {
                img.src = this.plus;
            }
        }
    }
    var links = this.Container.getElementsByTagName("a");
    for (var i =0; i < links.length; i++)
    {
        if (links[i].nextSibling && links[i].nextSibling.tagName != "IMG")
        {
            links[i].onclick = function (e)
            {
                return instance.Toggle(e);
            }
        }
    }
}


TreeNavigator.prototype.Toggle = function(e)
{
  if (!e)
  {
    e = window.event;
  }

  var src = e.srcElement ? e.srcElement : e.target;

    if (!src.tagName)
    {
        src = src.parentNode;
    }
    
    if (src.tagName != "A")
  {
        return false;
  }
    
  var category = src.nextSibling;
  if (!category || category.tagName == "IMG")
  {
    return true;
  }
  if (category.style.display == "block")
  {
    this.Hide(category);
  }
  else
  {
    if (this.SingleExpand)
    {
      var parent = category.parentNode.parentNode;

      for (var i = 0; i < parent.childNodes.length; i++)
      {
                if (parent.childNodes[i].childNodes.length > 2)
        {
                    if (parent.childNodes[i].childNodes[2] != category)
                    {
                        parent.childNodes[i].childNodes[2].style.display = "none";
                        parent.childNodes[i].className = "collapsed";
                        this.HideImage(parent.childNodes[i].childNodes[2]);
                    }
                }
      }
    }
    this.Show(category);
  }
  return false;
}

TreeNavigator.prototype.HideImage = function(node)
{
    if (document.all)
    {
        var instance = this;
        window.setTimeout(function() {
        node.parentNode.firstChild.src = instance.plus}, 1);
    }
    else
    {
        node.parentNode.firstChild.src = this.plus;
    }
}

TreeNavigator.prototype.ShowImage = function(node)
{
    if (document.all)
    {
        var instance = this;
        window.setTimeout(function() {
        node.parentNode.firstChild.src = instance.minus; }, 1);
    }
    else
    {
        node.parentNode.firstChild.src = this.minus;
    }
}

TreeNavigator.prototype.Hide = function(node, img)
{
  if (timeout && this.Showing)
  {
    window.clearTimeout(timeout);
    this.Showing = false;
  }
  this.Hiding = true;
  node.style.overflow = "hidden";
  node.parentNode.className = "collapsed";
    this.HideImage(node);
  window.HideStep = function (height)
  {
    TreeNavigator.HideStep(height, node);
  }
  timeout = window.setTimeout("HideStep(" + node.scrollHeight + ")",5);
}

TreeNavigator.HideStep = function (scroll, node)
{
  var height = node.scrollHeight;
    scroll = scroll - Delay;
  if (scroll > 10 )
  {
    node.style.height = scroll + "px";
    timeout = window.setTimeout("HideStep(" + scroll + ")",5);
  }else
  {
    node.style.oveflow = "";
    node.style.display = "none";
  }
}

TreeNavigator.prototype.Show = function(node, img)
{
  if (timeout && this.Hiding)
  {
    window.clearTimeout(timeout);
    this.Hiding = false;
  }
  this.Showing = true;

  node.style.width = "100%";
  node.style.overflow = "hidden";
  node.style.display = "block";
  node.style.height = "1px";
  node.parentNode.className = "expanded";
    
    this.ShowImage(node);
    
  window.ShowStep = function(step)
  {
    TreeNavigator.ShowStep(step, node);
  };
  timeout = window.setTimeout("ShowStep(1)", 5);
}

TreeNavigator.ShowStep = function(scroll, node)
{
  var height = node.scrollHeight;
  scroll = scroll + Delay;
  if (scroll <= height)
  {
    node.style.height = scroll + "px";
    timeout= window.setTimeout("ShowStep(" + scroll + ")", 5);
  }else
  {
    node.style.height = "";
    node.style.overflow = "";
  }
}

/* Left Menu End {{{ */