// 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(b){b.fn.tweetIt=function(a){function p(){if(a.popup)return q();b("#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(a.popupWidth)+",height="+parseInt(a.popupHeight))}function l(){var c="",d={linkEl:0,animate:0,closeButton:0,popupWidth:0,popupHeight:0};a.link=g;a.from=window.location.href;
for(var e in a)if(!(e in d)&&(typeof a[e]=="string"||typeof a[e]=="number"||typeof a[e]=="boolean")){if(c!="")c+="&";c+=e.replace(/[^a-zA-Z]+/gi,"")+"="+(typeof a[e]=="boolean"?a[e]?"true":"false":encodeURIComponent(a[e]))}return c}function j(){var c=a.animate,d=b("#tweet-it");m||p();if(!a.popup)if(typeof c=="string"&&c.toLowerCase()=="slide")d.slideDown();else typeof c=="string"&&c.toLowerCase()=="fade"?d.fadeIn():d.show()}function k(){if(!a.popup){var c=a.animate,d=b("#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:b("#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;a=b.extend({linkEl:"",popup:false,animate:"slide",hostedBlog:false,closeButton:"Close this panel and cancel tweet",
popupWidth:500,popupHeight:233},a);var g="",i=0,f;if(a.linkEl&&b(a.linkEl).length>0&&b(a.linkEl).html().match(h))g=b(a.linkEl).html();else{h=b("link[rev~='canonical'], link[rel~='canonical'], link[rel~='shortlink'], link[rel~='shorturl'], link[rel~='shorter']");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;b("head script[src^=http://tweet-it]").length>0?b("head script[src^=http://tweet-it]").before('<link rel="stylesheet" href="http://tweet-it.s3.amazonaws.com/tweet-it.css" type="text/css" />'):
b("head").append('<link rel="stylesheet" href="http://tweet-it.s3.amazonaws.com/tweet-it.css" type="text/css" />');b("body").append('<div id="tweet-it" style="display:none"><div><a id="tweet-it-close" title="'+a.closeButton+'" href="javascript://"></a><iframe width="500" height="230" allowtransparency="true" frameborder="0" scrolling="no"></iframe></div></div>');b("#tweet-it-close").click(k);a.hostedBlog&&(this.length>1||window.location.pathname=="/")?this.each(function(){b(this).hide()}):this.each(function(){b(this).click(n)});
document.referrer.match(/^http:\/\/tweet-it\.pongsocket\.com\/connect/i)&&window.parent==window&&j();b.tweetIt=o;b.tweetIt.toggle=n;b.tweetIt.show=j;b.tweetIt.hide=k;return this}})(jQuery);