/*
   ### TODO & improvements

   functionality:
     + adaption of basic functions for NS4
       + setInnerHTML()
     + recalculation must follow a change of timer intervall
     + documentation

   tests:
     + NS 6/7
     + Opera
     + NS4
     + Mac

   improvements:
     + fill all attributes like background-color, -image, etc.
     + definition of a starting and ending function of an action
*/
// =============================================================================
// BROWSER CHECK (dynAPI)
// =============================================================================

function Browser() {
    var b = navigator.appName;
    if (b.indexOf('Netscape') != -1) this.b = "ns";
    else if ((b == "Opera") || (navigator.userAgent.indexOf("Opera") > 0)) this.b = "opera";
    else if (b == "Microsoft Internet Explorer") this.b = "ie";
    if (!b) alert('Unidentified browser.\nThis browser is not supported,');
    this.version = navigator.appVersion;
    this.v = parseInt(this.version);
    this.ns = (this.b == "ns" && this.v >= 4);
    this.ns4 = (this.b == "ns" && this.v == 4);
    this.ns6 = (this.b == "ns" && this.v == 5);
    this.ie = (this.b == "ie" && this.v >= 4);
    this.ie4 = (this.version.indexOf('MSIE 4') > 0);
    this.ie5 = (this.version.indexOf('MSIE 5') > 0);
    this.ie55 = (this.version.indexOf('MSIE 5.5') > 0);
    this.ie6 = (this.version.indexOf('MSIE 6.0') > 0);
    this.opera = (this.b == "opera");
    this.dom = (document.createElement && document.appendChild && document.getElementsByTagName) ? true : false;
    this.def = (this.ie || this.dom);
    var ua = navigator.userAgent.toLowerCase();
    if (ua.indexOf("win") > -1) this.platform = "win32";
    else if (ua.indexOf("mac") > -1) this.platform = "mac";
    else this.platform = "other";
}
is = new Browser();

// =============================================================================
// LCWINDOW
// =============================================================================

function LCWindow_getWidth() {
  if (window.innerWidth) {
    return(window.innerWidth);
  } else if (window.document.body && window.document.body.clientWidth) {
    return(window.document.body.clientWidth);
  } else {
    return(800);
  }
}

function LCWindow_getHeight() {
  if (window.innerHeight) {
    return(window.innerHeight);
  } else if (window.document.body && window.document.body.clientHeight) {
    return(window.document.body.clientHeight);
  } else {
    return(600);
  }
}

function LCWindow_getCenterX() {
  return(this.getWidth() / 2);
}

function LCWindow_getCenterY() {
  return(this.getHeight() / 2);
}

function LCWindow_getPageXOffset() {
  return(is.ns ? window.pageXOffset : window.document.body.scrollLeft);
}

function LCWindow_getPageYOffset() {
  return(is.ns ? window.pageYOffset : window.document.body.scrollTop);
}

function LCWindow() {}
LCWindow.prototype.getWidth       = LCWindow_getWidth;
LCWindow.prototype.getHeight      = LCWindow_getHeight;
LCWindow.prototype.getCenterX     = LCWindow_getCenterX;
LCWindow.prototype.getCenterY     = LCWindow_getCenterY;
LCWindow.prototype.getPageXOffset = LCWindow_getPageXOffset;
LCWindow.prototype.getPageYOffset = LCWindow_getPageYOffset;

// =============================================================================
// LCIMAGE
// =============================================================================

var LCImage_Num = 0;

function LCImage_getObjectNN4(objDocument, strID)
{
    var objLayers  = objDocument.layers;
  var iNumLayers = objLayers.length;
    for (var i = 0; (i < iNumLayers); i++) {
      var objImages  = objLayers[i].document.images;
    var iNumImages = objImages.length;
      for (var j = 0; (j < iNumImages); j++) {
      if (objImages[j].name == strID) {
        return(objImages[j]);
      }
    }
    if (objLayers[i].layers.length > 0) {
      var tmp = LCImage_getObjectNN4(objLayers[i], strID);
      if (tmp) { return(tmp); }
    }
  }
  return(null);
}

function LCImage_getObject(strID) {
  if (arguments.length == 0) { strID = this.id; }
  if (document.getElementById) {
    return(document.getElementById(strID));
  } else if (document.all) {
    return(document.all[strID]);
  } else if (document.layers) {
    return(LCImage_getObjectNN4(document, strID));
  } else {
    return(null);
  }
}

function LCImage_setObject(strID) {
  var obj = this.getObject(strID);
  if (obj) {
    this.obj    = obj;
    this.css    = is.ns4 ? this.obj : this.obj.style;
    this.id     = is.ns4 ? this.obj.id : this.obj.name;
    this.src    = this.obj.src;
    this.width  = this.obj.width;
    this.height = this.obj.height;
    this.alt    = this.obj.alt;
    this.border = this.obj.border;
    this.linkUrl = this.obj.linkUrl;
    this.linkTarget = this.obj.linkTarget;
    this.eventOnMouseOver = this.obj.eventOnMouseOver;
    this.eventOnMouseOut = this.obj.eventOnMouseOut;
  }
}

function LCImage_getOuterHTML() {

  strRet = '';

  if(this.linkUrl.length > 0)
  {
      strRet += '<A HREF="' + this.linkUrl + '"';
      if(this.linkTarget.length > 0)
          strRet += ' TARGET="' + this.linkTarget + '"';
      strRet += '>';
  }

  strRet = strRet + '<IMG '
    + 'ID="' + this.id + '" '
    + 'NAME="' + this.id + '" '
    + 'SRC="' + this.src + '" '
    + ((this.width > 0) ? ('WIDTH="' + this.width + '" ') : '')
    + ((this.height > 0) ? ('HEIGHT="' + this.height + '" ') : '')
    + 'ALT="' + this.alt + '" '
    + 'BORDER="' + this.border + '" '
    + 'STYLE="filter:Alpha(enabled=0); -moz-opacity:1.0;" ';

    if(this.eventOnMouseOver.length > 0)
        strRet += 'onMouseover="' + this.eventOnMouseOver + '" ';

    if(this.eventOnMouseOut.length > 0)
        strRet += 'onMouseout="' + this.eventOnMouseOut + '"';

    strRet += '>';


    if(this.linkUrl.length > 0)
        strRet += '</A>';

    return strRet;
}

