var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;

function getWindowWidth() 
{
  if (isMinNS4) return window.innerWidth;
  if (isMinIE4) return document.body.clientWidth;
  return -1;
}

function getWindowHeight() 
{
  if (isMinNS4) return window.innerHeight;
  if (isMinIE4) return document.body.clientHeight;
  return -1;
}

function hideLayer(layer) 
{
  if (isMinNS4) layer.visibility = "hide";
  if (isMinIE4) layer.style.visibility = "hidden";
}

function showLayer(layer) 
{
  if (isMinNS4) layer.visibility = "show";
  if (isMinIE4) layer.style.visibility = "visible";
}

function moveLayerTo(layer, x, y) 
{
  if (isMinNS4) layer.moveTo(x, y);
  if (isMinIE4) 
  {
    layer.style.left = x;
    layer.style.top  = y;
  }
}

function clipLayer(layer, clipleft, cliptop, clipright, clipbottom) 
{
  if (isMinNS4) 
  {
    layer.clip.left   = clipleft;
    layer.clip.top    = cliptop;
    layer.clip.right  = clipright;
    layer.clip.bottom = clipbottom;
  }
  if (isMinIE4)
    layer.style.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
}
