if ((effect == 0) || (effect == 2)) {
  var itop= (effect== 0) ? bannerHeight : "auto";
  var bottom= (effect== 2) ? 0 : "auto";
  var left="auto";
  var right="auto";
}
else if ((effect == 1) || (effect == 3)) {
  var itop= "auto";
  var bottom= "auto";
  var left= (effect== 3) ? bannerWidth : "auto";
  var right= (effect== 1) ? 0 : "auto";
} 
else {
  var horz = parseInt(bannerWidth/2);
  var vert = parseInt(bannerHeight/2);
  var itop= vert;
  var bottom= vert;
  var left= horz;
  var right= horz;
}
var scrollY = 0;
var scrollFast = (NS4) ? 7 : 14;
var scrollSlow = (NS4) ? 1 : 3;
var done = 0;
var verInc = (bannerHeight > bannerWidth) ? (bannerHeight/bannerWidth) * expInc : expInc;
var horInc = (bannerWidth > bannerHeight) ? (bannerWidth/bannerHeight) * expInc : expInc;
var startVisibility = "hidden";
var textScroll = scrollSlow
var scrollInterval = 10;
var scrollHeight = bannerHeight-40;
var expand=0;
fontSize= (navigator.appVersion.indexOf("isMac") == -1) ? fontSize : fontSize+2;

layerContent  = '<div style="font-family:'+font+'; font-size:'+fontSize+'pt">';
if (firstLine != "") {
  layerContent += '<a style="text-decoration:none; color:'+firstLineColor+';">'+firstLine+'</a><br>';
}
for (var i = 0; i < pages.length; i++) {
  if (urls[i] != "#") {
    layerContent += '<a style="text-decoration:none; color:#'+fontColor+';" href="'+urls[i]+'">'+pages[i]+'</a><br>';
  } else if (i != 0) {
    layerContent += '<br><a style="text-decoration:none; color:#'+letterColor+'; font-size:'+("" + ((fontSize-0)+2))+'pt;" href="'+urls[i]+'">'+pages[i]+'</a><br>';
  } else {
    layerContent += '<a style="text-decoration:none; color:#'+letterColor+'; font-size:'+("" + ((fontSize-0)+2))+'pt;" href="'+urls[i]+'">'+pages[i]+'</a><br>';
  }
}
layerContent += '</div>';

stylestr  = '<style type="text/css">';

stylestr += '#outer {';
stylestr += 'position:absolute;';
stylestr += 'left: ' + startX + ';';
stylestr += 'top: ' + startY + ';';
stylestr += 'width: '+bannerWidth+'px;';
stylestr += 'height: '+bannerHeight+'px;';
stylestr += (NS4) ? 'layer-background-color: '+bannerColor+';' : 'background-color: '+bannerColor+';';
stylestr += 'visibility:'+startVisibility+';';
stylestr += 'z-index:100;';
stylestr += '}';

stylestr += '#topbar {';
stylestr += 'position: absolute;';
stylestr += 'top: 0;';
stylestr += 'height: 16;';
stylestr += 'width: '+bannerWidth+'px;';
stylestr += (NS4) ? 'layer-background-color: '+outlineColor+';' : 'background-color: '+outlineColor+';';
stylestr += 'font-family:'+font+';';
stylestr += (isMac) ? 'font-size:12pt;' : 'font-size:10pt;';
stylestr += '}';

stylestr += '#banner {';
stylestr += 'position: absolute;';
stylestr += 'left: 0;';
stylestr += 'top: 20;';
stylestr += 'width: '+bannerWidth+'px;';
stylestr += 'height: '+bannerHeight+'px;';
stylestr += (NS4) ? 'layer-background-color: '+bannerColor+';' : 'background-color: '+bannerColor+';';
stylestr += 'border: normal;';
stylestr += 'border-width: 1;';
stylestr += '}';

stylestr += '#message {';
stylestr += 'position: absolute;';
stylestr += 'left: 6;';
stylestr += 'cursor:hand;';
stylestr += '}';

stylestr += '#bottombar {';
stylestr += 'position: absolute;';
stylestr += 'top: '+(bannerHeight-16)+'px;';
stylestr += 'height: 16;';
stylestr += 'width: '+bannerWidth+'px;';
stylestr += (NS4) ? 'layer-background-color: '+outlineColor+';' : 'background-color: '+outlineColor+';';
stylestr += '}';

stylestr += '</style>';

document.write(stylestr);

