function zBrowserUtils(){}zBrowserUtils.getWidth=function(){if(window.innerHeight)return window.innerWidth;if(document.documentElement&&document.documentElement.clientWidth)return document.documentElement.clientWidth;if(document.body)return document.body.clientWidth};zBrowserUtils.getHeight=function(){if(window.innerHeight)return window.innerHeight;if(document.documentElement&&document.documentElement.clientHeight)return document.documentElement.clientHeight;if(document.body)return document.body.clientHeight};
zBrowserUtils.resizeAllImages=function(){for(var a=zBrowserUtils.getWidth()*0.6,b=0;b<document.images.length;b++)zBrowserUtils.resizeImage(document.images[b],a)};zBrowserUtils.resizeImage=function(a,b){b||(b=zBrowserUtils.getWidth()*0.6);if(a.width>b)a.width=b};zBrowserUtils.getCenterX=function(a){a=a?a:0;return zBrowserUtils.getWidth()/2-a/2};zBrowserUtils.getCenterY=function(a){a=a?a:0;return zBrowserUtils.getHeight()/2-a/2};
zBrowserUtils.getElementLeft=function(a){var b=a.offsetLeft;for(a=a.offsetParent;a!=null;){b+=a.offsetLeft;a=a.offsetParent}return b};zBrowserUtils.getElementTop=function(a){var b=a.offsetTop;for(a=a.offsetParent;a!=null;){b+=a.offsetTop;a=a.offsetParent}return b};zBrowserUtils.getElementHeight=function(a){return a.offsetHeight};zBrowserUtils.getElementWidth=function(a){return a.offsetWidth};
zBrowserUtils.setElementOpacity=function(a,b){if(b<0||b>10)throw Error("Invalid opacity: "+b);a.style.filter="alpha(style=0,opacity:"+b*10+")";a.style.KHTMLOpacity=b/10;a.style.MozOpacity=b/10;a.style.opacity=b/10};zBrowserUtils.getDocumentHead=function(){return document.getElementsByTagName("head")[0]};
zBrowserUtils.getMouseXY=function(a){var b={left:0,top:0};b.left=a.clientX+document.body.scrollLeft-document.body.clientLeft;b.top=a.clientY+document.body.scrollTop-document.body.clientTop;if(document.body.parentElement&&document.body.parentElement.clientLeft){a=document.body.parentElement;b.left+=a.scrollLeft-a.clientLeft;b.top+=a.scrollTop-a.clientTop}return b};zBrowserUtils.stopProp=function(a){if(!a)a=window.event;a.cancelBubble=true;a.stopPropagation&&a.stopPropagation()};Function.prototype.bind=function(a){var b=this;return function(){return b.apply(a,arguments)}};function zEvent(){this.ma_listeners=[]}zEvent.prototype.subscribe=function(a,b){var c=null;c=b!=null?a.bind(b):a;this.ma_listeners.push({mf_action:a,mo_listener:b,mf_bound:c})};
zEvent.prototype.unsubscribe=function(a,b){for(var c=this.ma_listeners.length-1;c>=0;c--)if(this.ma_listeners[c].mf_action==a&&this.ma_listeners[c].mo_listener==b){this.ma_listeners[c].mf_action=null;this.ma_listeners[c].mo_listener=null;this.ma_listeners.splice(c,1)}};zEvent.prototype.fire=function(a,b){for(var c=0;c<this.ma_listeners.length;c++)this.ma_listeners[c].mf_bound(a,b)};zEvent.prototype.hasListeners=function(){return this.ma_listeners.length!=0};
zEvent.prototype.destroy=function(){this.ma_listeners=null};function zArray(){this.ma_array=[]}zArray.prototype.getLength=function(){return this.ma_array.length};zArray.prototype.shift=function(){return this.ma_array.shift()};zArray.prototype.push=function(a){this.ma_array.push(a)};zArray.prototype.sort=function(a){this.ma_array=this.ma_array.sort(a)};zArray.prototype.toArray=function(){return this.ma_array};zArray.prototype.insert=function(a,b){b==true&&this.contains(a)==true||this.ma_array.push(a)};
zArray.prototype.contains=function(a){for(var b=0;b<this.ma_array.length;b++)if(this.ma_array[b].equals(a))return true;return false};zArray.prototype.notIn=function(a){for(var b=new zArray,c=0;c<this.ma_array.length;c++)a.contains(this.ma_array[c])==false&&b.push(this.ma_array[c]);return b};zArray.prototype.inArray=function(a){for(var b=new zArray,c=0;c<this.ma_array.length;c++)a.contains(this.ma_array[c])==true&&b.push(this.ma_array[c]);return b};zArray.prototype.getIndex=function(a){return this.ma_array[a]};
zArray.prototype.getIterator=function(){return new zArrayIterator(this)};function zArrayIterator(a){this.mn_nextIndex=0;this.mo_zArray=a}zArrayIterator.prototype.hasNext=function(){return this.mn_nextIndex<=this.mo_zArray.getLength()-1};zArrayIterator.prototype.getNext=function(){return this.mo_zArray.getIndex(this.mn_nextIndex++)};zArrayIterator.prototype.reset=function(){this.mn_nextIndex=0};function zSortedList(){}zSortedList.prototype=new zArray;
zSortedList.prototype.contains=function(a){return this.search(a)!=-1};zSortedList.prototype.insert=function(a,b){b&&this.binarySeach(a)!=-1||this.splice(this.binarySearch(a),1,a)};zSortedList.prototype.search=function(a,b){for(var c=this.ma_array.length,d=-1,e;c-d>1;)if(this.ma_array[e=c+d>>1].compareTo(a)<0)d=e;else c=e;return!this.ma_array[c].equals(a)?b?c:-1:c};function zList(){}zList.prototype=[];
zList.prototype.insert=function(a,b){if(this.containsKey(a))throw Error("List already contains key: "+a);this.push({key:a,value:b})};zList.prototype.remove=function(a){if(!this.containsKey(a))throw Error("List doesn't contain key: "+a);this.splice(this.indexOf(a,false),1)};zList.prototype.containsKey=function(a){return this.indexOf(a,false)>=0};zList.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b].key==a)return b;return-1};
zList.prototype.getValue=function(a){a=this.indexOf(a,false);return a>=0?this[a].value:null};zList.prototype.getKeys=function(){return this.getArray("key")};zList.prototype.getValues=function(){return this.getArray("value")};zList.prototype.getArray=function(a){for(var b=[],c=0;c<this.length;c++)b.push(this[c][a]);return b};zList.prototype.getLength=function(){return this.length};zList.prototype.removeLast=function(){return this.shift()};function zLinkFormatter(a){this.mo_formatter=a}
zLinkFormatter.prototype.format=function(a){var b=a;a=" "+String.fromCharCode(260)+" ";var c=" "+String.fromCharCode(261)+" ",d=/<a[^>]*>.*<\/a>/ig,e=/<\/?(?:[A-Z]\w*)\b[^>]*>/ig,f=RegExp(a,"g"),g=RegExp(c,"g"),h=b.match(e),i=b.match(d);b=b.replace(d,c);b=b.replace(e,a);b=b.split(" ");for(d=0;d<b.length;d++)b[d]=zFormatterUtils.isURL(b[d])?b[d].replace(zFormatterUtils.mr_url,this.replaceURL.bind(this)):b[d].replace("&#032;"," ","g");b=b.join(" ");if(f.test(b)){f=b.match(f);for(d=0;d<f.length;d++)b=
b.replace(a,h[d])}if(g.test(b)){f=b.match(g);for(d=0;d<f.length;d++)b=b.replace(c,i[d])}b=b.replace(/<a\s/gi,'<a target="_blank" ');return this.mo_formatter!=null?this.mo_formatter.format(b):b};zLinkFormatter.prototype.replaceURL=function(a,b,c){a=b;c=(c=c)?c+" - "+a:a;b=a.length>50?a.substr(0,50)+"...":a;if(a.indexOf("://")==-1)a="http://"+a;return'<a href="'+a+'" title="'+c+'">'+b+"</a>"};function zFormatterUtils(){}
zFormatterUtils.replaceURLSpaces=function(a){return a.replace(/((?:ft|ht)tp(?:s)?:\/\/|www)[^\/]+[^\.]+\.(?:htm|php|asp|jsp|jpg|jpeg|jpe|gif|png|bmp|wav)/gi,function(b){return b.replace(" ","%20","g")})};zFormatterUtils.replaceAsciiSpaces=function(a){return a.replace(" ","&#032;","g")};zFormatterUtils.mr_url=/^(?:\s+)?((?:(?:ft|ht)tps?:\/\/)?(?:(?:[^\s\.@\/]+\.)+(?:(?:com|edu|biz|gov|info|mil|net|org|name|pro|aero|coop|jobs|tel|travel|asia|[a-z]{2})\b)|(?:\d{1,3}\.){3}\d{1,3}\b)\/?(?:[!\w\-\.,\@\?\^=%&;:\/\*\~\+#\(\)]*[\w\-\@?^=%&;\/\~\+#\(\)])?)(?:\[(\S*)\])?(?:\s+)?$/gi;
zFormatterUtils.mr_img=/^(?:\s+)?((?:(?:ft|ht)tps?:\/\/)?[\w\-_]+(?:\.[\w\-_]+)+(?:[!\w\-\.,\@\?\^=%&;:\*\/~\+#\(\)]*[\w\-\@\?^=%&;\/~\+#\(\)])\.(?:jpg|jpeg|jpe|gif|png|bmp))(?:[^\s\[]*)?(?:\[(\S*)\])?(?:\s+)?$/gi;zFormatterUtils.mr_media=/^(?:\s+)?((?:(?:ft|ht)tps?:\/\/)?[\w\-_]+(?:\.[\w\-_]+)+(?:[!\w\-\.,\@\?\^=%&;:\*\/~\+#\(\)]*[\w\-\@\?^=%&;\/~\+#\(\)])\.(?:wav|wave|mp3|mp4|wmv|wma|ogv))(?:[^\s\[]*)?(?:\[(\S*)\])?(?:\s+)?$/gi;zFormatterUtils.isURL=function(a){return zFormatterUtils.mr_url.test(a)};
zFormatterUtils.isImgURL=function(a){return zFormatterUtils.mr_img.test(a)};zFormatterUtils.isMediaURL=function(a){return zFormatterUtils.mr_media.test(a)};zFormatterUtils.splitLongWord=function(a,b){if(a.length>b)a=a.substr(0,b)+"-<br />"+zFormatterUtils.splitLongWord(a.substring(b,a.length),b);return a};
zFormatterUtils.bbCodeToHTML=function(a){var b=a;b=b.replace(/\[list\](.+?)\[\/list\]/gi,"<ul><li>$1</ul>");b=b.replace(/\[img\](.+?)\[\/img\]/gi,'<img src="$1" alt="$1" title="$1" />');b=b.replace(/\[(b|i|u|code)\](.+?)\[\/\1\]/gi,"<$1>$2</$1>");b=b.replace(/\[color=\"(.+?)\"\](.+?)\[\/color\]/gi,'<span style="color:$1">$2</span>');b=b.replace(/\[size=\"(.+?)\"\](.+?)\[\/size\]/gi,'<span style="font-size:$1%">$2</span>');b=b.replace(/\[url=\"(.+?)\"\](.+?)\[\/url\]/gi,'<a href="$1">$2</a>');b=b.replace(/\[mail=\"(.+?)\"\](.+?)\[\/mail\]/gi,
'<a href="mailto:$1">$2</a>');return b!=a?zFormatterUtils.bbCodeToHTML(b):b};function zTweet(a){this.mo_data=a}zTweet.create=function(a){return new zTweet(a)};zTweet.prototype.equals=function(a){return this.mo_data.id==a.mo_data.id};zTweet.prototype.getId=function(){return this.mo_data.id};zTweet.prototype.getFromUserName=function(){return this.mo_data.from_user};zTweet.prototype.getFromUserId=function(){return this.mo_data.from_user_id};zTweet.prototype.getToUserName=function(){return this.mo_data.to_user};zTweet.prototype.getToUserId=function(){return this.mo_data.to_user_id};
zTweet.prototype.getText=function(){return this.mo_data.text};zTweet.prototype.getProfileImageURL=function(){return this.mo_data.profile_image_url};zTweet.prototype.getFromUserImageURL=function(){return this.mo_data.profile_image_url};zTweet.prototype.getFromUserFeedURL=function(){return"http://twitter.com/"+this.getFromUserName()};zTweet.prototype.getToUserFeedURL=function(){return"http://twitter.com/"+this.getToUserName()};zTweet.prototype.getCreatedDate=function(){return new Date(this.mo_data.created_at)};
zTweet.prototype.getTimeSinceCreated=function(){var a=(new Date).getTime()-this.getCreatedDate().getTime(),b=Math.floor(a/1E3/60/60/24);a-=b*1E3*60*60*24;var c=Math.floor(a/1E3/60/60);a-=c*1E3*60*60;var d=Math.floor(a/1E3/60);a-=d*1E3*60;return{days:b,hours:c,minutes:d,seconds:Math.floor(a/1E3)}};
zTweet.prototype.getTimeSinceText=function(){var a=this.getTimeSinceCreated(),b="";if(a.days==1)b+=a.days+" day ";else if(a.days>1)b+=a.days+" days ";if(a.hours==1)b+=a.hours+" hour ";else if(a.hours>1)b+=a.hours+" hours ";else if(a.hours<1){if(a.minutes>0)b+=a.minutes+" minutes ";if(a.minutes<1&&a.seconds>0)b+=a.seconds+" seconds "}b+="ago";return b};function zTwitterSearcher(){}zTwitterSearcher.ms_twitterSearchURL="http://search.twitter.com/search.json";
zTwitterSearcher.searchCallBack=function(a,b){for(var c=[],d=null,e=null,f=0;f<a.length;f++){d=new zTweet.create(a[f]);c.push(d);if(e==null)e=d.getId()}b({results:c,lastId:e})};zTwitterSearcher.search=function(a,b){var c=zTwitterSearcher.ms_twitterSearchURL+"?callback=?",d;for(d in a)if(a[d]!=null)switch(d){case "maxResults":c+="&rpp="+a[d];break;case "sinceID":c+="&since_id="+a[d];break;case "query":c+="&q="+a[d]}jQuery.getJSON(c,function(e){zTwitterSearcher.searchCallBack(e.results,b)})};
function zTwitterSearchFeed(a){this.ms_query=a;this.mo_tweets=new zArray;this.NewTweet=new zEvent;this.SearchFinished=new zEvent;this.ms_lastId=null;this.ms_maxResults=20;this.mn_intervalTime=this.mn_intervalHandle=null;this.mb_searchOnInterval=false;this.SearchFinished.subscribe(this.onSearchFinished,this)}
zTwitterSearchFeed.prototype.startSearch=function(a,b){var c=this;this.mb_searchOnInterval=true;this.mn_intervalTime=a;b==null&&c.search();this.mn_intervalHandle=setTimeout(function(){c.search()},a)};zTwitterSearchFeed.prototype.stopSearch=function(){this.mb_searchOnInterval=false;this.mn_intervalHandle=stopTimeout(this.mn_intervalHandle)};zTwitterSearchFeed.prototype.onSearchFinished=function(){this.mb_searchOnInterval&&this.startSearch(this.mn_intervalTime,true)};
zTwitterSearchFeed.prototype.search=function(){var a=this;zTwitterSearcher.search({query:this.ms_query,maxResults:this.mn_maxResults,sinceId:this.ms_lastId},function(b){if(b.results==null)alert("Outta tweets");else{var c=b.results;a.ms_lastId=b.lastId;for(b=c.length-1;b>=0;b--)a.addTweet(c[b]);a.SearchFinished.fire()}})};zTwitterSearchFeed.prototype.addTweet=function(a){if(a!=null&&!this.mo_tweets.contains(a)){this.mo_tweets.push(a);this.NewTweet.fire({tweet:a})}};
function zTwitterFormatter(a){this.mo_formatter=a}zTwitterFormatter.prototype.format=function(a){a=a.replace(/@(\w+)/gi,'@<a class="tweetMention" href="http://twitter.com/$1">$1</a>');a=a.replace(/#(\w+)/gi,'<a class="tweetHashtag" href="http://search.twitter.com/search?q=&tag=$1">#$1</a>');return this.mo_formatter!=null?this.mo_formatter.format(a):a};function zPanelManager(){this.mo_panels=[]}zPanelManager.prototype.addPanel=function(a){this.mo_panels.push(a);a.Opening.subscribe(this.onPanelOpening,this)};zPanelManager.prototype.onPanelOpening=function(a,b){for(var c=0;c<this.mo_panels.length;c++)this.mo_panels[c]!=b&&this.mo_panels[c].hide()};
function zPanel(a,b,c){this.Opening=new zEvent;this.mo_panel=document.getElementById(a);this.mo_trigger=document.getElementById(b);this.mb_neverClose=c!=null?c:false;this.mn_originalTop=50;this.mn_hiddenTop=0-jQuery(this.mo_panel).height()-100;this.mb_ready=this.mb_firstDisplay=true;this.mb_hidden=false;var d=this;jQuery(this.mo_trigger).click(function(){d.toggle();return false});this.hide()}
zPanel.prototype.show=function(){if(!(this.mb_ready==false||this.mb_hidden==false)){this.mb_ready=false;this.Opening.fire();if(this.mb_firstDisplay==true){jQuery(this.mo_panel).css("visibility","visible");this.mb_firstDisplay=false}this.mb_neverClose==true?jQuery(this.mo_panel).animate({top:this.mn_originalTop},500):jQuery(this.mo_panel).show("fast");jQuery(this.mo_trigger).addClass("active");this.mb_hidden=false;this.mb_ready=true}};
zPanel.prototype.hide=function(){if(!(this.mb_ready==false||this.mb_hidden==true)){this.mb_ready=false;this.mb_neverClose==true?jQuery(this.mo_panel).animate({top:this.mn_hiddenTop},500):jQuery(this.mo_panel).hide("fast");jQuery(this.mo_trigger).removeClass("active");this.mb_ready=this.mb_hidden=true}};zPanel.prototype.toggle=function(){this.mb_hidden==true?this.show():this.hide()};function zTumblrFeed(){this.mo_feeds=[]}zTumblrFeed.prototype.addFeed=function(a,b){this.mo_feeds.push({subdomain:a,tag:b})};
zTumblrFeed.prototype.draw=function(a,b){for(var c=function(e){for(var f="",g=0;g<=e.posts.length-1;g++){var h=new zTumblrPost(e.posts[g]);f+=h.getHTML()}document.getElementById(a).innerHTML+=f;f&&b()},d=0;d<=this.mo_feeds.length-1;d++)jQuery.getJSON("http://"+this.mo_feeds[d].subdomain+".tumblr.com/api/read/json?callback=?"+(this.mo_feeds[d].tag?"&tagged="+this.mo_feeds[d].tag:""),c)};function zTumblrPost(a){this.mo_data=a}
zTumblrPost.prototype.getHTML=function(){var a="";switch(this.mo_data.type){case "photo":a+='<div class="tumblrPhotoPost"><a href="'+this.mo_data.url+'" target="_blank"><img src="'+this.mo_data["photo-url-75"]+'"></a></div>'}return a};