function LCImage_create() {
  document.write(this.getOuterHTML());
  this.obj = this.getObject(this.id);
  this.css = this.obj ? (is.ns4 ? this.obj : this.obj.style) : null;
}

function LCImage_addFilter(strFilter, bAddFilter) {
  strFilter  = strFilter  ? strFilter  : '';
  bAddFilter = bAddFilter ? bAddFilter : false;
  if (strFilter.length > 0) {
    if (bAddFilter || (this.css.filter.indexOf(strFilter) == -1)) {
      this.css.filter += ' progid:' + strFilter + '()';
    }
    if (this.obj.filters[strFilter]) {
      return(this.obj.filters[strFilter]);
    }
  }
  return(null);
}

function LCImage_glow(iStrength, iColor) {
  if (this.obj.filters) {
    objGlow = this.addFilter('DXImageTransform.Microsoft.Glow');
    if (objGlow) {
      objGlow.strength = iStrength;
      objGlow.color    = iColor;
      objGlow.enabled  = (iStrength > 0) ? 1 : 0;
    }
  }
}

function LCImage_setSrc(strSrc)     { this.obj.src    = strSrc;  }
function LCImage_setWidth(iWidth)   { this.obj.width  = iWidth;  }
function LCImage_setHeight(iHeight) { this.obj.height = iHeight; }
function LCImage_setAlt(strAlt)     { this.obj.alt    = strAlt;  }
function LCImage_setBorder(iBorder) { this.obj.border = iBorder; }

function LCImage_getSrc()    { return(this.obj.src);    }
function LCImage_getWidth()  { return(this.obj.width);  }
function LCImage_getHeight() { return(this.obj.height); }
function LCImage_getAlt()    { return(this.obj.alt);    }
function LCImage_getBorder() { return(this.obj.border); }

function LCImage_resize(iWidth, iHeight) { this.setWidth(iWidth); this.setHeight(iHeight); }

function LCImage_addFilter(strFilter, bAddFilter) {
  strFilter  = strFilter  ? strFilter  : '';
  bAddFilter = bAddFilter ? bAddFilter : false;
  if (strFilter.length > 0) {
    if (bAddFilter || (this.css.filter.indexOf(strFilter) == -1)) {
      this.css.filter += ' progid:' + strFilter + '()';
    }
    if (this.obj.filters[strFilter]) {
      return(this.obj.filters[strFilter]);
    }
  }
  return(null);
}

function LCImage_glow(iStrength, iColor) {
  if (this.obj.filters) {
    objGlow = this.addFilter('DXImageTransform.Microsoft.Glow');
    if (objGlow) {
      objGlow.strength = iStrength;
      objGlow.color    = iColor;
      objGlow.enabled  = (iStrength > 0) ? 1 : 0;
    }
  }
}

function LCImage(strID, strSrc, iWidth, iHeight, strAlt, iBorder, linkUrl, linkTarget, eventOnMouseOver,
eventOnMouseOut) {
  if (arguments.length > 1) {
    LCImage_Num++;
    this.id     = strID ? strID : ('img' + LCImage_Num);
    this.src    = strSrc ? strSrc : '';
    this.width  = iWidth ? iWidth : 0;
    this.height = iHeight ? iHeight : 0;
    this.alt    = strAlt ? strAlt : '';
    this.border = iBorder ? iBorder : 0;
    this.obj    = null;
    this.linkUrl = linkUrl ? linkUrl : '';
    this.linkTarget = linkTarget ? linkTarget : '';
    this.eventOnMouseOver = eventOnMouseOver ? eventOnMouseOver : '';
    this.eventOnMouseOut = eventOnMouseOut ? eventOnMouseOut : '';
  } else {
    this.setObject(strID);
  }
}
LCImage.prototype.getObject    = LCImage_getObject;
LCImage.prototype.setObject    = LCImage_setObject;
LCImage.prototype.getOuterHTML = LCImage_getOuterHTML;
LCImage.prototype.create       = LCImage_create;
LCImage.prototype.setSrc       = LCImage_setSrc;
LCImage.prototype.setWidth     = LCImage_setWidth;
LCImage.prototype.setHeight    = LCImage_setHeight;
LCImage.prototype.setAlt       = LCImage_setAlt;
LCImage.prototype.setBorder    = LCImage_setBorder;
LCImage.prototype.getSrc       = LCImage_getSrc;
LCImage.prototype.getWidth     = LCImage_getWidth;
LCImage.prototype.getHeight    = LCImage_getHeight;
LCImage.prototype.getAlt       = LCImage_getAlt;
LCImage.prototype.getBorder    = LCImage_getBorder;
LCImage.prototype.resize       = LCImage_resize;
LCImage.prototype.glow         = LCImage_glow;
LCImage.prototype.addFilter    = LCImage_addFilter;


// =============================================================================
// LCLAYER
// =============================================================================

var LCLayer_Num = 0;
var LCLayer_FFList = new Array();

function LCLayer_getObjectNN4(objDocument, strID)
{
    var objLayers  = objDocument.layers;
  var iNumLayers = objLayers.length;
    for (var i = 0; (i < iNumLayers); i++) {
    if (objLayers[i].id == strID) {
      return(objLayers[i]);
    } else if (objLayers[i].layers.length > 0) {
      var tmp = LCLayer_getObjectNN4(objLayers[i], strID);
      if (tmp) { return(tmp); }
    }
  }
  return(null);
}

function LCLayer_getObject(strID) {
  if (arguments.length == 0) { strID = this.id; }
  if (document.getElementById) {
    return(document.getElementById(strID));
  } else if (document.all) {
    return(document.all[strID]);
  } else if (document.layers) {
    return(LCLayer_getObjectNN4(document, strID));
  } else {
    return(null);
  }
}

