/**********************************************************************************************
* ~License~ This portion should accompany the Script for Legal usage and Proper Credits
* author: Swashata
* email: admin@intechgrity.com
* ProjectPage: http://code.google.com/p/recent-filtered-posts-using-jquery-blogspot/
* Instruction at Blog: http://www.intechgrity.com/2009/08/jquery-recent-post-widget-for.html
* Copyright, 2009 inTechgrity
* Licensed under the GNU General Public License v3<http://www.gnu.org/licenses/>
***********************************************************************************************/
function RecentFilteredPost(k){var l=this;var g={BlogURL:"http://www.intechgrity.com",tag:[],maxPost:10,containerId:"",thumbH:32,thumbW:32,ulClass:"itg",aClass:"",onLoad:false,defImg:"http://i29.tinypic.com/2namq9h.png",imgEna:true,imgClass:"recent-image",aPermaTitle:"Permalink to"};g=$.extend({},g,k);if(!g.containerId){g.containerId="#recent-post";document.write('<div id="recent-post"></div>')}var c=$(g.containerId);var j=c.html();var h=0;var i=function(z,q,t,B){var u=t;var p=B;var x=z.feed.entry;if(x){for(var r=0;r<x.length;r++){var o=x[r];var y=o.link;var m="";for(var n=0;n<y.length;n++){if(y[n].rel=="alternate"){m=y[n].href;break}}var v=o.title.$t;var A=("content" in o)?o.content.$t:o.summary.$t;a=A.indexOf("<img");b=A.indexOf('src="',a);t=A.indexOf('"',b+5);d=A.substr(b+5,t-b-5);var w=(a!=-1&&b!=-1&&t!=-1&&d!="")?d:g.defImg;f(v,m,w);if(u=="recent"&&r==x.length-1){$("#iTgSwashata",c).remove()}else{if(u=="filtered"&&p==g.tag.length-1&&r==x.length-1){$("#iTgSwashata",c).remove()}}}}};var f=function(s,p,r){var n=$("li",mainUl);for(var o=0;o<n.length;o++){var m=$("a",n.eq(o));if(m.attr("href")==p){return}}var q="<li><a"+(g.aClass?' class="'+g.aClass+'"':"")+' href="'+p+'" title="'+g.aPermaTitle+" "+s+'">'+(g.imgEna?'<img class="'+g.imgClass+'" height="'+g.thumbH+'" width="'+g.thumbW+'" src="'+r+'"/>':"")+s+"</a></li>";mainUl.append(q)};var e=function(){c.html("");$('<div id="iTgSwashata">'+j+"</div>").appendTo(c);mainUl=$('<ul class="'+g.ulClass+'"/>').appendTo(c);var n=(g.imgEna)?"/feeds/posts/default":"/feeds/posts/summary";if(g.tag.length==0){$.ajax({url:g.BlogURL+n,data:{"max-results":g.maxPost,alt:"json-in-script"},success:function(p,o){i(p,o,"recent",0)},dataType:"jsonp",cache:true})}else{for(var m=0;m<g.tag.length;m++){$.ajax({url:g.BlogURL+n,data:{category:g.tag[m],"max-results":g.maxPost,alt:"json-in-script"},dataType:"jsonp",success:function(p,o){i(p,o,"filtered",h);h++},cache:true})}}};if(g.onLoad){$(window).load(e)}else{$(document).ready(e)}};