// when window has loaded
window.onload=init;

function init() {

  // if browser is capable
  if(document.getElementById) {

    // get all <p>
    var ps = document.getElementsByTagName('p');
    for(var i=0,length=ps.length; i<length; i++) {
    
      // if paragraph element has class 'duplicate'
      if (ps[i].className.indexOf('duplicate')>=0) {
      
        // apply behavior
        ps[i].onclick=function() {
          this.parentNode.appendChild(this.cloneNode(true));
        };
      }
    }
  }
  
}


