/******************************************************************************
* dhtmllib.js                                                                 *
*                                                                             *
* Copyright 1999 by Mike Hall.                                                *
* Web address: http://www.brainjar.com                                        *
* Last update: February 26, 2000.                                             *
*                                                                             *
* Provides basic functions for DHTML positioned elements which will work on   *
* both Netscape Communicator and Internet Explorer browsers (version 4.0 and  *
* up).                                                                        *
******************************************************************************/

// Determine browser.

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;

//-----------------------------------------------------------------------------
// Layer motion (IE).
//-----------------------------------------------------------------------------

function motion(layer,counter,stepSize,endPos){
	layer.style.pixelTop -= stepSize;
	layer.style.pixelLeft -= stepSize;
	if (layer.style.pixelTop < endPos)
		{clearTimeout(counter);}
}

function startMotionIE(){
document.all.layer1.style.pixelTop += 500;
document.all.layer1.style.pixelLeft += 500;
counter1 = setInterval('motionIE1()', 1);
}

function motionIE1(){
showLayer(layer1);
document.all.layer1.style.pixelTop -= 15;
document.all.layer1.style.pixelLeft -= 15;
if (document.all.layer1.style.pixelTop < 15)
{
clearTimeout(counter1);
document.all.layer2.style.pixelTop += 500;
document.all.layer2.style.pixelLeft += 455;
counter2 = setInterval('motionIE2()', 1);
}}

function motionIE2(){
showLayer(layer2);
document.all.layer2.style.pixelTop -= 15;
document.all.layer2.style.pixelLeft -= 15;
if (document.all.layer2.style.pixelTop < 60)
{
clearTimeout(counter2);
document.all.layer3.style.pixelTop += 500;
document.all.layer3.style.pixelLeft += 491;
counter3 = setInterval('motionIE3()', 2);
}}

function motionIE3(){
showLayer(layer3);
document.all.layer3.style.pixelTop -= 15;
document.all.layer3.style.pixelLeft -= 18;
if (document.all.layer3.style.pixelTop < 105)
{
clearTimeout(counter3);
document.all.layer4.style.pixelTop += 500;
document.all.layer4.style.pixelLeft += 509;
counter4 = setInterval('motionIE4()', 2);
}}

function motionIE4(){
showLayer(layer4);
document.all.layer4.style.pixelTop -= 15;
document.all.layer4.style.pixelLeft -= 21;
if (document.all.layer4.style.pixelTop < 150)
{
clearTimeout(counter4);
document.all.layer5.style.pixelTop += 500;
document.all.layer5.style.pixelLeft += 509;
counter5 = setInterval('motionIE5()', 2);
}}

function motionIE5(){
showLayer(layer5);
document.all.layer5.style.pixelTop -= 15;
document.all.layer5.style.pixelLeft -= 24;
if (document.all.layer5.style.pixelTop < 195)
{
clearTimeout(counter5);
document.all.layer6.style.pixelTop += 500;
document.all.layer6.style.pixelLeft += 509;
counter6 = setInterval('motionIE6()', 2);
}}

function motionIE6(){
showLayer(layer6);
document.all.layer6.style.pixelTop -= 15;
document.all.layer6.style.pixelLeft -= 28;
if (document.all.layer6.style.pixelTop < 240)
{
clearTimeout(counter6);
document.all.layer7.style.pixelTop += 500;
document.all.layer7.style.pixelLeft += 500;
counter7 = setInterval('motionIE7()', 2);
}}

function motionIE7(){
showLayer(layer7);
document.all.layer7.style.pixelTop -= 15;
document.all.layer7.style.pixelLeft -= 33;
if (document.all.layer7.style.pixelTop < 285)
{
clearTimeout(counter7);
document.all.layer8.style.pixelTop += 500;
document.all.layer8.style.pixelLeft += 509;
counter8 = setInterval('motionIE8()', 2);
}}

