/////////////////////
// PagePeel Script //
/////////////////////

var PP_Obj = new Object();

PP_Obj.GoTo = new Array();
// GoTo Variante1 (Url in Frame oder Fenster öffnen) => _blank/_parent/_self/frameName|ZielAdresse (Beispiel: '_parent|http://www.domain.tld')
// GoTo Variante2 (Url in neuem Fenster öffnen) => Adresse (Beispiel: 'http://www.domain.tld')
// GoTo Variante3 (JavaScript ausführen) => JavaScript:Function(); (Beispiel: 'JavaScript:MyFunction();')
// GoTo Variante3 (Mail ausführen) => MailTo:MailAddress; (Beispiel: 'MailTo:name@domain.tld')
PP_Obj.GoTo[PP_Obj.idx=0]= 'JavaScript:changeContentUrl(\"news.php\", null);';
//PP_Obj.GoTo[++PP_Obj.idx]= 'riwo|http://www.riwo.com';
PP_Obj.GoTo[++PP_Obj.idx]= 'hpe|http://www.hpe.de';
PP_Obj.GoTo[++PP_Obj.idx]= 'gdholz|http://www.gdholz.de';
// Wenn noch mehr Bilder und Links gebraucht werden einfach hier so weiter machen:  PP_Obj.GoTo[++PP_Obj.idx]=  u.s.w.

PP_Obj.image_small = new Array();
PP_Obj.image_small[PP_Obj.idx=0]= 'pagepeel/image/small1.gif';  //Hier URL angeben wo das Bild small.gif liegt
//PP_Obj.image_small[++PP_Obj.idx]= 'pagepeel/image/small2.gif';  
PP_Obj.image_small[++PP_Obj.idx]= 'pagepeel/image/small3.gif';  
PP_Obj.image_small[++PP_Obj.idx]= 'pagepeel/image/small4.gif';  
// Wenn noch mehr Bilder und Links gebraucht werden einfach hier so weiter machen:  PP_Obj.image_small[++PP_Obj.idx] u.s.w.

PP_Obj.image_big = new Array();
PP_Obj.image_big[PP_Obj.idx=0]= 'pagepeel/image/big1.gif';  //Hier URL angeben wo das Bild big.gif liegt
//PP_Obj.image_big[++PP_Obj.idx]= 'pagepeel/image/big2.gif';  
PP_Obj.image_big[++PP_Obj.idx]= 'pagepeel/image/big3.gif';  
PP_Obj.image_big[++PP_Obj.idx]= 'pagepeel/image/big4.gif';  
// Wenn noch mehr Bilder und Links gebraucht werden einfach hier so weiter machen:  PP_Obj.image_big[++PP_Obj.idx] u.s.w.

PP_Obj.urlTop_Array = new Array();
PP_Obj.urlTop_Array[PP_Obj.idx=0] = 248; //Hier den oberen Klickpunkt angeben
//PP_Obj.urlTop_Array[++PP_Obj.idx] = 264;
PP_Obj.urlTop_Array[++PP_Obj.idx] = 255;
PP_Obj.urlTop_Array[++PP_Obj.idx] = 264;

PP_Obj.urlLeft_Array = new Array();
PP_Obj.urlLeft_Array[PP_Obj.idx=0] = 504; //Hier den linken Klickpunkt angeben
//PP_Obj.urlLeft_Array[++PP_Obj.idx] = 504;
PP_Obj.urlLeft_Array[++PP_Obj.idx] = 500;
PP_Obj.urlLeft_Array[++PP_Obj.idx] = 500;

PP_Obj.urlWidth_Array = new Array();
PP_Obj.urlWidth_Array[PP_Obj.idx=0] = 124; //Hier die Breite des Klickpunkts angeben
//PP_Obj.urlWidth_Array[++PP_Obj.idx] = 124;
PP_Obj.urlWidth_Array[++PP_Obj.idx] = 124;
PP_Obj.urlWidth_Array[++PP_Obj.idx] = 124;