function LCLayer_setObject(strID) {
  var obj = this.getObject(strID);
  if (obj) {
    this.obj = obj;
    if (is.ns4) {
      this.css = this.obj;
          this.doc = this.obj.document;
    } else {
      this.css = this.obj.style;
          this.doc = this.obj.document;
    }
    this.id     = this.obj.id;
    this.x      = this.getX();
    this.y      = this.getY();
    this.width  = this.css.width;
    this.height = this.css.height;
    this.vis    = this.isVisible();
    this.z      = this.css.zIndex;
    this.children = new Array();
  }
}

function LCLayer_getX() { return(parseInt(this.css.left, 10)); }
function LCLayer_getY() { return(parseInt(this.css.top, 10));  }

function LCLayer_setX(iX) { return(this.moveTo(iX, 0)); }
function LCLayer_setY(iY) { return(this.moveTo(0, iY)); }

function LCLayer_getWidth()  { return(this.css.width);  }
function LCLayer_getHeight() { return(this.css.height); }

function LCLayer_setWidth(iWidth)   { this.css.width  = iWidth;  }
function LCLayer_setHeight(iHeight) { this.css.height = iHeight; }

function LCLayer_resize(iWidth, iHeight) { this.setWidth(iWidth); this.setHeight(iHeight); }

function LCLayer_setBgColor(strBgColor) {
  this.bgColor = strBgColor ? strBgColor : '';
  if (this.css) {
    if (is.def) {
      this.css.backgroundColor = this.bgColor;
    } else if (is.ns4) {
      this.css.bgColor = this.bgColor;
    }
  }
}

function LCLayer_setClipping(iLeft, iTop, iWidth, iHeight) {
  var iClipLeft   = 0;
  var iClipTop    = 0;
  var iClipWidth  = this.width;
  var iClipHeight = this.height;
  if (arguments.length == 2) {
    iClipLeft   = 0;
    iClipTop    = 0;
    iClipWidth  = iLeft
    iClipHeight = iTop
  } else if (arguments.length == 4) {
    iClipLeft   = iLeft;
    iClipTop    = iTop;
    iClipWidth  = iWidth;
    iClipHeight = iHeight;
  }
  if (this.css) {
    if (is.def) {
      this.css.clip = 'rect(' + iClipLeft + 'px,' + (iClipWidth + (is.ns ? (2 * this.borderWidth) : 0)) + 'px,' + (iClipHeight + (is.ns ? (2 * this.borderWidth) : 0)) + 'px,' + iClipTop + 'px)';
    } else if (is.ns4) {
      this.css.clip.width  = iClipWidth  + (is.ns ? (2 * this.borderWidth) : 0);
      this.css.clip.height = iClipHeight + (is.ns ? (2 * this.borderWidth) : 0);
    }
  }
}

function LCLayer_setBorder(iBorderWidth, strBorderColor, strBorderStyle) {
  this.borderWidth = iBorderWidth ? iBorderWidth : 0;
  this.borderColor = strBorderColor ? strBorderColor : 'black';
  this.borderStyle = strBorderStyle ? strBorderStyle : 'solid';
  if (this.css) {
    if (is.def) {
      this.css.border = this.borderWidth + 'px ' + this.borderColor + ' ' + this.borderStyle;
      this.setClipping();
    } else if (is.ns4) {
      // ## TODO set border for NS4???
      this.setClipping();
    }
  }
}

// ### TODO show/hide all children
function LCLayer_show() { this.css.visibility = LCLayer_getVisibilityToken(true);  }
function LCLayer_hide() { this.css.visibility = LCLayer_getVisibilityToken(false); }
function LCLayer_isVisible() { return((this.css.visibility != 'hide') && (this.css.visibility != 'hidden')); }
function LCLayer_getVisibilityToken(bVisible) { return(is.ns4 ? (bVisible ? "show" : "hide") : (bVisible ? "visible" : "hidden")); }

function LCLayer_moveTo(iX, iY)   { this.css.left = iX; this.css.top = iY; }
function LCLayer_moveBy(iDX, iDY) { this.moveTo(this.getX() + iDX, this.getY() + iDY); }

function LCLayer_getOpacity() {
  if (!is.ns4) {
    if (this.obj.filters) { return(100 - this.obj.filters.Alpha.opacity); }
    else if (this.css.MozOpacity) { return(1 - this.css.MozOpacity / 100); }
  }
}

function LCLayer_setOpacity(iPercent) {
  if (!is.ns4) {
    if (this.obj.filters) {
      objAlpha = this.obj.filters.alpha;
      if (objAlpha) {
        objAlpha.opacity = (100 - iPercent);
        objAlpha.enabled = ((100 - iPercent) >= 0) ? 1 : 0;
      }
    } else {
      // ### TODO has MozOpacity???
      this.css.MozOpacity = (1 - (iPercent / 100));
    }
  }
}

function LCLayer_addFilter(strFilter, bAddFilter) {
  strFilter  = strFilter  ? strFilter  : '';
  bAddFilter = bAddFilter ? bAddFilter : false;
  if (strFilter.length > 0) {
    if (bAddFilter || (this.css.filter.indexOf(strFilter) == -1)) {
      this.css.filter += ' progid:' + strFilter + '()';
    }
    if (this.obj.filters[strFilter]) {
      return(this.obj.filters[strFilter]);
    }
  }
  return(null);
}

function LCLayer_glow(iStrength, iColor) {
  if (this.obj.filters) {
    objGlow = this.addFilter('DXImageTransform.Microsoft.Glow');
    if (objGlow) {
      objGlow.strength = iStrength;
      objGlow.color    = iColor;
      objGlow.enabled  = (iStrength > 0) ? 1 : 0;
    }
  }
}

function LCLayer_motionblur(iStrength, iDirection, bAdd) {
    if (this.obj.filters) {
        objMotionblur = this.addFilter('DXImageTransform.Microsoft.MotionBlur');
        if(objMotionblur) {
            objMotionblur.strength = iStrength;
            objMotionblur.add = bAdd;
            objMotionblur.direction = iDirection;
            objMotionblur.enabled = (iStrength > 0) ? 1 : 0;
        }
    }
}