function motionIE8(){
showLayer(layer8);
document.all.layer8.style.pixelTop -= 15;
document.all.layer8.style.pixelLeft -= 42;
if (document.all.layer8.style.pixelTop < 330)
{
clearTimeout(counter8);
document.all.layer9.style.pixelTop += 500;
document.all.layer9.style.pixelLeft += 500;
counter9 = setInterval('motionIE9()', 2);
}}

function motionIE9(){
showLayer(layer9);
document.all.layer9.style.pixelTop -= 15;
document.all.layer9.style.pixelLeft -= 55;
if (document.all.layer9.style.pixelTop < 375)
{
clearTimeout(counter9);
document.all.layer10.style.pixelTop += 500;
document.all.layer10.style.pixelLeft += 503;
counter10 = setInterval('motionIE10()', 2);
}}

function motionIE10(){
showLayer(layer10);
document.all.layer10.style.pixelTop -= 15;
document.all.layer10.style.pixelLeft -= 83;
if (document.all.layer10.style.pixelTop < 420)
{
clearTimeout(counter10);
}}

//-----------------------------------------------------------------------------
// Layer motion (IE) q_vakgebieden.html.
//-----------------------------------------------------------------------------

function VGmotionIE1(){
document.all.layer1.style.visibility = "visible";
document.all.layer1.style.pixelTop -= 15;
if (document.all.layer1.style.pixelTop < 15)
{
clearTimeout(counter1);
document.all.layer2.style.visibility = "visible";
document.all.layer2.style.pixelTop += 400;
counter2 = setInterval('VGmotionIE2()', 1);
}}

function VGmotionIE2(){
document.all.layer2.style.pixelTop -= 15;
if (document.all.layer2.style.pixelTop < 30)
{
clearTimeout(counter2);
document.all.layer3.style.visibility = "visible";
document.all.layer3.style.pixelTop += 400;
counter3 = setInterval('VGmotionIE3()', 2);
}}

function VGmotionIE3(){
document.all.layer3.style.pixelTop -= 15;
if (document.all.layer3.style.pixelTop < 45)
{
clearTimeout(counter3);
document.all.layer4.style.visibility = "visible";
document.all.layer4.style.pixelTop += 400;
counter4 = setInterval('VGmotionIE4()', 2);
}}

function VGmotionIE4(){
document.all.layer4.style.pixelTop -= 15;
if (document.all.layer4.style.pixelTop < 60)
{
clearTimeout(counter4);
document.all.layer5.style.visibility = "visible";
document.all.layer5.style.pixelTop += 400;
counter5 = setInterval('VGmotionIE5()', 3);
}}

function VGmotionIE5(){
document.all.layer5.style.pixelTop -= 15;
if (document.all.layer5.style.pixelTop < 75)
{
clearTimeout(counter5);
document.all.layer6.style.visibility = "visible";
document.all.layer6.style.pixelTop += 400;
counter6 = setInterval('VGmotionIE6()', 3);
}}

function VGmotionIE6(){
document.all.layer6.style.pixelTop -= 15;
if (document.all.layer6.style.pixelTop < 90)
{
clearTimeout(counter6);
document.all.layer7.style.visibility = "visible";
document.all.layer7.style.pixelTop += 400;
counter7 = setInterval('VGmotionIE7()', 4);
}}

function VGmotionIE7(){
document.all.layer7.style.pixelTop -= 15;
if (document.all.layer7.style.pixelTop < 105)
{
clearTimeout(counter7);
document.all.layer8.style.visibility = "visible";
document.all.layer8.style.pixelTop += 400;
counter8 = setInterval('VGmotionIE8()', 4);
}}

function VGmotionIE8(){
document.all.layer8.style.pixelTop -= 15;
if (document.all.layer8.style.pixelTop < 120)
{
clearTimeout(counter8);
document.all.layer9.style.visibility = "visible";
document.all.layer9.style.pixelTop += 400;
counter9 = setInterval('VGmotionIE9()', 5);
}}

