if (parent.frames.length > 0) {
	parent.location.href = self.document.location;
}

/* tableH - class for handling rstable highlighting */

tableH = {
  // turn on table highlighting
  init: function() {
    if (!document.getElementsByTagName) return;  
  
    var all_cells = document.getElementsByTagName('td');
    for (var i = 0; i < all_cells.length; i++) {
      addEvent(all_cells[i], 'mouseover', tableH.hi_cell, false);
      addEvent(all_cells[i], 'mouseout', tableH.lo_cell, false);
    }
  },

  hi_cell: function(e) {
    var el;
    if (window.event && window.event.srcElement) el = window.event.srcElement;
    if (e && e.target) el = e.target;
    if (!el) return;

    el = ascendDOM(el, 'td');
    if (el == null) return;
	
	/*if (el.className.search(/\bth2\b/) == 0) return;*/

    var parent_row = ascendDOM(el, 'tr');
	if (parent_row == null) return;
	
	// Only want this behaviour in normal lines with class tl1 and tl2
	if (parent_row.className.substring(0,2) != 'tl') return;
    
    var parent_table = ascendDOM(parent_row, 'table');
    if (parent_table == null) return;

	// Only want this behaviour in rstables
	if (parent_table.className != 'rstable') return;
	
    // row styling
	//if (parent_row.className.substring(0,9) == 'tablehead') return;
	parent_row.className += ' hi';

    // column styling
	/*
    var ci = -1;
    for (var i = 0; i < parent_row.cells.length; i++) {
      if (el === parent_row.cells[i]) {
        ci = i;
      }
    }
    if (ci == -1) return; // this should never happen

    for (var i = 0; i < parent_table.rows.length; i++) {
      var cell = parent_table.rows[i].cells[ci];
      cell.className += ' hi';
    }
	*/
  },

  // turn off highlighting
  lo_cell: function(e) {
    var el;
    if (window.event && window.event.srcElement) el = window.event.srcElement;
    if (e && e.target) el = e.target;
    if (!el) return;

    el = ascendDOM(el, 'td');
    if (el == null) return;
  
    var parent_row = ascendDOM(el, 'tr');
    if (el == null) return;

    var parent_table = ascendDOM(parent_row, 'table');
    if (el == null) return;

    // row de-styling
    parent_row.className = parent_row.className.replace(/\b ?hi\b/, '');

    // column de-styling
    /*
	var ci = -1;
    for (var i = 0; i < parent_row.cells.length; i++) {
      if (el === parent_row.cells[i]) {
        ci = i;
      }
    }
    if (ci == -1) return; // this should never happen

    for (var i = 0; i < parent_table.rows.length; i++) {
      var cell = parent_table.rows[i].cells[ci];
      cell.className = cell.className.replace(/\b ?hi\b/, '');
    }
	*/
  }
};

/* tM - class for handling Technihow Menu */

tM = {
  init: function() {
    var uls = document.getElementsByTagName('ul');
    for (var u = 0; u < uls.length; u++) {
      if (uls[u].className.search(/\btopmenu\b/) == -1) continue;
      var lis = uls[u].getElementsByTagName('li');
      for (var i = 0; i < lis.length; i++) {
        var node = lis[i];
        if (node.nodeName.toLowerCase() == 'li' &&
          node.getElementsByTagName('ul').length > 0) {
          addEvent(node, 'mouseover', tM.getMoverFor(node), false);
          addEvent(node, 'mouseout', tM.getMoutFor(node), false);
          node.isIn = false;
        }
      }
    }
  },
  
  getMoverFor: function(node) {
    return function(e) { tM.mover(e, node); };
  },
  
  getMoutFor: function(node) {
    return function(e) { tM.mout(e, node); };
  },

  mover: function(e, targetElement) {
    var el = window.event ? targetElement : e ? e.currentTarget : null;
    if (!el) return;
	// Cleartimeout is critical.  It deals with mouse events in order when moving from element
	// to a new child element.  You get a mouse out, then a mouse in of the new element
	// then a mouse in of this one again.  The timer got started with the mouse out - if we 
	// don't stop it, then the sub-menu disappears again after 300ms
	clearTimeout(el.outTimeout);
    el.className += ' hi';
	if (!el.isIn) {
	  for (var i = 0; i < el.childNodes.length; i++) {
        var node = el.childNodes[i];
		if (node.nodeName.toLowerCase() == 'ul') {
          node.style.display = 'block';
		  break;
        }
      }
    }
    el.isIn = true;
    el.className += '';   // Force IE to recompute styles
  },

  mout: function(e, targetElement) {
    var el = window.event ? targetElement : e ? e.currentTarget : null;
    if (!el) return;
	el.className = el.className.replace(/\b ?hi\b/, '');
	el.outTimeout = setTimeout(function() { tM.mout2(el); }, 300);
  },

  mout2: function(el) {
    for (var i = 0; i < el.childNodes.length; i++) {
      var node = el.childNodes[i];
      if (node.nodeName.toLowerCase() == 'ul') {
        node.style.display = 'none';
		break;
      }
    }
    el.isIn = false;
  }
};

addEvent(window, 'load', tableH.init, false);
addEvent(window, 'load', tM.init, false);