function LCLayer_blur(iPixelRadius, bMakeShadow, fShadowOpacity) {
    if (this.obj.filters) {
        objBlur = this.addFilter('DXImageTransform.Microsoft.Blur');
        if(objBlur) {
            objBlur.pixelRadius = iPixelRadius;
            objBlur.makeShadow = bMakeShadow;
            objBlur.shadowOpacity = fShadowOpacity;
            objBlur.enabled = (iPixelRadius > 0) ? 1 : 0;
        }
    }
}

function LCLayer_pixelate(iDuration, iMaxSquare) {
  if (this.obj.filters) {
    objPixelate = this.addFilter('DXImageTransform.Microsoft.Pixelate');
    if (objPixelate) {
      objPixelate.duration  = iDuration;
      objPixelate.maxSquare = iMaxSquare;
      objPixelate.enabled   = 1;
      objPixelate.Apply();
      objPixelate.Play();
    }
  }
}

function LCLayer_FloatingFix(iEdge, iStartX, iStartY, iSpeed, iIntervall) {
  this.ff_id        = LCLayer_FFList.length;
  this.ff_edge      = iEdge ? iEdge : 5;
  this.ff_startX    = iStartX ? iStartX : this.getX();
  this.ff_startY    = iStartY ? iStartY : this.getY();
  this.ff_speed     = iSpeed ? iSpeed : 8;
  this.ff_intervall = iIntervall ? iIntervall : 10; // # TODO 10;

  this.ff_window    = new LCWindow();
  this.ff_currX     = this.ff_startX;
  this.ff_currY     = this.ff_startY;

  LCLayer_FFList[this.ff_id] = this;

  switch (this.ff_edge) {
    case 1 : // left
      this.moveTo(this.ff_currX, this.ff_currY);
      this.ff_execute = function () {
        this.ff_currX += (this.ff_window.getPageXOffset() + this.ff_startX - this.ff_currX) / this.ff_speed;
        this.moveTo(this.ff_currX, this.ff_currY);
        setTimeout('LCLayer_FFList[' + this.ff_id + '].ff_execute()', this.ff_intervall);
      }
      break;
    case 2 : // top
      this.moveTo(this.ff_currX, this.ff_currY);
      this.ff_execute = function () {
        this.ff_currY += (this.ff_window.getPageYOffset() + this.ff_startY - this.ff_currY) / this.ff_speed;
        this.moveTo(this.ff_currX, this.ff_currY);
        setTimeout('LCLayer_FFList[' + this.ff_id + '].ff_execute()', this.ff_intervall);
      }
      break;
    case 3 : // right
      this.ff_currX = this.ff_window.getPageXOffset() + this.ff_window.getWidth() - this.ff_startX;
      this.moveTo(this.ff_currX, this.ff_currY);
      this.ff_execute = function () {
        this.ff_currX += (this.ff_window.getPageXOffset() + this.ff_window.getWidth() - this.ff_startX - this.ff_currX) / this.ff_speed;
        this.moveTo(this.ff_currX, this.ff_currY);
        setTimeout('LCLayer_FFList[' + this.ff_id + '].ff_execute()', this.ff_intervall);
      }
      break;
    case 4 : // bottom
      this.ff_currY = this.ff_window.getPageYOffset() + this.ff_window.getHeight() - this.ff_startY;
      this.moveTo(this.ff_currX, this.ff_currY);
      this.ff_execute = function () {
        this.ff_currY += (this.ff_window.getPageYOffset() + this.ff_window.getHeight() - this.ff_startY - this.ff_currY) / this.ff_speed;
        this.moveTo(this.ff_currX, this.ff_currY);
        setTimeout('LCLayer_FFList[' + this.ff_id + '].ff_execute()', this.ff_intervall);
      }
      break;
    case 5 : // left-top
      this.moveTo(this.ff_currX, this.ff_currY);
      this.ff_execute = function () {
        this.ff_currX += (this.ff_window.getPageXOffset() + this.ff_startX - this.ff_currX) / this.ff_speed;
        this.ff_currY += (this.ff_window.getPageYOffset() + this.ff_startY - this.ff_currY) / this.ff_speed;
        this.moveTo(this.ff_currX, this.ff_currY);
        setTimeout('LCLayer_FFList[' + this.ff_id + '].ff_execute()', this.ff_intervall);
      }
      break;
    case 6 : // right-top
      this.ff_currX = this.ff_window.getPageXOffset() + this.ff_window.getWidth() - this.ff_startX;
      this.moveTo(this.ff_currX, this.ff_currY);
      this.ff_execute = function () {
        this.ff_currX += (this.ff_window.getPageXOffset() + this.ff_window.getWidth() - this.ff_startX - this.ff_currX) / this.ff_speed;
        this.ff_currY += (this.ff_window.getPageYOffset() + this.ff_startY - this.ff_currY) / this.ff_speed;
        this.moveTo(this.ff_currX, this.ff_currY);
        setTimeout('LCLayer_FFList[' + this.ff_id + '].ff_execute()', this.ff_intervall);
      }
      break;
    case 7 : // right-bottom
      this.ff_currX = this.ff_window.getPageXOffset() + this.ff_window.getWidth() - this.ff_startX;
      this.ff_currY = this.ff_window.getPageYOffset() + this.ff_window.getHeight() - this.ff_startY;
      this.moveTo(this.ff_currX, this.ff_currY);
      this.ff_execute = function () {
        this.ff_currX += (this.ff_window.getPageXOffset() + this.ff_window.getWidth() - this.ff_startX - this.ff_currX) / this.ff_speed;
        this.ff_currY += (this.ff_window.getPageYOffset() + this.ff_window.getHeight() - this.ff_startY - this.ff_currY) / this.ff_speed;
        this.moveTo(this.ff_currX, this.ff_currY);
        setTimeout('LCLayer_FFList[' + this.ff_id + '].ff_execute()', this.ff_intervall);
      }
      break;
    case 8 : // left-bottom
      this.ff_currY = this.ff_window.getPageYOffset() + this.ff_window.getHeight() - this.ff_startY;
      this.moveTo(this.ff_currX, this.ff_currY);
      this.ff_execute = function () {
        this.ff_currX += (this.ff_window.getPageXOffset() + this.ff_startX - this.ff_currX) / this.ff_speed;
        this.ff_currY += (this.ff_window.getPageYOffset() + this.ff_window.getHeight() - this.ff_startY - this.ff_currY) / this.ff_speed;
        this.moveTo(this.ff_currX, this.ff_currY);
        setTimeout('LCLayer_FFList[' + this.ff_id + '].ff_execute()', this.ff_intervall);
      }
      break;
    default:
      break;
  }
  this.ff_execute();
}