function VGmotionIE9(){
document.all.layer9.style.pixelTop -= 15;
if (document.all.layer9.style.pixelTop < 135)
{
clearTimeout(counter9);
document.all.layer10.style.visibility = "visible";
document.all.layer10.style.pixelTop += 400;
counter10 = setInterval('VGmotionIE10()', 5);
}}

function VGmotionIE10(){
document.all.layer10.style.pixelTop -= 15;
if (document.all.layer10.style.pixelTop < 150)
{
clearTimeout(counter10);
document.all.layer11.style.visibility = "visible";
document.all.layer11.style.pixelTop += 400;
counter11 = setInterval('VGmotionIE11()', 6);
}}

function VGmotionIE11(){
document.all.layer11.style.pixelTop -= 15;
if (document.all.layer11.style.pixelTop < 165)
{
clearTimeout(counter11);
document.all.layer12.style.visibility = "visible";
document.all.layer12.style.pixelTop += 400;
counter12 = setInterval('VGmotionIE12()', 6);
}}

function VGmotionIE12(){
document.all.layer12.style.pixelTop -= 15;
if (document.all.layer12.style.pixelTop < 180)
{
clearTimeout(counter12);
document.all.layer13.style.visibility = "visible";
document.all.layer13.style.pixelTop += 400;
counter13 = setInterval('VGmotionIE13()', 7);
}}

function VGmotionIE13(){
document.all.layer13.style.pixelTop -= 15;
if (document.all.layer13.style.pixelTop < 195)
{
clearTimeout(counter13);
document.all.layer14.style.visibility = "visible";
document.all.layer14.style.pixelTop += 400;
counter14 = setInterval('VGmotionIE14()', 7);
}}

function VGmotionIE14(){
document.all.layer14.style.pixelTop -= 15;
if (document.all.layer14.style.pixelTop < 210)
{
clearTimeout(counter14);
document.all.layer15.style.visibility = "visible";
document.all.layer15.style.pixelTop += 400;
counter15 = setInterval('VGmotionIE15()', 8);
}}

function VGmotionIE15(){
document.all.layer15.style.pixelTop -= 15;
if (document.all.layer15.style.pixelTop < 225)
{
clearTimeout(counter15);
document.all.layer16.style.visibility = "visible";
document.all.layer16.style.pixelTop += 400;
counter16 = setInterval('VGmotionIE16()', 8);
}}

function VGmotionIE16(){
document.all.layer16.style.pixelTop -= 15;
if (document.all.layer16.style.pixelTop < 240)
{
clearTimeout(counter16);
document.all.layer17.style.visibility = "visible";
document.all.layer17.style.pixelTop += 400;
counter17 = setInterval('VGmotionIE17()', 9);
}}

function VGmotionIE17(){
document.all.layer17.style.pixelTop -= 15;
if (document.all.layer17.style.pixelTop < 255)
{
clearTimeout(counter17);
document.all.layer18.style.visibility = "visible";
document.all.layer18.style.pixelTop += 400;
counter18 = setInterval('VGmotionIE18()', 9);
}}

function VGmotionIE18(){
document.all.layer18.style.pixelTop -= 15;
if (document.all.layer18.style.pixelTop < 285)
{
clearTimeout(counter18);
document.all.layer19.style.visibility = "visible";
document.all.layer19.style.pixelTop += 400;
counter19 = setInterval('VGmotionIE19()', 9);
}}

function VGmotionIE19(){
document.all.layer19.style.pixelTop -= 15;
if (document.all.layer19.style.pixelTop < 300)
{
//setVakgebied(parent.pagina.VakGebied.valueOf())
clearTimeout(counter19);
}
}

function actiefIE(x_pos){
document.all.layer0.style.pixelTop = x_pos;
if (x_pos == 251 || x_pos == 296) {
   document.V1.height=27;}else{document.V1.height=15;
   }
}

//-----------------------------------------------------------------------------
// Layer vakgebied actief (IE + Netscape).
//-----------------------------------------------------------------------------