PP_Obj.urlHeight_Array = new Array();
PP_Obj.urlHeight_Array[PP_Obj.idx=0] = 24; //Hier die Höhe des Klickpunkts angeben
//PP_Obj.urlHeight_Array[++PP_Obj.idx] = 24;
PP_Obj.urlHeight_Array[++PP_Obj.idx] = 24;
PP_Obj.urlHeight_Array[++PP_Obj.idx] = 24;

// Interval nächster Eintrag ( -1 = deaktiviert )
PP_Obj.interval = -1;

// Nächster Eintrag per Zufall auswählen (true) oder fortlaufend (false)
PP_Obj.randomInterval = true;

PP_Obj.small_path = 'pagepeel/swf/pagepeel_s.swf'; //Hier URL angeben wo die pagepeel_s.swf liegt
PP_Obj.small_width = 100;
PP_Obj.small_height = 100;

PP_Obj.big_path = 'pagepeel/swf/pagepeel_b.swf'; //Hier URL angeben wo die pagepeel_b.swf liegt
PP_Obj.big_width = 650;
PP_Obj.big_height = 650;

///////////////////////////////////////////////////////
///////////// Ab hier nichts mehr ändern //////////////
///////////////////////////////////////////////////////

PP_Obj.anzahl = PP_Obj.image_small.length;   //Hier die Anzahl der eingetragenen Links angeben

PP_Obj.nr = null;

PP_Obj.Link = null;
PP_Obj.Image1 = null;
PP_Obj.Image2 = null;

PP_Obj.urlTop = null;
PP_Obj.urlLeft = null;
PP_Obj.urlWidth = null;
PP_Obj.urlHeight = null;

PP_Obj.xCoord = 0;
PP_Obj.yCoord = 0;

PP_Obj.locked = false;
PP_Obj.resetFlag = false;

PP_Obj.urlWin = new Array();

PP_Obj.ad_url = null;

