Re-uploading www directory: 30 Aug 2010 02:30 GTM+1
[dtn] / www / DTN_Technical_Details / Scripts / iWebMediaGrid.js
1 //
2 // iWeb - iWebMediaGrid.js
3 // Copyright 2007-2008 Apple Inc.
4 // All rights reserved.
5 //
6
7 var IWAllFeeds={};function IWCreateFeed(url)
8 {var feed=IWAllFeeds[url];if(feed==null)
9 {feed=new IWFeed(url);}
10 return feed;}
11 var IWFeed=Class.create({initialize:function(url)
12 {if(url)
13 {if(IWAllFeeds.hasOwnProperty(url))
14 {iWLog("warning -- use IWCreateFeed rather than new IWFeed and you'll get better performance");}
15 this.mURL=url;this.mLoading=false;this.mLoaded=false;this.mCallbacks=[];this.mImageStream=null;IWAllFeeds[url]=this;}},sourceURL:function()
16 {return this.mURL;},load:function(baseURL,callback)
17 {if(this.mLoaded&&(callback!=null))
18 {callback(this.mImageStream);}
19 else
20 {if(callback!=null)
21 {this.mCallbacks.push(callback);}
22 if(this.mLoading==false)
23 {this.mLoading=true;this.p_sendRequest(baseURL);}}},p_sendRequest:function(baseURL)
24 {var url=this.mURL.toRelativeURL(baseURL);new Ajax.Request(url,{method:'get',onSuccess:this.p_onload.bind(this,baseURL),onFailure:this.p_requestFailed.bind(this,baseURL)});},p_requestFailed:function(baseURL,req)
25 {iWLog("There was a problem ("+req.status+") retrieving the feed:\n\r"+req.statusText);if(req.status==500)
26 {iWLog("working around status 500 by trying again...");window.setTimeout(this.p_sendRequest.bind(this,baseURL),100);}},p_onload:function(baseURL,req)
27 {var collectionItem;var doc=ajaxGetDocumentElement(req);var items=$A(doc.getElementsByTagName('item'));this.mImageStream=this.p_interpretItems(baseURL,items);this.p_postLoadCallbacks(this.mImageStream);},p_postLoadCallbacks:function(imageStream)
28 {for(var i=0;i<this.mCallbacks.length;++i)
29 {this.mCallbacks[i](imageStream);}
30 this.mLoaded=true;},p_applyEntryOrder:function(imageStream,entryGUIDs)
31 {var orderedStream=[];var guidToIndex=[];for(var i=0;i<imageStream.length;i++)
32 {var streamEntryGUID=imageStream[i].guid();if(streamEntryGUID)
33 {guidToIndex[streamEntryGUID]=i;}}
34 for(var i=0;i<entryGUIDs.length;i++)
35 {var index=guidToIndex[entryGUIDs[i]];if(index!==undefined)
36 {orderedStream.push(imageStream[index]);}}
37 (function(){return orderedStream.length==entryGUIDs.length}).assert();return orderedStream;},p_firstElementByTagNameNS:function(element,ns,tag)
38 {var child=null;for(child=element.firstChild;child!=null;child=child.nextSibling)
39 {if(child.baseName==tag||child.localName==tag)
40 {if(ns==null||ns==""||child.namespaceURI==ns)
41 {break;}}}
42 return child;}});var IWStreamEntry=Class.create({initialize:function(thumbnailURL,title,richTitle,guid)
43 {if(arguments.length>0)
44 {if(thumbnailURL)
45 {this.mThumbnail=IWCreateImage(thumbnailURL);}
46 if(title)
47 {this.mTitle=title.stringByEscapingXML().stringByConvertingNewlinesToBreakTags();}
48 if(richTitle)
49 {this.mRichTitle=richTitle;}
50 if(guid)
51 {this.mGUID=guid;}}},setThumbnailURL:function(thumbnailURL)
52 {this.mThumbnail=IWCreateImage(thumbnailURL);},loadThumbnail:function(callback)
53 {this.thumbnail().load(callback);},unloadThumbnail:function()
54 {this.thumbnail().unload();},thumbnailNaturalSize:function()
55 {return this.thumbnail().naturalSize();},thumbnail:function()
56 {return this.mThumbnail;},micro:function()
57 {return this.thumbnail();},mipThumbnail:function()
58 {return this.thumbnail();},title:function()
59 {return this.mTitle;},richTitle:function()
60 {return this.mRichTitle?this.mRichTitle:this.mTitle;},metric:function()
61 {return null;},guid:function()
62 {return this.mGUID;},isMovie:function()
63 {return false;},commentGUID:function()
64 {return null;},showCommentIndicator:function()
65 {return true;},badgeMarkupForRect:function(rect)
66 {return IWStreamEntryBadgeMarkup(rect,this.isMovie(),this.showCommentIndicator()?this.commentGUID():null);},thumbnailMarkupForRect:function(rect)
67 {return imgMarkup(this.thumbnail().sourceURL(),rect.position(),"",this.mTitle)+
68 this.badgeMarkupForRect(rect);},didInsertThumbnailMarkupIntoDocument:function()
69 {}});function IWStreamEntryBadgeMarkup(rect,isMovie,commentGUID)
70 {var kBadgeWidth=16.0;var kBadgeHeight=16.0;var badgeRect=new IWRect(rect.origin.x,rect.maxY()-kBadgeHeight,rect.size.width,kBadgeHeight);var markup="";if(isMovie)
71 {markup+='<div style="background-color: black; '+badgeRect.position()+iWOpacity(0.75)+'"></div>';}
72 var badgeSize=new IWSize(kBadgeWidth,kBadgeHeight);if(isMovie)
73 {var movieImage=IWImageNamed("movie overlay");var movieRect=new IWRect(badgeRect.origin,badgeSize);markup+=imgMarkup(movieImage.sourceURL(),movieRect.position(),'class="badge-overlay"');}
74 var commentLocation=new IWPoint(badgeRect.maxX()-kBadgeWidth,badgeRect.origin.y);if(commentGUID)
75 {var commentImage=IWImageNamed("comment overlay");var commentRect=new IWRect(commentLocation,badgeSize);markup+=imgMarkup(commentImage.sourceURL(),commentRect.position()+"display: none; ",'class="badge-overlay" id="comment-badge-'+commentGUID+'"');}
76 return markup;}
77 var IWCommentableStreamEntry=Class.create(IWStreamEntry,{initialize:function($super,assetURL,showCommentIndicator,thumbnailURL,title,richTitle,guid)
78 {$super(thumbnailURL,title,richTitle,guid);this.mAssetURL=assetURL;this.mShowCommentIndicator=showCommentIndicator;},commentGUID:function()
79 {return this.guid();},showCommentIndicator:function()
80 {return this.mShowCommentIndicator;},didInsertThumbnailMarkupIntoDocument:function()
81 {if(this.mAssetURL&&hostedOnDM())
82 {IWCommentCountForURL(this.mAssetURL,this.p_commentCountCallback.bind(this));}
83 else
84 {this.p_commentCountCallback(0);}},commentAssetURL:function()
85 {return this.mAssetURL;},p_commentCountCallback:function(commentCount)
86 {this.mCommentCount=commentCount;if(this.mCommentCount>0)
87 {$('comment-badge-'+this.commentGUID()).show();}}});var IWImageStreamEntry=Class.create(IWCommentableStreamEntry,{initialize:function($super,assetURL,showCommentIndicator,imageURL,thumbnailURL,microURL,mipThumbnailURL,title,richTitle,guid)
88 {$super(assetURL,showCommentIndicator,thumbnailURL,title,richTitle,guid);this.mImage=IWCreateImage(imageURL);if(microURL)
89 {this.mMicro=IWCreateImage(microURL);}
90 if(mipThumbnailURL)
91 {this.mMIPThumbnail=IWCreateImage(mipThumbnailURL);}},setImageURL:function(imageURL)
92 {this.mImage=IWCreateImage(imageURL);},image:function()
93 {return this.mImage;},micro:function()
94 {return this.mMicro?this.mMicro:this.thumbnail();},mipThumbnail:function()
95 {return this.mMIPThumbnail?this.mMIPThumbnail:this.thumbnail();},targetURL:function()
96 {return this.mImage.sourceURL();},slideshowValue:function(imageType)
97 {var image=this[imageType]();return{image:image,caption:this.title()};}});var IWMovieStreamEntry=Class.create(IWCommentableStreamEntry,{initialize:function($super,assetURL,showCommentIndicator,movieURL,thumbnailURL,title,richTitle,movieParams,guid)
98 {$super(assetURL,showCommentIndicator,thumbnailURL,title,richTitle,guid);this.mMovieURL=movieURL;this.mMovieParams=movieParams;},movieURL:function()
99 {return this.mMovieURL;},targetURL:function()
100 {return this.movieURL();},isMovie:function()
101 {return true;},setMovieParams:function(params)
102 {this.mMovieParams=params;},slideshowValue:function(imageType)
103 {return{image:this.thumbnail(),movieURL:this.movieURL(),caption:this.title(),params:this.mMovieParams};}});var IWMediaStreamPageEntry=Class.create(IWStreamEntry,{initialize:function($super,targetPageURL,thumbnailURL,title,richTitle,guid)
104 {if(arguments.length>0)
105 {$super(thumbnailURL,title,richTitle,guid);this.mTargetPageURL=targetPageURL;}},thumbnailNaturalSize:function()
106 {return new IWSize(4000,3000);},targetURL:function()
107 {return this.mTargetPageURL;},positionedThumbnailMarkupForRect:function(rect)
108 {return IWMediaStreamPageEntryPositionedThumbnailMarkupForRect(this.mThumbnail,rect);}});function IWMediaStreamPageEntryPositionedThumbnailMarkupForRect(thumbnail,rect)
109 {var thumbnailSize=thumbnail.naturalSize();var scale=Math.max(rect.size.width/thumbnailSize.width,rect.size.height/thumbnailSize.height);var imageSize=thumbnailSize.scale(scale,scale,true);var imagePosition=new IWPoint((rect.size.width-imageSize.width)/2,(rect.size.height-imageSize.height)/2);imagePosition=imagePosition.scale(1,1,true);var imageRect=new IWRect(imagePosition,imageSize);return imgMarkup(thumbnail.sourceURL(),imageRect.position());}
110 var IWMediaStreamPhotoPageEntryPrefs={};var IWMediaStreamPhotoPageEntries={};function IWMediaStreamPhotoPageSetPrefs(slideshowPrefs)
111 {IWMediaStreamPhotoPageEntryPrefs=slideshowPrefs;}
112 var IWMediaStreamPhotoPageEntryUniqueId=0;var IWMediaStreamPhotoPageEntry=Class.create(IWMediaStreamPageEntry,{initialize:function($super,streamScriptURL,targetPageURL,title,contentsFunction,guid)
113 {$super(targetPageURL,null,title,null,guid);this.mStreamScriptURL=streamScriptURL;this.mContentsFunction=contentsFunction;},loadThumbnail:function(callback)
114 {this.mThumbnailCallback=callback;this.mSlideshowId='gridEntry'+IWMediaStreamPhotoPageEntryUniqueId++;IWMediaStreamPhotoPageEntries[this.mSlideshowId]=this;var loadingArea=IWCreateLoadingArea();var uniqueId='iFrame_'+new Date().getTime()+IWMediaStreamPhotoPageEntryUniqueId;loadingArea.innerHTML='<iframe id='+uniqueId+' src="streamloader.html?scriptURL='+this.mStreamScriptURL+'&id='+this.mSlideshowId+'" style="position: absolute; visibility: hidden; ">'+'</iframe>';},streamDidLoad:function(media)
115 {this.mMedia=media;if(this.mMedia&&this.mMedia.length>0)
116 {this.mThumbnail=this.mMedia[0].mipThumbnail();this.mThumbnail.load(this.mThumbnailCallback);}
117 else
118 {this.mThumbnailCallback();}},metric:function()
119 {var photoCount=0;var clipCount=0;if(this.mMedia)
120 {for(var index=0;index<this.mMedia.length;++index)
121 {if(this.mMedia[index].isMovie())
122 ++clipCount;else
123 ++photoCount;}}
124 return this.mContentsFunction(photoCount,clipCount);},thumbnailMarkupForRect:function(rect)
125 {var markup="";if(this.mThumbnail)
126 {markup='<div id="'+this.mSlideshowId+'" style="overflow: hidden; '+rect.position()+'" onclick="window.location.href = \''+this.targetURL()+'\'">'+
127 this.positionedThumbnailMarkupForRect(rect)+'<div id="'+this.mSlideshowId+'-slideshow_placeholder" style="position: absolute; left: 0px; top: 0px; height: 100%; width: 100%; overflow: hidden; ">'+'</div>'+'</div>';}
128 return markup;},didInsertThumbnailMarkupIntoDocument:function()
129 {if(this.mThumbnail)
130 {if(isiPhone==false)
131 {var prefs=IWMediaStreamPhotoPageEntryPrefs;prefs["mediaStreamObject"]={load:function(media,baseURL,callback){callback(media);}.bind(null,this.mMedia)};new SlideshowGlue(this.mSlideshowId,'../Scripts/Widgets/Slideshow','../Scripts/Widgets/SharedResources','..',prefs);}}}});function IWMediaStreamPhotoPageSetMediaStream(mediaStream,slideshowId)
132 {mediaStream.load(IWMediaStreamPhotoPageEntryPrefs.baseURL,function(slideshowId,media)
133 {IWMediaStreamPhotoPageEntries[slideshowId].streamDidLoad(media);}.bind(null,slideshowId));}
134 var IWMediaStreamMediaPageEntryUniqueId=0;var IWMediaStreamMediaPageEntry=Class.create(IWMediaStreamPageEntry,{initialize:function($super,targetPageURL,thumbnailURL,title,contents,isMovie,guid)
135 {$super(targetPageURL,thumbnailURL,title,null,guid);this.mContents=contents;this.mIsMovie=isMovie;},isMovie:function()
136 {return this.mIsMovie;},metric:function()
137 {return this.mContents;},thumbnailMarkupForRect:function(rect)
138 {var badgeRect=new IWRect(new IWPoint(0,0),rect.size);var thumbnailMarkup=this.positionedThumbnailMarkupForRect(rect)+this.badgeMarkupForRect(badgeRect);var idAttribute="";var playButtonMarkup="";if(this.isMovie())
139 {this.mPlayButtonId='movieEntry'+IWMediaStreamMediaPageEntryUniqueId++;idAttribute='id="'+this.mPlayButtonId+'"';playButtonMarkup='<div id="'+this.mPlayButtonId+'-play_button" class="play_button">'+'<div>'+'</div>'+'</div>';}
140 var markup='<div '+idAttribute+' style="overflow: hidden; '+rect.position()+'" onclick="window.location.href = \''+this.targetURL()+'\'">'+
141 thumbnailMarkup+
142 playButtonMarkup+'</div>';return markup;},didInsertThumbnailMarkupIntoDocument:function()
143 {if(this.isMovie())
144 {if(isiPhone==false)
145 {new PlayButton(this.mPlayButtonId,'../Scripts/Widgets/PlayButton','../Scripts/Widgets/SharedResources','..',{});}}}});var gPhotoFormats=[];var gClipFormats=[];function IWCreateMediaCollection(url,slideshowEnabled,transitionIndex,photoFormats,clipFormats)
146 {var feed=IWAllFeeds[url];if(feed==null)
147 {if(gPhotoFormats.length==0)
148 {gPhotoFormats=photoFormats;}
149 if(gClipFormats.length==0)
150 {gClipFormats=clipFormats;}
151 feed=new IWMediaCollection(url,slideshowEnabled,transitionIndex);}
152 return feed;}
153 var IWMediaCollection=Class.create(IWFeed,{initialize:function($super,url,slideshowEnabled,transitionIndex)
154 {$super(url);this.mSlideshowEnabled=slideshowEnabled;this.mTransitionIndex=transitionIndex;},p_interpretItems:function(baseURL,items)
155 {var iWebNamespace='http://www.apple.com/iweb';var thumbnailNamespace='urn:iphoto:property';var truthFeed=this.mURL.indexOf('?webdav-method=truthget')!=-1;if(truthFeed)
156 {iWebNamespace=thumbnailNamespace="urn:iweb:";}
157 if(IWMediaStreamPhotoPageSetPrefs)
158 {IWMediaStreamPhotoPageSetPrefs({slideshowEnabled:this.mSlideshowEnabled,fadeIn:true,showOnMouseOver:true,photoDuration:2,startIndex:1,scaleMode:"fill",transitionIndex:this.mTransitionIndex,imageType:"mipThumbnail",movieMode:kPosterFrameOnly,baseURL:baseURL});}
159 var mediaStream=[];for(var i=0;i<items.length;++i)
160 {var item=items[i];var link=null;if(truthFeed)
161 {link=this.p_firstElementByTagNameNS(item,iWebNamespace,'link');}
162 if(link==null)
163 {link=item.getElementsByTagName('link')[0];}
164 if(link!=null)
165 {var titleText='';var title=item.getElementsByTagName('title')[0];if(title!=null)
166 {titleText=title.firstChild.nodeValue;}
167 var skip=false;if(truthFeed)
168 {title=this.p_firstElementByTagNameNS(item,iWebNamespace,'title');if(title!=null)
169 {titleText=title.firstChild.nodeValue;}
170 else
171 {skip=true;}}
172 if(skip==false)
173 {var pageURL=link.firstChild.nodeValue.toRelativeURL(baseURL);var entry=null;var guidNode=item.getElementsByTagName('useritemguid')[0];var guid=null;if(guidNode!=null)
174 {guid=guidNode.firstChild.nodeValue;}
175 var thumbnail=this.p_firstElementByTagNameNS(item,thumbnailNamespace,'thumbnail')||item.getElementsByTagName('thumbnail')[0];if(thumbnail)
176 {var thumbnailURL=transparentGifURL();if(thumbnail.firstChild&&thumbnail.firstChild.nodeValue)
177 {thumbnailURL=thumbnail.firstChild.nodeValue.toRelativeURL(baseURL);}
178 var contentsText=null;var contents=this.p_firstElementByTagNameNS(item,iWebNamespace,'contents');if(contents)
179 {contentsText=contents.firstChild.nodeValue;}
180 var isMovie=false;var isMovieValue=this.p_firstElementByTagNameNS(item,iWebNamespace,'is-movie');if(isMovieValue&&isMovieValue.firstChild&&isMovieValue.firstChild.nodeValue)
181 {isMovie=(isMovieValue.firstChild.nodeValue=='true');}
182 entry=new IWMediaStreamMediaPageEntry(pageURL,thumbnailURL,titleText,contentsText,isMovie,guid);}
183 else
184 {var pageName=pageURL.lastPathComponent().stringByDeletingPathExtension();var pageScriptURL=pageURL.stringByDeletingLastPathComponent().stringByAppendingPathComponent(pageName+"_files").stringByAppendingPathComponent(pageName+".js");entry=new IWMediaStreamPhotoPageEntry(pageScriptURL,pageURL,titleText,albumContentsFunction,guid);}
185 mediaStream.push(entry);}}}
186 return mediaStream;}});function albumContentsFunction(photoCount,clipCount)
187 {var contents="";photoFormat=gPhotoFormats[Math.min(photoCount,2)];clipFormat=gClipFormats[Math.min(clipCount,2)];photoFormat=photoFormat.replace(/%d/,photoCount);clipFormat=clipFormat.replace(/%d/,clipCount);if(clipFormat&&clipFormat.length>0&&photoCount==0)
188 {contents=clipFormat;}
189 else
190 {contents=photoFormat;if(clipFormat&&clipFormat.length>0)
191 {contents+=", "+clipFormat;}}
192 return contents;}
193 function IWCreatePhotocast(url,showCommentIndicator)
194 {var feed=IWAllFeeds[url];if(feed==null)
195 {feed=new IWPhotocast(url,showCommentIndicator);}
196 return feed;}
197 var IWPhotocast=Class.create(IWFeed,{initialize:function($super,url,showCommentIndicator)
198 {$super(url);this.mShowCommentIndicator=showCommentIndicator;},p_interpretItems:function(baseURL,items)
199 {var imageStream=[];for(var i=0;i<items.length;++i)
200 {var item=items[i];enclosure=item.getElementsByTagName('enclosure')[0];if(enclosure!=null)
201 {var titleText='';var title=item.getElementsByTagName('title')[0];if(title&&title.firstChild&&title.firstChild.nodeValue)
202 {titleText=title.firstChild.nodeValue;}
203 var iWebNamespace='http://www.apple.com/iweb';var thumbnailNamespace='urn:iphoto:property';var richTitleHTML;var richTitle=this.p_firstElementByTagNameNS(item,iWebNamespace,'richTitle');if(richTitle&&richTitle.firstChild&&richTitle.firstChild.nodeValue)
204 {richTitleHTML=richTitle.firstChild.nodeValue.stringByUnescapingXML();}
205 var guidNode=item.getElementsByTagName('guid')[0];var guid=null;if(guidNode!=null)
206 {guid=guidNode.firstChild.nodeValue;}
207 var thumbnail=this.p_firstElementByTagNameNS(item,thumbnailNamespace,'thumbnail')||item.getElementsByTagName('thumbnail')[0];IWAssert(function(){return thumbnail!=null},"Could not get thumbnail from feed.  Server configuration may have changed.");if(thumbnail)
208 {var entry=null;var type=enclosure.getAttribute("type").split("/");var thumbnailURL=thumbnail.firstChild.nodeValue.toRebasedURL(baseURL);if(type[0]=="video")
209 {var movieURL=enclosure.getAttribute('url').toRebasedURL(baseURL);var movieParams=null;var movieParamsElement=this.p_firstElementByTagNameNS(item,iWebNamespace,'movieParams');if(movieParamsElement&&movieParamsElement.firstChild&&movieParamsElement.firstChild.nodeValue)
210 {var movieParamsJSON=movieParamsElement.firstChild.nodeValue.stringByUnescapingXML();movieParams=eval('('+movieParamsJSON+')');}
211 var assetURL=movieURL.stringByDeletingLastPathComponent();IWAssert(function(){return assetURL!=null},"could not determine asset URL for movie: "+movieURL);entry=new IWMovieStreamEntry(assetURL,this.mShowCommentIndicator,movieURL,thumbnailURL,titleText,richTitleHTML,movieParams,guid);}
212 else
213 {var imageURL=enclosure.getAttribute('url').toRebasedURL(baseURL);var assetURL=imageURL.urlStringByDeletingQueryAndFragment().stringByDeletingPathExtension();var microURL=null;var micro=this.p_firstElementByTagNameNS(item,iWebNamespace,'micro');if(micro&&micro.firstChild&&micro.firstChild.nodeValue)
214 {microURL=micro.firstChild.nodeValue.toRebasedURL(baseURL);}
215 if(!microURL)
216 {microURL=(imageURL.urlStringByDeletingQueryAndFragment()+"?derivative=micro").toRebasedURL(baseURL);}
217 var mipThumbnailURL=null;var mipThumbnail=this.p_firstElementByTagNameNS(item,iWebNamespace,'mip-thumbnail');if(mipThumbnail&&mipThumbnail.firstChild&&mipThumbnail.firstChild.nodeValue)
218 {mipThumbnailURL=mipThumbnail.firstChild.nodeValue.toRebasedURL(baseURL);}
219 if(!mipThumbnailURL)
220 {mipThumbnailURL=(imageURL.urlStringByDeletingQueryAndFragment()+"?derivative=mip&alternate=thumb").toRebasedURL(baseURL);}
221 IWAssert(function(){return assetURL!=null},"could not determine asset URL for image: "+imageURL);entry=new IWImageStreamEntry(assetURL,this.mShowCommentIndicator,imageURL,thumbnailURL,microURL,mipThumbnailURL,titleText,richTitleHTML,guid);}
222 imageStream.push(entry);}}}
223 return imageStream;}});var kPhotoViewMovieControllerHeight=16;var kShowMovie=0;var kAutoplayMovie=1;var kPosterFrameOnly=2;function setFrameOptionallyMovingContents(element,frame,moveContents)
224 {var oldOrigin=new IWPoint(element.offsetLeft,element.offsetTop);$(element).setStyle({left:px(frame.origin.x),top:px(frame.origin.y),width:px(frame.size.width),height:px(frame.size.height)});var offset=new IWPoint(oldOrigin.x-frame.origin.x,oldOrigin.y-frame.origin.y);if(moveContents)
225 {offsetChildren(element,offset,false);}
226 return offset;}
227 function offsetChildren(element,offset,reverse)
228 {for(var node=element.firstChild;node;node=node.nextSibling)
229 {var left=parseFloat(node.style.left||0);var top=parseFloat(node.style.top||0);$(node).setStyle({left:px(reverse?left-offset.x:left+offset.x),top:px(reverse?top-offset.y:top+offset.y)});}}
230 var PhotoViewWaitingForDonePlaying=[];function PhotoViewDonePlaying(index)
231 {PhotoViewWaitingForDonePlaying[index]();return false;}
232 var PhotoView=Class.create({initialize:function(container,scaleMode,reflectionHeight,reflectionOffset,backgroundColor,movieMode,captionHeight)
233 {this.scaleMode="fit";this.reflectionHeight=0;this.reflectionOffset=0;this.backgroundColor="black";this.movieMode=kShowMovie;this.captionHeight=0;if(scaleMode)
234 {this.scaleMode=scaleMode;}
235 if(reflectionHeight)
236 {this.reflectionHeight=reflectionHeight;if(reflectionOffset)
237 {this.reflectionOffset=reflectionOffset;}
238 if(windowsInternetExplorer)
239 {this.reflection=document.createElement("img");}
240 else
241 {this.reflection=document.createElement("canvas");}}
242 if(captionHeight)
243 {this.captionHeight=captionHeight;this.caption=document.createElement("div");}
244 if(backgroundColor)
245 {this.backgroundColor=backgroundColor;}
246 if(movieMode!==undefined)
247 {this.movieMode=movieMode;}
248 var div=document.createElement("div");var canvas=document.createElement("canvas");if(canvas.getContext&&!isOpera)
249 {div.appendChild(canvas);this.canvas=canvas;}
250 else
251 {var img=document.createElement("img");img.src=transparentGifURL();div.appendChild(img);this.img=img;}
252 if(this.reflection)
253 {div.appendChild(this.reflection);}
254 if(this.caption)
255 {div.appendChild(this.caption);}
256 container.appendChild(div);this.box=container;this.div=div;this.initStyle();},boxSize:function()
257 {return{width:this.box.offsetWidth,height:this.box.offsetHeight};},initStyle:function()
258 {var box_size=this.boxSize();$(this.div).setStyle({position:"absolute",width:px(box_size.width),height:px(box_size.height),backgroundColor:this.backgroundColor});if(this.canvas)
259 {$(this.canvas).setStyle({position:"absolute",left:0,top:0});$(this.canvas).setAttribute("width",box_size.width);$(this.canvas).setAttribute("height",box_size.height-Math.max(this.reflectionHeight+this.reflectionOffset,this.captionHeight));if(!windowsInternetExplorer)
260 {this.canvas.style.zIndex="inherit";}}
261 else if(this.img)
262 {this.img.style.position="absolute";}
263 if(this.reflection)
264 {this.reflection.style.position="absolute";if(!windowsInternetExplorer)
265 {this.reflection.setAttribute("width",box_size.width);this.reflection.setAttribute("height",this.reflectionHeight);}}
266 if(this.caption)
267 {$(this.caption).setStyle({position:"absolute",top:px(box_size.height-this.captionHeight*0.6),left:0,width:px(box_size.width)});this.caption.className="caption";}
268 this.resetSizeAndPosition();},setImage:function(photo)
269 {if(this.photo!==photo)
270 {if(this.photo)
271 {this.photo.image.allowUnloading();this.photo.image.unload();}
272 if(photo)
273 {photo.image.preventUnloading();}}
274 this.photo=photo;this.image=photo.image;this.movieURL=null;if(this.movieMode!=kPosterFrameOnly&&photo.movieURL)
275 {this.movieURL=photo.movieURL;}
276 if(this.caption)
277 {this.caption.innerHTML=photo.caption||'';}
278 var box_size=this.boxSize();box_size.height-=Math.max(this.reflectionHeight+this.reflectionOffset,this.captionHeight);if(this.movieURL&&box_size.height>kPhotoViewMovieControllerHeight)
279 {box_size.height-=kPhotoViewMovieControllerHeight;}
280 var box_aspect=box_size.height/box_size.width;var img_size=this.image.naturalSize();var img_aspect=img_size.height/img_size.width;var w=box_size.width;var h=box_size.height;if((img_aspect>box_aspect&&this.scaleMode=="fit")||(img_aspect<box_aspect&&this.scaleMode=="fill"))
281 {var ratio=box_size.height/img_size.height;if(this.scaleMode=="fit")
282 ratio=Math.min(ratio,1.0);w=Math.round(img_size.width*ratio);h=Math.round(img_size.height*ratio);}
283 else if((img_aspect<box_aspect&&this.scaleMode=="fit")||(img_aspect>box_aspect&&this.scaleMode=="fill"))
284 {var ratio=box_size.width/img_size.width;if(this.scaleMode=="fit")
285 ratio=Math.min(ratio,1.0);w=Math.round(img_size.width*ratio);h=Math.round(img_size.height*ratio);}
286 var x=Math.floor((box_size.width-w)/2);var y=Math.floor((box_size.height-h)/2);if(this.canvas)
287 {if(this.scaleMode=="fit")
288 {if(this.canvas.width!=w||this.canvas.height!=h)
289 {if(true)
290 {var newCanvas=this.canvas.cloneNode(false);newCanvas.setAttribute("width",w);newCanvas.setAttribute("height",h);this.canvas.parentNode.replaceChild(newCanvas,this.canvas);this.canvas=newCanvas;}
291 else
292 {this.canvas.setAttribute("width",w);this.canvas.setAttribute("height",h);}
293 $(this.canvas).setStyle({top:px(y),left:px(x)});}
294 if(w>0&&h>0)
295 {var context=this.canvas.getContext("2d");context.clearRect(0,0,w,h);context.drawImage(this.image.imgObject(),0,0,w,h);}}
296 else
297 {if(w>0&&h>0)
298 {var context=this.canvas.getContext("2d");context.clearRect(0,0,this.canvas.width,this.canvas.height);context.drawImage(this.image.imgObject(),x,y,w,h);}}}
299 else if(this.img)
300 {$(this.img).src=this.image.sourceURL();$(this.img).setStyle({width:px(w),height:px(h),top:px(y),left:px(x)});}
301 this.updateReflection(x,y,w,h);if(windowsInternetExplorer)
302 {setTimeout(this.updateReflection.bind(this,x,y,w,h),0);}
303 if(this.movieURL)
304 {this.movieRect=new IWRect(x,y,w,h);this.p_updateMovieRect();}},willAnimate:function()
305 {if(this.caption&&this.caption.parentNode==this.div)
306 {this.div.removeChild(this.caption);}},didAnimate:function()
307 {if(this.caption&&this.caption.parentNode!=this.div)
308 {this.div.appendChild(this.caption);}},transitionComplete:function()
309 {if(this.movieURL&&this.movieMode!=kPosterFrameOnly)
310 {this.p_showMovie();}},updateReflection:function(x,y,w,h)
311 {if(this.reflection)
312 {var opacity=0.5;this.reflection.style.top=px(y+h+this.reflectionOffset);if(windowsInternetExplorer)
313 {this.reflection.src=this.image.sourceURL();$(this.reflection).setStyle({left:px(x),width:px(w),height:px(h)});this.reflection.style.filter='flipv'+' progid:DXImageTransform.Microsoft.Alpha(opacity='+opacity*100+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+this.reflectionHeight/h*100+')';}
314 else if(this.reflection.getContext)
315 {if(true)
316 {var newReflection=this.reflection.cloneNode(false);newReflection.setAttribute("width",w);this.reflection.parentNode.replaceChild(newReflection,this.reflection);this.reflection=newReflection;}
317 else
318 {this.reflection.setAttribute("width",w);}
319 this.reflection.style.left=px(x);if(w>0&&this.reflection.height>0)
320 {var context=this.reflection.getContext("2d");context.clearRect(0,0,w,this.reflection.height);context.save();context.translate(0,h-1);context.scale(1,-1);context.drawImage(this.image.imgObject(),0,0,w,h);context.restore();context.save();var gradient=context.createLinearGradient(0,0,0,this.reflectionHeight);gradient.addColorStop(1,this.backgroundColor);var partiallyOpaque="rgba(0,0,0,"+opacity+")";var components=this.backgroundColor.toLowerCase().match(/#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/);if(components&&components.length>=4)
321 {partiallyOpaque="rgba("+parseInt(components[1],16)+", "+parseInt(components[2],16)+", "+parseInt(components[3],16)+", "+opacity+")";}
322 gradient.addColorStop(0,partiallyOpaque);context.fillStyle=gradient;if(navigator.appVersion.indexOf('WebKit')!=-1)
323 {context.rect(0,0,w,this.reflectionHeight*2);context.fill();}
324 else
325 {context.fillRect(0,0,w,this.reflectionHeight*2);}
326 context.restore();}}}},updateSize:function()
327 {this.initStyle();if(this.photo)
328 {this.photo.image.load(this.setImage.bind(this,this.photo));}},setZIndex:function(zIndex)
329 {this.div.style.zIndex=zIndex;},upper:function()
330 {this.setZIndex(1);},lower:function()
331 {this.setZIndex(0);},show:function()
332 {this.div.style.visibility="visible";},hide:function()
333 {this.p_destroyMovie();this.div.style.visibility="hidden";},upperShown:function()
334 {this.upper();this.show();},upperHidden:function()
335 {this.hide();this.upper();},lowerShown:function()
336 {this.lower();this.show();},lowerHidden:function()
337 {this.hide();this.lower();},setClipPx:function(top,width,height,left)
338 {this.div.style.clip="rect("+top+"px "+width+"px "+height+"px "+left+"px)";},setLeftPx:function(left)
339 {this.div.style.left=px(left);},setTopPx:function(top)
340 {this.div.style.top=px(top);},setClipToMax:function()
341 {var size=this.boxSize();this.div.style.clip="rect(0px "+size.width+"px "+size.height+"px 0px)";},resetSizeAndPosition:function()
342 {$(this.div).setStyle({left:0,top:0});this.setClipToMax();},setOpacity:function(opacity)
343 {IWSetDivOpacity(this.div,opacity)},p_appendParamToObject:function(name,value)
344 {var param=document.createElement("param");param.name=name;param.value=value;this.object.appendChild(param);},p_stopMovie:function()
345 {var movie=this.movieID?document[this.movieID]:null;if(movie)
346 {var status=null;try
347 {status=movie.GetPluginStatus();}
348 catch(e)
349 {status=null;}
350 if(status==null||status.startsWith("Error:")||status=="Waiting"||status=="Loading")
351 {}
352 else
353 {if(status=="Playable"||status=="Complete")
354 {if(movie.GetRate()>0)
355 {movie.Stop();}}}}},p_destroyMovie:function()
356 {if(this.movieID)
357 {this.p_stopMovie();var movie=document[this.movieID];if(movie)
358 {movie.style.display="none";}
359 this.div.removeChild(this.object);delete this.object;delete this.movieIndex;delete this.movieID;}},p_movieDidFinish:function()
360 {NotificationCenter.postNotification(new IWNotification("PhotoViewMovieDidEnd",this,{}));},p_timeString:function(time)
361 {var seconds=Math.floor(time);var frames=(time-seconds)*30;var minutes=Math.floor(seconds/60);var hours=Math.floor(minutes/60);seconds-=minutes*60;minutes-=hours*60;if(minutes<10)
362 {minutes="0"+minutes;}
363 if(seconds<10)
364 {seconds="0"+seconds;}
365 frames=Math.round(frames*10)/10;if(frames<10)
366 {frames="0"+frames;}
367 var timeString=hours+":"+minutes+":"+seconds+":"+frames;return timeString;},p_movieHeight:function()
368 {var movieHeight=this.movieRect.size.height;if(this.photo.params.movieShowController)
369 {movieHeight+=kPhotoViewMovieControllerHeight;}
370 return movieHeight;},p_updateMovieRect:function()
371 {if(this.object)
372 {this.object.setAttribute("width",this.movieRect.size.width);this.object.setAttribute("height",this.p_movieHeight());$(this.object).setStyle({position:"absolute",left:px(this.movieRect.origin.x),top:px(this.movieRect.origin.y)});}},p_showMovie:function()
373 {this.object=document.createElement("object");if(this.object)
374 {this.movieIndex=PhotoViewWaitingForDonePlaying.length;this.movieID="photoViewMovie"+this.movieIndex;this.object.id=this.movieID;if(!windowsInternetExplorer)
375 {this.object.type="video/quicktime";this.object.setAttribute("data",this.movieURL);this.object.style.zIndex="inherit";}
376 this.p_updateMovieRect();var shouldAutoplay=this.movieMode==kAutoplayMovie||this.photo.params.movieAutoPlay;this.p_appendParamToObject("controller",this.photo.params.movieShowController?"true":"false");this.p_appendParamToObject("autoplay",shouldAutoplay?"true":"false");this.p_appendParamToObject("scale","tofit");this.p_appendParamToObject("volume","12800");this.p_appendParamToObject("loop",this.photo.params.movieLoop!="SFDMovieNoLoop"?"true":"false");this.p_appendParamToObject("starttime",this.p_timeString(this.photo.params.movieStartTime*this.photo.params.movieDuration));this.p_appendParamToObject("endtime",this.p_timeString(this.photo.params.movieEndTime*this.photo.params.movieDuration));this.p_appendParamToObject("src",this.movieURL);PhotoViewWaitingForDonePlaying[this.movieIndex]=this.p_movieDidFinish.bind(this);this.p_appendParamToObject("qtnext1","<javascript:PhotoViewDonePlaying("+this.movieIndex+");>");this.div.appendChild(this.object);if(windowsInternetExplorer)
377 {this.object.classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";this.object.codebase="http://www.apple.com/qtactivex/qtplugin.cab";}}},setMovieTime:function(time)
378 {if(this.object)
379 {var movie=document[this.movieID];movie.Stop();movie.SetTime(time*movie.GetDuration());}},p_updateMovieParams:function()
380 {if(this.object)
381 {var movie=document[this.movieID];if(movie)
382 {var params=$H(this.photo.params);var self=this;params.each(function(pair)
383 {if(pair.key=="movieShowController")
384 {if(movie.GetControllerVisible()!=pair.value)
385 {movie.SetControllerVisible(pair.value);self.object.setAttribute("height",self.p_movieHeight());}}
386 else if(pair.key=="movieLoop")
387 {movie.SetIsLooping(pair.value!="SFDMovieNoLoop");}
388 else if(pair.key=="movieAutoPlay")
389 {movie.SetAutoPlay(pair.value||this.movieMode==kAutoplayMovie);}
390 else if(pair.key=="movieStartTime")
391 {movie.SetStartTime(pair.value*movie.GetDuration());}
392 else if(pair.key=="movieEndTime")
393 {movie.SetEndTime(pair.value*movie.GetDuration());}});}}},setMovieParams:function(params)
394 {var photo=this.photo;$H(params).each(function(pair)
395 {photo.params[pair.key]=pair.value;});this.p_updateMovieParams();}});var SimpleAnimation=Class.create({initialize:function(oncomplete)
396 {this.duration=500;this.from=0.0;this.to=1.0;if(oncomplete!=null){this.oncomplete=oncomplete;}},animationComplete:function()
397 {delete this.animation;delete this.animator;this.post();if(this.oncomplete!=null){this.oncomplete();}},stop:function()
398 {if(this.animation!=null){this.animator.stop();this.post();delete this.animation;delete this.animator;}},start:function()
399 {this.stop();this.pre();var self=this;var animator=new AppleAnimator(this.duration,13);animator.oncomplete=function(){self.animationComplete();};this.animator=animator;this.framecount=0;var update=function(animation,now,first,done){self.update(now);++self.framecount;}
400 this.animation=new AppleAnimation(this.from,this.to,update);animator.addAnimation(this.animation);animator.start();},pre:function()
401 {},post:function()
402 {},update:function(now)
403 {}});var TransitionEffect=Class.create({initialize:function(current,next,oncomplete,shouldTighten)
404 {this.current=current;this.next=next;this.oncomplete=oncomplete;this.shouldTighten=shouldTighten;this.effects=[{name:"Random",method:"random"},{name:"Jump",method:"jump"},{name:"Fade",method:"fade"},{name:"Wipe",directions:[{name:"Right",method:"wipeRight"},{name:"Left",method:"wipeLeft"},{name:"Down",method:"wipeDown"},{name:"Up",method:"wipeUp"},{name:"In",method:"wipeIn"},{name:"Out",method:"wipeOut"}]},{name:"Close",directions:[{name:"Horizontal",method:"wipeCloseHoriz"},{name:"Vertical",method:"wipeCloseVert"}]},{name:"Open",directions:[{name:"Horizontal",method:"wipeOpenHoriz"},{name:"Vertical",method:"wipeOpenVert"}]},{name:"Reveal",directions:[{name:"Right",method:"slideOffRight"},{name:"Left",method:"slideOffLeft"},{name:"Down",method:"slideOffDown"},{name:"Up",method:"slideOffUp"}]},{name:"Slide On",directions:[{name:"Right",method:"slideOnRight"},{name:"Left",method:"slideOnLeft"},{name:"Down",method:"slideOnDown"},{name:"Up",method:"slideOnUp"}]},{name:"Push",directions:[{name:"Right",method:"pushRight"},{name:"Left",method:"pushLeft"},{name:"Down",method:"pushDown"},{name:"Up",method:"pushUp"}]},{name:"Fade Through Black",method:"fadeThroughBlack"}];},doEffect:function(effect)
405 {this[effect]();},random:function()
406 {var supportedEffects=[2,6,8,9];var idx=Math.floor(Math.random()*supportedEffects.length);var num=supportedEffects[idx];var effect=this.effects[num];var method=effect.directions?effect.directions[0].method:effect.method;this.doEffect(method);},animationComplete:function()
407 {delete this.animation;if(this.oncomplete!=null){this.oncomplete();}},jump:function()
408 {this.stop();this.next.upperShown();this.current.lowerHidden();this.animationComplete();},tighten:function(horiz,vert)
409 {if(this.shouldTighten&&(vert||horiz))
410 {var top=99999;var left=99999;var right=0;var bottom=0;function expand(div)
411 {for(var node=div.firstChild;node;node=node.nextSibling)
412 {var t=node.offsetTop;var l=node.offsetLeft;left=Math.min(left,l);top=Math.min(top,t);right=Math.max(right,l+node.offsetWidth);bottom=Math.max(bottom,t+node.offsetHeight);}}
413 expand(this.current.div);expand(this.next.div);if(vert==false||horiz==false)
414 {var boxSize=this.current.boxSize();if(vert==false)
415 {top=0;bottom=boxSize.height;}
416 if(horiz==false)
417 {left=0;right=boxSize.width;}}
418 var frame=new IWRect(left,top,right-left,bottom-top);this.current.originalFrame=new IWRect(this.current.div.offsetLeft,this.current.div.offsetTop,this.current.div.offsetWidth,this.current.div.offsetHeight);this.next.originalFrame=new IWRect(this.next.div.offsetLeft,this.next.div.offsetTop,this.next.div.offsetWidth,this.next.div.offsetHeight);this.current.offset=setFrameOptionallyMovingContents(this.current.div,frame,true);this.next.offset=setFrameOptionallyMovingContents(this.next.div,frame,true);}},loosen:function(loosenHoriz,loosenVert)
419 {if(this.shouldTighten&&(loosenHoriz||loosenVert))
420 {setFrameOptionallyMovingContents(this.current.div,this.current.originalFrame,false);setFrameOptionallyMovingContents(this.next.div,this.next.originalFrame,false);offsetChildren(this.current.div,this.current.offset,true);offsetChildren(this.next.div,this.next.offset,true);}},fade:function()
421 {this.stop();var self=this;this.animation=new SimpleAnimation(function(){self.animationComplete();});this.animation.pre=function()
422 {self.tighten(true,true);self.current.upperShown();self.next.lowerShown();self.current.setOpacity(1.0);self.next.setOpacity(1.0);}
423 this.animation.post=function()
424 {self.loosen(true,true);self.next.upperShown();self.next.setOpacity(1.0);self.current.lowerHidden();self.current.setOpacity(1.0);}
425 this.animation.update=function(now)
426 {self.current.setOpacity(1.0-now);}
427 this.animation.start();},fadeThroughBlack:function()
428 {this.stop();var self=this;this.animation=new SimpleAnimation(function(){self.animationComplete();});this.animation.pre=function()
429 {self.tighten(true,true);self.current.upperShown();self.next.lowerShown();self.current.setOpacity(1.0);self.next.setOpacity(0.0);}
430 this.animation.post=function()
431 {self.loosen(true,true);self.next.upperShown();self.next.setOpacity(1.0);self.current.lowerHidden();self.current.setOpacity(1.0);}
432 this.animation.update=function(now)
433 {if(now<0.5)
434 {self.current.setOpacity((0.5-now)*2);}
435 else
436 {self.current.lowerHidden();self.next.setOpacity((now-0.5)*2);}}
437 this.animation.start();},doWipe:function(wiper,inFlag,tightenHoriz,tightenVert)
438 {this.stop();var self=this;this.animation=new SimpleAnimation(function(){self.animationComplete();});this.animation.pre=function()
439 {self.current.resetSizeAndPosition();self.width=parseInt(self.current.div.style.width);self.height=parseInt(self.current.div.style.height);self.tighten(tightenHoriz,tightenVert);if(inFlag){wiper.call(self,self.animation.from);self.next.upperShown();self.current.lowerShown();}
440 else{self.current.upperShown();self.next.lowerShown();}}
441 this.animation.post=function()
442 {self.loosen(tightenHoriz,tightenVert);self.next.upperShown();self.next.resetSizeAndPosition();self.current.lowerHidden();self.current.resetSizeAndPosition();}
443 this.animation.update=function(now)
444 {wiper.call(self,now);}
445 this.animation.start();},wipeRight:function()
446 {this.doWipe(function(now)
447 {this.current.setClipPx(0,this.width,this.height,now*this.width);});},wipeLeft:function()
448 {this.doWipe(function(now)
449 {this.current.setClipPx(0,this.width-now*this.width,this.height,0);});},wipeDown:function()
450 {this.doWipe(function(now)
451 {this.current.setClipPx(now*this.height,this.width,this.height,0);});},wipeUp:function()
452 {this.doWipe(function(now)
453 {this.current.setClipPx(0,this.width,this.height-now*this.height,0);});},wipeIn:function()
454 {this.doWipe(function(now)
455 {var x=this.width*(1-now)/2;var y=this.height*(1-now)/2;this.next.setClipPx(y,this.width-x,this.height-y,x);},true);},wipeOut:function()
456 {this.doWipe(function(now)
457 {var x=this.width*now/2;var y=this.height*now/2;this.current.setClipPx(y,this.width-x,this.height-y,x);});},wipeCloseHoriz:function()
458 {this.doWipe(function(now)
459 {var x=this.width*now/2;this.current.setClipPx(0,this.width-x,this.height,x);});},wipeCloseVert:function()
460 {this.doWipe(function(now)
461 {var y=this.height*now/2;this.current.setClipPx(y,this.width,this.height-y,0);});},wipeOpenHoriz:function()
462 {this.doWipe(function(now)
463 {var x=this.width*(1-now)/2;this.next.setClipPx(0,this.width-x,this.height,x);},true);},wipeOpenVert:function()
464 {this.doWipe(function(now)
465 {var y=this.height*(1-now)/2;this.next.setClipPx(y,this.width,this.height-y,0);},true);},slideOffRight:function()
466 {this.doWipe(function(now)
467 {var x=now*this.width;this.current.setLeftPx(x+(this.width-parseInt(this.current.div.style.width))/2);},false,true,true);},slideOffLeft:function()
468 {this.doWipe(function(now)
469 {var x=now*this.width;this.current.setClipPx(0,this.width,this.height,x);this.current.setLeftPx(-x);});},slideOffDown:function()
470 {this.doWipe(function(now)
471 {var y=now*this.height;this.current.setClipPx(0,this.width,this.height-y,0);this.current.setTopPx(y);});},slideOffUp:function()
472 {this.doWipe(function(now)
473 {var y=now*this.width;this.current.setClipPx(y,this.width,this.height,0);this.current.setTopPx(-y);});},slideOnRight:function()
474 {this.doWipe(function(now)
475 {var x=(1-now)*this.width;this.next.setClipPx(0,this.width,this.height,x);this.next.setLeftPx(-x);},true);},slideOnLeft:function()
476 {this.doWipe(function(now)
477 {var x=now*this.width;this.next.setClipPx(0,x,this.height,0);this.next.setLeftPx(this.width-x);},true);},slideOnDown:function()
478 {this.doWipe(function(now)
479 {var y=(1-now)*this.height;this.next.setClipPx(y,this.width,this.height,0);this.next.setTopPx(-y);},true);},slideOnUp:function()
480 {this.doWipe(function(now)
481 {var y=now*this.height;this.next.setClipPx(0,this.width,y,0);this.next.setTopPx(this.height-y);},true);},pushRight:function()
482 {this.doWipe(function(now)
483 {var x=now*this.width;this.current.setLeftPx(x+(this.width-parseInt(this.current.div.style.width))/2);this.next.setLeftPx(x-this.width+(this.width-parseInt(this.current.div.style.width))/2);},false,true,true);},pushLeft:function()
484 {this.doWipe(function(now)
485 {var x=now*this.width;this.current.setClipPx(0,this.width,this.height,x);this.current.setLeftPx(-x);this.next.setClipPx(0,x,this.height,0);this.next.setLeftPx(this.width-x);});},pushDown:function()
486 {this.doWipe(function(now)
487 {var y=now*this.height;this.current.setClipPx(0,this.width,this.height-y,0);this.current.setTopPx(y);this.next.setClipPx(this.height-y,this.width,this.height,0);this.next.setTopPx(y-this.height);});},pushUp:function()
488 {this.doWipe(function(now)
489 {var y=now*this.height;this.current.setClipPx(y,this.width,this.height,0);this.current.setTopPx(-y);this.next.setClipPx(0,this.width,y,0);this.next.setTopPx(this.height-y);});},stop:function()
490 {if(this.animation!=null){this.animation.stop();delete this.animation;}}});var Slideshow=Class.create({initialize:function(container,photos,onchange,options)
491 {this.reflectionHeight=0;this.reflectionOffset=0;this.backgroundColor='black';this.scaleMode="fit";this.movieMode=kShowMovie;this.advanceAnchor=null;this.captionHeight=0;this.shouldTighten=true;if(options)
492 {if(options.reflectionHeight)
493 {this.reflectionHeight=parseFloat(options.reflectionHeight);}
494 if(options.reflectionOffset)
495 {this.reflectionOffset=parseFloat(options.reflectionOffset);}
496 if(options.backgroundColor)
497 {this.backgroundColor=options.backgroundColor;}
498 if(options.scaleMode)
499 {this.scaleMode=options.scaleMode;}
500 if(options.movieMode!==undefined)
501 {this.movieMode=options.movieMode;}
502 if(options.advanceAnchor!==undefined)
503 {this.advanceAnchor=options.advanceAnchor;}
504 if(options.captionHeight!==undefined)
505 {this.captionHeight=options.captionHeight;}
506 if(options.shouldTighten!==undefined)
507 {this.shouldTighten=options.shouldTighten;}}
508 this.background=new PhotoView(container,this.scaleMode,0,0,this.backgroundColor,false,false,0);this.current={view:new PhotoView(container,this.scaleMode,this.reflectionHeight,this.reflectionOffset,this.backgroundColor,this.movieMode,this.captionHeight)};this.prev={view:new PhotoView(container,this.scaleMode,this.reflectionHeight,this.reflectionOffset,this.backgroundColor,this.movieMode,this.captionHeight)};this.next={view:new PhotoView(container,this.scaleMode,this.reflectionHeight,this.reflectionOffset,this.backgroundColor,this.movieMode,this.captionHeight)};this.current.view.upperShown();this.prev.view.lowerHidden();this.next.view.lowerHidden();this.photos=photos;this.onchange=onchange;this.paused=true;this.photoDuration=5000;this.currentPhotoNumber=0;this.selectedTransition="random";this.lastPhotoChange=new Date();},updateSize:function()
509 {this.background.updateSize();this.current.view.updateSize();this.prev.view.updateSize();this.next.view.updateSize();this.p_updateAnchorSize();},transitionComplete:function(number)
510 {this.transition.current.didAnimate();this.transition.next.didAnimate();this.transition.next.transitionComplete();delete this.transition;if(this.onchange!=null){this.onchange(number);}},showPhotoNumber:function(number,skipTransition)
511 {this.p_showPhotoNumber(number,skipTransition,true);},p_updateAnchorSize:function()
512 {if(this.advanceAnchor)
513 {var box_size=this.current.view.boxSize();$(this.advanceAnchor).setStyle({position:"absolute",width:px(box_size.width),height:px(box_size.height)});if(windowsInternetExplorer)
514 {var img=this.advanceAnchor.firstChild;if(!img)
515 {img=document.createElement('img');this.advanceAnchor.appendChild(img);}
516 img.src=transparentGifURL();img.style.width=this.advanceAnchor.style.width;img.style.height=this.advanceAnchor.style.height;}}},p_setAdvanceAnchorHandler:function()
517 {if(this.advanceAnchor)
518 {if(this.current.photo&&this.current.photo.movieURL)
519 {this.advanceAnchor.style.display='none';this.advanceAnchor.href='';this.advanceAnchor.onclick=function(){return false;};}
520 else
521 {this.advanceAnchor.style.display='';this.advanceAnchor.href='#'+this.nextPhotoNumber();this.advanceAnchor.onclick=function(i){setTimeout(this.showPhotoNumber.bind(this,i,true),0);}.bind(this,this.nextPhotoNumber());}}},p_showPhotoNumber:function(number,skipTransition,override)
522 {this.cancelNextPhotoTimer();if(this.transition!=null)
523 {this.transition.stop();delete this.transition;}
524 var transitionTime=500;var current=this.current;var prev=this.prev;var next=this.next;if(next.photo==undefined||next.photo!==this.photos[number])
525 {if(prev.photo!=undefined&&prev.photo===this.photos[number])
526 {next=prev;}
527 else if(override)
528 {next.photo=this.photos[number];}
529 else
530 {return;}}
531 if(next.photo.image.loaded()==false)
532 {next.photo.image.load(arguments.callee.bind(this,number,skipTransition,false));return;}
533 if(next.view.image==undefined||next.view.image!==next.photo.image)
534 {next.view.setImage(next.photo);}
535 var self=this;current.view.willAnimate();next.view.willAnimate();this.transition=new TransitionEffect(current.view,next.view,function(){self.transitionComplete(number);},this.shouldTighten);if(skipTransition||(new Date()).getTime()-this.lastPhotoChange.getTime()<transitionTime)
536 {this.transition.jump();}
537 else
538 {this.transition.doEffect(this.selectedTransition);}
539 this.currentPhotoNumber=number;this.lastPhotoChange=new Date();this.current=next;this.p_setAdvanceAnchorHandler();if(next===prev)
540 {this.prev=this.next;this.next=current;this.prev.photo=this.photos[this.prevPhotoNumber()];this.prev.photo.image.load(this.prev.view.setImage.bind(this.prev.view,this.prev.photo));}
541 else
542 {this.prev=current;this.next=prev;this.next.photo=this.photos[this.nextPhotoNumber()];this.next.photo.image.load(this.next.view.setImage.bind(this.next.view,this.next.photo));}
543 this.startNextPhotoTimer();},start:function()
544 {this.paused=false;this.showPhotoNumber(0);},pause:function()
545 {if(!this.paused){this.paused=true;this.cancelNextPhotoTimer();}},resume:function()
546 {if(this.paused){this.paused=false;this.startNextPhotoTimer();}},inactivate:function()
547 {this.pause();this.current.view.p_stopMovie();},startNextPhotoTimer:function(time)
548 {if(this.paused){return;}
549 if(this.nextPhotoTimer!=null){(function(){return false}).assert("trying to set overlapping timer");return;}
550 var self=this;var timedAdvance=function()
551 {delete self.nextPhotoTimer;var canAdvance=true;if(this.current.view.movieURL!=null)
552 {var movie=document[this.current.view.movieID];var status=null;try
553 {status=movie.GetPluginStatus();}
554 catch(e)
555 {status=null;}
556 if(status==null||status.startsWith("Error:"))
557 {}
558 else
559 {var time=movie.GetTime();var duration=movie.GetDuration();var timeScale=movie.GetTimeScale();var timeRemaining=duration-time;var timeRemainingInMS=timeRemaining/timeScale*1000;if(status=="Waiting"||status=="Loading")
560 {canAdvance=false;this.startNextPhotoTimer(timeRemainingInMS);}
561 else if(status=="Playable"||status=="Complete")
562 {if(timeRemainingInMS>0)
563 {canAdvance=false;this.startNextPhotoTimer(timeRemainingInMS);}}}}
564 if(canAdvance)
565 {self.advance();}}.bind(this)
566 this.nextPhotoTimer=setTimeout(timedAdvance,time||this.photoDuration);},cancelNextPhotoTimer:function()
567 {if(this.nextPhotoTimer!=null){clearTimeout(this.nextPhotoTimer);delete this.nextPhotoTimer;}},halt:function()
568 {this.cancelNextPhotoTimer();},unhalt:function()
569 {this.startNextPhotoTimer();},nextPhotoNumber:function()
570 {var number=this.currentPhotoNumber+1;if(number>=this.photos.length){number=0;}
571 return number;},prevPhotoNumber:function()
572 {var number=this.currentPhotoNumber-1;if(number<0){number=this.photos.length-1;}
573 return number;},advance:function()
574 {this.showPhotoNumber(this.nextPhotoNumber());},goBack:function()
575 {this.showPhotoNumber(this.prevPhotoNumber());},setMovieTime:function(time)
576 {this.current.view.setMovieTime(time);},setMovieParams:function(params)
577 {this.current.view.setMovieParams(params);},setImage:function(image)
578 {var current=this.current;current.photo.image=image;current.photo.image.load(current.view.setImage.bind(current.view,current.photo));},getAvailableTransitions:function()
579 {var te=new TransitionEffect;return te.effects;},setTransitionIndex:function(effectId,directionId)
580 {var effects=this.getAvailableTransitions();var effect=effects[effectId];if(effect!=null){if(effect.directions==null){if(effect.method!=null){this.selectedTransition=effect.method;}}
581 else{var dir=effect.directions[directionId];if(dir!=null&&dir.method!=null){this.selectedTransition=dir.method;}}}}});var IWHorizontalAlignment={kImageAlignLeft:0,kImageAlignCenter:1,kImageAlignRight:2}
582 var IWVerticalAlignment={kImageAlignTop:0,kImageAlignMiddle:1,kImageAlignBottom:2}
583 var IWPhotoGridLayoutConstants={kBorderThickness:6.0,vTextOffsetFromImage:5.0,vTextOffsetFromBottom:10.0,vTopSpacing:5.0,hMinSpacing:15.0}
584 var latestImageStream=null;var latestIndex=null;function IWStartSlideshow(url,imageStream,index,fullScreen)
585 {var windowWidth=800;var windowHeight=800;if(fullScreen)
586 {windowWidth=screen.availWidth;windowHeight=screen.availHeight;}
587 else
588 {if(screen.availHeight>975)
589 {windowWidth=1000;windowHeight=950;}
590 else if(screen.availHeight>775)
591 {windowWidth=800;windowHeight=750;}
592 else
593 {windowWidth=711;windowHeight=533;}}
594 windowWidth=Math.min(screen.availWidth,windowWidth);windowHeight=Math.min(screen.availHeight,windowHeight);var windowLeft=Math.round((screen.availWidth-windowWidth)/2);var windowTop=Math.round((screen.availHeight-windowHeight)/2)-25;windowTop=Math.max(windowTop,0);var slideWindow=window.open(url,'slideshow','scrollbars=no,titlebar=no,location=no,status=no,toolbar=no,resizable=no,width='+windowWidth+',height='+windowHeight+',top='+windowTop+',left='+windowLeft);if(slideWindow.screenY&&slideWindow.screenY>windowTop)
595 {slideWindow.screenY=windowTop;}
596 latestImageStream=imageStream;latestIndex=index;slideWindow.focus();return false;}
597 function IWUpdateVerticalAlignment(element)
598 {element=$(element);function setVerticalAlignmentAndClearClass(element,valign)
599 {var table=$(document.createElement("table"));table.setStyle({width:"100%",height:"100%",borderSpacing:0});var tr=document.createElement("tr");table.appendChild(tr);var td=document.createElement("td");td.setAttribute("valign",valign);tr.appendChild(td);element.className=element.className.replace(new RegExp('\\bvalign-'+valign+'\\b'),"");element.parentNode.replaceChild(table,element);td.appendChild(element);if(windowsInternetExplorer)
600 {var html=table.parentElement.innerHTML;table.parentElement.innerHTML=html;}}
601 var middleAligns=element.select('.valign-middle');for(var i=0;i<middleAligns.length;++i)
602 {setVerticalAlignmentAndClearClass(middleAligns[i],"middle");}
603 var bottomAligns=element.select('.valign-bottom');for(var i=0;i<bottomAligns.length;++i)
604 {setVerticalAlignmentAndClearClass(bottomAligns[i],"bottom");}}
605 function IWShowDiv(div,show)
606 {div.style.display=show?"inline":"none";}
607 function IWToggleDetailView(showDetail,index,divID,headerViewID,footerViewID,detailViewID,shadow)
608 {var grid=$(divID);var header=$(headerViewID);var footer=$(footerViewID);var detail=$(detailViewID);var showGrid=!showDetail;function showHide()
609 {IWShowDiv(grid,showGrid);IWShowDiv(header,showGrid);IWShowDiv(footer,showGrid);IWShowDiv(detail,showDetail);}
610 if(showDetail)
611 {var detailWidget=widgets[detailViewID];function showDetailView()
612 {showHide();detailWidget.willShow(index);IWSetSpacerHeight(grid,detailWidget.height());window.scrollTo(0,0);}
613 if(index!==undefined)
614 {detailWidget.showPhotoNumber(index,showDetailView);}
615 else
616 {showDetailView();}}
617 else
618 {showHide();if(isSafari&&!isEarlyWebKitVersion&&shadow)
619 {$(divID).select('.framedImage').each(function(framed)
620 {var renderShadowJob=shadow.applyToElement.bind(shadow,framed);IWJobQueue.sharedJobQueue.addJob(renderShadowJob);});}
621 if(grid.style.height)
622 {IWSetSpacerHeight(grid,parseFloat(grid.style.height));}}}
623 function IWSetSpacerHeight(photogrid,height)
624 {var parent=$(photogrid.parentNode);var spacers=parent.select('.spacer');var spacer=spacers[spacers.length-1];if(initialSpacerHeight==0)
625 {initialSpacerHeight=parseInt(spacer.style.height);}
626 var spacerHeight=Math.max(parseInt(photogrid.style.top)+height-spacer.offsetTop,initialSpacerHeight);spacer.style.height=spacer.style.lineHeight=px(spacerHeight);}
627 function IWLayoutPhotoGrid(divID,layout,stroke,imageStream,range,shadow,valignClass,opacity,slideshowParameters,slideshowURL,headerViewID,detailViewID,footerViewID,layoutOptions)
628 {if(range.length()==0)
629 {return;}
630 IWJobQueue.sharedJobQueue.clearJobs();function toggleDetailViewNotification(notification)
631 {var userInfo=notification.userInfo();IWToggleDetailView(userInfo.showDetailView,userInfo.index,divID,headerViewID,footerViewID,detailViewID,shadow);}
632 var showPhotoIndex=undefined;var hash=location.hash;if(hash.length>1)
633 {if(hash.match(/^\#(\d+)$/))
634 {var idx=RegExp.$1;if(idx<imageStream.length)
635 {showPhotoIndex=parseInt(idx);}}}
636 if(isiPhone)
637 {slideshowURL=slideshowURL.stringByDeletingLastPathComponent().stringByAppendingPathComponent("phoneshow.html");}
638 slideshowURL=slideshowURL.stringByAppendingAsQueryString(slideshowParameters);if(detailViewID!=null)
639 {var detailView=widgets[detailViewID];if(!detailView.preferenceForKey("mediaStreamObject"))
640 {if(showPhotoIndex!==undefined)
641 {detailView.setPreferenceForKey(showPhotoIndex,"startIndex");}
642 var mediaStreamObject={load:function(baseURL,callback){callback(imageStream);}};detailView.setPreferenceForKey(mediaStreamObject,"mediaStreamObject");NotificationCenter.addObserver(null,toggleDetailViewNotification,DetailViewToggleNotification,divID);if(slideshowParameters)
643 {detailView.setPlaySlideshowFunction(IWStartSlideshow.bind(null,slideshowURL,imageStream,0,slideshowParameters["fullScreen"]));}}}
644 var photogrid=$(divID);photogrid.innerHTML="";for(var i=0;i<range.length();++i)
645 {var frame=$(document.createElement('div'));var translation=layout.translationForTileAtIndex(i);var size=layout.tileSize();frame.style.cssText=iWPosition(true,translation.x,translation.y,size.width,size.height);frame.hide();photogrid.appendChild(frame);}
646 var textBoxSize=layout.mTextBoxSize;var renderThumb=function(i,streamIndex)
647 {var imageStreamEntry=imageStream[streamIndex];var wrapper=photogrid.childNodes[i];var textPos=layout.translationForTextAtIndexWithOffset(i,null);var textMarkup="";if(textBoxSize.height>0)
648 {var richTitle=imageStreamEntry.richTitle();if(richTitle==null)
649 {richTitle=imageStreamEntry.title();}
650 var valignClassName='';if(valignClass)
651 {valignClassName=' '+valignClass;}
652 var metric=imageStreamEntry.metric();if(metric!=null&&metric.length>0)
653 {metric='<span class="metric">'+metric+'</span>';}
654 else
655 {metric="";}
656 var showTitle=layoutOptions?layoutOptions.showTitle:true;var showMetric=layoutOptions?layoutOptions.showMetric:true;var richCaption='<div class="caption'+valignClassName+'">'+
657 (showTitle?('<span class="title">'+richTitle+'</span>'):'')+
658 ((showTitle&&showMetric)?'<br />':'')+
659 (showMetric?metric:'')+'</div>';var opacityMarkup='';if(opacity<0.999)
660 {opacityMarkup=windowsInternetExplorer?" filter: progid:DXImageTransform.Microsoft.Alpha(opacity="+opacity*100+"); ":" opacity: "+opacity+"; ";}
661 var overflowMarkup="overflow: hidden; ";textMarkup='<div style="'+iWPosition(true,textPos.x,textPos.y,textBoxSize.width,textBoxSize.height)+opacityMarkup+overflowMarkup+'">'+
662 richCaption+'</div>';}
663 var thumbnailSize=imageStreamEntry.thumbnailNaturalSize();var scale=layout.p_scaleForImageOfSize(thumbnailSize);var scaledImageSize=thumbnailSize.scale(scale,scale,true);if(Math.abs(scaledImageSize.width-thumbnailSize.width)<=2&&Math.abs(scaledImageSize.height-thumbnailSize.height)<=2)
664 {scaledImageSize=thumbnailSize;}
665 var frameMarkup=stroke.markupForImageStreamEntry(imageStreamEntry,scaledImageSize);wrapper.insert(frameMarkup);wrapper.insert(textMarkup);if(textMarkup.length>0)
666 {var textWrapper=wrapper.lastChild;textWrapper.style.zIndex=1;}
667 IWUpdateVerticalAlignment(wrapper);var framed=$(wrapper).selectFirst('.framedImage');var framePos=layout.translationForImageOfSizeAtIndexWithOffset(new IWSize(parseFloat(framed.style.width||0),parseFloat(framed.style.height||0)),i,null);framed.setStyle({left:px(framePos.x),top:px(framePos.y),zIndex:1});if(detailViewID)
668 {var anchor=$(document.createElement("a"));anchor.setStyle({position:"absolute",left:framed.style.left,top:framed.style.top,width:framed.style.width,height:framed.style.height,zIndex:1});anchor.href='#'+streamIndex;anchor.onclick=IWToggleDetailView.bind(null,true,streamIndex,divID,headerViewID,footerViewID,detailViewID,shadow);if(windowsInternetExplorer&&(effectiveBrowserVersion>=7))
669 {var img=document.createElement('img');img.src=transparentGifURL();img.style.width=framed.style.width;img.style.height=framed.style.height;anchor.appendChild(img);}
670 framed.parentNode.insertBefore(anchor,framed.nextSibling);}
671 IWSetDivOpacity(framed,opacity);wrapper.show();if(shadow)
672 {if(windowsInternetExplorer)
673 {var imgs=framed.select('img');var left=0,top=0;var right=parseFloat(framed.style.width||0);var bottom=parseFloat(framed.style.height||0);for(var e=0;e<imgs.length;++e)
674 {var style=imgs[e].style;var l=parseFloat(style.left||0);var t=parseFloat(style.top||0);left=Math.min(l,left);top=Math.min(t,top);right=Math.max(l+parseFloat(style.width||0),right);bottom=Math.max(t+parseFloat(style.height||0),bottom);}
675 framed.setStyle({left:px(parseFloat(framed.style.left||0)+left),top:px(parseFloat(framed.style.top||0)+top),width:px(right-left),height:px(bottom-top)});var framedChildren=framed.childNodes;for(var c=0;c<framedChildren.length;++c)
676 {var child=framedChildren[c];if(child.nodeType==Node.ELEMENT_NODE)
677 {child.style.left=px(parseFloat(child.style.left||0)-left);child.style.top=px(parseFloat(child.style.top||0)-top);}}
678 var blurRadius=shadow.mBlurRadius*.75;var xOffset=shadow.mOffset.x-blurRadius;var yOffset=shadow.mOffset.y-blurRadius;var shadowDiv=framed.cloneNodeExcludingIDs(true);shadowDiv.style.left=px(framePos.x+xOffset);shadowDiv.style.top=px(framePos.y+yOffset);shadowDiv.style.filter="progid:DXImageTransform.Microsoft.MaskFilter()"+" progid:DXImageTransform.Microsoft.MaskFilter(color="+shadow.mColor+")"+" progid:DXImageTransform.Microsoft.Blur(pixelradius="+blurRadius+")"+" progid:DXImageTransform.Microsoft.Alpha(opacity="+shadow.mOpacity*opacity*100+")";framed.parentNode.insertBefore(shadowDiv,framed);}
679 else
680 {if(!isEarlyWebKitVersion)
681 {shadow.applyToElement(framed);}}}
682 imageStreamEntry.didInsertThumbnailMarkupIntoDocument();imageStreamEntry.unloadThumbnail();};for(var i=0;i<range.length();++i)
683 {var streamIndex=range.location()+i;var renderThumbJob=renderThumb.bind(null,i,streamIndex);imageStream[streamIndex].loadThumbnail(IWJobQueue.prototype.addJob.bind(IWJobQueue.sharedJobQueue,renderThumbJob));}
684 var headerView=widgets[headerViewID];if(headerView)
685 {if(slideshowParameters)
686 {headerView.setPlaySlideshowFunction(IWStartSlideshow.bind(null,slideshowURL,imageStream,0,slideshowParameters["fullScreen"]));}
687 headerView.setPreferenceForKey(imageStream.length,"entryCount");}
688 function setFooterOffset(height)
689 {var footer=$(footerViewID);var footerOffsetTop=photogrid.offsetTop+height-layout.mBottomPadding;footer.style.top=px(footerOffsetTop);}
690 var gridHeight=layout.totalHeightForCount(range.length());setFooterOffset(gridHeight);IWSetSpacerHeight(photogrid,gridHeight);photogrid.style.height=px(gridHeight);if(showPhotoIndex!==undefined)
691 {IWToggleDetailView(true,showPhotoIndex,divID,headerViewID,footerViewID,detailViewID,shadow);}}
692 var initialSpacerHeight=0;var IWPhotoGridLayout=Class.create({initialize:function(columnCount,maxImageSize,textBoxSize,tileSize,topPadding,bottomPadding,spacing,framePadding)
693 {this.mColumnCount=columnCount;this.mMaxImageSize=maxImageSize;this.mTextBoxSize=textBoxSize;this.mTileSize=tileSize;this.mTopPadding=topPadding;this.mBottomPadding=bottomPadding;this.mSpacing=spacing;this.mFramePadding=framePadding;this.mCachedDataValid=true;},tileSize:function()
694 {return this.mTileSize;},translationForTileAtIndex:function(index)
695 {var tileSize=this.mTileSize;var columnCount=this.mColumnCount;var translation=new IWPoint(tileSize.width*(index%columnCount)+IWPhotoGridLayoutConstants.kBorderThickness,tileSize.height*Math.floor(index/columnCount)+IWPhotoGridLayoutConstants.kBorderThickness+this.mTopPadding+IWPhotoGridLayoutConstants.vTopSpacing);return translation;},translationForImageOfSizeAtIndexWithOffset:function(imageSize,index,offset)
696 {var tileSize=this.mTileSize;var translation=new IWPoint(0,0);var imageAreaSize=new IWSize(tileSize.width,tileSize.height-(IWPhotoGridLayoutConstants.vTextOffsetFromImage+this.mTextBoxSize.height+IWPhotoGridLayoutConstants.vTextOffsetFromBottom));translation.x+=(imageAreaSize.width-imageSize.width)/2;translation.y+=(imageAreaSize.height-imageSize.height);if(offset!=null)
697 {translation.x+=offset.translation.width;translation.y+=offset.translation.height;}
698 return translation;},translationForTextAtIndexWithOffset:function(index,offset)
699 {var tileSize=this.mTileSize;var textBoxSize=this.mTextBoxSize;var translation=new IWPoint((tileSize.width-textBoxSize.width)/2.0,(tileSize.height-textBoxSize.height)-IWPhotoGridLayoutConstants.vTextOffsetFromBottom);if(offset!=null)
700 {translation.x+=offset.translation.width;translation.y+=offset.translation.height;}
701 return translation;},totalHeightForCount:function(count)
702 {if(count==0)
703 count=1;var columnCount=this.mColumnCount;var lastRow=Math.floor((count+columnCount-1)/columnCount);var tileSize=this.mTileSize;return tileSize.height*lastRow+IWPhotoGridLayoutConstants.kBorderThickness*2+this.mTopPadding+this.mBottomPadding;},p_scaleForImageOfSize:function(imageSize)
704 {var maxImageSize=this.mMaxImageSize;return Math.min((maxImageSize.width-this.mFramePadding.width)/imageSize.width,(maxImageSize.height-this.mFramePadding.height)/imageSize.height);}});var IWJobQueue=Class.create({initialize:function()
705 {this.mJobQueue=[];this.mTimeout=null;},addJob:function(job)
706 {this.mJobQueue.push(job);this.p_setTimeout();},clearJobs:function(job)
707 {this.p_cancelTimeout();this.mJobQueue=[];},p_runQueuedJobs:function()
708 {this.p_cancelTimeout();var startTime=new Date().getTime();var duration=0;while(this.mJobQueue.length>0&&duration<100)
709 {var job=this.mJobQueue.shift();if(job)
710 {job();}
711 duration=(new Date().getTime())-startTime;}
712 if(this.mJobQueue.length>0)
713 {this.p_setTimeout();}},p_cancelTimeout:function()
714 {if(this.mTimeout!=null)
715 {clearTimeout(this.mTimeout);this.mTimeout=null;}},p_setTimeout:function()
716 {if(this.mTimeout==null)
717 {this.mTimeout=setTimeout(this.p_runQueuedJobs.bind(this),0);}}});IWJobQueue.sharedJobQueue=new IWJobQueue();var AppleAnimator=Class.create({initialize:function(duration,interval,optionalFrom,optionalTo,optionalCallback)
718 {this.startTime=0;this.duration=duration;this.interval=interval;this.animations=new Array;this.timer=null;this.oncomplete=null;this._firstTime=true;var self=this;this.animate=function(self){function limit_3(a,b,c){return a<b?b:(a>c?c:a);}
719 var T,time;var ease;var time=(new Date).getTime();var dur=self.duration;var done;T=limit_3(time-self.startTime,0,dur);time=T/dur;ease=0.5-(0.5*Math.cos(Math.PI*time));done=T>=dur;var array=self.animations;var c=array.length;var first=self._firstTime;for(var i=0;i<c;++i)
720 {array[i].doFrame(self,ease,first,done,time);}
721 if(done)
722 {self.stop();if(self.oncomplete!=null)
723 {self.oncomplete();}}
724 self._firstTime=false;}
725 if(optionalFrom!==undefined&&optionalTo!==undefined&&optionalCallback!==undefined)
726 {this.addAnimation(new AppleAnimation(optionalFrom,optionalTo,optionalCallback));}},start:function(){if(this.timer==null)
727 {var timeNow=(new Date).getTime();var interval=this.interval;this.startTime=timeNow-interval;this.timer=setInterval(this.animate.bind(null,this),interval);}},stop:function(){if(this.timer!=null)
728 {clearInterval(this.timer);this.timer=null;}},addAnimation:function(animation){this.animations[this.animations.length]=animation;}});var AppleAnimation=Class.create({initialize:function(from,to,callback)
729 {this.from=from;this.to=to;this.callback=callback;this.now=from;this.ease=0;this.time=0;},doFrame:function(animation,ease,first,done,time){var now;if(done)
730 now=this.to;else
731 now=this.from+(this.to-this.from)*ease;this.now=now;this.ease=ease;this.time=time;this.callback(animation,now,first,done);}});function IWCommentSummaryInfoForURL(resourceURL,callback)
732 {function handleSummaryData(request)
733 {var result={};if(request.responseText)
734 {var r=request.responseText.match(/.*= ((true)|(false));.*\n.*= (\d+)/);if(r)
735 {result.enabled=(r[1]=="true");result.count=Number(r[4]);}}
736 callback(result);}
737 var summaryURL=resourceURL+"?wsc=summary.js&ts="+(new Date().getTime());new Ajax.Request(summaryURL,{method:'get',onSuccess:handleSummaryData,onFailure:callback.bind(null,{})});}
738 function IWCommentCountForURL(resourceURL,callback)
739 {function myCallback(info)
740 {if(info.count===undefined)
741 info.count=0;callback(info.count);}
742 IWCommentSummaryInfoForURL(resourceURL,myCallback);}