function actief(x_pos){
if (isNet){
   document.layer0.top = x_pos-4;
   if (x_pos == 251 || x_pos == 296) {
      document.layer0.document.V1.height=27;}else{document.layer0.document.V1.height=15;
   }
}
if (isIE){
   document.all.layer0.style.pixelTop = x_pos;
   if (x_pos == 251 || x_pos == 296) {
      document.V1.height=27;}else{document.V1.height=15;
   }
}
}

function setVakgebied(VG){
if (isIE)
{
switch(VG)
   {
   case 1 : actiefIE(11); break;
   case 2 : actiefIE(26); break;
   case 3 : actiefIE(41); break;
   case 4 : actiefIE(56); break;
   case 5 : actiefIE(71); break;
   case 6 : actiefIE(86); break;
   case 7 : actiefIE(101); break;
   case 8 : actiefIE(116); break;
   case 9 : actiefIE(131); break;
   case 10 : actiefIE(146); break;
   case 11 : actiefIE(161); break;
   case 12 : actiefIE(176); break;
   case 13 : actiefIE(191); break;
   case 14 : actiefIE(206); break;
   case 15 : actiefIE(221); break;
   case 16 : actiefIE(236); break;
   case 17 : actiefIE(251); break;
   case 18 : actiefIE(281); break;
   case 19 : actiefIE(296); break;
   }
}
if (isNet)
{
switch(VG)
   {
   case 1 : actiefNet(11); break;
   case 2 : actiefNet(26); break;
   case 3 : actiefNet(41); break;
   case 4 : actiefNet(56); break;
   case 5 : actiefNet(71); break;
   case 6 : actiefNet(86); break;
   case 7 : actiefNet(101); break;
   case 8 : actiefNet(116); break;
   case 9 : actiefNet(131); break;
   case 10 : actiefNet(146); break;
   case 11 : actiefNet(161); break;
   case 12 : actiefNet(176); break;
   case 13 : actiefNet(191); break;
   case 14 : actiefNet(206); break;
   case 15 : actiefNet(221); break;
   case 16 : actiefNet(236); break;
   case 17 : actiefNet(251); break;
   case 18 : actiefNet(281); break;
   case 19 : actiefNet(296); break;
   }   
}
}
   
//-----------------------------------------------------------------------------
// Layer motion (Netscape).
//-----------------------------------------------------------------------------

function startMotionNet(layer){
layer.top += 500;
layer.left += 500;
counter1 = setInterval('motionNet1(document.layer1)', 1);
}

function motionNet1(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 15;
if (layer.top < 15)
{
clearTimeout(counter1);
document.layer2.top += 500;
document.layer2.left += 455;
counter2 = setInterval('motionNet2(document.layer2)', 1);
}}

function motionNet2(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 15;
if (layer.top < 60)
{
clearTimeout(counter2);
document.layer3.top += 500;
document.layer3.left += 491;
counter3 = setInterval('motionNet3(document.layer3)', 2);
}}

function motionNet3(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 18;
if (layer.top < 105)
{
clearTimeout(counter3);
document.layer4.top += 500;
document.layer4.left += 509;
counter4 = setInterval('motionNet4(document.layer4)', 2);
}}

function motionNet4(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 21;
if (layer.top < 150)
{
clearTimeout(counter4);
document.layer5.top += 500;
document.layer5.left += 509;
counter5 = setInterval('motionNet5(document.layer5)', 2);
}}

function motionNet5(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 24;
if (layer.top < 195)
{
clearTimeout(counter5);
document.layer6.top += 500;
document.layer6.left += 509;
counter6 = setInterval('motionNet6(document.layer6)', 2);
}}

function motionNet6(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 28;
if (layer.top < 240)
{
clearTimeout(counter6);
document.layer7.top += 500;
document.layer7.left += 500;
counter7 = setInterval('motionNet7(document.layer7)', 2);
}}

function motionNet7(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 33;
if (layer.top < 285)
{
clearTimeout(counter7);
document.layer8.top += 500;
document.layer8.left += 509;
counter8 = setInterval('motionNet8(document.layer8)', 2);
}}

