// Simple Set Clipboard System
// Author: Joseph Huckaby
var ZeroClipboard_TableTools={version:"1.0.4-TableTools2",clients:{},// registered upload clients on page, indexed by id
moviePath:"",// URL to movie
nextId:1,// ID of next movie
$:function(e){// simple DOM lookup utility function
return"string"==typeof e&&(e=document.getElementById(e)),e.addClass||(// extend element with a few useful methods
e.hide=function(){this.style.display="none"},e.show=function(){this.style.display=""},e.addClass=function(e){this.removeClass(e),this.className+=" "+e},e.removeClass=function(e){this.className=this.className.replace(new RegExp("\\s*"+e+"\\s*")," ").replace(/^\s+/,"").replace(/\s+$/,"")},e.hasClass=function(e){return!!this.className.match(new RegExp("\\s*"+e+"\\s*"))}),e},setMoviePath:function(e){// set path to ZeroClipboard.swf
this.moviePath=e},dispatch:function(e,t,i){// receive event from flash movie, send to client
var s=this.clients[e];s&&s.receiveEvent(t,i)},register:function(e,t){// register new client to receive events
this.clients[e]=t},getDOMObjectPosition:function(e){// get absolute coordinates for dom element
var t={left:0,top:0,width:e.width?e.width:e.offsetWidth,height:e.height?e.height:e.offsetHeight};for(""!=e.style.width&&(t.width=e.style.width.replace("px","")),""!=e.style.height&&(t.height=e.style.height.replace("px",""));e;)t.left+=e.offsetLeft,t.top+=e.offsetTop,e=e.offsetParent;return t},Client:function(e){// constructor for new simple upload client
this.handlers={},// unique ID
this.id=ZeroClipboard_TableTools.nextId++,this.movieId="ZeroClipboard_TableToolsMovie_"+this.id,// register client with singleton to receive flash events
ZeroClipboard_TableTools.register(this.id,this),// create movie
e&&this.glue(e)}};ZeroClipboard_TableTools.Client.prototype={id:0,// unique ID for us
ready:!1,// whether movie is ready to receive events or not
movie:null,// reference to movie object
clipText:"",// text to copy to clipboard
fileName:"",// default file save name
action:"copy",// action to perform
handCursorEnabled:!0,// whether to show hand cursor, or default pointer cursor
cssEffects:!0,// enable CSS mouse effects on dom container
handlers:null,// user event handlers
sized:!1,glue:function(e,t){// glue to DOM element
// elem can be ID or actual DOM element object
this.domElement=ZeroClipboard_TableTools.$(e);// float just above object, or zIndex 99 if dom element isn't set
var i=99;this.domElement.style.zIndex&&(i=parseInt(this.domElement.style.zIndex)+1);// find X/Y position of domElement
var s=ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);// create floating DIV above element
this.div=document.createElement("div");var o=this.div.style;o.position="absolute",o.left="0px",o.top="0px",o.width=s.width+"px",o.height=s.height+"px",o.zIndex=i,"undefined"!=typeof t&&""!=t&&(this.div.title=t),0!=s.width&&0!=s.height&&(this.sized=!0),// style.backgroundColor = '#f00'; // debug
this.domElement&&(this.domElement.appendChild(this.div),this.div.innerHTML=this.getHTML(s.width,s.height))},positionElement:function(){var e=ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement),t=this.div.style;if(t.position="absolute",//style.left = (this.domElement.offsetLeft)+'px';
//style.top = this.domElement.offsetTop+'px';
t.width=e.width+"px",t.height=e.height+"px",0!=e.width&&0!=e.height){this.sized=!0;var i=this.div.childNodes[0];i.width=e.width,i.height=e.height}},getHTML:function(e,t){// return HTML for movie
var i="",s="id="+this.id+"&width="+e+"&height="+t;if(navigator.userAgent.match(/MSIE/)){// IE gets an OBJECT tag
var o=location.href.match(/^https/i)?"https://":"http://";i+=''}else// all other browsers get an EMBED tag
i+='';return i},hide:function(){// temporarily hide floater offscreen
this.div&&(this.div.style.left="-2000px")},show:function(){// show ourselves after a call to hide()
this.reposition()},destroy:function(){// destroy control and floater
if(this.domElement&&this.div){this.hide(),this.div.innerHTML="";var e=document.getElementsByTagName("body")[0];try{e.removeChild(this.div)}catch(t){}this.domElement=null,this.div=null}},reposition:function(e){if(// reposition our floating div, optionally to new container
// warning: container CANNOT change size, only position
e&&(this.domElement=ZeroClipboard_TableTools.$(e),this.domElement||this.hide()),this.domElement&&this.div){var t=ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement),i=this.div.style;i.left=""+t.left+"px",i.top=""+t.top+"px"}},clearText:function(){// clear the text to be copy / saved
this.clipText="",this.ready&&this.movie.clearText()},appendText:function(e){// append text to that which is to be copied / saved
this.clipText+=e,this.ready&&this.movie.appendText(e)},setText:function(e){// set text to be copied to be copied / saved
this.clipText=e,this.ready&&this.movie.setText(e)},setCharSet:function(e){// set the character set (UTF16LE or UTF8)
this.charSet=e,this.ready&&this.movie.setCharSet(e)},setBomInc:function(e){// set if the BOM should be included or not
this.incBom=e,this.ready&&this.movie.setBomInc(e)},setFileName:function(e){// set the file name
this.fileName=e,this.ready&&this.movie.setFileName(e)},setAction:function(e){// set action (save or copy)
this.action=e,this.ready&&this.movie.setAction(e)},addEventListener:function(e,t){// add user event listener for event
// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
e=e.toString().toLowerCase().replace(/^on/,""),this.handlers[e]||(this.handlers[e]=[]),this.handlers[e].push(t)},setHandCursor:function(e){// enable hand cursor (true), or default arrow cursor (false)
this.handCursorEnabled=e,this.ready&&this.movie.setHandCursor(e)},setCSSEffects:function(e){// enable or disable CSS effects on DOM container
this.cssEffects=!!e},receiveEvent:function(e,t){// special behavior for certain events
switch(// receive event from flash
e=e.toString().toLowerCase().replace(/^on/,"")){case"load":if(// movie claims it is ready, but in IE this isn't always the case...
// bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function
this.movie=document.getElementById(this.movieId),!this.movie){var i=this;return setTimeout(function(){i.receiveEvent("load",null)},1),void 0}// firefox on pc needs a "kick" in order to set these in certain cases
if(!this.ready&&navigator.userAgent.match(/Firefox/)&&navigator.userAgent.match(/Windows/)){var i=this;return setTimeout(function(){i.receiveEvent("load",null)},100),this.ready=!0,void 0}this.ready=!0,this.movie.clearText(),this.movie.appendText(this.clipText),this.movie.setFileName(this.fileName),this.movie.setAction(this.action),this.movie.setCharSet(this.charSet),this.movie.setBomInc(this.incBom),this.movie.setHandCursor(this.handCursorEnabled);break;case"mouseover":this.domElement&&this.cssEffects&&//this.domElement.addClass('hover');
this.recoverActive&&this.domElement.addClass("active");break;case"mouseout":this.domElement&&this.cssEffects&&(this.recoverActive=!1,this.domElement.hasClass("active")&&(this.domElement.removeClass("active"),this.recoverActive=!0));break;case"mousedown":this.domElement&&this.cssEffects&&this.domElement.addClass("active");break;case"mouseup":this.domElement&&this.cssEffects&&(this.domElement.removeClass("active"),this.recoverActive=!1)}// switch eventName
if(this.handlers[e])for(var s=0,o=this.handlers[e].length;o>s;s++){var a=this.handlers[e][s];"function"==typeof a?// actual function reference
a(this,t):"object"==typeof a&&2==a.length?// PHP style object + method, i.e. [myObject, 'myMethod']
a[0][a[1]](this,t):"string"==typeof a&&// name of function
window[a](this,t)}}};