function LCLayer_setInnerHTML(strHTML) {
  if (is.ns4) {
        this.doc.open();
        this.doc.write(unescape(strHTML));
        this.doc.close();
  } else if (is.ie) {
        this.obj.innerHTML = unescape(strHTML);
  } else if (document.getElementById) {
    rng = document.createRange();
    rng.setStartBefore(this.obj);
    htmlFrag = rng.createContextualFragment(unescape(strHTML));
    while (this.obj.hasChildNodes()) { this.obj.removeChild(this.obj.lastChild); }
    this.obj.appendChild(htmlFrag);
  }
}

function LCLayer_getStartTag() {
  if (is.def) {
    return(
        '<DIV '
      + 'ID="' + this.id + '" '
      + 'NAME="' + this.id + '" '
      + 'STYLE="'
      + 'position:absolute; '
      + 'left:' + this.x + 'px; '
      + 'top:' + this.y + 'px; '
      + ((this.width > 0) ? ('width:' + this.width + 'px; ') : (''))
      + ((this.height > 0) ? ('height:' + this.height + 'px; ') : (''))
      + ((this.clip) ? ('clip:rect(0px,' + (this.width + (is.ns ? (2 * this.borderWidth) : 0)) + 'px,' + (this.height + (is.ns ? (2 * this.borderWidth) : 0)) + 'px,0px); ') : (''))
      + ((this.borderWidth) ? ('border:' + this.borderWidth + 'px ' + this.borderColor + ' ' + this.borderStyle + '; ') : (''))
      + ((this.bgColor) ? ('background:' + this.bgColor + '; ') : (''))
      + 'z-index:' + this.z + '; '
      + 'visibility:' + LCLayer_getVisibilityToken(this.vis) + '; '
      + 'filter:Alpha(enabled=0); -moz-opacity:1.0;'
      + '"'
      + '>'
    );
  } else if (is.ns4) {
    return(
        '<LAYER '
      + 'ID="' + this.id + '" '
      + 'NAME="' + this.id + '" '
      + 'PAGEX="' + this.x + '" '
      + 'PAGEY="' + this.y + '" '
      + ((this.width > 0) ? ('WIDTH="' + this.width + '" ') : (''))
      + ((this.height > 0) ? ('HEIGHT="' + this.height + '" ') : (''))
      + ((this.clip) ? ('CLIP="' + this.width + ',' + this.height + '" ') : (''))
      + ((this.bgColor) ? ('BGCOLOR="' + this.bgColor + '" ') : (''))
      + 'Z-INDEX="' + this.z + '" '
      + 'VISIBILITY="' + LCLayer_getVisibilityToken(this.vis) + '" '
      + '>'
    );
  } else {
    return('');
  }
}

function LCLayer_getEndTag() {
  if (is.def) {
    return('</DIV>');
  } else if (is.ns4) {
    return('</LAYER>');
  } else {
    return('');
  }
}

function LCLayer_getOuterHTML() { return(this.getStartTag() + unescape(this.cont) + this.getEndTag()); }

function LCLayer_addChild(objLCLayer) { this.children[this.children.length] = objLCLayer; }

function LCLayer_create(iXOffset, iYOffset) {
  iXOffset = (iXOffset) ? iXOffset : 0;
  iYOffset = (iYOffset) ? iYOffset : 0;

  if (is.def) {
    document.write(this.getStartTag());
    for (var i = 0; (i < this.children.length); i++) {
      this.children[i].create(this.x, this.y);
    }
    document.write(this.cont);
    document.write(this.getEndTag());
    this.obj = this.getObject(this.id);
    if (this.obj) {
      this.css = this.obj.style;
          this.doc = this.obj.document;
      return;
    }
  } else if (is.ns4) {
    this.x += iXOffset;
    this.y += iYOffset;
    document.write(this.getStartTag());
    for (var i = 0; (i < this.children.length); i++) {
      this.children[i].create(this.x, this.y);
    }
    document.write(this.cont);
    document.write(this.getEndTag());
    this.obj = this.getObject(this.id);
    if (this.obj) {
      this.css = this.obj;
          this.doc = this.obj.document;
      return;
    }
  }
  this.obj = null;
  this.css = null;
  this.doc = null;
}