function motionNet8(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 42;
if (layer.top < 330)
{
clearTimeout(counter8);
document.layer9.top += 500;
document.layer9.left += 500;
counter9 = setInterval('motionNet9(document.layer9)', 2);
}}

function motionNet9(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 55;
if (layer.top < 375)
{
clearTimeout(counter9);
document.layer10.top += 500;
document.layer10.left += 503;
counter10 = setInterval('motionNet10(document.layer10)', 2);
}}

function motionNet10(layer){
showLayer(layer);
layer.top -= 15;
layer.left -= 83;
if (layer.top < 420)
{
clearTimeout(counter10);
}}

//-----------------------------------------------------------------------------
// Layer motion (Net) q_vakgebieden.html.
//-----------------------------------------------------------------------------

function VGmotionNet1(layer){
showLayer(layer);
layer.top -= 15;
if (layer.top < 15)
{
clearTimeout(counter1);
showLayer(document.layer2);
document.layer2.top += 400;
counter2 = setInterval('VGmotionNet2(document.layer2)', 1);
}}

function VGmotionNet2(layer){
layer.top -= 15;
if (layer.top < 30)
{
clearTimeout(counter2);
showLayer(document.layer3);
document.layer3.top += 400;
counter3 = setInterval('VGmotionNet3(document.layer3)', 2);
}}

function VGmotionNet3(layer){
layer.top -= 15;
if (layer.top < 45)
{
clearTimeout(counter3);
showLayer(document.layer4);
document.layer4.top += 400;
counter4 = setInterval('VGmotionNet4(document.layer4)', 2);
}}

function VGmotionNet4(layer){
layer.top -= 15;
if (layer.top < 60)
{
clearTimeout(counter4);
showLayer(document.layer5);
document.layer5.top += 400;
counter5 = setInterval('VGmotionNet5(document.layer5)', 3);
}}

function VGmotionNet5(layer){
layer.top -= 15;
if (layer.top < 75)
{
clearTimeout(counter5);
showLayer(document.layer6);
document.layer6.top += 400;
counter6 = setInterval('VGmotionNet6(document.layer6)', 3);
}}

function VGmotionNet6(layer){
layer.top -= 15;
if (layer.top < 90)
{
clearTimeout(counter6);
showLayer(document.layer7);
document.layer7.top += 400;
counter7 = setInterval('VGmotionNet7(document.layer7)', 4);
}}

function VGmotionNet7(layer){
layer.top -= 15;
if (layer.top < 105)
{
clearTimeout(counter7);
showLayer(document.layer8);
document.layer8.top += 400;
counter8 = setInterval('VGmotionNet8(document.layer8)', 4);
}}

function VGmotionNet8(layer){
layer.top -= 15;
if (layer.top < 120)
{
clearTimeout(counter8);
showLayer(document.layer9);
document.layer9.top += 400;
counter9 = setInterval('VGmotionNet9(document.layer9)', 5);
}}

function VGmotionNet9(layer){
layer.top -= 15;
if (layer.top < 135)
{
clearTimeout(counter9);
showLayer(document.layer10);
document.layer10.top += 400;
counter10 = setInterval('VGmotionNet10(document.layer10)', 5);
}}

function VGmotionNet10(layer){
layer.top -= 15;
if (layer.top < 150)
{
clearTimeout(counter10);
showLayer(document.layer11);
document.layer11.top += 400;
counter11 = setInterval('VGmotionNet11(document.layer11)', 6);
}}

function VGmotionNet11(layer){
layer.top -= 15;
if (layer.top < 165)
{
clearTimeout(counter11);
showLayer(document.layer12);
document.layer12.top += 400;
counter12 = setInterval('VGmotionNet12(document.layer12)', 6);
}}

function VGmotionNet12(layer){
layer.top -= 15;
if (layer.top < 180)
{
clearTimeout(counter12);
showLayer(document.layer13);
document.layer13.top += 400;
counter13 = setInterval('VGmotionNet13(document.layer13)', 7);
}}

