var uri = window.location.toString();
uri = uri.substr(0,uri.lastIndexOf('/'));
var ehash = new Array();
var opera = (navigator.userAgent.indexOf('Opera') >= 0) ? true : false;
var ie = (document.all && !opera)? true : false;

function hexdec(hex) { return parseInt(hex,16) }
function cancel_event(e) { if (window.event) { window.event.cancelBubble = true } else if (e.stopPropagation) { e.stopPropagation() }}
function event_item(e) { var i = (window.event)?window.event.srcElement:e.currentTarget; return i }
function validate_parent(parent) { if (!parent) parent = document.getElementsByTagName("body")[0]; return parent }
function create_element(type, parent)
{
  var item = null;
  if (document.createElementNS) { item = document.createElementNS("http://www.w3.org/1999/xhtml", type) } else { item = document.createElement(type)}
  if (typeof(parent) != "undefined") parent.appendChild(item);
  return item;
}
function ieGetUniqueID(o)
{
  if (o === window) { return 'theWindow'; }
  else if (o === document) { return 'theDocument'; }
  else { return o.uniqueID; }
}
function add_event(item, name, func)
{
  if ((typeof item.attachEvent != 'undefined') && ie)
  {
    var key = '{FNKEY::obj_'+ieGetUniqueID(item)+'::evt_'+name+'::fn_'+func+'}';
    var f = ehash[key];
    if (typeof f != 'undefined') { return; }
    f = function() { func.call(item) }
    ehash[key] = f;
    item.attachEvent('on'+name, f);
    // attach unload event to the window to clean up possibly IE memory leaks
    window.attachEvent('onunload', function() { item.detachEvent('on'+name, f) });
    key = null;
  }
//  else if (typeof window.opera == 'boolean') { window.addEventListener(name, func, false) }
  else if (typeof item.addEventListener == 'function') { item.addEventListener(name, func, false) }
  else { item["on" + name] = func }
}

function _get_sv(i,d)
{
  var o = document.getElementById(i);
  if (!o) return d;
  var i = o.selectedIndex;
  if (i < 0) return d;
  return o.options[i].value;
}
function _get(i,d)
{
  var o = document.getElementById(i);
  if (!o) return d;
  return o.value;
}
function _set(n,v)
{
  var e = document.getElementById(n);
  if (!e)
  {
    e = document.createElement('input');
    e.name = n; e.id = n; e.type='hidden';
    document.forms[0].appendChild(e);
  }
  e.value = v;
  return 0;
}
function _done(m,a)
{
  var fr = document.forms[0];
  if (a) fr.action = a;
  if (m) fr.method = m;
  fr.submit();
  return 1;
}