function LCLayer(strID, iPosX, iPosY, strContent, iWidth, iHeight, strBgColor, bVisible, iBorderWidth, strBorderColor, strBorderStyle, iIndexZ) {
  if (arguments.length != 1) {
    LCLayer_Num++;
    this.id          = strID ? strID : ('layer' + LCLayer_Num);
    this.x           = iPosX ? iPosX : 0;
    this.y           = iPosY ? iPosY : 0;
    this.cont        = strContent ? strContent : '';
    this.width       = iWidth ? iWidth : 0;
    this.height      = iHeight ? iHeight : 0;
    this.bgColor     = strBgColor ? strBgColor : '';
    this.clip        = false;
    this.vis         = (arguments.length > 6) ? bVisible : true;
    this.borderWidth = iBorderWidth ? iBorderWidth : 0;
    this.borderColor = strBorderColor ? strBorderColor : 'black';
    this.borderStyle = strBorderStyle ? strBorderStyle : 'solid';
    this.z           = iIndexZ ? iIndexZ : LCLayer_Num;
    this.children    = new Array();
  } else {
    this.setObject(strID);
  }
}
LCLayer.prototype.setObject    = LCLayer_setObject;
LCLayer.prototype.getObject    = LCLayer_getObject;
LCLayer.prototype.getX         = LCLayer_getX;
LCLayer.prototype.getY         = LCLayer_getY;
LCLayer.prototype.setX         = LCLayer_setX;
LCLayer.prototype.setY         = LCLayer_setY;
LCLayer.prototype.setWidth     = LCLayer_setWidth;
LCLayer.prototype.setHeight    = LCLayer_setHeight;
LCLayer.prototype.getWidth     = LCLayer_getWidth;
LCLayer.prototype.getHeight    = LCLayer_getHeight;
LCLayer.prototype.resize       = LCLayer_resize;
LCLayer.prototype.setBgColor   = LCLayer_setBgColor;
LCLayer.prototype.setClipping  = LCLayer_setClipping;
LCLayer.prototype.setBorder    = LCLayer_setBorder;
LCLayer.prototype.show         = LCLayer_show;
LCLayer.prototype.hide         = LCLayer_hide;
LCLayer.prototype.moveTo       = LCLayer_moveTo;
LCLayer.prototype.moveBy       = LCLayer_moveBy;
LCLayer.prototype.getOpacity   = LCLayer_getOpacity;
LCLayer.prototype.setOpacity   = LCLayer_setOpacity;
LCLayer.prototype.setInnerHTML = LCLayer_setInnerHTML;
LCLayer.prototype.glow         = LCLayer_glow;
LCLayer.prototype.motionblur     = LCLayer_motionblur;
LCLayer.prototype.blur                 = LCLayer_blur;
LCLayer.prototype.addFilter    = LCLayer_addFilter;
LCLayer.prototype.pixelate     = LCLayer_pixelate;
LCLayer.prototype.floatingFix  = LCLayer_FloatingFix;
LCLayer.prototype.getStartTag  = LCLayer_getStartTag;
LCLayer.prototype.getEndTag    = LCLayer_getEndTag;
LCLayer.prototype.getOuterHTML = LCLayer_getOuterHTML;
LCLayer.prototype.addChild     = LCLayer_addChild;
LCLayer.prototype.create       = LCLayer_create;


// =============================================================================
// LCACTION
// =============================================================================

var LCAction_Num = 0;

function LCAction_moveFromToInit() {
  this.startX = arguments[0];
  this.startY = arguments[1];
  this.endX   = arguments[2];
  this.endY   = arguments[3];
  this.deltaX = (this.endX - this.startX);
  this.deltaY = (this.endY - this.startY);
  if ((this.deltaX == 0) || (Math.abs(this.deltaX) <= Math.abs(this.deltaY))) {
    this.dTick = this.sumTicks / ((Math.abs(this.deltaY) == 0) ? 1 : Math.abs(this.deltaY));
  } else if ((this.deltaY == 0) || (Math.abs(this.deltaY) <= Math.abs(this.deltaX))) {
    this.dTick = this.sumTicks / ((Math.abs(this.deltaX) == 0) ? 1 : Math.abs(this.deltaX));
  }
  this.dTick  = (this.dTick < 1) ? 1 : Math.floor(this.dTick);
  this.dTickX = this.deltaX / this.sumTicks;
  this.dTickY = this.deltaY / this.sumTicks;
}

function LCAction_moveFromTo(iTick, iLoop) {
  if ((iTick >= this.nextTick) && (iTick <= this.endTick)) {
    this.layer.moveTo(this.startX + this.dTickX * (iTick - this.startTick), this.startY + this.dTickY * (iTick - this.startTick));
    this.nextTick = this.nextTick + this.dTick;
  }
}

function LCAction_moveToInit() {
  this.startX = this.layer.getX();
  this.startY = this.layer.getY();
  this.endX   = arguments[0];
  this.endY   = arguments[1];
  this.deltaX = (this.endX - this.startX);
  this.deltaY = (this.endY - this.startY);
  if ((this.deltaX == 0) || (Math.abs(this.deltaX) <= Math.abs(this.deltaY))) {
    this.dTick = this.sumTicks / ((Math.abs(this.deltaY) == 0) ? 1 : Math.abs(this.deltaY));
  } else if ((this.deltaY == 0) || (Math.abs(this.deltaY) <= Math.abs(this.deltaX))) {
    this.dTick = this.sumTicks / ((Math.abs(this.deltaX) == 0) ? 1 : Math.abs(this.deltaX));
  }
  this.dTick  = (this.dTick < 1) ? 1 : Math.floor(this.dTick);
  this.dTickX = this.deltaX / this.sumTicks;
  this.dTickY = this.deltaY / this.sumTicks;
}

function LCAction_moveTo(iTick, iLoop) {
  if (iTick == this.startTick) {
    if (iLoop == 1) {
      this.moveToInit(this.endX, this.endY);
    } else {
      this.moveFromToInit(this.startX, this.startY, this.endX, this.endY);
    }
  }
  this.moveFromTo(iTick, iLoop);
}

function LCAction_moveCircleInit() {
  this.radiusX    = arguments[0];
  this.radiusY    = arguments[1];
  this.startAngle = arguments[2];
  this.endAngle   = arguments[3];
  this.steps      = (this.endTick - this.startTick);
  this.deltaAngle = (this.endAngle - this.startAngle);
  this.stepAngle  = this.deltaAngle / this.steps;
  this.centerX = this.layer.getX() - this.radiusX * Math.sin(this.startAngle * Math.PI / 180);
  this.centerY = this.layer.getY() + this.radiusY * Math.cos(this.startAngle * Math.PI / 180);
  var angle = this.startAngle;
  this.coordsX = new Array();
  this.coordsY = new Array();
  for (i = this.startTick; (i <= this.endTick); i++) {
    angle = angle + this.stepAngle;
    this.coordsX[i] = this.radiusX * Math.sin(angle * Math.PI / 180);
    this.coordsY[i] = this.radiusY * Math.cos(angle * Math.PI / 180);
  }
}

