  var clip = null;
  var infomsgText = '';

  function couponcopy() {

    $('div.coupon').each(function () {

      $(this).after('<div id="infomsg">'+infomsgText+'</div>');
      var infomsg = $('#infomsg');

      var data = $(this).metadata({type:'elem', name:'script'});
      var postID = data.postID;
      
      var code = $(this).find('.couponcode strong');
      
      if(code.length > 0) {
           
        $(this).mouseover(function(){
        
            if (clip) {
              clip.destroy();
            }
            
            clip = new ZeroClipboard.Client();
           
            var pos = code.position();      
              
            clip.setText(code.text());
            clip.setHandCursor(true);
            clip.glue(code.get(0));
        
            // Wenn der Coupon geklickt wurde
            clip.addEventListener('onComplete', function() {
              code.css({
                textDecoration: 'line-through',
                color         : '#CCCCCC'
              });
              infomsg.text('kopiert!');
              window.open('http://uk.coupondoo.com?p='+postID+'&exit=yes');
            });
        
            // when coupon code is hovered...
            clip.addEventListener('mouseOver', function() {
              infomsg.text('Klicken und kopieren...');
              infomsg.css({
                left: pos.left + code.width() + 20, 
                top: pos.top - 10,
                opacity: 0.8, 
                display: 'none'
              }).fadeIn(200);
            });
            
            clip.addEventListener('mouseOut', function() { 
              infomsg.fadeOut(200);
            });
        });
      } // end: if code
    })
  }
