function GFslideShow(c,a,b){this.feedUrl=null;this.directEntries=null;if(typeof c=="string"){this.feedUrl=c}else{if(c&&c.length&&c.length>1){this.directEntries=c}else{throw"invalid argument: photoFeed"}}if(typeof a=="string"){a=document.getElementById(a)}this.container=a;this.parseOptions(b);this.setup()}GFslideShow.THUMBNAILS_SMALL="small";GFslideShow.THUMBNAILS_MEDIUM="medium";GFslideShow.THUMBNAILS_LARGE="large";GFslideShow.MRSS_THUMBNAIL_TAG="thumbnail";GFslideShow.MRSS_THUMBNAIL_NS="http://search.yahoo.com/mrss/";GFslideShow.ITMS_THUMBNAIL_TAG="coverArt";GFslideShow.ITMS_THUMBNAIL_NS="http://phobos.apple.com/rss/1.0/modules/itms/";GFslideShow.DEFAULT_THUMBNAIL_TAG=GFslideShow.MRSS_THUMBNAIL_TAG;GFslideShow.DEFAULT_THUMBNAIL_NS=GFslideShow.MRSS_THUMBNAIL_NS;GFslideShow.DEFAULT_DISPLAY_TIME=3000;GFslideShow.DEFAULT_TRANSISTION_TIME=1000;GFslideShow.DEFAULT_TRANSISTION_STEP=40;GFslideShow.DEFAULT_PAUSE_PNG=google.loader.ServiceBase+"/solutions/slideshow/pause.png";GFslideShow.DEFAULT_PLAY_PNG=google.loader.ServiceBase+"/solutions/slideshow/play.png";GFslideShow.FC_PAUSE_PNG={small:google.loader.ServiceBase+"/solutions/slideshow/btn_pause_small.png",big:google.loader.ServiceBase+"/solutions/slideshow/btn_pause.png"};GFslideShow.FC_PLAY_PNG={small:google.loader.ServiceBase+"/solutions/slideshow/btn_play_small.png",big:google.loader.ServiceBase+"/solutions/slideshow/btn_play.png"};GFslideShow.FC_PREV_PNG={small:google.loader.ServiceBase+"/solutions/slideshow/btn_prev_small.png",big:google.loader.ServiceBase+"/solutions/slideshow/btn_prev.png"};GFslideShow.FC_NEXT_PNG={small:google.loader.ServiceBase+"/solutions/slideshow/btn_next_small.png",big:google.loader.ServiceBase+"/solutions/slideshow/btn_next.png"};GFslideShow.DEFAULT_FC_FADEOUT_TIME=5000;GFslideShow.DEFAULT_FC_OPACITY=0.65;GFslideShow.prototype.parseOptions=function(a){var c;if(google!=undefined&&google.feeds!=undefined){c=google.feeds.Feed.MAX_ENTRIES}else{c=20}this.options={numResults:c,scaleImages:false,thumbnailTag:GFslideShow.DEFAULT_THUMBNAIL_TAG,thumbnailNamespace:GFslideShow.DEFAULT_THUMBNAIL_NS,thumbnailSize:GFslideShow.THUMBNAILS_LARGE,linkTarget:null,displayTime:GFslideShow.DEFAULT_DISPLAY_TIME,transitionTime:GFslideShow.DEFAULT_TRANSISTION_TIME,transitionStep:GFslideShow.DEFAULT_TRANSISTION_STEP,pauseOnHover:true,pauseImage:GFslideShow.DEFAULT_PAUSE_PNG,pauseStateCallback:null,scalePauseImage:true,autoCleanup:true,thumbnailUrlResolver:null,transitionCallback:null,transitionAnimationCallback:null,feedLoadCallback:null,feedProcessedCallback:null,imageClickCallback:null,centerBias:{topBias:0,leftBias:0},pauseCenterBias:{topBias:0,leftBias:0},fullControlPanel:false,fullControlPanelCursor:false,fullControlPanelFadeOutTime:GFslideShow.DEFAULT_FC_FADEOUT_TIME,fullControlPanelPlayCallback:null,fullControlPanelSmallIcons:false,maintainAspectRatio:true};if(a){for(o in this.options){if(typeof a[o]!="undefined"){this.options[o]=a[o]}}}if(this.options.displayTime<100){this.options.displayTime=100}var b=(this.options.transitionTime/this.options.transitionStep);this.delta=Math.min(1,(1/b));this.started=false};GFslideShow.prototype.setup=function(){if(this.container==null){return}if(window.ActiveXObject){this.ie=this[window.XMLHttpRequest?"ie7":"ie6"]=true}else{if(window.opera){this.opera=true}else{if(document.childNodes&&!document.all&&!navigator.taintEnabled){this.safari=true;if(navigator.userAgent.indexOf("iPhone")>0){this.iphone=true}}else{if(document.getBoxObjectFor!=null){this.gecko=true}}}}if(this.feedUrl){this.feed=new google.feeds.Feed(this.feedUrl);this.feed.setResultFormat(google.feeds.Feed.MIXED_FORMAT);this.feed.setNumEntries(this.options.numResults);this.feed.load(this.bind(this.feedLoaded))}else{if(this.directEntries){this.feedLoaded(this.directEntries)}}};GFslideShow.prototype.addEntries=function(a){this.processEntries(a);if(!this.thumb_timer){this.processThumbs()}};GFslideShow.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)}};GFslideShow.prototype.mouseOver=function(c){var b=c||window.event;var a=b.relatedTarget||b.fromElement;while(a!=null){if(a==this.container){return}a=a.parentNode}if(this.options.fullControlPanel){if(this.options.pauseOnHover&&!this.display_paused){this.pauseOrPlayFullControl()}this.fadeInFullControl()}else{this.display_paused=true;if(this.pauseImage){this.pauseImage.style.visibility="visible"}}if(this.options.pauseStateCallback){this.options.pauseStateCallback(this.display_paused)}};GFslideShow.prototype.mouseOut=function(c){var b=c||window.event;var a=b.relatedTarget||b.toElement;while(a!=null){if(a==this.container){return}a=a.parentNode}if(this.options.fullControlPanel){this.fadeOutFullControl();this.container.onmousemove=null;if(this.options.pauseOnHover&&this.display_paused){this.pauseOrPlayFullControl()}}else{this.display_paused=false;if(this.pauseImage){this.pauseImage.style.visibility="hidden"}}if(this.options.pauseStateCallback){this.options.pauseStateCallback(this.display_paused)}if(this.display_timer==null&&this.transition_timer==null){this.displayNextPhoto()}};GFslideShow.prototype.operaClickAndCallout=function(){var b=this.entries[this.photo_index];var a=this.createLink(b.link);a.click()};GFslideShow.prototype.pause=function(b){var a=this.pauseImage;if(b){this.pauseImage=null}this.pauseAndCallout();this.pauseImage=a};GFslideShow.prototype.resume=function(){this.resumeSlideShow()};GFslideShow.prototype.pauseAndCallout=function(){this.display_paused=true;if(this.pauseImage){this.pauseImage.style.visibility="visible"}this.container.onmouseout=null;if(this.options.imageClickCallback){this.options.imageClickCallback(this.entries[this.photo_index])}};GFslideShow.prototype.resumeSlideShow=function(){if(this.options.pauseOnHover||this.options.fullControlPanel){this.container.onmouseover=this.bind(this.mouseOver);this.container.onmouseout=this.bind(this.mouseOut)}this.display_paused=false;if(this.pauseImage){this.pauseImage.style.visibility="hidden"}if(this.display_timer==null&&this.transition_timer==null){this.displayNextPhoto()}};GFslideShow.prototype.clearNode=function(a){if(a==null){return}var b;while(b=a.firstChild){a.removeChild(b)}};GFslideShow.prototype.createSubContainer=function(){var a=document.createElement("div");a.style.width="100%";a.style.height="100%";a.style.position="relative";a.style.overflow="hidden";this.clearNode(this.container);this.container.appendChild(a);this.container=a};GFslideShow.prototype.grabThumb=function(b){var c=0;if(b.length>1){if(this.options.thumbnailSize==GFslideShow.THUMBNAILS_LARGE){c=b.length-1}else{if(this.options.thumbnailSize==GFslideShow.THUMBNAILS_MEDIUM){c=Math.floor(b.length/2)}}}var d=b[c];var a=null;var a=d.getAttribute("url");if(!a){a=d.firstChild.nodeValue}return a};GFslideShow.prototype.processThumbs=function(g,j){this.thumb_timer=null;var a=this.thumbs_index;var e=this.entries.length;var k=g||4;if(e>(a+k)){e=(a+k);var c=this.bind(this.processThumbs);var l=j||Math.round(this.options.displayTime/4);this.thumb_timer=window.setTimeout(c,l)}for(var d=a;d<e;d++){var f=this.entries[d].thumbUrl;var b=this.createImage(f);this.images.push(b);if(this.options.linkTarget){if(!this.opera){var h=this.createLink(this.entries[d].link);h.appendChild(b);this.container.appendChild(h)}else{b.onclick=this.bind(this.operaClickAndCallout);b.style.cursor="pointer";this.container.appendChild(b)}}else{this.container.appendChild(b)}if(b.complete){this.imageLoaded(b)}else{b.onerror=this.bind(this.imageError,b);b.onload=this.bind(this.imageLoaded,b)}this.thumbs_index++}};GFslideShow.prototype.processEntries=function(a){for(var c=0;c<a.length;c++){var d=null;if(this.options.thumbnailUrlResolver){d=this.options.thumbnailUrlResolver(a[c])}else{var b=google.feeds.getElementsByTagNameNS(a[c].xmlNode,this.options.thumbnailNamespace,this.options.thumbnailTag);if(b&&b.length>0){d=this.grabThumb(b)}}if(d){a[c].thumbUrl=d;this.entries.push(a[c])}}};GFslideShow.prototype.feedLoaded=function(b){if(this.options.feedLoadCallback){this.options.feedLoadCallback(b)}if((this.feedUrl&&b.error)||(this.directEntries&&this.directEntries.length==0)){if(!this.options.feedLoadCallback){this.container.innerHTML='<center style="color: gray">feed could not be loaded.</center>'}return}this.createSubContainer();if(this.container.offsetWidth){this.width=this.container.offsetWidth;this.height=this.container.offsetHeight}this.createPauseImage();this.images=[];this.entries=[];this.thumbs_index=0;var a;if(this.feedUrl){a=b.feed.entries}else{a=this.directEntries}this.processEntries(a);if(this.options.feedProcessedCallback){this.options.feedProcessedCallback(b)}if(this.options.fullControlPanel&&this.entries.length>0){this.createFullControlPanel()}if((this.options.pauseOnHover||this.options.fullControlPanel)&&this.entries.length>0){this.container.onmouseover=this.bind(this.mouseOver);this.container.onmouseout=this.bind(this.mouseOut)}if(this.options.imageClickCallback){this.container.onclick=this.bind(this.pauseAndCallout)}this.processThumbs(1,100+(Math.random()*100))};GFslideShow.prototype.imageLoaded=function(b){b.__gfloaded=true;this.adjustImage(b);if(!this.started){for(var a=0;a<this.images.length;a++){if(b==this.images[a]){this.beginSlideShow(a)}break}}};GFslideShow.prototype.imageError=function(a){a.__gferror=true};GFslideShow.prototype.adjustImage=function(a){if(this.options.scaleImages){if(this.options.maintainAspectRatio){this.scaleImage(a)}else{a.style.height=this.height+"px";a.style.width=this.width+"px"}}this.centerImage(a)};GFslideShow.prototype.scaleImage=function(c,a,f){var b=a||this.width;var i=f||this.height;var g=c.offsetWidth;var d=c.offsetHeight;if(g<=0||d<=0){return}var e=i/d;var h=b/g;if(e<h){c.style.height=i+"px";c.style.width=Math.round(g*e)+"px"}else{c.style.width=b+"px";c.style.height=Math.round(d*h)+"px"}};GFslideShow.prototype.centerImage=function(e){var c=this.height-e.offsetHeight;var b=this.width-e.offsetWidth;e.style.top="0px";e.style.left="0px";if(c>0){var a=Math.round(c/2);e.style.top=e.offsetTop+a+this.options.centerBias.topBias+"px"}if(b>0){var d=Math.round(b/2);e.style.left=e.offsetLeft+d+this.options.centerBias.leftBias+"px"}};GFslideShow.prototype.createLink=function(a){var b=document.createElement("a");b.setAttribute("href",a);if(this.options.linkTarget){b.setAttribute("target",this.options.linkTarget)}return b};GFslideShow.prototype.createImage=function(b){var a=document.createElement("img");a.style.position="absolute";a.setAttribute("src",b);this.setOpacity(a,0);return a};GFslideShow.prototype.adjustPauseImage=function(c){if(this.options.scalePauseImage){var a=Math.round(this.height*0.33);var b=Math.round(this.width*0.33);this.scaleImage(c,b,a)}this.placePauseImage(c)};GFslideShow.prototype.placePauseImage=function(e){var c=this.height-e.offsetHeight;var b=this.width-e.offsetWidth;e.style.top="0px";e.style.left="0px";if(c>0){var f=Math.round(this.height*0.1);if(f<15){f=10}var a=this.height-(e.offsetHeight+f);if(a<0){a=0}e.style.top=e.offsetTop+a+this.options.pauseCenterBias.topBias+"px"}if(b>0){var d=Math.round(b/2);e.style.left=e.offsetLeft+d+this.options.pauseCenterBias.leftBias+"px"}};GFslideShow.prototype.createAlphaPauseImage=function(e){this.adjustPauseImage(e);var c=e.offsetWidth;var g=e.offsetHeight;var d=e.style.top;var b=e.style.left;var a=null;if(this.ie){var f=this.options.pauseImage;a=document.createElement("div");a.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+f+"', sizingMethod='scale')";a.style.position="absolute";a.style.width=c+"px";a.style.height=g+"px";a.style.left=b;a.style.top=d}else{a=e;a.style.opacity=""}a.style.visibility="hidden";a.style.zIndex=222;if(a!=e){this.container.appendChild(a);this.container.removeChild(e)}this.pauseImage=a};GFslideShow.prototype.pauseImageLoaded=function(a){this.createAlphaPauseImage(a)};GFslideShow.prototype.createPauseImage=function(b){if(!this.options.pauseOnHover){return}var a=this.createImage(this.options.pauseImage);this.container.appendChild(a);if(a.complete){this.createAlphaPauseImage(a)}else{a.onload=this.bind(this.pauseImageLoaded,a)}};GFslideShow.prototype.createFullControlPanel=function(){var e=(this.options.fullControlPanelSmallIcons?25:45);if(this.options.fullControlPanelCursor){e+=10}var g=(this.options.fullControlPanelSmallIcons?5:10);var d=5;var a=document.createElement("div");a.style.backgroundColor="#000000";a.style.height=e+"px";a.style.top=(this.height-(e+d+g))+"px";a.style.width="100%";a.style.zIndex="222";a.style.position="relative";a.style.textAlign="center";a.style.direction="ltr";a.style.paddingTop=g+"px";a.style.paddingBottom=d+"px";var i=this.options.fullControlPanelSmallIcons?"small":"big";var b=this.ie?"hand":"pointer";var k=document.createElement("img");k.src=GFslideShow.FC_PAUSE_PNG[i];k.style.cursor=b;var f=document.createElement("img");f.src=GFslideShow.FC_NEXT_PNG[i];f.style.cursor=b;var c=document.createElement("img");c.src=GFslideShow.FC_PREV_PNG[i];c.style.cursor=b;k.style.marginLeft="5px";k.style.marginRight="5px";a.appendChild(c);a.appendChild(k);a.appendChild(f);var j=null;if(this.options.fullControlPanelCursor){j=document.createElement("div");j.style.height="1.3em";j.style.fontSize="11px";j.style.color="#bbbbbb";a.appendChild(j)}this.fc={};this.fc.container=a;this.fc.pause=k;this.fc.next=f;this.fc.prev=c;this.fc.cursor=j;f.onclick=this.bind(this.goForward);c.onclick=this.bind(this.goBackward);k.onclick=this.bind(this.pauseOrPlayClick);this.fc.container.style.visibility="hidden";this.container.appendChild(a)};GFslideShow.prototype.clearTransitionTimer=function(){if(this.transition_timer){clearInterval(this.transition_timer);this.transition_timer=null}};GFslideShow.prototype.setTransitionTimer=function(){this.clearTransitionTimer();this.lastTick=GFslideShow.timeNow();var a=this.bind(this.transitionAnimation);this.transition_timer=window.setInterval(a,this.options.transitionStep)};GFslideShow.prototype.clearDisplayTimer=function(){if(this.display_timer){clearTimeout(this.display_timer);this.display_timer=null}};GFslideShow.prototype.setDisplayTimer=function(){if(this.display_timer){return}var a=this.bind(this.displayNextPhoto);this.display_timer=window.setTimeout(a,this.options.displayTime)};GFslideShow.prototype.clearThumbTimer=function(){if(this.thumb_timer){clearTimeout(this.thumb_timer);this.thumb_timer=null}};GFslideShow.prototype.beginSlideShow=function(a){this.photo_index=a;this.next=this.images[this.photo_index];this.snapToNextPhoto();this.started=true};GFslideShow.timeNow=function(){var a=new Date();return a.getTime()};GFslideShow.prototype.goForward=function(){this.finishTransition();this.setNextPhoto();this.snapToNextPhoto();this.clearFullControlTimeoutTimer()};GFslideShow.prototype.goBackward=function(){this.finishTransition();this.setPreviousPhoto();this.snapToNextPhoto();this.clearFullControlTimeoutTimer()};GFslideShow.prototype.gotoIndex=function(a){if(a==this.photo_index){return}this.clearTransitionTimer();this.setPhotoIndex(a);this.snapToNextPhoto();this.clearFullControlTimeoutTimer()};GFslideShow.prototype.pauseOrPlayClick=function(){if(this.options.fullControlPanelPlayCallback&&this.display_paused){this.container.onmouseover=null;this.container.onmouseout=null;this.options.fullControlPanelPlayCallback(this.entries[this.photo_index]);this.fadeOutFullControl()}else{this.pauseOrPlayFullControl()}};GFslideShow.prototype.pauseOrPlayFullControl=function(){var a=this.options.fullControlPanelSmallIcons?"small":"big";if(this.display_paused){this.display_paused=false;this.fc.pause.src=GFslideShow.FC_PAUSE_PNG[a];if(this.display_timer==null&&this.transition_timer==null){this.displayNextPhoto()}}else{this.display_paused=true;this.fc.pause.src=GFslideShow.FC_PLAY_PNG[a]}};GFslideShow.prototype.fullControlMotion=function(){var a=this.fc.container.opacity;if(a<GFslideShow.DEFAULT_FC_OPACITY){this.container.onmousemove=null;this.clearFullControlTimeoutTimer();this.fadeInFullControl()}else{this.setFullControlTimeoutTimer()}};GFslideShow.prototype.clearFullControlTimeoutTimer=function(){if(!this.fc){return}if(this.fc.timeout){clearTimeout(this.fc.timeout);this.fc.timeout=null}};GFslideShow.prototype.setFullControlTimeoutTimer=function(){if(this.fc.timeout){clearTimeout(this.fc.timeout);this.fc.timeout=null}if(this.options.fullControlPanelFadeOutTime>0){var a=this.bind(this.fadeOutFullControl);this.fc.timeout=setTimeout(a,this.options.fullControlPanelFadeOutTime)}};GFslideShow.prototype.setFullControlTimeout=function(){this.container.onmousemove=this.bind(this.fullControlMotion);this.setFullControlTimeoutTimer()};GFslideShow.prototype.fadeInFullControl=function(){this.setOpacity(this.fc.container,0);var a=this.bind(this.fadeInFullControlAnimation);this.setFullControlFadeTimer(a)};GFslideShow.prototype.fadeInFullControlAnimation=function(){var a=this.fc.container.opacity;a+=0.075;a=Math.min(GFslideShow.DEFAULT_FC_OPACITY,a);this.setOpacity(this.fc.container,a);if(a>=GFslideShow.DEFAULT_FC_OPACITY){this.setFullControlFadeTimer();this.setFullControlTimeout()}};GFslideShow.prototype.fadeOutFullControl=function(){var a=this.bind(this.fadeOutFullControlAnimation);this.setFullControlFadeTimer(a)};GFslideShow.prototype.fadeOutFullControlAnimation=function(){var a=this.fc.container.opacity;a-=0.075;this.setOpacity(this.fc.container,a);if(a<=0){this.setFullControlFadeTimer()}};GFslideShow.prototype.setFullControlFadeTimer=function(a){if(this.fc.fade_timer){clearInterval(this.fc.fade_timer);this.fc.fade_timer=null}if(a){this.fc.fade_timer=window.setInterval(a,40)}};GFslideShow.prototype.transitionAnimation=function(){if(this.current&&this.next){var f=this.delta;var e=this.options.transitionStep;var b=GFslideShow.timeNow();var d=b-this.lastTick;this.lastTick=b;f*=(d/e);if(f<0){return}var a=this.current.opacity-f;var c=this.next.opacity+f;this.setOpacity(this.current,a);this.setOpacity(this.next,c);if(this.options.transitionAnimationCallback){this.options.transitionAnimationCallback(this.next.opacity)}if(a>0){return}}this.finishTransition()};GFslideShow.prototype.setNextPhoto=function(){if(this.images.length==0){return}var a=this.photo_index;if(++this.photo_index>=this.images.length){this.photo_index=0}var b=this.images[this.photo_index];if(b&&b.__gfloaded){this.next=b}else{if(this.photo_index==a){this.next=this.images[0]}}};GFslideShow.prototype.setPreviousPhoto=function(){var a=this.photo_index;if(this.images.length!=0){if(--this.photo_index<0){this.photo_index=this.images.length-1}var b=this.images[this.photo_index];if(b&&b.__gfloaded){this.next=b}else{if(this.photo_index==a){this.next=this.images[0]}}}};GFslideShow.prototype.setPhotoIndex=function(a){if(a<0||a>=this.images.length){return}var b=this.images[a];if(b&&b.__gfloaded){this.next=b;this.photo_index=a}};GFslideShow.prototype.clearPauseEvents=function(){this.container.onmouseover=null;this.container.onmouseout=null};GFslideShow.prototype.cleanup=function(){this.clearTransitionTimer();this.clearDisplayTimer();this.clearThumbTimer();this.clearPauseEvents();this.clearNode(this.container);this.container=null};GFslideShow.prototype.displayNextPhoto=function(){this.display_timer=null;if(!this.started){return false}if(this.display_paused){return}if((!this.container||!this.container.parentNode)&&this.options.autoCleanup){this.cleanup();return}this.setNextPhoto();this.beginTransition()};GFslideShow.prototype.snapToNextPhoto=function(){this.setOpacity(this.next,1);this.setOpacity(this.current,0);this.current=this.next;this.setDisplayTimer();if(this.options.transitionCallback){this.options.transitionCallback(this.entries[this.photo_index],this.options.transitionTime)}if(this.options.fullControlPanel&&this.options.fullControlPanelCursor){var a=(this.photo_index+1)+" / "+this.images.length;this.fc.cursor.innerHTML=a}};GFslideShow.prototype.beginTransition=function(){if(!this.current||!this.next||(this.current==this.next)){this.setDisplayTimer();return}if(this.options.transitionTime>=this.options.transitionStep){this.setTransitionTimer()}else{this.snapToNextPhoto()}};GFslideShow.prototype.finishTransition=function(){this.clearTransitionTimer();this.snapToNextPhoto()};GFslideShow.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){b.style.filter="alpha(opacity="+a*100+")"}b.style.opacity=b.opacity=a};