function LCAction_moveCircle(iTick, iLoop) {
  if (iTick == this.startTick) {
    this.centerX = this.layer.getX() - this.radiusX * Math.sin(this.startAngle * Math.PI / 180);
    this.centerY = this.layer.getY() + this.radiusY * Math.cos(this.startAngle * Math.PI / 180);
  }
  if ((iTick >= this.startTick) && (iTick <= this.endTick)) {
    this.layer.moveTo(this.centerX + this.coordsX[iTick], this.centerY - this.coordsY[iTick], iLoop);
  }
}

function LCAction_resizeInit() {
  this.widthFrom   = arguments[0];
  this.heightFrom  = arguments[1];
  this.widthTo     = arguments[2];
  this.heightTo    = arguments[3];
  this.deltaWidth  = (this.widthTo - this.widthFrom);
  this.deltaHeight = (this.heightTo - this.heightFrom);
  if ((this.deltaWidth == 0) || (Math.abs(this.deltaWidth) <= Math.abs(this.deltaHeight))) {
    this.dTick = this.sumTicks / ((Math.abs(this.deltaHeight) == 0) ? 1 : Math.abs(this.deltaHeight));
  } else if ((this.deltaHeight == 0) || (Math.abs(this.deltaHeight) <= Math.abs(this.deltaWidth))) {
    this.dTick = this.sumTicks / ((Math.abs(this.deltaWidth) == 0) ? 1 : Math.abs(this.deltaWidth));
  }
  this.dTick = (this.dTick < 1) ? 1 : Math.floor(this.dTick);
  this.dTickWidth  = this.deltaWidth  / this.sumTicks;
  this.dTickHeight = this.deltaHeight / this.sumTicks;
}

function LCAction_resize(iTick, iLoop) {
  if ((iTick >= this.nextTick) && (iTick <= this.endTick)) {
    this.layer.resize(this.widthFrom + this.dTickWidth * (iTick - this.startTick), this.heightFrom + this.dTickHeight * (iTick - this.startTick));
    this.nextTick = this.nextTick + this.dTick;
  }
}

function LCAction_fadeInit() {
  this.start   = arguments[0];
  this.end     = arguments[1];
  this.delta   = (this.end - this.start);
  this.dTick   = this.sumTicks / Math.abs(this.delta);
  this.dTick   = (this.dTick < 1) ? 1 : Math.floor(this.dTick);
  this.tickFac = this.delta / this.sumTicks;
}

function LCAction_fade(iTick, iLoop) {
  if ((iTick >= this.nextTick) && (iTick <= this.endTick)) {
    this.layer.setOpacity(this.start + this.tickFac * (iTick - this.startTick));
    this.nextTick = this.nextTick + this.dTick;
  }
}

function LCAction_fadeInInit()          { this.fadeInit(100, 0); }
function LCAction_fadeIn(iTick, iLoop)  { this.fade(iTick, iLoop); }

function LCAction_fadeOutInit()         { this.fadeInit(0, 100); }
function LCAction_fadeOut(iTick, iLoop) { this.fade(iTick, iLoop); }

function LCAction_glowInit() {
  this.startStrength = arguments[0];
  this.endStrength   = arguments[1];
  this.color         = arguments[2];
  this.deltaStrength = (this.endStrength - this.startStrength);
  this.dTick         = this.sumTicks / Math.abs(this.deltaStrength);
  this.dTick         = (this.dTick < 1) ? 1 : Math.floor(this.dTick);
  this.tickFac       = this.deltaStrength / this.sumTicks;
}

function LCAction_glow(iTick, iLoop) {
  if ((iTick >= this.nextTick) && /* (iTick >= this.startTick) && */(iTick <= this.endTick)) {
    this.layer.glow((this.startStrength + this.tickFac * (iTick - this.startTick)), this.color);
    this.nextTick = this.nextTick + this.dTick;
  }
}

function LCAction_blurInit() {
    this.startPixelRadius = arguments[0];
    this.endPixelRadius = arguments[1];
    this.makeShadow = arguments[2];
    this.shadowOpacity = arguments[3];
    this.deltaPixelRadius = (this.endPixelRadius - this.startPixelRadius);
    this.dTick = this.sumTicks / Math.abs(this.deltaPixelRadius);
    this.dTick = (this.dTick < 1) ? 1 : Math.floor(this.dTick);
    this.tickFac = this.deltaPixelRadius / this.sumTicks;
}

function LCAction_blur(iTick, iLoop) {
    if ((iTick >= this.nextTick) && (iTick <= this.endTick)) {
        this.layer.blur((this.startPixelRadius + this.tickFac * (iTick - this.startTick)),
                    this.makeShadow, this.shadowOpacity);
        this.nextTick = this.nextTick + this.dTick;
    }
}

function LCAction_motionblurInit() {
    this.startStrength = arguments[0];
    this.endStrength = arguments[1];
    this.direction = arguments[2];
    this.add = arguments[3];
    this.deltaStrength = (this.endStrength - this.startStrength);
    this.dTick = this.sumTicks / Math.abs(this.deltaStrength);
    this.dTick = (this.dTick < 1) ? 1 : Math.floor(this.dTick);
    this.tickFac = this.deltaStrength / this.sumTicks;
}

function LCAction_motionblur(iTick, iLoop) {
    if ((iTick >= this.nextTick) && (iTick <= this.endTick)) {
        this.layer.motionblur((this.startStrength + this.tickFac * (iTick - this.startTick)),
                    this.direction, this.add);
        this.nextTick = this.nextTick + this.dTick;
    }
}

function LCAction_showInit() { }
function LCAction_show(iTick, iLoop) {
  if (iTick == this.nextTick) {
    this.layer.show();
  }
}

function LCAction_hideInit() { }
function LCAction_hide(iTick, iLoop) {
  if (iTick == this.nextTick) {
    this.layer.hide();
  }
}

function LCAction_setInnerHTMLInit() { this.cont = arguments[0]; }
function LCAction_setInnerHTML(iTick, iLoop) {
  if (iTick == this.nextTick) {
    this.layer.setInnerHTML(this.cont);
  }
}

function LCAction_action(iTick, iLoop) { this.actionFunc(iTick, iLoop); }

