// V1.02 20051012 by hmd
//
// V1.01 overlay und Kompatibilität zu ns eingebaut
// V1.02 fixe Reihenfolge
//
// Defines by CMS
// DO NOT EDIT THE DECLARATIONS HERE!!!
// Override the following values in your htm-page!
//
var LCBanners = new Array();
var lcbaw = 5;

// position of banner images
var LCBPos = new Array();

//z-index of the first Banner Position
var LCBPosZIndexStart = 999;

//increment of the z-index for each banner position
var LCBPosZIndexIncrement = 0;

// width & height of images
var LCBWidth = 160;
var LCBHeight = 100;

//width & height of hoverimages
var LCBHoverWidth = 200;
var LCBHoverHeight = 120;

// width and style of optional border around images
// example: adds a red glow effect around images
//
// var LCBBorderWidth = 3;
// var LCBBorderStyle = " filter:Glow(color=#FF0000, strength=2);";
//
var LCBBorderWidth = 0;
var LCBBorderStyle = "";

// position of image description text
var LCBTxtPos = new Array();

//position of mouse over images
var LCBHoverPos = new Array();

var LCBHoverHorizontalAlign = 'center';
var LCBHoverVerticalAlign = 'middle';

// required to pause on mouse over
var LCBSwapTimeouts = new Array();
var LCBSwapTimeoutLengths = new Array();
var LCBSwapStartTimes = new Array();
var LCBSwapBreakTimes = new Array();

//Holds the Mouse Over Image and Layer objects
var LCBHoverLayerObjects = new Array();
var LCBHoverImageObjects = new Array();

var LCBHoverSequencesOver = new Array();
var LCBHoverSequencesOut = new Array();

var LCBHoverImageSources = new Array();


// optional text style of image description text
// example:
//
// var LCBTxtPos = new Array( 5,20, 5,80, 5,140, 5,200, 5,260 );
var LCBTxtStyle = "font-family : Verdana, Arial, Helvetica, sans-serif;color: #BB2226;text-align:center; font-size : 10px;font-weight: bold;";
var LCBTxtPre = '<font color="#BB2226" face="Verdana, Arial, Helvetica, sans-serif" size="1" align="center"><b>';
var LCBTxtPost = '</font></b>';
//

// highlights the images if mouse is over
var LCBHighlightImages = false;

// initial delay after loading page
var LCBLoadDelay = 100;

// display delay of one image after loading
var LCBImgDelay = 200;

// images are randomly swapped each (LCBSwapDelayMin+(0-99)*LCBSwapDelayTick) ms
var LCBSwapDelayMin  = 3000;
var LCBSwapDelayTick = 500;

// images are changed in random order?
var LCBRandomOrder = 1;

// Array of possible filters, filterno - duration
var LCBFilters = new Array(
                             0, 1.5,    // Box in
                             1, 1.5,    // Box out
                             2, 1.5,    // Circle in
                             3, 1.5,    // Circle out
                             4, 1.5,    // Wipe up
                             5, 1.5,    // Wipe down
                             6, 1.5,    // Wipe right
                             7, 1.5,    // Wipe left
                             8, 1.5,    // Vertical blinds
                             9, 1.5,    // Horizontal blinds
                            10, 1.5,    // Checkerboard across
                            11, 1.5,    // Checkerboard down
                            12, 1.5,    // Random dissolve
                            13, 1.5,    // Split vertical in
                            14, 1.5,    // Split vertical out
                            15, 1.5,    // Split horizontal in
                            16, 1.5,    // Split horizontal out
                            17, 1.5,    // Strips left down
                            18, 1.5,    // Strips left up
                            19, 1.5,    // Strips right down
                            20, 1.5,    // Strips right up
                            21, 1.5,    // Random bars horizontal
                            22, 1.5,    // Random bars vertical
                            23, 1.5        // Random transition from above possible values
                            );

// empty pic for alignment
var LCBEmptyPic = "images/pixempty.gif";

// Vars

// contains url of current displayed image at banner position
var LCBPicsDisplayed = new Array();
var LCBLinks = new Array();
var LCBTargets = new Array();

var LCBNoLink = false;

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_setInnerHTML(obj, strHTML) {
  if (is_nav4) {
        obj.doc.open();
        obj.doc.write(unescape(strHTML));
        obj.doc.close();
  } else if (document.getElementById) {
        obj.innerHTML = unescape(strHTML);
  }
}

