/* Author : Mike @ moretechtips.net
Blog : http://www.moretechtips.net
Project: http://code.google.com/p/jquery-ed-google-blog-bar/
Copyright 2009 [Mike @ moretechtips.net]
Licensed under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
//default auto. mode: if 'y' then all div with class='my-blog-bar' will be auto. loaded unless stated otherwise
//set it to 'n' and auto mode is disabled by default
var _myBlogBar_Auto='y';
(function($){
$.fn.myBlogBar=function(allOptions){
// This default options will apply on all matched elements unless element has his own options
// Set your key, set Debug to 'true' to try then set 'false' when you done
var defaults={
key:'ABQIAAAATuS3ry9bXmbx3b8LVYTwzhToXAi_TZLm6yAVxvqAS_CRnZJK1BSDalcFUEDvtquihHPhB0zAH8MMcQ'
,debug:true
,blogURL:'italib.blogspot.com'
,q:'italib'
,defaultQ:''
,v:'1.0'
,rsz:'large'
,hl:'en'
,scoring:''
,duration:4000
,title:''
,content:false
,visibleURL:false
,powered:'
بواسطة

'
};
allOptions=$.extend({},defaults,allOptions);return this.each(function(){var count=0,ul=null;var div=$(this);var op=allOptions;if(div.attr('options')){try{op=eval('('+div.attr('options')+')');}catch(e){if(op.debug)div.html(''+e+'');return;}
op=$.extend({},defaults,op);}
var searchLoaded=function(json,status){if(!json.responseData){if(op.debug)div.html('Error: '+json.responseDetails+'');return;}
if(!json.responseData.results)return;var rs=json.responseData.results;count=rs.length;var inDiv=$('').appendTo(div.html(''));if(op.title)$(''+op.title+'
').appendTo(inDiv);ul=$('').appendTo(inDiv);for(var i=0;i'+' '+rs[i].titleNoFormatting+''+' - '+by+''+(op.content?''+rs[i].content+'
':'')+(op.visibleURL?''+rs[i].blogUrl+'
':'')+'').appendTo(ul)};if(op.powered)$(op.powered).appendTo(div);if(op.duration)fadeOut();}
var visible=-1;var fadeOut=function(){if(visible>-1)$('li',ul).eq(visible).fadeOut(500,fadeIn);else fadeIn();}
var fadeIn=function(){visible++;if(visible>=count)visible=0;$('li',ul).eq(visible).fadeIn(500,fadeStill);}
var fadeStill=function(){$('li',ul).eq(visible).animate({opacity:1},op.duration,"linear",fadeOut);}
var formatDate=function(dstr){var dat=new Date(),tody=new Date();dat.setTime(Date.parse(dstr));var td=tody.getDate(),tm=tody.getMonth()+1,ty=tody.getFullYear(),th=tody.getHours();var d=dat.getDate(),m=dat.getMonth()+1,y=dat.getFullYear(),h=dat.getHours();if(y==ty&&m==tm&&d==td)return(th-h)+'ساعة مضت';else return m+'/'+d+'/'+y;}
var init=function(){var tags=[];if(!op.q)$('a[rel="tag"]').each(function(){var tag=$.trim($(this).text().replace(/\n/g,''));if($.inArray(tag,tags)==-1)tags[tags.length]=tag;});if(tags.length>0)op.q=tags.join(" | ");if(!op.q)op.q=op.defaultQ;if(!op.q)return;if(op.blogURL)op.q+=" blogurl:"+op.blogURL;var data={hl:op.hl,q:op.q,v:op.v,rsz:op.rsz,key:op.key};if(op.scoring)data.scoring=op.scoring;$.ajax({url:'http://ajax.googleapis.com/ajax/services/search/blogs',data:data,success:searchLoaded,dataType:'jsonp'});}
init();});}})(jQuery);var autoLoad=function(){if(window.myBlogBar_Auto)_myBlogBar_Auto=window.myBlogBar_Auto;if(window.myBlogBar_Auto=='n')return;$(document).ready(function(){$('div.my-blog-bar').myBlogBar();});}
autoLoad();