topbarstr  = '<div align=center><b>'+title+'</b></div><img src="'+spacer+'" width='+bannerWidth+' height=1 border=0>';
bottombarstr  = '<div align=center>';
bottombarstr += '<a href="javascript:void(0);" onmouseover="scrollID=setInterval(\'moveDown(textScroll)\', scrollInterval);" onMouseDown="textScroll=scrollFast;" onMouseUp="textScroll=scrollSlow;" onmouseout="clearInterval(scrollID); textScroll=scrollSlow;"><img name="a1" src="'+upArrow+'" width=19 height=10 alt="Use this arrow to scroll up." border=0></a>&nbsp;&nbsp;';
bottombarstr += '<img src="'+spacer+'" width=20 height=1 border=0>';
bottombarstr += '<a href="javascript:void(0);" onmouseover="scrollID=setInterval(\'moveUp(textScroll)\', scrollInterval);" onMouseDown="textScroll=scrollFast;" onMouseUp="textScroll=scrollSlow;" onmouseout="clearInterval(scrollID); textScroll=scrollSlow;"><img name="a2" src="'+downArrow+'" width=19 height=10 alt="Use this arrow to scroll down." border=0></a>';
bottombarstr += '</div>';
bottombarstr += '<img src="'+spacer+'" width='+bannerWidth+' height=15 border=0><br>';
document.write('<div id="outer" style="filter:blendTrans(duration=2)"><div id="topbar">'+topbarstr+'</div><div id="banner"><div id="message"></div></div><div id="bottombar">'+bottombarstr+'</div></div>');

