/* Script adapted from http://plugins.jquery.com/project/copypaste/ */
window.jQuery&&(function($){$.fn.copypaste=function(oOptions){var oSettings={clipboard:'<b>%title%</b><br />\n&bdquo;%copy%&ldquo;<br />\n<br />\n<address><a href="%url%">%url%</a></address>',skip_tags:['INPUT','TEXTAREA'],base_node:'<span></span>',word_separator:/[^A-Za-z0-9]+/i,trim:true,min_chars:0,max_chars:0,min_words:0,max_words:0,track_events:true};if(oOptions){if(typeof oOptions==typeof function(){})oOptions={clipboard:oOptions};else if(typeof oOptions!=typeof{})oOptions={clipboard:(''+oOptions)};$.extend(oSettings,oOptions)}this.bind('copy',function(hEvent){if(oSettings.clipboard){var mClipboard=oSettings.clipboard;var bSkip=false;if(oSettings.skip_tags){var sTag=hEvent.target.nodeName.toUpperCase();for(var i in oSettings.skip_tags){if(oSettings.skip_tags[i].toUpperCase()==sTag){bSkip=true;break}}}if(!bSkip){var fCopySkip=function(sSelection){if((oSettings.min_chars>0&&sSelection.length<oSettings.min_chars)||(oSettings.max_chars>0&&sSelection.length>oSettings.max_chars))return true;else if(oSettings.min_words>0||oSettings.max_words>0){var aSelection=sSelection.split(oSettings.word_separator);if((oSettings.min_words>0&&aSelection.length<oSettings.min_words)||(oSettings.max_words>0&&aSelection.length>oSettings.max_words))return true}return false};var fTrackEvent=function(sSelection){if(oSettings.track_events){if(window._gaq&&_gaq.push){_gaq.push(['_trackEvent','Copy & Paste','Copy',sSelection]);return true}else if(window._gat&&_gat._getTracker&&window.pageTracker&&pageTracker._trackEvent){pageTracker._trackEvent('Copy & Paste','Copy',sSelection);return true}return false}return null};if(typeof mClipboard!=typeof function(){}){var dDate=new Date();var fEncodeHTML=function(sString){return(''+sString).split('&').join('&amp;').split('<').join('&lt;').split('>').join('&gt;').split('"').join('&quot;').split('\'').join('&#39;')};mClipboard=''+mClipboard;mClipboard=mClipboard.replace(/%title%/gi,fEncodeHTML(document.title));mClipboard=mClipboard.replace(/%url%/gi,fEncodeHTML(location.href));mClipboard=mClipboard.replace(/%domain%/gi,fEncodeHTML(location.hostname));mClipboard=mClipboard.replace(/%path%/gi,fEncodeHTML(location.pathname));mClipboard=mClipboard.replace(/%referrer%/gi,fEncodeHTML(document.referrer));mClipboard=mClipboard.replace(/%date%/gi,fEncodeHTML(dDate.toLocaleDateString()));mClipboard=mClipboard.replace(/%time%/gi,fEncodeHTML(dDate.getHours()+':'+('00'+dDate.getMinutes()).slice(-2)));mClipboard=mClipboard.replace(/%timestamp%/gi,fEncodeHTML(dDate.getTime()));mClipboard=mClipboard.replace(/%random%/gi,fEncodeHTML(Math.round(Math.random()*0x7fffffff)));mClipboard=mClipboard.replace(/%hide-start%/gi,'<span style="position:absolute; left:-999999px; top:auto; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); clip:rect(0,0,0,0);">');mClipboard=mClipboard.replace(/%hide-end%/gi,'</span>');mClipboard=mClipboard.replace(/%browser%/gi,fEncodeHTML(navigator.userAgent));mClipboard=mClipboard.replace(/%percent%/gi,'%')}try{if(document.selection&&document.selection.createRange&&document.body&&document.body.createTextRange&&!window.opera){var hSelection=document.selection.createRange();var sSelection=oSettings.trim?$.trim(hSelection.text):hSelection.text;if(sSelection&&!fCopySkip(sSelection)){var sRange=hSelection.htmlText;var sClipboard=typeof mClipboard==typeof function(){}?mClipboard(sRange):mClipboard.replace(/%(copy|paste|clipboard)%/gi,sRange);if(sClipboard!=null){fTrackEvent(sSelection);var hJsFunctions=[document.write,document.writeln];document.write=function(){Â};document.writeln=function(){Â};var hTmpNodeIn=$(oSettings.base_node?oSettings.base_node:'<span></span>').append(''+sClipboard);var hTmpNode=$('<div></div>').css({position:'absolute',left:$('body').scrollLeft()+'px',top:$('body').scrollTop()+'px',width:'1px',height:'1px',overflow:'hidden',clip:'rect(0 0 0 0)'}).append('<br />');hTmpNode.append(hTmpNodeIn);$('body').append(hTmpNode);var hRange=document.body.createTextRange();hRange.moveToElementText(hTmpNodeIn.get(0));hRange.select();window.setTimeout(function(){hTmpNode.remove();document.write=hJsFunctions[0];document.writeln=hJsFunctions[1];try{hSelection.select()}catch(exception){}},1)}}}else if(window.getSelection&&document.createRange){var hSelection=getSelection();var sSelection=oSettings.trim?$.trim(hSelection.toString()):hSelection.toString();if(sSelection&&!fCopySkip(sSelection)){if(hSelection.getRangeAt)var hRange=hSelection.getRangeAt(0);else{var hRange=document.createRange();hRange.setStart(hSelection.anchorNode,hSelection.anchorOffset);hRange.setEnd(hSelection.focusNode,hSelection.focusOffset)}var sRange=$('<span></span>').append(hRange.cloneContents()).html();var sClipboard=typeof mClipboard==typeof function(){}?mClipboard(sRange):mClipboard.replace(/%(copy|paste|clipboard)%/gi,sRange);if(sClipboard!=null){fTrackEvent(sSelection);var hJsFunctions=[document.write,document.writeln];document.write=function(){Â};document.writeln=function(){Â};var hTmpNodeIn=$(oSettings.base_node?oSettings.base_node:'<span></span>').append(''+sClipboard);var hTmpNode=$('<div></div>').css({position:'absolute',left:'-999999px',top:'-999999px',width:'1px',height:'1px',overflow:'hidden',clip:'rect(0,0,0,0)'}).append('<br />');hTmpNode.append(hTmpNodeIn);$('body').append(hTmpNode);if(hSelection.selectAllChildren)hSelection.selectAllChildren(hTmpNodeIn.get(0));else{var hTmpRange=document.createRange();hTmpRange.selectNodeContents(hTmpNodeIn.get(0));hSelection.removeAllRanges();hSelection.addRange(hTmpRange)}window.setTimeout(function(){hTmpNode.remove();document.write=hJsFunctions[0];document.writeln=hJsFunctions[1];try{if(hSelection.setBaseAndExtent)hSelection.setBaseAndExtent(hRange.startContainer,hRange.startOffset,hRange.endContainer,hRange.endOffset);else{hSelection.removeAllRanges();hSelection.addRange(hRange)}}catch(exception){}},1)}}}}catch(exception){}}}});return this};$.copypaste=function(oOptions){return $(function(){$('body').copypaste(oOptions)})}})(jQuery);
$.copypaste({clipboard:'\n%copy%\n<br>\n<address>Read more at <a href="%url%">%url%</a></address>',skip_tags:['INPUT','TEXTAREA'],base_node:'<span></span>',min_chars:0,max_chars:0,word_separator:/[^A-Za-z0-9]+/i,min_words:0,max_words:0});
