// LIKE IT? TWEET IT!
// An app for your blog
// A script that depends on jQuery
// By Andy Graulund
// He has a blog on http://pongsocket.com/

// Copyright (c) 2010 Andy Graulund

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Uncompressed code is: tweet-it-uc.js
(function(a){a.fn.tweetIt=function(b){function p(){if(b.popup)return q();a("#tweet-it iframe")[0].src="http://tweet-it.pongsocket.com/tweetframe?"+l();m=true}function q(){window.open("http://tweet-it.pongsocket.com/tweetframe?"+l(),"likeItTweetIt","status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,width="+parseInt(s.popupWidth)+",height="+parseInt(s.popupHeight))}function l(){var c="",d={linkEl:0,animate:0,closeButton:0,popupWidth:0,popupHeight:0};b.link=g;b.from=window.location.href; for(var e in b)if(!(e in d)&&(typeof b[e]=="string"||typeof b[e]=="number"||typeof b[e]=="boolean")){if(c!="")c+="&";c+=e.replace(/[^a-zA-Z]+/gi,"")+"="+(typeof b[e]=="boolean"?b[e]?"true":"false":encodeURIComponent(b[e]))}return c}function j(){var c=b.animate,d=a("#tweet-it");m||p();if(typeof c=="string"&&c.toLowerCase()=="slide")d.slideDown();else typeof c=="string"&&c.toLowerCase()=="fade"?d.fadeIn():d.show()}function k(){var c=b.animate,d=a("#tweet-it");if(typeof c=="string"&&c.toLowerCase()== "slide")d.slideUp();else typeof c=="string"&&c.toLowerCase()=="fade"?d.fadeOut():d.hide()}function n(c){(typeof c=="boolean"?c:a("#tweet-it").is(":hidden"))?j():k();return false}var o={},h=/https?:\/\/((([-a-z0-9_]+\.)?[a-z0-9][-a-z0-9]*\.[a-z]+(\.[a-z]{2,2})?)|(www\.[a-z0-9][-a-z0-9]*\.[a-z]+(\.[a-z]{2,2})?))\/?[a-zA-Z0-9.,_\/~#&=:;%+?!-]+[a-zA-Z0-9\/#=?]{1,1}/,m=false;b=a.extend({linkEl:"",popup:false,animate:"slide",hostedBlog:false,closeButton:"Close this panel and cancel tweet",popupWidth:500, popupHeight:233},b);var g="",i=0,f;if(b.linkEl&&a(b.linkEl).length>0&&a(b.linkEl).html().match(h))g=a(b.linkEl).html();else{h=a("link[rev~='canonical'],link[rel~='canonical'],link[rel~='shortlink'],link[rel~='shorturl']");h.length>0&&h.each(function(){f=this.href;if((i==0||i!=0&&i>f.length)&&!(f==window.location.href&&f.length>32)){g=f;i=f.length}})}o.link=g;a("head script[src^=http://tweet-it]").length>0?a("head script[src^=http://tweet-it]").before('<link rel="stylesheet" href="http://tweet-it.s3.amazonaws.com/tweet-it.css" type="text/css" />'): a("head").append('<link rel="stylesheet" href="http://tweet-it.s3.amazonaws.com/tweet-it.css" type="text/css" />');a("body").append('<div id="tweet-it" style="display:none"><div><a id="tweet-it-close" title="'+b.closeButton+'" href="javascript://"></a><iframe width="500" height="230" allowtransparency="true" frameborder="0" scrolling="no"></iframe></div></div>');a("#tweet-it-close").click(k);b.hostedBlog&&(this.length>1||window.location.pathname=="/")?this.each(function(){a(this).hide()}):this.each(function(){a(this).click(n)}); document.referrer.match(/^http:\/\/tweet-it\.pongsocket\.com\/connect/i)&&window.parent==window&&j();a.tweetIt=o;a.tweetIt.toggle=n;a.tweetIt.show=j;a.tweetIt.hide=k;return this}})(jQuery);