ZeroClipboard.setMoviePath( 'http://www.spendlessonline.co.uk/wp-content/plugins/extra-coupons/js/ZeroClipboard.swf' ); var clip, codeClip; jQuery(document).ready(function() { var link, coupon, couponCode, couponButton; jQuery('.xtraCoupon').each(function() { jQuery(this).mouseover(function() { if(clip) { clip.destroy(); } if(codeClip) { codeClip.destroy(); } link = jQuery(this).find('.xtraCouponLink').attr('href'); couponCode = jQuery(this).find('.xtraCouponCode').text(); couponButton = jQuery(this).find('.xtraCouponLinkBox')[0]; coupon = this; clip = new ZeroClipboard.Client(); clip.setText(couponCode); clip.setHandCursor(true); clip.glue(couponButton); codeClip = new ZeroClipboard.Client(); codeClip.setText(couponCode); codeClip.setHandCursor(true); codeClip.glue(jQuery(this).find('.xtraCouponCode')[0]); codeClip.setCSSEffects(true); clip.addEventListener('onComplete', function() { clipOnComplete(coupon, link); }); codeClip.addEventListener('onComplete', function() { clipOnComplete(coupon, link); }); }); }); }); function clipOnComplete(couponCode, link) { jQuery(couponCode).find('.xtraCouponCover').css('display','none'); var merchantWindow = window.open(link, '_blank', 'toolbar=1,location=1,directories=1,scrollbars=1,resizable=1,status=1,menubar=1'); if (typeof merchantWindow === "object") merchantWindow.blur(); }