function LCBDisplayImage(imgno)
{
    clearInterval(LCBSwapTimeouts[imgno]);
    var html = "";

    if (is_ie4up)
    {
        var filterNo = (Math.floor(Math.random()*LCBFilters.length/2))*2;
        eval('LCBImg'+imgno+'.filters.revealTrans.Transition='+LCBFilters[filterNo]);
        eval('LCBImg'+imgno+'.filters.revealTrans.Duration='+LCBFilters[filterNo+1]);
        eval('LCBImg'+imgno+'.filters.revealTrans.stop()');
        eval('LCBImg'+imgno+'.filters.revealTrans.apply()');
    }

    var img = -1, max=100, ind = 0;
    var ok = false;
    while (!ok && max > 0)
    {
        // nur gewisse Banner an dieser Position?
        if (typeof(LCBFixedPos) != "undefined")
        {
            if (imgno >= 0 && imgno < LCBFixedPos.length &&
                LCBFixedPos[imgno].length > 0)
            {
                // beliebige Banner aus dieser Menge
                ind = Math.floor(Math.random()*(LCBFixedPos[imgno].length));
                if (ind >= 0 && ind < LCBFixedPos[imgno].length)
                {
                    img = LCBFixedPos[imgno][ind];
                }
            }
            else
            {
                if (LCBRandomOrder > 0)
                {
                  // beliebige Banner aus Zufallsmenge
                  img = LCBRandomPos[Math.floor(Math.random()*(LCBRandomPos.length))];
                }
                else
                {
                    // aktuell angezeigtes bild, starten mit erstem
                    if (LCBRandomPos.length > 0)
                        img = LCBRandomPos[0];

                    for(i = 0;i < LCBRandomPos.length;i++)
                    {
                        if (LCBPicsDisplayed[imgno] == LCBanners[LCBRandomPos[i]*lcbaw])
                        {
                            // aktuell angezeigtes Bild gefunden,l nächstes verwenden
                            i++;

                            if (i >= LCBRandomPos.length)
                               i = 0;
                            img = LCBRandomPos[i];

                            break;
                        }
                    }
                }
            }
        }
        else
        {
            // keine Fixierungen angegeben

            if (LCBRandomOrder > 0)
            {
                // Zufällige Wiedergabe
              img = Math.floor(Math.random()*(LCBanners.length/lcbaw));
            }
            else
            {
                // aktuell angezeigtes bild, starten mit erstem
                if (LCBanners.length > 0)
                    img = 0;

                for(i = 0;i < LCBanners.length;i++)
                {
                    if (LCBPicsDisplayed[imgno] == LCBanners[i*lcbaw])
                    {
                        // aktuell angezeigtes Bild gefunden,l nächstes verwenden
                        i++;

                        if (i >= LCBanners.length)
                           i = 0;
                        img = i;

                        break;
                    }
                }
            }
        }

        // alert(img);

        ok = true;
        for(i=0;i<LCBPicsDisplayed.length;i++)
        {
            // img already shown?
            if (typeof(LCBPicsDisplayed[i]) != "undefined" &&
                LCBPicsDisplayed[i] == LCBanners[img*lcbaw])
            {
                ok = false;
                break;
            }
        }
        max--;
    }

    if (typeof(img) == "undefined" ||
        img >= (LCBanners.length/lcbaw) ||
        max==0)
    {
        return;
    }

    LCBPicsDisplayed[imgno] = LCBanners[img*lcbaw];
    LCBLinks[imgno] = LCBanners[img*lcbaw+1];
    LCBTargets[imgno] = LCBanners[img*lcbaw+2];
    if(lcbaw >= 6)
    {
            LCBHoverImageSources[imgno] = LCBanners[img*lcbaw+5];
    }
    var txtObj = null;

    if (document.layers)
    {
        eval('document.layers.LCBLyr'+imgno+'.document.images.LCBImg'+imgno+'.src="' + LCBanners[img*lcbaw] + '"');
        eval('document.layers.LCBLyr'+imgno+'.document.images.LCBImg'+imgno+'.alt="' + LCBanners[img*lcbaw+3] + '";');
        eval('document.layers.LCBLyr'+imgno+'.document.images.LCBImg'+imgno+'.width="' + LCBWidth + '";');
        eval('document.layers.LCBLyr'+imgno+'.document.images.LCBImg'+imgno+'.height="' + LCBHeight + '";');

        eval('txtObj = document.layers.LCBTxtLyr'+imgno+';');

        if (typeof(txtObj) != "undefined")
        {
            txtObj.document.open();
            txtObj.document.write(    LCBTxtPre + '<div style="'+LCBTxtStyle+'">' +
                                    LCBanners[img*lcbaw+4]) +
                                    '</div>' + LCBTxtPost;

            txtObj.document.close();
        }
    }
    else
    {
        eval('document.images.LCBImg'+imgno+'.src="' + LCBanners[img*lcbaw] + '";');
        eval('document.images.LCBImg'+imgno+'.alt="' + LCBanners[img*lcbaw+3] + '";');
        eval('document.images.LCBImg'+imgno+'.width="' + LCBWidth + '";');
        eval('document.images.LCBImg'+imgno+'.height="' + LCBHeight + '";');

        txtObj = LCLayer_getObject('LCBTxt'+imgno);
        if (txtObj)
        {
           LCLayer_setInnerHTML(txtObj, LCBanners[img*lcbaw+4]);
        }
    }

    if (is_ie4up)
    {
        eval('LCBImg'+imgno+'.filters.revealTrans.play()');
    }

    // nächstes Austauschen
    var iTimeout = LCBSwapDelayMin + Math.floor(Math.random()*100)*LCBSwapDelayTick;
    LCBSwapTimeouts[imgno] = setInterval('LCBDisplayImage('+imgno+');', iTimeout);
    LCBSwapTimeoutLengths[imgno] = iTimeout;
    LCBSwapStartTimes[imgno] = new Date();
}