function VGmotionNet13(layer){
layer.top -= 15;
if (layer.top < 195)
{
clearTimeout(counter13);
showLayer(document.layer14);
document.layer14.top += 400;
counter14 = setInterval('VGmotionNet14(document.layer14)', 7);
}}

function VGmotionNet14(layer){
layer.top -= 15;
if (layer.top < 210)
{
clearTimeout(counter14);
showLayer(document.layer15);
document.layer15.top += 400;
counter15 = setInterval('VGmotionNet15(document.layer15)', 8);
}}

function VGmotionNet15(layer){
layer.top -= 15;
if (layer.top < 225)
{
clearTimeout(counter15);
showLayer(document.layer16);
document.layer16.top += 400;
counter16 = setInterval('VGmotionNet16(document.layer16)', 8);
}}

function VGmotionNet16(layer){
layer.top -= 15;
if (layer.top < 240)
{
clearTimeout(counter16);
showLayer(document.layer17);
document.layer17.top += 400;
counter17 = setInterval('VGmotionNet17(document.layer17)', 9);
}}

function VGmotionNet17(layer){
layer.top -= 15;
if (layer.top < 255)
{
clearTimeout(counter17);
showLayer(document.layer18);
document.layer18.top += 400;
counter18 = setInterval('VGmotionNet18(document.layer18)', 9);
}}

function VGmotionNet18(layer){
layer.top -= 15;
if (layer.top < 285)
{
clearTimeout(counter18);
showLayer(document.layer19);
document.layer19.top += 400;
counter19 = setInterval('VGmotionNet19(document.layer19)', 9);
}}

function VGmotionNet19(layer){
layer.top -= 15;
if (layer.top < 300)
{
setVakgebied(parent.pagina.VakGebied.valueOf())
clearTimeout(counter19);
}}

function actiefNet(x_pos){
document.layer0.top = x_pos-4;
if (x_pos == 251 || x_pos == 296) {
   document.layer0.document.V1.height=27;}else{document.layer0.document.V1.height=15;
   }
}

//-----------------------------------------------------------------------------
// Layer visibility.
//-----------------------------------------------------------------------------

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 inheritLayer(layer) {

  if (isMinNS4)
    layer.visibility = "inherit";
  if (isMinIE4)
    layer.style.visibility = "inherit";
}

function getVisibility(layer) {

  if (isMinNS4) {
    if (layer.visibility == "show")
      return "visible";
    if (layer.visibility == "hide")
      return "hidden";
    return layer.visibility;
  }
  if (isMinIE4)
    return layer.style.visibility;
  return "";
}

//-----------------------------------------------------------------------------
// Layer positioning.
//-----------------------------------------------------------------------------

function moveLayerTo(layer, x, y) {

  if (isMinNS4)
    layer.moveTo(x, y);
  if (isMinIE4) {
    layer.style.left = x;
    layer.style.top  = y;
  }
}

function moveLayerBy(layer, dx, dy) {

  if (isMinNS4)
    layer.moveBy(dx, dy);
  if (isMinIE4) {
    layer.style.pixelLeft += dx;
    layer.style.pixelTop  += dy;
  }
}

function getLeft(layer) {

  if (isMinNS4)
    return layer.left;
  if (isMinIE4)
    return layer.style.pixelLeft;
  return -1;
}

function getTop(layer) {

  if (isMinNS4)
    return layer.top;
  if (isMinIE4)
    return layer.style.pixelTop;
  return -1;
}

function getRight(layer) {

  if (isMinNS4)
    return layer.left + getWidth(layer);
  if (isMinIE4)
    return layer.style.pixelLeft + getWidth(layer);
  return -1;
}

function getBottom(layer) {

  if (isMinNS4)
    return layer.top + getHeight(layer);
  if (isMinIE4)
    return layer.style.pixelTop + getHeight(layer);
  return -1;
}

function getPageLeft(layer) {

  var x;

  if (isMinNS4)
    return layer.pageX;
  if (isMinIE4) {
    x = 0;
    while (layer.offsetParent != null) {
      x += layer.offsetLeft;
      layer = layer.offsetParent;
    }
    x += layer.offsetLeft;
    return x;
  }
  return -1;
}

