/*  Copyright (c) 2001-2007 FOX Software Sp. z o.o. author: marcin.lisok@fox.com.pl */
var op = /opera/i.test(navigator.userAgent);
var ie = !op && /msie/i.test(navigator.userAgent);	     
var mz = !op && /mozilla\/5/i.test(navigator.userAgent); 

// funkcja przełącza TabSheet
function changeTabSheet() {
  if ((!this) || (this.className == 'front')) return false;
  var ul = this.parentNode;
  var li = ul.getElementsByTagName('LI');
  for (var i=0; i<li.length; i++ ) {
    li[i].className = (li[i]==this) ? li[i].className.replace('back','front') : li[i].className.replace('front','back');
    var pg = document.getElementById('page'+i);
    if (pg) {
      pg.className = (li[i]==this)? pg.className.replace('back','front') : pg.className.replace('front','back');
    }
  }
  return false;
}
function activateTabSheet() {
  var ul = document.getElementsByTagName('UL');
  for( i=0; i<ul.length; i++ ) {
    if (ul[i].className != 'tabs') continue;
    var li = ul[i].getElementsByTagName('LI');
    for( j=0; j<li.length; j++ )
      li[j].onclick = changeTabSheet;
  }
}

function findParentElement( node, tag ) {
  var res = null;
  tag = tag.toUpperCase();
  while (node && node.tagName != tag) {
    node = node.parentNode;
  } 
  if (node && node.tagName == tag) res = node;
  return res;
}
function activateDetailView() {
  var arr = document.getElementsByTagName('A');
  for (var i=0; i<arr.length; i++) {
    if (arr[i].className.indexOf('detail') == -1) continue;
    arr[i].onclick = function () {
      var tr = findParentElement( this, 'TR' );
      if (tr) {
        tr = tr.nextSibling;
        while (tr.nodeType != 1) tr = tr.nextSibling;
        if (!tr) return true;
        var td = tr.cells[0];
        if (td.style.display != 'none' && td.style.display != '' ) {
          td.style.display = 'none';
          if ( ie ) tr.style.display = 'none';
        } else {
          if ( ie ) {
            td.style.display = 'block';
            tr.style.display = '';
          } else {
            td.style.display = 'table-cell';
          }
        }
      }
      return false;
    }
  }
}

window.onload = function() {
  activateTabSheet();
  activateDetailView();
}