function LCBGoto(imgno)
{
    if(LCBNoLink == true)
    {
        if (LCBLinks[imgno] != "")
        {
            LCBGotoReal(LCBLinks[imgno], LCBTargets[imgno], LCBHoverImageSources[imgno]);
        }
    }
    else
    {
        if (LCBLinks[imgno] != "" && typeof(LCBLinks[imgno]) != "undefined")
        {
            LCBGotoReal(LCBLinks[imgno], LCBTargets[imgno], LCBHoverImageSources[imgno]);
        }
    }
}

function LCBGotoReal(strLink, strTarget, strHoverImgSource)
{
    window.open(strLink, strTarget);
}

var theobject = null;
var highlighting = null;

function high(which2)
{
  theobject = which2;
  highlighting = setInterval('highlightit(theobject)', 20);
}

function low(which2)
{
    clearInterval(highlighting);

  if(which2)
  {
      if(which2.style.MozOpacity)
      {
            which2.style.MozOpacity = 0.5;
      }
        else if(which2.filters)
      {
        which2.filters.alpha.opacity = 50;
      }
    }
}

function highlightit(cur2)
{
  if(cur2)
  {
      var mozOpa = Number(cur2.style.MozOpacity);
      if(mozOpa < 1)
      {
          if(mozOpa == 0)
          {
              mozOpa = 0.0;
          }

          mozOpa += 0.06;
          if(mozOpa >= 1)
          {
              mozOpa = 0.99;
          }

        cur2.style.MozOpacity = mozOpa;
      }
      else if(cur2.filters && cur2.filters.alpha.opacity < 100)
      {
        cur2.filters.alpha.opacity += 6;
      }
      else if(window.highlighting)
      {
        clearInterval(highlighting);
      }
    }
    else
    {
      if(window.highlighting)
      {
        clearInterval(highlighting);
      }
    }
}


