function GFdynamicFeedControl(D,A,B){this.nodes={};this.feeds=[];this.results=[];if(typeof D=="string"){this.feeds.push({url:D})}else{if(typeof D=="object"){for(var C=0;C<D.length;C++){var E=D[C];var F={};var G;if(typeof E=="string"){F.url=D[C]}else{if(typeof E=="object"){F=D[C]}}this.feeds.push(F)}}}if(typeof A=="string"){A=document.getElementById(A)}this.parseOptions_(B);this.setup_(A)}GFdynamicFeedControl.DEFAULT_NUM_RESULTS=4;GFdynamicFeedControl.DEFAULT_FEED_CYCLE_TIME=1800000;GFdynamicFeedControl.DEFAULT_DISPLAY_TIME=6000;GFdynamicFeedControl.DEFAULT_FADEOUT_TIME=2000;GFdynamicFeedControl.DEFAULT_TRANSISTION_STEP=40;GFdynamicFeedControl.DEFAULT_HOVER_TIME=100;GFdynamicFeedControl.prototype.parseOptions_=function(A){this.options={numResults:GFdynamicFeedControl.DEFAULT_NUM_RESULTS,feedCycleTime:GFdynamicFeedControl.DEFAULT_FEED_CYCLE_TIME,linkTarget:google.feeds.LINK_TARGET_SELF,displayTime:GFdynamicFeedControl.DEFAULT_DISPLAY_TIME,transitionTime:GFdynamicFeedControl.DEFAULT_TRANSISTION_TIME,transitionStep:GFdynamicFeedControl.DEFAULT_TRANSISTION_STEP,fadeOutTime:GFdynamicFeedControl.DEFAULT_FADEOUT_TIME,scrollOnFadeOut:true,pauseOnHover:true,hoverTime:GFdynamicFeedControl.DEFAULT_HOVER_TIME,autoCleanup:true,transitionCallback:null,feedTransitionCallback:null,feedLoadCallback:null,horizontal:false,stacked:false,title:null,maxTitleLength:25};if(A){for(var C in this.options){if(typeof A[C]!="undefined"){this.options[C]=A[C]}}}this.options.displayTime=Math.max(200,this.options.displayTime);this.options.fadeOutTime=Math.max(0,this.options.fadeOutTime);var B=this.options.fadeOutTime/this.options.transitionStep;this.fadeOutDelta=Math.min(1,(1/B));this.started=false};function cutTitle(A,B){A=A.slice(0,(A.indexOf(" ",B)));return A}GFdynamicFeedControl.prototype.setup_=function(A){if(A==null){return}this.nodes.container=A;if(window.ActiveXObject){this.ie=this[window.XMLHttpRequest?"ie7":"ie6"]=true}else{if(document.childNodes&&!document.all&&!navigator.taintEnabled){this.safari=true}else{if(document.getBoxObjectFor!=null){this.gecko=true}}}this.feedControl=new google.feeds.FeedControl();this.feedControl.setLinkTarget(this.options.linkTarget);this.expected=this.feeds.length;this.errors=0;for(var B=0;B<this.feeds.length;B++){var C=new google.feeds.Feed(this.feeds[B].url);C.setResultFormat(google.feeds.Feed.JSON_FORMAT);C.setNumEntries(this.options.numResults);C.load(this.bind_(this.feedLoaded_,B))}};GFdynamicFeedControl.prototype.bind_=function(C){var A=this;var B=[].slice.call(arguments,1);return function(){var D=B.concat([].slice.call(arguments));return C.apply(A,D)}};GFdynamicFeedControl.prototype.feedLoaded_=function(B,A){if(this.options.feedLoadCallback){this.options.feedLoadCallback(A)}if(A.error){if(++this.errors>=this.expected){this.nodes.container.innerHTML="Feed"+((this.expected>1)?"s ":" ")+"could not be loaded."}return}if(this.feeds[B].title){A.feed.title=this.feeds[B].title}this.results.push(A);if(!this.started){this.createSubContainers_();this.displayResult_(0)}else{if(!this.options.horizontal&&this.options.stacked){this.addResult_(this.results.length-1)}}};GFdynamicFeedControl.prototype.addResult_=function(B){var A=this.results[B];var D=this.createDiv_("gfg-subtitle");this.setTitle_(A.feed,D);var C=this.createDiv_("gfg-list");this.createListEntries_(B,C);this.nodes.root.appendChild(D);this.nodes.root.appendChild(C)};GFdynamicFeedControl.prototype.displayResult_=function(B){this.resultIndex=B;var A=this.results[B];if(this.options.feedTransitionCallback){this.options.feedTransitionCallback(A)}if(this.options.title){this.setPlainTitle_(this.options.title)}else{this.setTitle_(A.feed)}this.clearNode_(this.nodes.entry);if(this.started&&!this.options.horizontal&&this.options.stacked){this.entries=A.feed.entries}else{this.createListEntries_(B,this.nodes.list)}this.displayEntries_()};GFdynamicFeedControl.prototype.setPlainTitle_=function(C,B){var A=B||this.nodes.title;A.innerHTML=C};GFdynamicFeedControl.prototype.setTitle_=function(A,D){var B=D||this.nodes.title;this.clearNode_(B);var C=document.createElement("a");C.target=google.feeds.LINK_TARGET_BLANK;C.href=A.link;C.innerHTML=A.title;B.appendChild(C)};GFdynamicFeedControl.prototype.createListEntries_=function(C,G){var B=this.results[C].feed.entries;this.clearNode_(G);for(var D=0;D<B.length;D++){this.feedControl.createHtml(B[D]);var E="gfg-listentry ";E+=(D%2)?"gfg-listentry-even":"gfg-listentry-odd";var A=this.createDiv_(E);if(B[D].title.length>=this.options.maxTitleLength){B[D].title=cutTitle(B[D].title,this.options.maxTitleLength)+"... "}var F=this.createLink_(B[D].link,B[D].title,this.options.linkTarget);A.appendChild(F);if(this.options.pauseOnHover){A.onmouseover=this.bind_(this.listMouseOver_,C,D);A.onmouseout=this.bind_(this.listMouseOut_,C,D)}B[D].listEntry=A;G.appendChild(A)}if(G==this.nodes.list){this.entries=B}};GFdynamicFeedControl.prototype.displayEntries_=function(){this.entryIndex=0;this.displayCurrentEntry_();this.setDisplayTimer_();this.started=true};GFdynamicFeedControl.prototype.displayNextEntry_=function(){if(this.options.autoCleanup&&this.isOrphaned_()){this.cleanup_();return}if(++this.entryIndex>=this.entries.length){if(this.results.length>1){if(++this.resultIndex>=this.results.length){this.resultIndex=0}this.displayResult_(this.resultIndex);return}else{this.entryIndex=0}}if(this.options.transitionCallback){this.options.transitionCallback(this.entries[this.entryIndex])}this.displayCurrentEntry_();this.setDisplayTimer_()};GFdynamicFeedControl.prototype.displayCurrentEntry_=function(){this.clearNode_(this.nodes.entry);this.current=this.entries[this.entryIndex].html;this.current.style.top="0px";this.nodes.entry.appendChild(this.current);this.createOverlay_();if(this.currentList){var A="gfg-listentry ";A+=(this.currentListIndex%2)?"gfg-listentry-even":"gfg-listentry-odd";this.currentList.className=A}this.currentList=this.entries[this.entryIndex].listEntry;this.currentListIndex=this.entryIndex;var A="gfg-listentry gfg-listentry-highlight ";A+=(this.currentListIndex%2)?"gfg-listentry-even":"gfg-listentry-odd";this.currentList.className=A};GFdynamicFeedControl.prototype.listMouseHover_=function(C,D){var B=this.results[C];var A=B.feed.entries[D].listEntry;A.selectTimer=null;this.clearTransitionTimer_();this.clearDisplayTimer_();this.resultIndex=C;this.entries=B.feed.entries;this.entryIndex=D;this.displayCurrentEntry_()};GFdynamicFeedControl.prototype.listMouseOver_=function(D,E){var C=this.results[D];var B=C.feed.entries[E].listEntry;var A=this.bind_(this.listMouseHover_,D,E);B.selectTimer=setTimeout(A,this.options.hoverTime)};GFdynamicFeedControl.prototype.listMouseOut_=function(C,D){var B=this.results[C];var A=B.feed.entries[D].listEntry;if(A.selectTimer){clearTimeout(A.selectTimer);A.selectTimer=null}else{this.setDisplayTimer_()}};GFdynamicFeedControl.prototype.entryMouseOver_=function(A){this.clearDisplayTimer_();if(this.transitionTimer){this.clearTransitionTimer_();this.displayCurrentEntry_()}};GFdynamicFeedControl.prototype.entryMouseOut_=function(A){this.setDisplayTimer_()};GFdynamicFeedControl.prototype.createOverlay_=function(){if(this.current==null){return}if(this.overlay==null){var A=this.createDiv_("gfg-entry");A.style.position="absolute";A.style.top="0px";A.style.left="0px";this.overlay=A}this.setOpacity_(this.overlay,0);this.nodes.entry.appendChild(this.overlay)};GFdynamicFeedControl.prototype.setDisplayTimer_=function(){if(this.displayTimer){this.clearDisplayTimer_()}var A=this.bind_(this.setFadeOutTimer_);this.displayTimer=setTimeout(A,this.options.displayTime)};GFdynamicFeedControl.timeNow=function(){var A=new Date();return A.getTime()};GFdynamicFeedControl.prototype.fadeOutEntry_=function(){if(this.overlay){var G=this.fadeOutDelta;var E=this.options.transitionStep;var B=GFdynamicFeedControl.timeNow();var C=B-this.lastTick;this.lastTick=B;G*=(C/E);var F=this.overlay.opacity+G;this.setOpacity_(this.overlay,F);if(this.options.scrollOnFadeOut&&(F>0.5)){var D=(F-0.5)*2;var A=Math.round(this.current.offsetHeight*D);this.current.style.top=A+"px"}if(F<1){return}}this.clearTransitionTimer_();this.displayNextEntry_()};GFdynamicFeedControl.prototype.setFadeOutTimer_=function(){this.clearTransitionTimer_();this.lastTick=GFdynamicFeedControl.timeNow();var A=this.bind_(this.fadeOutEntry_);this.transitionTimer=setInterval(A,this.options.transitionStep)};GFdynamicFeedControl.prototype.clearTransitionTimer_=function(){if(this.transitionTimer){clearInterval(this.transitionTimer);this.transitionTimer=null}};GFdynamicFeedControl.prototype.clearDisplayTimer_=function(){if(this.displayTimer){clearTimeout(this.displayTimer);this.displayTimer=null}};GFdynamicFeedControl.prototype.createSubContainers_=function(){var B=this.nodes;var A=this.nodes.container;this.clearNode_(A);if(this.options.horizontal){A=this.createDiv_("gfg-horizontal-container");B.root=this.createDiv_("gfg-horizontal-root");this.nodes.container.appendChild(A)}else{B.root=this.createDiv_("gfg-root")}B.title=this.createDiv_("gfg-title");B.entry=this.createDiv_("gfg-entry");B.list=this.createDiv_("gfg-list");B.root.appendChild(B.title);B.root.appendChild(B.entry);if(!this.options.horizontal&&this.options.stacked){var C=this.createDiv_("gfg-subtitle");B.root.appendChild(C);this.setTitle_(this.results[0].feed,C)}B.root.appendChild(B.list);A.appendChild(B.root);if(this.options.pauseOnHover){B.entry.onmouseover=this.bind_(this.entryMouseOver_);B.entry.onmouseout=this.bind_(this.entryMouseOut_)}if(this.options.horizontal){B.branding=this.createDiv_("gfg-branding");google.feeds.getBranding(B.branding,google.feeds.VERTICAL_BRANDING);A.appendChild(B.branding)}};GFdynamicFeedControl.prototype.clearNode_=function(A){if(A==null){return}var B;while((B=A.firstChild)){A.removeChild(B)}};GFdynamicFeedControl.prototype.createDiv_=function(C,A){var B=document.createElement("div");if(A){B.innerHTML=A}if(C){B.className=C}return B};GFdynamicFeedControl.prototype.createLink_=function(A,D,B){var C=document.createElement("a");C.href=A;C.innerHTML=D;if(B){C.target=B}return C};GFdynamicFeedControl.prototype.clearResults_=function(){for(var C=0;C<this.results.length;C++){var B=this.results[C];var A=B.feed.entries;for(var C=0;C<A.length;C++){var D=A[C];D.html=null;D.listEntry.onmouseover=null;D.listEntry.onmouseout=null;if(D.listEntry.selectTimer){clearTimeout(D.listEntry.selectTimer);D.listEntry.selectTimer=null}D.listEntry=null}}};GFdynamicFeedControl.prototype.isOrphaned_=function(){var A=this.nodes.root;var B=false;if(!A||!A.parentNode){B=true}else{if(this.options.horizontal&&!A.parentNode.parentNode){B=true}}return B};GFdynamicFeedControl.prototype.cleanup_=function(){this.started=false;this.clearDisplayTimer_();this.clearTransitionTimer_();this.clearResults_();this.clearNode_(this.nodes.root);this.nodes.container=null};GFdynamicFeedControl.prototype.setOpacity_=function(B,A){if(B==null){return}A=Math.max(0,Math.min(1,A));if(A==0){if(B.style.visibility!="hidden"){B.style.visibility="hidden"}}else{if(B.style.visibility!="visible"){B.style.visibility="visible"}}if(this.ie){var C=Math.round(A*100);B.style.filter="alpha(opacity="+C+")"}B.style.opacity=B.opacity=A};GFgadget=GFdynamicFeedControl;

