Type.registerNamespace('SpottedScript.Controls.PhotoBrowser');
SpottedScript.Controls.PhotoBrowser.Controller=function(view){SpottedScript.Controls.PhotoBrowser.Controller.initializeBase(this,[[view.get_uiPhotoRepeaterContainer()]]);this.$5=view;this.$8=Number.parseInvariant(view.get_uiIconsPerRow().value);this.$9=Number.parseInvariant(view.get_uiIconSize().value);this.$7=Number.parseInvariant(view.get_uiIconsPerPage().value);view.get_uiPaginationControl().$2=Function.createDelegate(this,this.$16);this.$6=new Array(this.$7);for(var $0=0;$0<this.$6.length;$0++){this.$6[$0]=document.getElementById(view.get_uiTableCellsPrefix().value+$0);}for(var $1=0;$1<this.$6.length;$1++){$addHandler(this.$6[$1].childNodes[0],'click',Function.createDelegate(this,this.$12));}this.set_$E(this.$13());this.$0=Function.createDelegate(this,this.$1A);this.$1=Function.createDelegate(this,this.$1B);this.$2=Function.createDelegate(this,this.$1C);this.$3=Function.createDelegate(this,this.$1D);this.$4=Function.createDelegate(this,this.$11);}
SpottedScript.Controls.PhotoBrowser.Controller.prototype={$5:null,$6:null,$7:0,$8:0,$9:0,$A:null,get_$B:function(){return this.$A;},set_$B:function($p0){this.$A=$p0;return $p0;},get_$C:function(){return this.$5.get_uiPaginationControl();},$D:0,get_$E:function(){return this.$D;},set_$E:function($p0){this.$D=$p0;return $p0;},$F:null,$10:null,$11:function($p0,$p1){},$12:function($p0){$p0.preventDefault();for(var $0=0;$0<this.$6.length;$0++){if(this.$6[$0]===$p0.target.parentNode.parentNode){this.set_$E($0);break;}}this.$14();if(this.$F){this.$F(this,new SpottedScript.IntEventArgs(this.get_$E()));}},$13:function(){for(var $0=0;$0<this.$6.length;$0++){if(this.$6[$0].className==='PhotoBrowserCellHighlight'){return $0;}}return 0;},$14:function(){if(!this.$18()){this.$19();}for(var $2=0;$2<this.$6.length;$2++){this.$6[$2].className='';var $3=this.$6[$2].childNodes[0].childNodes[1];if($3.className!=='PhotoBrowserImage'){$3.className='PhotoBrowserImage';$3.style.width=this.$9.toString()+'px';$3.style.height=this.$9.toString()+'px';}var $4=this.$6[$2].childNodes[0].childNodes[2];if($4.className!=='PhotoBrowserImage'){$4.className='PhotoBrowserImage';$4.style.marginTop='0px';$4.style.marginLeft='0px';}}this.$6[this.get_$E()].className='PhotoBrowserCellHighlight';var $0=this.$6[this.get_$E()].childNodes[0].childNodes[1];$0.className='PhotoBrowserImageHighlight';$0.style.width=(this.$9-2).toString()+'px';$0.style.height=(this.$9-2).toString()+'px';var $1=this.$6[this.get_$E()].childNodes[0].childNodes[2];$1.className='PhotoBrowserImageHighlight';$1.style.marginTop='-1px';$1.style.marginLeft='-1px';},photoSetIsLoadingFromServer:false,firstLoad:true,doPostLoadPhotoSetActions:function(sender,e){this.photoSetIsLoadingFromServer=false;if(!this.firstLoad){this.$15();this.$19();this.$14();}this.firstLoad=false;this.$5.get_uiPaginationControl().set_$0(this.get_$B().get_currentPhotoSet().lastPage);if(this.$10){this.$10(this,new SpottedScript.Controls.PhotoBrowser.PhotoSetEventArgs(this.get_$B().get_currentPhotoSet().photos,this.get_$E()));}},photoSetIsLoadingFromServer:function(sender,e){this.photoSetIsLoadingFromServer=true;},$15:function(){for(var $0=0;$0<this.$6.length;$0++){if($0<this.get_$B().get_currentPhotoSet().photos.length){(this.$6[$0].childNodes[0].childNodes[1]).src='/gfx/1pix.gif';}else{break;}}for(var $1=0;$1<this.$6.length;$1++){if($1<this.get_$B().get_currentPhotoSet().photos.length){this.$6[$1].style.display='';this.setRolloverMouseOverText($1);(this.$6[$1].childNodes[0].childNodes[1]).src=this.get_$B().get_currentPhotoSet().photos[$1].iconPath;var $2=(this.$6[$1].childNodes[0].childNodes[2]);$2.src=this.get_$B().get_currentPhotoSet().photos[$1].thumbPath;$2.style.width=this.get_$B().get_currentPhotoSet().photos[$1].thumbWidth.toString()+'px';$2.style.height=this.get_$B().get_currentPhotoSet().photos[$1].thumbHeight.toString()+'px';$2.style.top=(-(this.get_$B().get_currentPhotoSet().photos[$1].thumbHeight-75)/2).toString()+'px';$2.style.left=(-(this.get_$B().get_currentPhotoSet().photos[$1].thumbWidth-75)/2).toString()+'px';}else{this.$6[$1].style.display='none';}}},$16:function($p0,$p1){this.get_$B().loadPhotos(($p1).value);},$17:function(){this.$14();if(this.$F){this.$F(this,new SpottedScript.IntEventArgs(this.get_$E()));}},$18:function(){return this.get_$E()>=0&&this.get_$E()<this.get_$B().get_currentPhotoSet().photos.length;},$19:function(){if(this.get_$E()<0){this.set_$E(0);}else if(this.get_$E()>=this.get_$B().get_currentPhotoSet().photos.length){this.set_$E(this.get_$B().get_currentPhotoSet().photos.length-1);}},$1A:function($p0,$p1){if(!this.photoSetIsLoadingFromServer){this.set_$E(this.get_$E()+1)-1;if(this.get_$E()>=this.get_$B().get_currentPhotoSet().photos.length||!this.get_$B().get_currentPhotoSet().photos[this.get_$E()]){this.set_$E(0);this.$5.get_uiPaginationControl().$3();}else{this.$17();}}},$1B:function($p0,$p1){if(!this.photoSetIsLoadingFromServer){this.set_$E(this.get_$E()-1)+1;if(this.get_$E()<0){this.set_$E(this.get_$E()+this.$6.length);this.$5.get_uiPaginationControl().$4();}else{this.$17();}}},$1C:function($p0,$p1){this.set_$E(this.get_$E()-this.$8);if(this.get_$E()<0){this.set_$E(this.get_$E()+this.$6.length);this.$5.get_uiPaginationControl().$4();}else{this.$17();}},$1D:function($p0,$p1){if(this.get_$E()===this.get_$B().get_currentPhotoSet().photos.length-1||this.get_$E()+this.$8>=this.$6.length){this.setSelectedIndexToBeInFirstRow();this.$5.get_uiPaginationControl().$3();}else{this.set_$E(this.get_$E()+this.$8);this.$17();}},setSelectedIndexToBeInFirstRow:function(){while(this.get_$E()<0){this.set_$E(this.get_$E()+this.$8);}while(this.get_$E()>=this.$8){this.set_$E(this.get_$E()-this.$8);}},$1E:function($p0,$p1){var $0=($p1).value;this.setRolloverMouseOverText($0);},setRolloverMouseOverText:function(index){this.$6[index].childNodes[0].childNodes[0].setAttribute('rolloverMouseOverText',this.get_$B().get_currentPhotoSet().photos[index].rolloverMouseOverText);}}
SpottedScript.Controls.PhotoBrowser.PhotoEventArgs=function(photo){SpottedScript.Controls.PhotoBrowser.PhotoEventArgs.initializeBase(this);this.photo=photo;}
SpottedScript.Controls.PhotoBrowser.PhotoEventArgs.prototype={photo:null}
SpottedScript.Controls.PhotoBrowser.PhotoSetEventArgs=function(photoSet,selectedIndex){SpottedScript.Controls.PhotoBrowser.PhotoSetEventArgs.initializeBase(this);this.photoSet=photoSet;this.selectedIndex=selectedIndex;}
SpottedScript.Controls.PhotoBrowser.PhotoSetEventArgs.prototype={photoSet:null,selectedIndex:0}
SpottedScript.Controls.PhotoBrowser.PhotoBrowsingUsingKeysControl=function(focusControls){for(var $0=0;$0<focusControls.length;$0++){$addHandler(focusControls[$0],'keydown',Function.createDelegate(this,this.keyDown));}}
SpottedScript.Controls.PhotoBrowser.PhotoBrowsingUsingKeysControl.prototype={$0:null,$1:null,$2:null,$3:null,$4:null,keyDown:function(e){if(e.keyCode===39){if(this.$4){this.$4(this,Sys.EventArgs.Empty);}if(this.$0){this.$0(this,Sys.EventArgs.Empty);}e.preventDefault();}else if(e.keyCode===37){if(this.$4){this.$4(this,Sys.EventArgs.Empty);}if(this.$1){this.$1(this,Sys.EventArgs.Empty);}e.preventDefault();}else{this.nonArrowKeyDown(e);}},nonArrowKeyDown:function(e){}}
SpottedScript.Controls.PhotoBrowser.PhotoProvider=function(){}
SpottedScript.Controls.PhotoBrowser.PhotoProvider.prototype={$0:null,get_currentPhotoSet:function(){return this.$0;},set_currentPhotoSet:function(value){this.$0=value;return value;},doPostLoadPhotoSetActions:null,photoSetIsLoadingFromServer:null,successCallback:function(result,pageNumber,methodName){this.set_currentPhotoSet(result);this.storePhotosInCache(this.get_currentPhotoSet(),pageNumber);if(this.doPostLoadPhotoSetActions){this.doPostLoadPhotoSetActions(this,Sys.EventArgs.Empty);}},loadPhotos:function(pageNumber){if(this.loadPhotosFromCache(pageNumber)){if(this.doPostLoadPhotoSetActions){this.doPostLoadPhotoSetActions(this,Sys.EventArgs.Empty);}}else{if(this.photoSetIsLoadingFromServer){this.photoSetIsLoadingFromServer(this,Sys.EventArgs.Empty);}this.loadPhotosViaWebRequest(pageNumber);}}}
SpottedScript.Controls.PhotoBrowser.EventPhotoProvider=function(galleryK,eventK){SpottedScript.Controls.PhotoBrowser.EventPhotoProvider.initializeBase(this);this.galleryK=galleryK;this.eventK=eventK;this.photoSetsByGalleryK=[];this.photoSetsByEventK=[];}
SpottedScript.Controls.PhotoBrowser.EventPhotoProvider.prototype={photoSetsByGalleryK:null,photoSetsByEventK:null,galleryK:0,eventK:0,loadPhotosViaWebRequest:function(pageNumber){if(this.galleryK>0){Spotted.WebServices.Controls.PhotoControl.Service.getPhotosByGalleryAndPage(this.galleryK,pageNumber,Function.createDelegate(this,this.successCallback),Function.createDelegate(null,Utils.Trace.webServiceFailure),pageNumber,-1);}else{Spotted.WebServices.Controls.PhotoControl.Service.getPhotosByEventAndPage(this.eventK,pageNumber,Function.createDelegate(this,this.successCallback),Function.createDelegate(null,Utils.Trace.webServiceFailure),pageNumber,-1);}},loadPhotosFromCache:function(pageNumber){if(this.galleryK>0){if((this.photoSetsByGalleryK[this.galleryK])&&((this.photoSetsByGalleryK[this.galleryK])[pageNumber])){this.set_currentPhotoSet((this.photoSetsByGalleryK[this.galleryK])[pageNumber]);return true;}}else if(this.eventK>0&&(this.photoSetsByEventK[this.eventK])&&((this.photoSetsByEventK[this.eventK])[pageNumber])){this.set_currentPhotoSet((this.photoSetsByEventK[this.eventK])[pageNumber]);return true;}return false;},storePhotosInCache:function(photos,pageNumber){if(this.galleryK>0){if(!this.photoSetsByGalleryK[this.galleryK]){this.photoSetsByGalleryK[this.galleryK]=[];}(this.photoSetsByGalleryK[this.galleryK])[pageNumber]=photos;return true;}if(this.eventK>0){if(!this.photoSetsByEventK[this.eventK]){this.photoSetsByEventK[this.eventK]=[];}(this.photoSetsByEventK[this.eventK])[pageNumber]=photos;return true;}return false;},$1:function($p0){this.galleryK=$p0;this.loadPhotos(1);}}
SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider=function(key){SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider.initializeBase(this);this.key=key;this.photoSets=[];}
SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider.prototype={photoSets:null,key:0,storePhotosInCache:function(photoSet,pageNumber){if(this.key>0){if(!this.photoSets[this.key]){this.photoSets[this.key]=[];}(this.photoSets[this.key])[pageNumber]=photoSet;return true;}return false;},loadPhotosFromCache:function(pageNumber){if(this.key>0&&this.photoSets[this.key]&&(this.photoSets[this.key])[pageNumber]){this.set_currentPhotoSet((this.photoSets[this.key])[pageNumber]);return true;}return false;}}
SpottedScript.Controls.PhotoBrowser.ArticlePhotoProvider=function(k){SpottedScript.Controls.PhotoBrowser.ArticlePhotoProvider.initializeBase(this,[k]);}
SpottedScript.Controls.PhotoBrowser.ArticlePhotoProvider.prototype={loadPhotosViaWebRequest:function(pageNumber){Spotted.WebServices.Controls.PhotoControl.Service.getPhotosByArticle(this.key,pageNumber,Function.createDelegate(this,this.successCallback),Function.createDelegate(null,Utils.Trace.webServiceFailure),pageNumber,-1);}}
SpottedScript.Controls.PhotoBrowser.TagPhotoProvider=function(k){SpottedScript.Controls.PhotoBrowser.TagPhotoProvider.initializeBase(this,[k]);}
SpottedScript.Controls.PhotoBrowser.TagPhotoProvider.prototype={loadPhotosViaWebRequest:function(pageNumber){Spotted.WebServices.Controls.PhotoControl.Service.getPhotosByTag(this.key,pageNumber,Function.createDelegate(this,this.successCallback),Function.createDelegate(null,Utils.Trace.webServiceFailure),pageNumber,-1);}}
SpottedScript.Controls.PhotoBrowser.GroupPhotoProvider=function(k){SpottedScript.Controls.PhotoBrowser.GroupPhotoProvider.initializeBase(this,[k]);}
SpottedScript.Controls.PhotoBrowser.GroupPhotoProvider.prototype={loadPhotosViaWebRequest:function(pageNumber){Spotted.WebServices.Controls.PhotoControl.Service.getPhotosByGroup(this.key,pageNumber,Function.createDelegate(this,this.successCallback),Function.createDelegate(null,Utils.Trace.webServiceFailure),pageNumber,-1);}}
SpottedScript.Controls.PhotoBrowser.PhotosOfUsrProvider=function(k,spottedByUsrK){SpottedScript.Controls.PhotoBrowser.PhotosOfUsrProvider.initializeBase(this,[k]);this.$1=spottedByUsrK;}
SpottedScript.Controls.PhotoBrowser.PhotosOfUsrProvider.prototype={$1:0,loadPhotosViaWebRequest:function(pageNumber){Spotted.WebServices.Controls.PhotoControl.Service.getPhotosOfUsr(this.key,pageNumber,this.$1,Function.createDelegate(this,this.successCallback),Function.createDelegate(null,Utils.Trace.webServiceFailure),pageNumber,-1);}}
SpottedScript.Controls.PhotoBrowser.FavouritePhotosOfUsrProvider=function(k){SpottedScript.Controls.PhotoBrowser.FavouritePhotosOfUsrProvider.initializeBase(this,[k]);}
SpottedScript.Controls.PhotoBrowser.FavouritePhotosOfUsrProvider.prototype={loadPhotosViaWebRequest:function(pageNumber){Spotted.WebServices.Controls.PhotoControl.Service.getFavouritePhotosOfUsr(this.key,pageNumber,Function.createDelegate(this,this.successCallback),Function.createDelegate(null,Utils.Trace.webServiceFailure),pageNumber,-1);}}
SpottedScript.Controls.PhotoBrowser.VideoPhotoProvider=function(){SpottedScript.Controls.PhotoBrowser.VideoPhotoProvider.initializeBase(this);this.$1=[];}
SpottedScript.Controls.PhotoBrowser.VideoPhotoProvider.prototype={$1:null,storePhotosInCache:function(photoSet,pageNumber){this.$1[pageNumber]=photoSet;return true;},loadPhotosFromCache:function(pageNumber){if(this.$1[pageNumber]){this.set_currentPhotoSet(this.$1[pageNumber]);return true;}return false;},loadPhotosViaWebRequest:function(pageNumber){Spotted.WebServices.Controls.PhotoControl.Service.getRecentVideos(pageNumber,Function.createDelegate(this,this.successCallback),Function.createDelegate(null,Utils.Trace.webServiceFailure),pageNumber,-1);}}
SpottedScript.Controls.PhotoBrowser.PhotosController=function(){}
SpottedScript.Controls.PhotoBrowser.PhotosController.prototype={setupController:function(){this.get_photoProvider().doPostLoadPhotoSetActions=Function.createDelegate(this.get_photoBrowser(),this.get_photoBrowser().doPostLoadPhotoSetActions);this.get_photoProvider().photoSetIsLoadingFromServer=Function.createDelegate(this.get_photoBrowser(),this.get_photoBrowser().photoSetIsLoadingFromServer);this.get_photoProvider().loadPhotos(this.get_photoBrowser().get_$C().get_$1());this.get_photoBrowser().set_$B(this.get_photoProvider());this.get_photoBrowser().$10=Function.createDelegate(this.get_photoControl(),this.get_photoControl().$12);this.get_photoBrowser().$F=Function.createDelegate(this.get_photoControl(),this.get_photoControl().$15);this.get_photoControl().$0=Function.createDelegate(this.get_photoBrowser(),this.get_photoBrowser().$1A);this.get_photoControl().$1=Function.createDelegate(this.get_photoBrowser(),this.get_photoBrowser().$1B);this.get_photoControl().$2=Function.createDelegate(this.get_photoBrowser(),this.get_photoBrowser().$1C);this.get_photoControl().$3=Function.createDelegate(this.get_photoBrowser(),this.get_photoBrowser().$1D);this.get_photoControl().$14=Function.createDelegate(this,this.photoChanged);this.get_photoControl().$16=Function.createDelegate(this,this.photoChangedAfterDelay);this.get_photoControl().$D=Function.createDelegate(this.get_photoBrowser(),this.get_photoBrowser().$1E);this.get_threadControl().onThreadCreated=Function.createDelegate(this,this.threadCreated);this.get_threadControl().onCommentPosted=Function.createDelegate(this,this.commentPosted);this.get_threadControl().get_uiCommentsDisplay().onThreadDeleted=Function.createDelegate(this,this.threadDeleted);},photoChanged:function(o,e){var $0=e;this.get_threadControl().get_uiCommentsDisplay().setCommentsCount($0.photo.commentsCount);this.get_latestChatController().$3();},photoChangedAfterDelay:function(o,e){var $0=e;this.get_threadControl().get_uiCommentsDisplay().showComments($0.photo.threadK,1);this.get_threadControl().set_currentParentObjectK($0.photo.k);this.get_latestChatController().$4($0.photo.k);},threadCreated:function(o,e){if(!this.get_photoControl().get_currentPhoto().threadK){this.get_photoControl().get_currentPhoto().threadK=(e).value;}this.get_photoControl().get_currentPhoto().commentsCount=1;this.get_latestChatController().$5(o,e);},commentPosted:function(o,e){if(this.get_photoControl().get_currentPhoto().threadK===(e).value){this.get_photoControl().get_currentPhoto().commentsCount++;}},threadDeleted:function(o,e){if(this.get_photoControl().get_currentPhoto().threadK===(e).value){this.get_photoControl().get_currentPhoto().threadK=0;this.get_photoControl().get_currentPhoto().commentsCount=0;}}}
SpottedScript.Controls.PhotoBrowser.View=function(clientId){this.clientId=clientId;}
SpottedScript.Controls.PhotoBrowser.View.prototype={clientId:null,get_uiPhotoRepeaterContainer:function(){return document.getElementById(this.clientId+'_uiPhotoRepeaterContainer');},get_uiPaginationControl:function(){return eval(this.clientId+'_uiPaginationControlController');},get_uiPhotoRepeater:function(){return document.getElementById(this.clientId+'_uiPhotoRepeater');},get_uiBlowUpIconSpan:function(){return document.getElementById(this.clientId+'_uiBlowUpIconSpan');},get_uiIconsPerPage:function(){return document.getElementById(this.clientId+'_uiIconsPerPage');},get_uiIconsPerRow:function(){return document.getElementById(this.clientId+'_uiIconsPerRow');},get_uiIconSize:function(){return document.getElementById(this.clientId+'_uiIconSize');},get_uiTableCellsPrefix:function(){return document.getElementById(this.clientId+'_uiTableCellsPrefix');}}
SpottedScript.Controls.PhotoBrowser.PhotosController.registerClass('SpottedScript.Controls.PhotoBrowser.PhotosController');
SpottedScript.Controls.PhotoBrowser.PhotoBrowsingUsingKeysControl.registerClass('SpottedScript.Controls.PhotoBrowser.PhotoBrowsingUsingKeysControl');
SpottedScript.Controls.PhotoBrowser.Controller.registerClass('SpottedScript.Controls.PhotoBrowser.Controller',SpottedScript.Controls.PhotoBrowser.PhotoBrowsingUsingKeysControl);
SpottedScript.Controls.PhotoBrowser.PhotoEventArgs.registerClass('SpottedScript.Controls.PhotoBrowser.PhotoEventArgs',Sys.EventArgs);
SpottedScript.Controls.PhotoBrowser.PhotoSetEventArgs.registerClass('SpottedScript.Controls.PhotoBrowser.PhotoSetEventArgs',Sys.EventArgs);
SpottedScript.Controls.PhotoBrowser.PhotoProvider.registerClass('SpottedScript.Controls.PhotoBrowser.PhotoProvider');
SpottedScript.Controls.PhotoBrowser.EventPhotoProvider.registerClass('SpottedScript.Controls.PhotoBrowser.EventPhotoProvider',SpottedScript.Controls.PhotoBrowser.PhotoProvider);
SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider.registerClass('SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider',SpottedScript.Controls.PhotoBrowser.PhotoProvider);
SpottedScript.Controls.PhotoBrowser.ArticlePhotoProvider.registerClass('SpottedScript.Controls.PhotoBrowser.ArticlePhotoProvider',SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider);
SpottedScript.Controls.PhotoBrowser.TagPhotoProvider.registerClass('SpottedScript.Controls.PhotoBrowser.TagPhotoProvider',SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider);
SpottedScript.Controls.PhotoBrowser.GroupPhotoProvider.registerClass('SpottedScript.Controls.PhotoBrowser.GroupPhotoProvider',SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider);
SpottedScript.Controls.PhotoBrowser.PhotosOfUsrProvider.registerClass('SpottedScript.Controls.PhotoBrowser.PhotosOfUsrProvider',SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider);
SpottedScript.Controls.PhotoBrowser.FavouritePhotosOfUsrProvider.registerClass('SpottedScript.Controls.PhotoBrowser.FavouritePhotosOfUsrProvider',SpottedScript.Controls.PhotoBrowser.SingleKeyPhotoProvider);
SpottedScript.Controls.PhotoBrowser.VideoPhotoProvider.registerClass('SpottedScript.Controls.PhotoBrowser.VideoPhotoProvider',SpottedScript.Controls.PhotoBrowser.PhotoProvider);
SpottedScript.Controls.PhotoBrowser.View.registerClass('SpottedScript.Controls.PhotoBrowser.View');