function LCBStartup()
{
    var html = "";
    var trg, sub, img, lyrPre, lyrPost;

    for(i = 0;i < LCBPos.length/2;i++)
    {
        img = '<img src="'+LCBEmptyPic+'" name="LCBImg'+i+'" alt=" "';

        if (is_ie4up)
        {
            img += ' style="filter:revealTrans(duration=2,transition=23)"';
        }

        img += ' border="0">';

        if(LCBNoLink == false)
        {
            img = '<a href="javascript:LCBGoto('+i+')">' + img + '</a>';
        }

        img = '<table width="'+(LCBWidth+2*LCBBorderWidth)+'" border="0" cellspacing="0" cellpadding="'+LCBBorderWidth+ '" align="center"><tr><td align="center" valign="middle" height="' + LCBHeight + '">' +
              img + '</td></tr></table>';

        if (document.layers)
        {
            lyrPre = '<layer name="LCBLyr'+i+'" left="'+LCBPos[i*2]+'" top="'+LCBPos[i*2+1]+'" width="' + (LCBWidth+2*LCBBorderWidth) +
                        '" height="' + (LCBHeight + 2*LCBBorderWidth) + '">';
            lyrPost = '</layer>';
        }
        else
        {
            lyrPre = '<div " id="bpic' + i + '" style=\'';

            if (LCBHighlightImages)
            {
                lyrPre += ' filter: alpha(opacity=50); opacity: 0.5;';
            }

            lyrPre += ' position:absolute; left:'+LCBPos[i*2]+'px;' +
                      ' top:'+LCBPos[i*2+1]+'px;' +
                      ' width:' + (LCBWidth+2*LCBBorderWidth) + 'px;' +
                      ' height:' + (LCBHeight + 2*LCBBorderWidth) + 'px; ' +
                      LCBBorderStyle + ' \'>';

            lyrPost = '</div>';

            lyrPre2 = '<div ';

            if(LCBNoLink == true)
            {
                lyrPre2 += ' style="z-index:' + (LCBPosZIndexStart + (LCBPosZIndexIncrement * (i / 2))) + ';border-width:0px;border-color:transparent;border-style:none;' +
                           ' position:absolute;' +
                           ' left:'+LCBPos[i*2]+'px;' +
                           ' top:' + LCBPos[i*2+1]+'px;" onMouseOver="LCBMouseOver(\'' + i + '\');" onMouseOut="LCBMouseOut(\'' + i + '\');">' +
                           '   <img src="'+LCBEmptyPic+'" border="0" ' +
                           ' width="'+ (LCBWidth+2*LCBBorderWidth) + '" height="' + (LCBHeight + 2*LCBBorderWidth) + '">';
            }
            else
            {
                lyrPre2 += ' style="z-index:' + (LCBPosZIndexStart + (LCBPosZIndexIncrement * (i / 2))) + ';' +
                           ' position:absolute;' +
                           ' left:'+LCBPos[i*2]+'px;' +
                           ' top:' + LCBPos[i*2+1]+'px;">' +
                           ' <a href="javascript:LCBGoto('+i+')">' +
                           '   <img src="'+LCBEmptyPic+'" width="'+ (LCBWidth+2*LCBBorderWidth) + '"' +
                           '    height="' + (LCBHeight + 2*LCBBorderWidth) + '" border="0" onMouseOver="LCBMouseOver(\'' + i + '\');" onMouseOut="LCBMouseOut(\'' + i + '\');">' +
                           ' </a>';
            }

            lyrPost2 = '</div>';
        }

        html += lyrPre+img+lyrPost + lyrPre2+lyrPost2;
    }

    document.write(html);

    for(i = 0;i < LCBHoverPos.length/2;i++)
    {
        html = '';

        LCBHoverLayerObjects[i] = new LCLayer('lcbHoverImageLayer' + i,
                    LCBHoverPos[i*2], LCBHoverPos[(i*2)+1], null, LCBHoverWidth, LCBHoverHeight, null, false, null, null, null, 300+i);
        LCBHoverImageObjects[i] = new LCImage('lcbHoverImageImage' + i, LCBEmptyPic);

        LCBHoverLayerObjects[i].addChild(LCBHoverImageObjects[i]);
        LCBHoverLayerObjects[i].create();

        LCBHoverLayerObjects[i].getObject().style.textAlign = LCBHoverHorizontalAlign;
        LCBHoverLayerObjects[i].getObject().style.verticalAlign = LCBHoverVerticalAlign;

        LCBHoverSequencesOver[i] = null;
        LCBHoverSequencesOut[i] = null;
    }

    if (typeof(LCBTxtPos) != "undefined")
    {
        html = '';
        for(i = 0;i < LCBTxtPos.length/2;i++)
        {
            if (document.layers)
            {
                lyrPre = '<layer name="LCBTxtLyr'+i+'" left="'+LCBTxtPos[i*2]+'" top="'+LCBTxtPos[i*2+1]+'" width="' + (LCBWidth+2*LCBBorderWidth) +
                            '" height="' + (LCBHeight + 2*LCBBorderWidth) + '">';
                lyrPost = '</layer>';
            }
            else
            {
                lyrPre = '<div style="position:absolute; ' +
                         'left:'+LCBTxtPos[i*2]+'px; ' +
                         'top:'+LCBTxtPos[i*2+1]+'px; ' +
                         'width:' + (LCBWidth+2*LCBBorderWidth) + 'px; ' +
                         'height:' + (LCBHeight + 2*LCBBorderWidth) + 'px;">';
                lyrPost = '</div>';
            }

            html += lyrPre+LCBTxtPre+'<div id="LCBTxt'+i+'" style="'+LCBTxtStyle+'">&nbsp;</div>'+LCBTxtPost+lyrPost;
        }
    }

    document.write(html);

    for(i = 0;i < LCBPos.length/2;i++)
    {
        var iTimeout = LCBLoadDelay+i*LCBImgDelay;
        LCBSwapTimeouts[i] = setInterval('LCBDisplayImage('+i+')', iTimeout);
        LCBSwapTimeoutLengths[i] = iTimeout;
        LCBSwapStartTimes[i] = new Date();
    }
}

