/* auto_prettyphoto.js
 * Bilder welche als Klasse open_with_prettyphoto (ohne Anker als Parent) mit prettyphoto öffnen bei klick.
 * siehe ngi-wiki (https://intranet.studcom.ch/ngiwiki/index.php/Eigene_jQuery-Module)
 *
 * This is a jQuery-Plugin (jquery necessary)
 *
 * Version 0.1 14.01.2011
 * Johannes Wüthrich für Studcom GmbH Muttenz
 */
 
  jQuery.fn.autoPrettyphoto = function(){
  
    var $ = jQuery;
    
    $('img.open_with_prettyphoto', this).each(function(){
    
      if($(this).parent().get(0).tagName != "A")
      {
        var name = $(this).attr('name');
        var src = $(this).attr('src');
        
        if(/thumbnails/.test(src) && name!="")
          src = name;
        
        var copy = $(this).clone();
        
        $('<a href="'+src+'" target="_self" rel="prettyPhoto[content_image]" ></a>').append(copy).replaceAll(this); 
      }
    });
    
    return this;
  };