function getPageTop(layer) {

  var y;

  if (isMinNS4)
    return layer.pageY;
  if (isMinIE4) {
    y = 0;
    while (layer.offsetParent != null) {
      y += layer.offsetTop;
      layer = layer.offsetParent;
    }
    y += layer.offsetTop;
    return y;
  }
  return -1;
}

function getWidth(layer) {

  if (isMinNS4) {
    if (layer.document.width)
      return layer.document.width;
    else
      return layer.clip.right - layer.clip.left;
  }
  if (isMinIE4) {
    if (layer.style.pixelWidth)
      return layer.style.pixelWidth;
    else
      return layer.clientWidth;
  }
  return -1;
}

function getHeight(layer) {

  if (isMinNS4) {
    if (layer.document.height)
      return layer.document.height;
    else
      return layer.clip.bottom - layer.clip.top;
  }
  if (isMinIE4) {
    if (layer.style.pixelHeight)
      return layer.style.pixelHeight;
    else
      return layer.clientHeight;
  }
  return -1;
}

function getzIndex(layer) {

  if (isMinNS4)
    return layer.zIndex;
  if (isMinIE4)
    return layer.style.zIndex;

  return -1;
}

function setzIndex(layer, z) {

  if (isMinNS4)
    layer.zIndex = z;
  if (isMinIE4)
    layer.style.zIndex = z;
}

//-----------------------------------------------------------------------------
// Layer clipping.
//-----------------------------------------------------------------------------

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 +')';
}

function getClipLeft(layer) {

  if (isMinNS4)
    return layer.clip.left;
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return 0;
    var clip = getIEClipValues(layer.style.clip);
    return(clip[3]);
  }
  return -1;
}

function getClipTop(layer) {

  if (isMinNS4)
    return layer.clip.top;
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return 0;
    var clip = getIEClipValues(layer.style.clip);
    return clip[0];
  }
  return -1;
}

function getClipRight(layer) {

  if (isMinNS4)
    return layer.clip.right;
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return layer.style.pixelWidth;
    var clip = getIEClipValues(layer.style.clip);
    return clip[1];
  }
  return -1;
}

function getClipBottom(layer) {

  if (isMinNS4)
    return layer.clip.bottom;
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return layer.style.pixelHeight;
    var clip = getIEClipValues(layer.style.clip);
    return clip[2];
  }
  return -1;
}

function getClipWidth(layer) {

  if (isMinNS4)
    return layer.clip.width;
  if (isMinIE4) {
    var str = layer.style.clip;
    if (!str)
      return layer.style.pixelWidth;
    var clip = getIEClipValues(layer.style.clip);
    return clip[1] - clip[3];
  }
  return -1;
}

function getClipHeight(layer) {

  if (isMinNS4)
    return layer.clip.height;
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return layer.style.pixelHeight;
    var clip = getIEClipValues(layer.style.clip);
    return clip[2] - clip[0];
  }
  return -1;
}

function getIEClipValues(str) {

  var clip = new Array();
  var i;

  // Parse out the clipping values for IE layers.

  i = str.indexOf("(");
  clip[0] = parseInt(str.substring(i + 1, str.length), 10);
  i = str.indexOf(" ", i + 1);
  clip[1] = parseInt(str.substring(i + 1, str.length), 10);
  i = str.indexOf(" ", i + 1);
  clip[2] = parseInt(str.substring(i + 1, str.length), 10);
  i = str.indexOf(" ", i + 1);
  clip[3] = parseInt(str.substring(i + 1, str.length), 10);
  return clip;
}

//-----------------------------------------------------------------------------
// Layer scrolling.
//-----------------------------------------------------------------------------

function scrollLayerTo(layer, x, y, bound) {

  var dx = getClipLeft(layer) - x;
  var dy = getClipTop(layer) - y;

  scrollLayerBy(layer, -dx, -dy, bound);
}