function LCBPreLoad()
{
    var LCBPre=new Array()
    for (i=0;i<LCBanners.length/lcbaw;i+=lcbaw)
    {
        LCBPre[i]=new Image();
        LCBPre[i].src=LCBanners[i*lcbaw];
    }
}

function LCBMouseOver(imgno)
{
    clearInterval(LCBSwapTimeouts[imgno]);
    LCBSwapBreakTimes[imgno] = new Date();

    if (LCBHighlightImages)
    {
        high(LCLayer_getObject('bpic' + imgno));
    }

    if(LCBHoverSequencesOver[imgno] != null)
    {
        LCBHoverSequencesOver[imgno].stop();
        LCBHoverSequencesOver[imgno] = null;
    }

    if(LCBHoverSequencesOut[imgno] != null)
    {
        LCBHoverSequencesOut[imgno].stop();
        LCBHoverSequencesOut[imgno] = null;
    }

    if(typeof(LCBHoverImageSources[imgno]) != 'undefined' && typeof(LCBHoverImageSources[imgno].length) != 'undefined')
    {
        if(LCBHoverImageSources[imgno].length > 0)
        {
            LCBHoverImageObjects[imgno].setSrc(LCBHoverImageSources[imgno]);

            LCBHoverSequencesOver[imgno] = new LCSequence();
            LCBHoverSequencesOver[imgno].addAction(new LCAction(0, 1, LCBHoverLayerObjects[imgno], 'fade', 100, 100));
            LCBHoverSequencesOver[imgno].addAction(new LCAction(0, 1, LCBHoverLayerObjects[imgno], 'show'));
            LCBHoverSequencesOver[imgno].addAction(new LCAction(1, 10, LCBHoverLayerObjects[imgno], 'fade', 100, 0));

            LCBHoverSequencesOut[imgno] = new LCSequence();
            LCBHoverSequencesOut[imgno].addAction(new LCAction(0, 9, LCBHoverLayerObjects[imgno], 'fade', 0, 100));
            LCBHoverSequencesOut[imgno].addAction(new LCAction(9, 10, LCBHoverLayerObjects[imgno], 'hide'));

            LCBHoverSequencesOver[imgno].play();
        }
        }
}

function LCBMouseOut(imgno)
{
    if(LCBHighlightImages)
    {
        low(LCLayer_getObject('bpic' + imgno));
    }

    if(LCBHoverSequencesOver[imgno] != null)
    {
        LCBHoverSequencesOver[imgno].stop();
        LCBHoverSequencesOver[imgno] = null;
    }

    if(LCBHoverSequencesOut[imgno] != null)
    {
        LCBHoverSequencesOut[imgno].play();
    }

    var iTimeout = LCBSwapTimeoutLengths[imgno] - (LCBSwapBreakTimes[imgno].getTime() - LCBSwapStartTimes[imgno].getTime());
    LCBSwapTimeouts[imgno] = setInterval('LCBDisplayImage('+imgno+');', LCBSwapTimeoutLengths[imgno]);
    LCBSwapTimeoutLengths[imgno] = iTimeout;
    LCBSwapStartTimes[imgno] = new Date();
}