function LCAction(iStartTick, iEndTick, layerForAction, strAction) {
  this.id         = LCAction_Num++;
  this.startTick  = iStartTick;
  this.endTick    = iEndTick;
  this.nextTick   = this.startTick;
  this.sumTicks   = (this.endTick - this.startTick);
  this.layer      = layerForAction;
  if (strAction != 'callback') {

    this.actionName = strAction;
    this.actionFunc = eval('LCAction_' + strAction);

    this.obj = null;
    this.css = null;
    this.doc = null;

    this.init = 'this.' + strAction + 'Init(';
    for (i = 4; (i < arguments.length); i++) {
      this.init = this.init + ((typeof(arguments[i]) == 'string') ? '\'' : '') + arguments[i] + ((typeof(arguments[i]) == 'string') ? '\'' : '') + ((i < (arguments.length - 1)) ? ',' : '');
    }
    this.init = this.init + ')';
    eval(this.init);
  } else {
    this.actionName = argument[4];
    this.actionFunc = eval('LCAction_' + argument[4]);

    this.obj = null;
    this.css = null;
    this.doc = null;

    eval('LCAction.prototype.' + argument[4] + 'Init = LCAction_' + argument[4] + 'Init');
    eval('LCAction.prototype.' + argument[4] + ' = LCAction_' + argument[4]);
    this.init = 'this.' + strAction + 'Init(';
    for (i = 4; (i < arguments.length); i++) {
      this.init = this.init + ((typeof(arguments[i]) == 'string') ? '\'' : '') + arguments[i] + ((typeof(arguments[i]) == 'string') ? '\'' : '') + ((i < (arguments.length - 1)) ? ',' : '');
    }
    this.init = this.init + ')';
    eval(this.init);
  }
}
LCAction.prototype.moveFromToInit   = LCAction_moveFromToInit;
LCAction.prototype.moveFromTo       = LCAction_moveFromTo;
LCAction.prototype.moveToInit       = LCAction_moveToInit;
LCAction.prototype.moveTo           = LCAction_moveTo;
LCAction.prototype.moveCircleInit   = LCAction_moveCircleInit;
LCAction.prototype.moveCircle       = LCAction_moveCircle;
LCAction.prototype.resizeInit       = LCAction_resizeInit;
LCAction.prototype.resize           = LCAction_resize;
LCAction.prototype.fadeInit         = LCAction_fadeInit;
LCAction.prototype.fade             = LCAction_fade;
LCAction.prototype.fadeInInit       = LCAction_fadeInInit;
LCAction.prototype.fadeIn           = LCAction_fadeIn;
LCAction.prototype.fadeOutInit      = LCAction_fadeOutInit;
LCAction.prototype.fadeOut          = LCAction_fadeOut;
LCAction.prototype.glowInit         = LCAction_glowInit;
LCAction.prototype.glow             = LCAction_glow;
LCAction.prototype.motionblurInit   = LCAction_motionblurInit;
LCAction.prototype.motionblur                = LCAction_motionblur;
LCAction.prototype.blurInit                    = LCAction_blurInit;
LCAction.prototype.blur                            = LCAction_blur;
LCAction.prototype.setInnerHTMLInit = LCAction_setInnerHTMLInit;
LCAction.prototype.setInnerHTML     = LCAction_setInnerHTML;
LCAction.prototype.showInit         = LCAction_showInit;
LCAction.prototype.show             = LCAction_show;
LCAction.prototype.hideInit         = LCAction_hideInit;
LCAction.prototype.hide             = LCAction_hide;
LCAction.prototype.action           = LCAction_action;


// =============================================================================
// LCSEQUENCE
// =============================================================================

LCSequence_Num   = 0;
LCSequence_Timer = new Array();

function LCSequence_ticker() {

  for (i = 0; (i < this.numActions); i++) {
    this.actions[i].action(this.tick, this.loops);
  }

  this.tick++;
  if (this.tick > this.endTick) {
    this.loops++;
    if ((this.endLoop > 0) && (this.loops > this.endLoop)) {
      this.stop();
    } else {
      this.stop();
      this.play();
    }
  }
}

function LCSequence_addAction(actionNew) {
  if ((this.startTick == -1) || (this.startTick > actionNew.startTick)) { this.startTick = actionNew.startTick; }
  if ((this.endTick   == -1) || (this.endTick   < actionNew.endTick  )) { this.endTick   = actionNew.endTick;   }
  this.actions[this.actions.length] = actionNew;
  this.numActions = this.actions.length;
}

function LCSequence_play() {
  LCSequence_Timer[this.id] = this;
  LCSequence_Timer[this.id].ticker();
  this.timer = setInterval('LCSequence_Timer[' + this.id + '].ticker()', this.timerInt)
}

function LCSequence_stop() {
  clearInterval(this.timer);
  for (i = 0; (i < this.numActions); i++) {
    this.actions[i].nextTick = this.actions[i].startTick;
  }
  this.tick = 0;
}

function LCSequence_setTick(iTick) { this.tick = iTick; }

function LCSequence_setTickInt(iTickInt) { this.timerInt = iTickInt; }

function LCSequence_setLoops(iEndLoop) { this.endLoop = iEndLoop; }

function LCSequence() {
  this.id         = LCSequence_Num++;
  this.tick       = 0;
  this.startTick  = -1;
  this.endTick    = -1;
  this.loops      = 1;
  this.endLoop    = 1;
  this.actions    = new Array();
  this.numActions = 0;
  this.timer      = null;
  this.timerInt   = 10;
}
LCSequence.prototype.ticker     = LCSequence_ticker;
LCSequence.prototype.addAction  = LCSequence_addAction;
LCSequence.prototype.setLoops   = LCSequence_setLoops;
LCSequence.prototype.play       = LCSequence_play;
LCSequence.prototype.stop       = LCSequence_stop;
LCSequence.prototype.setTick    = LCSequence_setTick;
LCSequence.prototype.setTickInt = LCSequence_setTickInt;
LCSequence.prototype.setLoops   = LCSequence_setLoops;