function scrollLayerBy(layer, dx, dy, bound) {

  var cl = getClipLeft(layer);
  var ct = getClipTop(layer);
  var cr = getClipRight(layer);
  var cb = getClipBottom(layer);

  if (bound) {
    if (cl + dx < 0)
      dx = -cl;
    else if (cr + dx > getWidth(layer))
      dx = getWidth(layer) - cr;
    if (ct + dy < 0)
      dy = -ct;
    else if (cb + dy > getHeight(layer))
      dy = getHeight(layer) - cb;
  }
  clipLayer(layer, cl + dx, ct + dy, cr + dx, cb + dy);
  moveLayerBy(layer, -dx, -dy);
}

//-----------------------------------------------------------------------------
// Layer background.
//-----------------------------------------------------------------------------

function setBgColor(layer, color) {

  if (isMinNS4)
    layer.bgColor = color;
  if (isMinIE4)
    layer.style.backgroundColor = color;
}

function setBgImage(layer, src) {

  if (isMinNS4)
    layer.background.src = src;
  if (isMinIE4)
    layer.style.backgroundImage = "url(" + src + ")";
}

//-----------------------------------------------------------------------------
// Layer utilities.
//-----------------------------------------------------------------------------

function getLayer(name) {

  if (isMinNS4)
    return findLayer(name, document);
  if (isMinIE4)
    return eval('document.all.' + name);
  return null;
}

function findLayer(name, doc) {

  var i, layer;

  for (i = 0; i < doc.layers.length; i++) {
    layer = doc.layers[i];
    if (layer.name == name)
      return layer;
    if (layer.document.layers.length > 0)
      if ((layer = findLayer(name, layer.document)) != null)
        return layer;
  }
  return null;
}

//-----------------------------------------------------------------------------
// Image utilities.
//-----------------------------------------------------------------------------

function getImage(name) {

  if (isMinNS4) {
    return findImage(name, document);
  }
  if (isMinIE4)
    return eval('document.all.' + name);
  return null;
}

function findImage(name, doc) {

  var i, img;

  for (i = 0; i < doc.images.length; i++)
    if (doc.images[i].name == name)
      return doc.images[i];
  for (i = 0; i < doc.layers.length; i++)
    if ((img = findImage(name, doc.layers[i].document)) != null) {
      img.container = doc.layers[i];
      return img;
    }
  return null;
}

function getImagePageLeft(img) {

  var x, obj;

  if (isMinNS4) {
    if (img.container != null)
      return img.container.pageX + img.x;
    else
      return img.x;
  }
  if (isMinIE4) {
    x = 0;
    obj = img;
    while (obj.offsetParent != null) {
      x += obj.offsetLeft;
      obj = obj.offsetParent;
    }
    x += obj.offsetLeft;
    return x;
  }
  return -1;
}

function getImagePageTop(img) {

  var y, obj;

  if (isMinNS4) {
    if (img.container != null)
      return img.container.pageY + img.y;
    else
      return img.y;
  }
  if (isMinIE4) {
    y = 0;
    obj = img;
    while (obj.offsetParent != null) {
      y += obj.offsetTop;
      obj = obj.offsetParent;
    }
    y += obj.offsetTop;
    return y;
  }
  return -1;
}

//-----------------------------------------------------------------------------
// Window and page properties.
//-----------------------------------------------------------------------------

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 getPageWidth() {

  if (isMinNS4)
    return document.width;
  if (isMinIE4)
    return document.body.scrollWidth;
  return -1;
}

function getPageHeight() {

  if (isMinNS4)
    return document.height;
  if (isMinIE4)
    return document.body.scrollHeight;
  return -1;
}

function getPageScrollX() {

  if (isMinNS4)
    return window.pageXOffset;
  if (isMinIE4)
    return document.body.scrollLeft;
  return -1;
}

function getPageScrollY() {

  if (isMinNS4)
    return window.pageYOffset;
  if (isMinIE4)
    return document.body.scrollTop;
  return -1;
}
