/***********************************************
** File:      %M%  version %I%
** Author:    nat
** Modified:  %G%
** Copyright: I-Next Ltd
***********************************************/
/* ident %W% */

function set( name, p, v ){ // object, param and value
  var o = get( name );
  var b = bIndex();
  if ( p == 'height' ) var myA = new Array('style.height','document.height','style.height');
  if ( p == 'width' ) var myA = new Array('style.width','document.width','style.width');
  if ( p == 'top' ) var myA = new Array('style.pixelTop','top','style.top');
  if ( p == 'left' ) var myA = new Array('style.pixelLeft','left','style.left');
  if ( p == 'visibility' ) var myA = new Array('style.visibility','visibility','style.visibility');
  if ( p == 'clip' ){
    var a = set.arguments;
    if ( document.layers ){ o.clip.top = a[2]; o.clip.right = a[3]; o.clip.bottom = a[4]; o.clip.left = a[5]; }
    else { o.style.clip = 'rect(' + a[2] + 'px, ' + a[3] + 'px, ' + a[4] + 'px, ' + a[5] + 'px)'; }
  } else {
    if ( v.NaN ) eval( 'o.' + myA[ b ] + ' = "' + v + '"'); // setting with string value
    else eval( 'o.' + myA[ b ] + ' = \'' + v + '\''); // setting with numeric value
  }
}

function get( name, p ){ // ('ie','n4+','n6')
  var retObj = '';
  var b = bIndex();
  var pair = '';
  // check for a nested div
  if ( name.search(/:/) != -1 ){ // get the last div name
    var pair = name.split(':');
    name = pair[ pair.length - 1 ];
  }
  // build the object
  if ( b == 0 ){ retObj = 'document.all("' + name + '")'; } // ie
  else if ( b == 1 ){ // check for nesting
    if ( pair != '' ){
      for ( var i=0; i < pair.length; i ++ ){ retObj += ( retObj == '' )? 'document.' + pair[i] : '.document.' + pair[i]; }
    } else{ retObj = 'document.layers["' + name + '"]'; } // netscape 4 +
  } else if ( b == 2 ){ retObj = 'document.getElementById("' + name + '")'; } // netscape 6
  if ( !p ) { return eval(retObj); }
  else if ( p == 'dom' ) { return ( b == 1 )? retObj : retObj + '.style'; }
  else {
    if ( p == 'height' ) var myA = new Array('clientHeight','document.height','offsetHeight');
    if ( p == 'width' ) var myA = new Array('clientWidth','document.width','offsetWidth');
    if ( p == 'top' ) var myA = new Array('offsetTop','top','offsetTop');
    if ( p == 'left' ) var myA = new Array('offsetLeft','left','offsetLeft');
    if ( p == 'visibility' ) var myA = new Array('style.visibility','visibility','style.visibility');
    return eval( retObj + '.' + myA[ b ] );
  }
}

function bIndex(){ // return browser index
  if ( document.all ) return 0; // ie
  else if ( document.layers ) return 1; // netscape pre 6
  else if ( document.getElementById ) return 2; // netscape 6 +
}

var alertString = '';

function highlightNav(divName, folderMatch) {
  var theDiv = document.getElementById(divName);
  if (theDiv) {
    var A = theDiv.getElementsByTagName('a');
    var here = "" + window.location;
    // strip any #<name> from the end
    here = here.replace(new RegExp("#.*"),"");  
    // strip /index.htm or last / from the end
    here = here.replace(new RegExp("/index\.htm"),"");
    here = here.replace(new RegExp("/$"),"");
    // split the protocol off
    here = here.toLowerCase().split('//')[1];
    // split the domain name off
    here = here.substring(here.indexOf('/'));
    
    for (var i=0; i<A.length; i++ ) { // check each link
      // split the protocol off
      var there = A[i].href.toLowerCase().split('//')[1];
      // strip any #<name> from the end
      there = there.replace(new RegExp("#.*"),"");        
      // strip /index.htm or last / from the end
      there = there.replace(new RegExp("/index\.htm"),"");
      there = there.replace(new RegExp("/$"),"");      
      // split the domain name from the front
      there = there.substring(there.indexOf('/'));
      alertString = '';
      
      // match to subpath, but not for first (home) item
      if ((pathMatch(here,there, folderMatch, 1)) && (i>0)) {
        A[i].className = A[i].className + "current";
      }
      else if (pathMatch(here,there,0,1)) {
        A[i].className = A[i].className + "current";
      }        
    }
  }
}

function pathMatch(here, there, folderMatch, n) {
  if (here==there) {
    if (((here=='') && (n==1)) || (here!='')) {
      return 1;
    }
    else {
      return 0;
    }  
  }
  else if ((folderMatch == 1) && (here != '')) {
    here  = here.substring(0,here.lastIndexOf('/'));
    return pathMatch(here, there, folderMatch, n+1);
  }    
}

var scrollI   = 0; // global var to hold current scroll paragraph
var scrollMax = 0; // global var to hold number of paragraphs to scroll
var scrollPs = new Array(); // global array to hold scrolling paragraphs
var scrollLeftInit = 204;
var scrollLeft = scrollLeftInit; // global var to hold current left position of scrolling paragraph
var scrollSpeed = 10;
var scrollBreak = 750;

function initScrollTag() {
  // start the scroller
  var D = document.getElementById('tag');
  if (D) {
    // get the paragraphs
    var P = D.getElementsByTagName('p');
    if (P.length>0) {
      scrollMax = P.length
      // copy ps in to array
      for (var i=0; i<P.length; i++) {
        scrollPs[i] = P[i];
      }
      // set first p up
      scrollPs[0].style.marginLeft = scrollLeft + 'px';     
      scrollPs[0].style.display = 'block';
      // do the scroll
      setTimeout(thisScrollTag, scrollSpeed);
    }
  }  
}

function thisScrollTag() {
  scrollLeft --;
  scrollPs[scrollI].style.marginLeft = scrollLeft + 'px';
  if (scrollLeft == 0) {
    setTimeout(nextScrollTag, scrollBreak);
  }
  else {
    setTimeout(thisScrollTag, scrollSpeed);    
  }
}
function nextScrollTag() {
  // hide the current one
  scrollPs[scrollI].style.display = 'none';
  // update counter
  scrollI ++;
  // reset left
  scrollLeft = scrollLeftInit;
  if (scrollI == scrollMax) { scrollI = 0;}
  // show the next one
  scrollPs[scrollI].style.display = 'block';
  // pause
  setTimeout(thisScrollTag, scrollSpeed);  
}

function doload(){
  highlightNav('leftnav', 1);
  highlightNav('topnav', 0);
  initScrollTag();
  initRollovers();
} 

window.onload = doload; 