/* http://keith-wood.name/gsnewsbar.html
   Google Search Newsbar for jQuery v1.0.1.
   See http://www.google.com/uds/solutions/newsbar/reference.html.
   Written by Keith Wood (kbwood{at}iinet.com.au) November 2008.
   Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 
   MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. 
   Please attribute the author if you use it. */
(function($){function GSNewsbar(){this._defaults={horizontal:true,verticalCompressed:false,title:'',search:'jquery',manyResults:false,cycleTime:this.cycleManual,cycleMode:this.cycleLinear,linkTarget:this.targetBlank,currentResult:''}}var g='gsnewsbar';$.extend(GSNewsbar.prototype,{markerClassName:'hasGSNewsbar',cycleVShort:3000,cycleShort:10000,cycleMedium:15000,cycleLong:30000,cycleManual:3000000,cycleRandom:1,cycleLinear:2,targetSelf:'_self',targetBlank:'_blank',targetTop:'_top',targetParent:'_parent',setDefaults:function(a){extendRemove(this._defaults,a||{});return this},_attachGSNewsbar:function(a,b){a=$(a);if(a.is('.'+this.markerClassName)){return}a.addClass(this.markerClassName);var c={target:a};c.options=$.extend({},b);$.data(a[0],g,c);this._updateGSNewsbar(a,c)},_changeGSNewsbar:function(a,b){var c=$.data(a,g);if(c){extendRemove(c.options,b||{});$.data(a,g,c);this._updateGSNewsbar($(a),c)}},_searchGSNewsbar:function(a,b){var c=$.data(a,g);if(c){extendRemove(c.options,{search:b});$.data(a,g,c);c.newsbar.execute(b)}},_updateGSNewsbar:function(c,d){var e=function(a){var b=$.gsnewsbar._get(d,a);b=(b?(b.jQuery?b:$(b)):null);return(b&&b.length?b[0]:null)};var f=this._get(d,'search');f=(isArray(f)?f:[f]);d.newsbar=new GSnewsBar(c[0],{largeResultSet:this._get(d,'manyResults'),horizontal:this._get(d,'horizontal'),resultStyle:(this._get(d,'verticalCompressed')?2:1),title:this._get(d,'title'),linkTarget:this._get(d,'linkTarget'),currentResult:e('currentResult'),autoExecuteList:{executeList:f,cycleTime:this._get(d,'cycleTime'),cycleMode:this._get(d,'cycleMode')}})},_destroyGSNewsbar:function(a){a=$(a);if(!a.is('.'+this.markerClassName)){return}a.removeClass(this.markerClassName).empty();$.removeData(a[0],g)},_get:function(a,b){return(a.options[b]!=null?a.options[b]:$.gsnewsbar._defaults[b])}});function extendRemove(a,b){$.extend(a,b);for(var c in b){if(b[c]==null){a[c]=null}}return a}function isArray(a){return(a&&a.constructor==Array)}$.fn.gsnewsbar=function(a){var b=Array.prototype.slice.call(arguments,1);return this.each(function(){if(typeof a=='string'){$.gsnewsbar['_'+a+'GSNewsbar'].apply($.gsnewsbar,[this].concat(b))}else{$.gsnewsbar._attachGSNewsbar(this,a)}})};if($('script[src*=www.google.com/uds/api?file=uds.js]').length==0){if(!$.googleSearchKey){throw'Missing Google Search Key';}document.write('<script type="text/javascript" src="http://www.google.com/uds/'+'api?file=uds.js&v=1.0&key='+$.googleSearchKey+'"></script>\n'+'<link type="text/css" href="http://www.google.com/uds/css/gsearch.css" rel="stylesheet"/>\n')}document.write('<script type="text/javascript" src="http://www.google.com/uds/'+'solutions/newsbar/gsnewsbar.js"></script>\n'+'<link type="text/css" href="http://www.google.com/uds/solutions/newsbar/gsnewsbar.css" '+'rel="stylesheet"/>\n');$.gsnewsbar=new GSNewsbar()})(jQuery);