PP_Obj.now = new Date();
PP_Obj.now = PP_Obj.now.getTime();

  PP_Obj.setPagePeelVars = function()
  {
    if(PP_Obj.locked == true)
      return(false);

    PP_Obj.resetFlag = true;

    if(PP_Obj.anzahl > 1)
    {
      if(PP_Obj.randomInterval == true)
      {
        if(PP_Obj.nr != null)
        {
          oldNr = PP_Obj.nr;

          for(i=0 ; (PP_Obj.nr = Math.round((PP_Obj.anzahl-1) * Math.random())) == oldNr ; i++)
          {
            if(i > 100)
              break;
          }
        }
        else
          PP_Obj.nr = 0;
      }
      else
      {
        if(PP_Obj.nr == null)
          PP_Obj.nr = 0;
        else
        {
          PP_Obj.nr++;

          if(PP_Obj.nr > PP_Obj.anzahl-1)
            PP_Obj.nr = 0;
        }
      }
    }
    else
      PP_Obj.nr = 0;

    PP_Obj.Link = PP_Obj.GoTo[PP_Obj.nr];
    PP_Obj.Image1 = PP_Obj.image_small[PP_Obj.nr] + "?" + PP_Obj.now;
    PP_Obj.Image2 = PP_Obj.image_big[PP_Obj.nr] + "?" + PP_Obj.now;

    PP_Obj.urlTop = PP_Obj.urlTop_Array[PP_Obj.nr];
    PP_Obj.urlLeft = PP_Obj.urlLeft_Array[PP_Obj.nr];
    PP_Obj.urlWidth = PP_Obj.urlWidth_Array[PP_Obj.nr];
    PP_Obj.urlHeight = PP_Obj.urlHeight_Array[PP_Obj.nr];

    // PP_Obj.ad_url = escape(PP_Obj.Link); // Deaktiviert
    PP_Obj.ad_url = "";

    PP_Obj.small_image = escape(PP_Obj.Image1);
    PP_Obj.small_params = 'ico=' + PP_Obj.small_image;

    PP_Obj.big_image = escape(PP_Obj.Image2);
    PP_Obj.big_params = 'big=' + PP_Obj.big_image + '&ad_url=' + PP_Obj.ad_url;

    return(true);  
  }

  PP_Obj.getSmallCode = function()
  {
    objectCode  = '  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" id="pagepeelSmallObject" width="' + PP_Obj.small_width + '" height="' + PP_Obj.small_height + '">';
    objectCode += '    <param name="allowScriptAccess" value="always"/> ';
    objectCode += '    <param name="movie" value="' + PP_Obj.small_path + '?' + PP_Obj.small_params + '"/>';
    objectCode += '    <param name="wmode" value="transparent" />';
    objectCode += '    <param name="quality" value="high" /> ';
    objectCode += '    <param name="FlashVars" value="' + PP_Obj.small_params + '"/>';
    objectCode += '    <embed src="' + PP_Obj.small_path + '?' + PP_Obj.small_params + '" name="pagepeelSmallObject" wmode="transparent" quality="high" width="' + PP_Obj.small_width + '" height="' + PP_Obj.small_height + '" flashvars="' + PP_Obj.small_params + '" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
    objectCode += '  </object>';

    return(objectCode);
  }

  PP_Obj.getBigCode = function()
  {
    objectCode  = '  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" id="pagepeelBigObject" width="' + PP_Obj.big_width + '" height="' + PP_Obj.big_height + '">';
    objectCode += '    <param name="allowScriptAccess" value="always"/> ';
    objectCode += '    <param name="movie" value="' + PP_Obj.big_path + '?'+ PP_Obj.big_params + '"/>';
    objectCode += '    <param name="wmode" value="transparent" />';
    objectCode += '    <param name="quality" value="high" /> ';
    objectCode += '    <param name="FlashVars" value="' + PP_Obj.big_params + '"/>';
    objectCode += '    <embed src="' + PP_Obj.big_path + '?' + PP_Obj.big_params + '" id="pagepeelBigEmbed" name="pagepeelBigObject" wmode="transparent" quality="high" width="' + PP_Obj.big_width + '" height="' + PP_Obj.big_height + '" flashvars="' + PP_Obj.big_params + '" swliveconnect="true" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
    objectCode += '  </object>';

    return(objectCode);
  }

  PP_Obj.resetPagePeel = function()
  {
    if(PP_Obj.setPagePeelVars() == true)
    {
      innerHTMLsmall = PP_Obj.getSmallCode();
      innerHTMLbig   = PP_Obj.getBigCode();

      document.getElementById("pagepeelSmall").innerHTML = innerHTMLsmall;
      document.getElementById("pagepeelBig").innerHTML = innerHTMLbig;

      PP_Obj.initPagePeel();
      PP_Obj.showPagePeel(PP_Obj.xCoord, PP_Obj.yCoord);
    }
    
    if(PP_Obj.interval > 0)
    {
      setTimeout("PP_Obj.resetPagePeel();", PP_Obj.interval);
    }
  }

  PP_Obj.initMouse = function()
  {
    PP_Obj.locked = true;

    if (navigator.appName == 'Netscape')
      document.getElementById("pagepeelBig").addEventListener("mousedown", PP_Obj.MouseDown, true);
    else
      document.getElementById("pagepeelBig").onmousedown = PP_Obj.MouseDown;
  }

  PP_Obj.KeyDown = function(e)
  {
    if(document.layers || (document.getElementById && !document.all))
      keyCode = e.which;
    else
      keyCode = window.event.keyCode;
 
    switch(keyCode)
    {
      case 27: PP_Obj.popupTimeOut = null;
               break;
    }
  }

  PP_Obj.MouseDown = function(e)
  {
    if (navigator.appName == 'Netscape')
    {
      mouseEventX = PP_Obj.big_width - (PP_Obj.xCoord - e.pageX);
      mouseEventY = e.pageY - PP_Obj.yCoord;

      pressedButton = e.button;
    }
    else
    {
      mouseEventX = PP_Obj.big_width - (PP_Obj.xCoord - window.event.x) + document.body.scrollLeft;
      mouseEventY = window.event.y + document.body.scrollTop - PP_Obj.yCoord;
    
      pressedButton = window.event.button;
    }

    if(PP_Obj.resetFlag == false && pressedButton < 2)
      PP_Obj.setUrlAction(mouseEventX, mouseEventY);
  }

  PP_Obj.getUrlAction = function()
  {
    if(PP_Obj.Link == "")
      return;

    var urlLink = PP_Obj.Link.split("|");

    if(urlLink[0].toLowerCase().indexOf("javascript:", 0) < 0 && urlLink[0].toLowerCase().indexOf("mailto:", 0) < 0) // Kein JavaScript und kein MailTo
    {
      if(urlLink.length == 1)
      {
        urlLink[1] = urlLink[0];
        urlLink[0] = "_blank";
      }

      if(urlLink[1].toLowerCase().indexOf("www.", 0) == 0)
      	urlLink[1] = "http://" + urlLink[1];

      urlRef = "";

      for(i=1 ; i < urlLink.length ; i++)
      {
        if(i > 1)
          urlRef += "|";

        urlRef += urlLink[i];
      }
    }
    else
    {
      urlRef = urlLink[0];
      urlRef = urlRef.replace(/mailto:/i,"MailTo:");
      urlRef = urlRef.replace(/javascript:/i,"JavaScript:");
    }

    if(urlLink.length > 1)
      PP_Obj.runUrlAction(urlRef, urlLink[0], PP_Obj.nr);
    else
      self.location.href = urlRef;
  }

  PP_Obj.popupTimeOut = null;

  PP_Obj.setPopupPosition = function()
  {
    if(PP_Obj.popupTimeOut)
    {
      PP_Obj.locked = true;
      
      document.getElementById("activePopupBlocker").style.display = "none";
    
      document.getElementById("activePopupBlocker").style.width = document.body.scrollWidth + 'px';
      document.getElementById("activePopupBlocker").style.height = document.body.scrollHeight + 'px';

      document.getElementById("activePopupBlockerWin").style.left = document.body.clientWidth/2 - parseInt(document.getElementById("activePopupBlockerWin").style.width)/2 + document.body.scrollLeft;
      document.getElementById("activePopupBlockerWin").style.top  = document.body.clientHeight/2 - parseInt(document.getElementById("activePopupBlockerWin").style.height)/2 + document.body.scrollTop;

      document.getElementById("activePopupBlocker").style.display = "inline";
      
      PP_Obj.popupTimeOut = setTimeout("PP_Obj.setPopupPosition();", 250);
    }
    else
    {
      document.onkeydown = PP_Obj.savedKeyEventHandler;
    	
      PP_Obj.locked = false;
      document.getElementById("activePopupBlocker").style.display = "none";
    }
  }

  PP_Obj.savedKeyEventHandler = null;

  PP_Obj.runUrlAction = function(urlRef, urlLink, nr)
  {
    if(PP_Obj.urlWin[nr] && PP_Obj.urlWin[nr].closed != true)
      PP_Obj.urlWin[nr].close();

    PP_Obj.urlWin[nr] = window.open(urlRef, urlLink, "left=20, top=20, width=" + (screen.availWidth-60) + ", height=" + (screen.availHeight-200) + ", location=yes, menubar=yes, resizable=yes, scrollbars=yes, toolbar=yes");

    if(PP_Obj.urlWin[nr])
    {
      PP_Obj.popupTimeOut = null;
      document.getElementById("activePopupBlocker").style.display = "none";
      
      PP_Obj.urlWin[nr].focus();
      return false;
    }

    PP_Obj.savedKeyEventHandler = document.onkeydown;
    document.onkeydown = PP_Obj.KeyDown;

    document.getElementById("urlGif").style.backgroundImage = "url(" + PP_Obj.image_small[nr] + "?" + PP_Obj.now + ")";
    document.getElementById("extUrl").innerHTML = "<input type=\"button\" value=\"Seite aufrufen\" onClick=\"PP_Obj.runUrlAction('" + urlRef + "', '" + urlLink + "', " + nr + ");\" style=\"cursor:pointer;\">";

    PP_Obj.popupTimeOut = setTimeout("PP_Obj.setPopupPosition();", 50);

    return true;
  }

  PP_Obj.setUrlAction = function(mouseEventX, mouseEventY)
  {
    // alert("mouseEventX=" + mouseEventX + " - mouseEventY=" + mouseEventY);

    if(mouseEventX >= PP_Obj.urlLeft && mouseEventX <= PP_Obj.urlLeft+PP_Obj.urlWidth && mouseEventY >= PP_Obj.urlTop && mouseEventY <= PP_Obj.urlTop+PP_Obj.urlHeight)
    {
      PP_Obj.getUrlAction();
      sizedown987();
    }
  }

  PP_Obj.waitForPreviewImage = function(i)
  {
    if(document.getElementById("previewImage").complete == true || i> 100)
    {
      document.getElementById("pagepeelSmall").style.display = "inline";
      document.getElementById("pagepeelBig").style.display = "inline";

      setTimeout('document.getElementById("pagepeelBig").style.top = "-1000px"; PP_Obj.resetFlag = false;', 500);
      
      return;
    }
    
    i++;

    setTimeout("PP_Obj.waitForPreviewImage("+i+");", 50);
  }

  PP_Obj.startPagePeel = function()
  {
    PP_Obj.waitForPreviewImage(0);
  }

  PP_Obj.setPagePeelInterval = function(millisec)
  {
    if(PP_Obj.interval < 0)
    {
      PP_Obj.interval = millisec;

      setTimeout("PP_Obj.resetPagePeel();", PP_Obj.interval);
    }
  }

  PP_Obj.initPagePeel = function ()
  {
    document.getElementById("pagepeelSmall").style.display = "none";
    document.getElementById("pagepeelBig").style.display = "none";
  }

  PP_Obj.showPagePeel = function (x, y)
  {
    PP_Obj.xCoord = x;
    PP_Obj.yCoord = y;

    document.getElementById("pagepeelSmall").style.left = (PP_Obj.xCoord-PP_Obj.small_width) + "px";
    document.getElementById("pagepeelSmall").style.top = PP_Obj.yCoord + "px";

    document.getElementById('pagepeelBig').style.left = (PP_Obj.xCoord-PP_Obj.big_width) + 'px';
    document.getElementById('pagepeelBig').style.top = PP_Obj.yCoord + 'px';
    
    PP_Obj.startPagePeel();
  }

  PP_Obj.hidePagePeel = function ()
  {
    document.getElementById("pagepeelSmall").style.display = "none";
    document.getElementById("pagepeelBig").style.display = "none";
  }

  PP_Obj.closeTimeOut = null;

  function sizeup987()
  {
    document.getElementById('pagepeelBig').style.left = (PP_Obj.xCoord-PP_Obj.big_width) + 'px';
    document.getElementById('pagepeelBig').style.top = PP_Obj.yCoord + 'px';
    document.getElementById('pagepeelSmall').style.top = '-1000px';
    
    if(PP_Obj.closeTimeOut == null)
      PP_Obj.closeTimeOut = setTimeout("sizedown987(); PP_Obj.locked = false;", 10000);
  }

  function sizedown987()
  {
    document.getElementById("pagepeelSmall").style.left = (PP_Obj.xCoord-PP_Obj.small_width) + 'px';
    document.getElementById("pagepeelSmall").style.top = PP_Obj.yCoord + 'px';

    document.getElementById("pagepeelBig").style.top = "-1000px";

    if(PP_Obj.closeTimeOut != null)
    {
      clearTimeout(PP_Obj.closeTimeOut);
      PP_Obj.closeTimeOut = null;
    }
  }

