function loadiframe(frame,url)
{
  parent.frames[frame].location.href = url;
}

function loadpage(url)
{
  document.location = url;
}

function utf8encode(s)
{
  return unescape(encodeURIComponent(s));
}

function utf8decode(s)
{
  return decodeURIComponent(escape(s));
}

function getoffsets(e)
{
  var o = {height: e.offsetHeight,width: e.offsetWidth};
  var x = e.offsetLeft;
  var y = e.offsetTop;
  var p = e.offsetParent;
	
  while (p) // && (p.nodeType != 9))
  {
    x += p.offsetLeft;
    y += p.offsetTop;
    p  = p.offsetParent;
  }
  o.left = x;
  o.top  = y;
  return o;
}

function getwindowwidth()
{
  var windowWidth;
  if (self.innerHeight) // all except Explorer
  {
    windowWidth  = self.innerWidth;
  }
  else
  if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
  {
    windowWidth  = document.documentElement.clientWidth;
  }
  else
  if (document.body) // other Explorers
  {
    windowWidth  = document.body.clientWidth;
  }

  return windowWidth;
}

function getwindowheight()
{
  var windowHeight;
  if (self.innerHeight) // all except Explorer
  {
    windowHeight = self.innerHeight;
  }
  else
  if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
  {
    windowHeight = document.documentElement.clientHeight;
  }
  else
  if (document.body) // other Explorers
  {
    windowHeight = document.body.clientHeight;
  }

  return windowHeight;
}

function resizecoliframes()
{
  h = getwindowheight()-coldelh;

  if (document.getElementById && !(document.all))
  {
    ifitem = document.getElementById('ifitem');
    iflist = document.getElementById('iflist');
    iflcon = document.getElementById('iflcon');
    ifmenu = document.getElementById('ifmenu');
    ifcap  = document.getElementById('ifcap');
    if (ifitem==null || iflist==null || ifmenu==null) return;
    ifitem.style.height     = h-colmnuh;
    iflist.style.height     = h-28; // 28 = height of pane caption+bottomline 
    ifmenu.style.height     = colmnuh;
    ifcap .innerHTML        = "";
    ifcap .style.display    = 'none';
    iflcon.style.visibility = 'visible';
  }
  else
  {
    document.all.ifitem.style.height     = h;
    document.all.iflist.style.height     = h;
    document.all.ifmenu.style.height     = colmnuh;
    document.all.ifcap .innerHTML        = "";
    document.all.ifcap .style.display    = 'none';
    document.all.iflcon.style.visibility = 'visible';
  }
}

function resizegaliframes()
{
  h = getwindowheight()-galdelh;
  if (h<1) h = 1;

  if (document.getElementById && !(document.all))
  {
    ifview = document.getElementById('ifview');
    ifinfo = document.getElementById('ifinfo');
    iflist = document.getElementById('iflist');
    ifcap  = document.getElementById('ifcap');
    if (ifview==null || ifinfo==null || iflist==null) return;
    ifview.style.height  = galimgh;
    ifinfo.style.height  = h;
    iflist.style.height  = gallsth;
    ifcap .innerHTML     = "";
    ifcap .style.display = 'none';
  }
  else
  {
    document.all.ifview.style.height  = galimgh;
    document.all.ifinfo.style.height  = h;
    document.all.iflist.style.height  = gallsth;
    document.all.ifcap .innerHTML     = "";
    document.all.ifcap .style.display = 'none';
  }
}

var onloadfunctions   = [];
var onunloadfunctions = [];

/*
function addonload(f)
{
  onloadfunctions[onloadfunctions.length] = f;
  window.onload = doonload;
}
*/

function addonload(f)
{
  var oldonload = window.onload;

  if (typeof oldonload=="function")
  {
    window.onload = function()
                    {
                      if (oldonload) { oldonload(); }
                      f();
                    }
  }
  else
  {
    window.onload = f;
  } 
}
function addonunload(f)
{
  onunloadfunctions[onunloadfunctions.length] = f;
  window.onunload = doonunload;
}

function doonload()
{
  for (var i=0;i<onloadfunctions.length;i++) onloadfunctions[i]();
}

function doonunload()
{
  for (var i=0;i<onunloadfunctions.length;i++) onunloadfunctions[i]();
}
