
function KrebsLocalPictures () {
  // ------------------------------------------------------------------
  // variables && constants
  // ------------------------------------------------------------------

  // ------------------------------------------------------------------
  // methods
  // ------------------------------------------------------------------

  this.onLoad = function(id) {
    if (!id) id = 'col3_content';

    var pictures = $$('#'+id+' .popup');

    for (var i = 0; i < pictures.length; i++){
      var pict = pictures[i];
      var anch = pict.parentNode;
      var cont = anch.parentNode;

      var pclone = pict.cloneNode(true);

      // popups hierachisch nach "oben" verschieben
      // alles ganz boeser scope voodoo
      cont.replaceChild(pclone, anch);
    }
  };

  // ------------------------------------------------------------------

  this.openPopup = function(url, width, height, title) {
    var settings = "width="+width+",height="+height;
    var popup;

    if (!title) title = 'www.cottbus.de';

    if (url.match(/\.jpg$/)){
      popup = window.open('', 'popup', settings);

      popup.document.open();
      popup.document.write("<html><head><title>"+title+"</title></head>");
      popup.document.write("<body style='margin: 0px; padding: 0px'>");
      popup.document.write("<a href='javascript:window.close();true;'><img src='"+url+"' alt='' border='0'></a>");
      popup.document.write("</body></html>");
      popup.document.close();

    }else{
      popup = window.open(url, "popup", settings);
    }

    if (window.focus) { popup.focus() }

    return false;
  };
};

var KrebsLocalPictures = new KrebsLocalPictures();

Event.observe(document, "dom:loaded", function() { KrebsLocalPictures.onLoad(); });