PP_Obj.putObjects = function ()
{
  PP_Obj.setPagePeelVars();

  document.write('  <img id="previewImage" src="' + PP_Obj.image_big[PP_Obj.nr] + '?' + PP_Obj.now + '" width="10" height="10" style="position:absolute; left:0px; top:0px; visibility:hidden;">');
  
  document.write('<div id="pagepeelSmall" style="position:absolute;width:' + PP_Obj.small_width + 'px;height:' + PP_Obj.small_height + 'px;z-index:9998;top:-1000px;display:none;">');
  document.write(PP_Obj.getSmallCode());
  document.write('</div>');

  document.write('<div id="pagepeelBig" onMouseover="PP_Obj.initMouse();" onMouseout="PP_Obj.locked=false;" style="position:absolute;width:' + PP_Obj.big_width + 'px;height:' + PP_Obj.big_height + 'px;z-index:9998;top:-1000px;display:none;">');
  document.write(PP_Obj.getBigCode());
  document.write('</div>');

  document.write('<div id="activePopupBlocker" style="background-image:url(pagepeel/image/transparenz.png); width:1px; height:1px; position:absolute; left:0px; top:0px; z-index:9999; display:none;">');

  document.write('  <table id="activePopupBlockerWin" border="0" cellpadding="0" cellspacing="0" style="position:absolute;left:0px; top:0px; width:400px; height:300px; border-width:2px; border-color:silver; border-style:solid;">');
  document.write('    <tr>');
  document.write('      <td colspan="3" height="22" align="center" valign="middle" style="background-color:#3A6E9E;">');
  document.write('        <span style="float:left; cursor:default;"><img src="pagepeel/image/popup_title.gif" height="22" width="140" alt="" title=""></span><span style="cursor:pointer; float:right;"><img src="pagepeel/image/popup_close_default.gif" height="22" width="41" alt="" title="Fenster schliessen" onmouseover="this.src=\'pagepeel/image/popup_close_over.gif\';" onmouseout="this.src=\'pagepeel/image/popup_close_default.gif\'" onclick="PP_Obj.popupTimeOut = null; document.getElementById(\'activePopupBlocker\').style.display=\'none\';"></span>');
  document.write('      </td>');
  document.write('    </tr>');
  document.write('    <tr>');
  document.write('      <td colspan="3" height="15" style="background-color:#FFFFFF;"></td>');
  document.write('    </tr>');
  document.write('    <tr>');
  document.write('      <td width="10" style="background-color:#FFFFFF;"></td>');
  document.write('      <td align="center" id="urlGif" valign="top" style="background-image:url(); background-repeat:no-repeat; background-position:top right; background-color:#FFFFFF; color:#3A6E9E; font-family: arial, helvetica, tahoma ,verdana, sans-serif; font-size:18px;"><br><br>Die Aktion wurde vom Browser blockiert<br><br><font style="color:#000000; font-size:14px;">Sie haben in den Popup-Optionen Ihres Browsers die Möglichkeit, Popups für diese Seite zu erlauben.<br><br>Alternativ können Sie die Seite auch über den nachfolgenden Button erreichen.<br><br></font><span id="extUrl"><input type="button" value="Seite aufrufen" onClick="" style="cursor:pointer;"></span><br><br><img src="pagepeel/image/info.gif" height="16" width="16" title="" alt="" style="position:relative; top:4px;"><font style="font-size:10px; color:grey;">&nbsp;&nbsp;Popup-Blocker unterbinden unerwünschte Browser-Fenster (z.B. Werbung).</font></td>');
  document.write('      <td width="10" style="background-color:#FFFFFF;"></td>');
  document.write('    </tr>');
  document.write('  </table>');

  document.write('<\/div>');
}

PP_Obj.putObjects();

