
var ZeroClipboard={moviepath:'http://localhost/jquery.zeroclipboard/scripts/ZeroClipboard.swf',objects:[],pairs:{},dispatch:function(id,eventName,args){var eventName=eventName.toString().toLowerCase().replace(/^on/,'');switch(eventName){case'load':var movie=document.getElementById('zeroclipboard_swf_'+id);if(!movie){setTimeout(function(){ZeroClipboard.dispatch(id,'load',null);},1);return;}
if(!$(ZeroClipboard.pairs[id]).data("zeroclipboard_ready")&&navigator.userAgent.match(/Firefox/)&&navigator.userAgent.match(/Windows/)){setTimeout(function(){ZeroClipboard.dispatch(id,'load',null);},100);$(this.pairs[id]).data("zeroclipboard_ready",true);return;}
$(this.pairs[id]).data("zeroclipboard_ready",true);ZeroClipboard.update(id);break;case'complete':break;case'mouseover':$(this.pairs[id]).trigger('mouseover');break;case'mouseout':$(this.pairs[id]).trigger('mouseout');if($(this.pairs[id]).data('zeroclipboard_downfix')){$(this.pairs[id]).trigger('mouseup');}
break;case'mouseup':$(this.pairs[id]).trigger('mouseup');$(this.pairs[id]).data('zeroclipboard_downfix',false);break;case'mousedown':$(this.pairs[id]).data('zeroclipboard_downfix',true);$(this.pairs[id]).trigger('mousedown');break;}},update:function(id){var original=this.pairs[id];if($(original).data("zeroclipboard_ready")){var flash=document.getElementById('zeroclipboard_swf_'+id);if($(original).data('zeroclipboard_resize')){var elemWidth=$(original).outerWidth();var elemHeight=$(original).outerHeight();var elemPos=$(original).offset();$(flash).attr('width',elemWidth).attr('height',elemHeight);$(flash).parent().css({'width':elemWidth+'px','height':elemHeight+'px','top':elemPos.top,'left':elemPos.left});$(original).data('zeroclipboard_resize',false);}
flash.setText($(original).data('zeroclipboard_text'));flash.setHandCursor($(original).data('zeroclipboard_hand'));}else{}}};(function($){(function(){var ev=new $.Event('remove'),orig=$.fn.remove;$.fn.remove=function(){$(this).trigger(ev);orig.apply(this,arguments);}})();$(window).resize(function(){$.each(ZeroClipboard.pairs,function(id,contents){if(contents==null)return;$(contents).data('zeroclipboard_resize',true);ZeroClipboard.update(id);});});$("*").bind('remove',function(){$(window).resize();});$.fn.zeroclipboarduid=function(fnoptions){if($(this).length<1)return;var options={'prefix':'','length':8,'chars':"0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"};if(typeof fnoptions!="undefined"){$.extend(options,fnoptions);}
if(typeof prefix=="undefined"){prefix="";}
return this.each(function(){if($(this).attr('id')!='')return $;var retrn='';var id='#';do{retrn='';var first=true;for(var i=0;i<options.length;i++){var rnum=Math.floor(Math.random()*options.chars.length);retrn+=options.chars.substring(rnum,rnum+1);}
id='#'+retrn;}while($('#'+retrn).length>0||retrn.match(/^[A-Za-z].*/)!=retrn);$(this).attr('id',retrn);return $;});}
$.fn.zeroclipboard=function(fnoptions){if($(this).length<1)return;var options={'destroy':false};if(typeof fnoptions!="undefined"){$.extend(options,fnoptions);}
var update=$(this).data('zeroclipboard_id');var id=null;if(!!update&&options.destroy){var id=$(this).data('zeroclipboard_id');$('#zeroclipboard_swf_'+id).parent().remove();ZeroClipboard.pairs[id]=null;}else{if(!update){$(this).zeroclipboarduid();id=$(this).attr('id');$(this).data('zeroclipboard_ready',false).data('zeroclipboard_text',"Set something to copy!").data('zeroclipboard_resize',false).data('zeroclipboard_hand',false);$(this).data('zeroclipboard_id',id);ZeroClipboard.pairs[id]=this;var elemWidth=$(this).outerWidth();var elemHeight=$(this).outerHeight();var elemPos=$(this).offset();var flashObj=null;$('<div></div>').attr('id','zeroclipboard_swf_'+id).appendTo('body');swfobject.embedSWF(ZeroClipboard.moviepath,'zeroclipboard_swf_'+id,elemWidth,elemHeight,"9.0.0","",{'id':id,'width':elemWidth,'height':elemHeight},{wmode:'transparent',bgcolor:'#ffffff',quality:'best',loop:'false',allowscriptaccess:'always',allowfullscreen:'false'});var flashCont=$('<div></div>').css({'width':elemWidth+'px','height':elemHeight+'px','position':'absolute','left':elemPos.left,'top':elemPos.top})
$('#zeroclipboard_swf_'+id).appendTo(flashCont);ZeroClipboard.zindex++;$(flashCont).appendTo('body');$(this).resize(function(){$(this).data('zeroclipboard_resize',true);ZeroClipboard.update(id);});$(this).bind('remove',function(event){var id=$(this).data('zeroclipboard_id');$('#zeroclipboard_swf_'+id).parent().remove();ZeroClipboard.pairs[id]=null;});}else{id=$(this).data('zeroclipboard_id');}
if(typeof options.text!="undefined"){$(this).data('zeroclipboard_text',options.text);}
if(typeof options.hand!="undefined"){$(this).data('zeroclipboard_hand',options.hand);}
ZeroClipboard.update(id);}
return this.each(function(){return $;});};})(jQuery);