if (ver4) {
  if (NS4) {
    activeEl = document.outer;
    activeEl.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
    outer = document.outer;
    banner = document.outer.document.banner;
    message = banner.document.message;
    banner.clip.bottom=scrollHeight;
    layerButton = document.layerButton;
  } else {    activeEl = outer;
    banner.style.clip = "rect(0 " + bannerWidth + " " + scrollHeight + " 0)";
  }
}
function fillLayer() {
  if (NS4) {
    message.document.write(layerContent);
    message.document.close();
    message.top=scrollY;
  } else {
    message.innerHTML = layerContent;
    message.style.pixelTop=scrollY;
    outer.style.visibility = startVisibility;
  }
}
function openLayer() {
  if (expand == 1) {
    clearInterval(expandClip);
    expand=3;
  } 
  if (expand == 2) {
    clearInterval(contractClip);
    expand=0;
  }
  interval=1;
  if (NS4) {
    if (expand != 0) {
      contractClip = setInterval("close_clip()", interval);
    } else {
      if (effect == 0) {
        outer.clip.top = itop;
        outer.clip.bottom = 0;
      }
        else if (effect == 1) {
        outer.clip.right = right;
        outer.clip.bottom = bannerHeight;
      }
      else if (effect == 2) {
        outer.clip.bottom = bottom;
      }
      else if (effect == 3) {
        outer.clip.left = left;
        outer.clip.bottom = bannerHeight;
      }
      else {
        outer.clip.top=itop;
        outer.clip.right=right;
        outer.clip.bottom=bottom;
        outer.clip.left=left;
      }
      outer.visibility = "show";
      expandClip = setInterval("open_clip()", interval)
    }
  } else {
    if (expand != 0) {
      contractClip = setInterval("close_clip()", interval);
    } else {
      outer.style.clip="rect("+itop+" "+right+" "+bottom+" "+left+")";
      outer.style.visibility = "visible";
      expandClip = setInterval("open_clip()", interval);
    }
  }
}
function open_clip() {
  expand=1;
  if (NS4) {
    if (effect == 0) {
      outer.clip.top = (outer.clip.top - expInc >= 0) ? (outer.clip.top - expInc) : 0;
      if (outer.clip.top == 0) {
        done = 1;
      }
    }
    else if (effect == 1) {
      outer.clip.right = (outer.clip.right + expInc <= bannerWidth) ? (outer.clip.right + expInc) : bannerWidth;
      if (outer.clip.right == bannerWidth) {
        done = 1;
      }
    }
    else if (effect == 2) {
      outer.clip.bottom = (outer.clip.bottom + expInc <= bannerHeight) ? (outer.clip.bottom + expInc) : bannerHeight;
      if (outer.clip.bottom == bannerHeight) {
        done = 1;
      }
    }
    else if (effect == 3) {
      outer.clip.left = (outer.clip.left - expInc >= 0) ? (outer.clip.left - expInc) : 0;
      if (outer.clip.left == 0) {
        done = 1;
      }
    }
    else {
      outer.clip.top = (outer.clip.top - verInc >= 0) ? (outer.clip.top - verInc) : 0;
      outer.clip.right = (outer.clip.right + horInc <= bannerWidth) ? (outer.clip.right + horInc) : bannerWidth;
      outer.clip.bottom = (outer.clip.bottom + verInc <= bannerHeight) ? (outer.clip.bottom + verInc) : bannerHeight;
      outer.clip.left = (outer.clip.left - horInc >= 0) ? (outer.clip.left - horInc) : 0;
      if ((outer.clip.top == 0) && (outer.clip.right == bannerWidth) && (outer.clip.bottom == bannerHeight) && (outer.clip.left == 0)) {
        done = 1;
      }
    }
    if (done == 1) {
      clearInterval(expandClip);
      expand=3;
      done = 0;
    }
  } else {
    if (effect == 0) {
      itop = (itop - expInc >= 0) ? parseInt(itop - expInc) : 0;
      if (itop == 0) {
        done = 1;
      }
    }
    else if (effect == 1) {
      right = (right + expInc <= bannerWidth) ? parseInt(right + expInc) : bannerWidth;
      if (right == bannerWidth) {
        done = 1;
      }
    }
    else if (effect == 2) {
      bottom = (bottom + expInc <= bannerHeight) ? parseInt(bottom + expInc) : bannerHeight;
      if (bottom == bannerHeight) {
        done = 1;
      }
    }
    else if (effect == 3) {
      left = (left - expInc >= 0) ? parseInt(left - expInc) : 0;
      if (left == 0) {
        done = 1;
      }
    }
    else {
      itop = (itop - verInc >= 0) ? parseInt(itop - verInc) : 0;
      right = (right + horInc <= bannerWidth) ? parseInt(right + horInc) : bannerWidth;
      bottom = (bottom + verInc <= bannerHeight) ? parseInt(bottom + verInc) : bannerHeight;
      left = (left - horInc >= 0) ? parseInt(left - horInc) : 0;
      if ((itop == 0) && (right == bannerWidth) && (bottom == bannerHeight) && (left == 0)) {
        done = 1;
      }
    }
    outer.style.clip="rect("+itop+" "+right+" "+bottom+" "+left+")";
    if (done == 1) {
      clearInterval(expandClip);
      expand=3;
      done=0;
    }
  }
}
function close_clip() {
  expand=2;
  if (NS4) {
    if (effect == 0) {
      outer.clip.top = (outer.clip.top + expInc <= bannerHeight) ? (outer.clip.top + expInc) : bannerHeight;
      if (outer.clip.top == bannerHeight) {
        done = 1;
      }
    }
    else if (effect == 1) {
      outer.clip.right = (outer.clip.right - expInc >= 0) ? (outer.clip.right - expInc) : 0;
      if (outer.clip.right == 0) {
        done = 1;
      }
    }
    else if (effect == 2) {
      outer.clip.bottom = (outer.clip.bottom - expInc >= 0) ? (outer.clip.bottom - expInc) : 0;
      if (outer.clip.bottom == 0) {
        done = 1;
      }
    }
    else if (effect == 3) {
      outer.clip.left = (outer.clip.left + expInc <= bannerWidth) ? (outer.clip.left + expInc) : bannerWidth;
      if (outer.clip.left == bannerWidth) {
        done = 1;
      }
    }
    else {
      outer.clip.top = (outer.clip.top + verInc <= vert) ? (outer.clip.top + verInc) : vert;
      outer.clip.right = (outer.clip.right - horInc >= horz) ? (outer.clip.right - horInc) : horz;
      outer.clip.bottom = (outer.clip.bottom - verInc >= vert) ? (outer.clip.bottom - verInc) : vert;
      outer.clip.left = (outer.clip.left + horInc <= horz) ? (outer.clip.left + horInc) : horz;
      if ((outer.clip.top == bannerHeight) && (outer.clip.right == 0) && (outer.clip.bottom == 0) && (outer.clip.left == bannerWidth)) {
        done = 1;
      }
    }
    if (done == 1) {
      clearInterval(contractClip);
      outer.visibility = "hide";
      expand=0;
      done = 0;
    }
  } else {
    if (effect == 0) {
      itop = (itop + verInc <= bannerHeight) ? parseInt(itop + verInc) : bannerHeight;
      if (itop == bannerHeight) {
        done = 1;
      }
    }
    else if (effect == 1) {
      right = (right - expInc >= 0) ? parseInt(right - expInc) : 0;
      if (right == 0) {
        done = 1;
      }
    }
    else if (effect == 2) {
      bottom = (bottom - expInc >= 0) ? parseInt(bottom - expInc) : 0;
      if (bottom == 0) {
        done = 1;
      }
    }
    else if (effect == 3) {
      left = (left + expInc <= bannerWidth) ? parseInt(left + expInc) : bannerWidth;
      if (left == bannerWidth) {
        done = 1;
      }
    }
    else {
      itop = (itop + verInc <= bannerHeight) ? parseInt(itop + verInc) : bannerHeight;
      right = (right - expInc >= 0) ? parseInt(right - expInc) : 0;
      bottom = (bottom - expInc >= 0) ? parseInt(bottom - expInc) : 0;
      left = (left + expInc <= bannerWidth) ? parseInt(left + expInc) : bannerWidth;
      if ((itop == bannerHeight) && (right == 0) && (bottom == 0) && (left == bannerWidth)) {
        done = 1;
      }
    }
    outer.style.clip="rect("+itop+" "+right+" "+bottom+" "+left+")";
    if (done == 1) {
      clearInterval(contractClip);
      outer.style.visibility="hidden";
      expand=0;
      done=0;
    }
  }
}
function moveUp(speed) {
  if (NS4) {
    if (message.top + message.document.height > scrollHeight) {
      message.top -= speed;
    }
  } else {
    if ((message.style.pixelTop) + message.offsetHeight > scrollHeight) {
      message.style.pixelTop -= speed;
    }
  }
}
function moveDown(speed) {
  if (NS4) {
    if (message.top < 0) {
      message.top += speed;
    }
  } else {
    if ((message.style.pixelTop) < 0) {
      message.style.pixelTop += speed;
    }
  }
}
