/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  December 22nd 2009 10:01:38 AM PST                           */
/*      Machine:  10.16.139.109                                                */
/*       Source:  Local Cache                                                  */
/*     Location:  rsrc:4:dq8o4kv0                                              */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/profile/photos.js                                         */

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/profile\/photos.js"]); }

function ProfilePhotosTabController(b,a,d,c,e){copy_properties(this,{user:b,id:a||b,viewas:d||b,view:c,vm:e||'',pagerSections:{}});ProfilePhotosTabController.viewControllers[c]=this;}copy_properties(ProfilePhotosTabController,{viewControllers:{},registerPagerSection:function(a){if(!ProfilePhotosTabController.viewControllers[a.view])return false;ProfilePhotosTabController.viewControllers[a.view].registerPagerSection(a);},resetPagerSections:function(a){if(ProfilePhotosTabController.viewControllers[a])ProfilePhotosTabController.viewControllers[a].resetPagerSections();},transitionHandler:function(f,e,a){if(ProfilePhotosTabController.viewControllers[f]&&ProfilePhotosTabController.viewControllers[f].transitionHandler(e,a))return true;var d=e.getQueryData();var c=d.v||a;var b=ProfilePhotosTabController.viewControllers[c];if(c!=f&&b&&b.matchesURI(e))return null;if(b)tab_controller.dirtyCachedView(c);if(d.s>0||d.so>0||d.sb>0||d.vm)return false;return null;}});copy_properties(ProfilePhotosTabController.prototype,{registerPagerSection:function(a){this.pagerSections[a.start_param]=a;},resetPagerSections:function(){this.pagerSections={};},transitionHandler:function(m,d){var j=m.getQueryData();if(((j.id||this.user)!=this.id)||((j.viewas||this.user)!=this.viewas)||((j.v)!=this.view))return false;var g=(j.vm||'');if(g!=this.vm){var c={};copy_properties(c,j);copy_properties(c,{action:'vm'});new AsyncRequest().setURI('/ajax/photos.php').setMethod('GET').setReadOnly(true).setData(c).setHandler(this._changeViewMode.bind(this,g)).setFinallyHandler(function(){PageTransitions.transitionComplete();}).send();return true;}var l=this.pagerSections;var a=null;for(var i in l){var k=l[i];if((j[i]||0)!=k.start){if(a!==null)return false;a=i;}}if(a===null)return false;var b=l[a];var e=b.in_transition;var h=b.start;var f=parseInt(j[a]||0,10);if(e||h==f)return false;pagers={};for(var i in l){if(i==a)continue;var k=l[i];pagers[k.name]={count:k.count,start:j[k.start_param]||0,page_size:k.page_size,start_param:k.start_param};}var c={};copy_properties(c,j);copy_properties(c,{action:'page',section:b.name,pagers:JSON.encode(pagers),extra_data:JSON.encode(b.extra_data)});new AsyncRequest().setURI('/ajax/photos.php').setMethod('GET').setReadOnly(true).setData(c).setHandler(this._updateSections.bind(this,a,h,f)).setFinallyHandler(function(){PageTransitions.transitionComplete();}).send();return true;},_changeViewMode:function(a,c){if(this.view!=tab_controller.currentView)return;var d=$('tab_canvas').firstChild;var b=c.getPayload();DOM.setContent(d,HTML(b.html));this.resetPagerSections();this.vm=a;},_updateSections:function(a,d,c,g){if(this.view!=tab_controller.currentView)return;var f=g.getPayload();var j=this.pagerSections;var b=j[a];for(var e in this.pagerSections){var h=j[e];var i=f[h.name];if(e==a)h.updateContent(d,c,i.content);h.updatePager(HTML(i.pager));}},matchesURI:function(e){var b=e.getQueryData();if((b.vm||'')!=this.vm)return false;var d=this.pagerSections;for(var a in d){var c=d[a];if((b[a]||0)!=c.start)return false;}return true;}});function ProfilePhotosTabPagerSection(i,d,h,g,b,e,f,a,c){copy_properties(this,{view:i,name:d,start_param:h,start:g||0,count:b,in_transition:false,page_size:e,pager:ge(f),content_wrapper:ge(a),extra_data:c||{}});if(!this.pager||!this.content_wrapper)return;ProfilePhotosTabController.registerPagerSection(this);}copy_properties(ProfilePhotosTabPagerSection,{ANIM_DURATION:400,CONTENT_WIDTH:750});copy_properties(ProfilePhotosTabPagerSection.prototype,{updatePager:function(a){DOM.setContent(this.pager,a);},updateContent:function(i,g,a){if(this.in_transition||this.start==g)return;this.in_transition=true;this.start=g;var j=g>i;this._unloaded_count=0;this.old_content=this.content_wrapper.firstChild;var h=Vector2.getElementDimensions(this.old_content).y;this.content_wrapper.style.height=''+h+'px';this.old_content.style.position='absolute';this.old_content.style.left='0px';this.old_content.style.top='0px';var c=HTML(a).getRootNode();var e=(ProfilePhotosTabPagerSection.CONTENT_WIDTH*(j?1:-1));c.style.top='0px';c.style.left=e+'px';c.style.position='absolute';this.new_content=c;this.content_wrapper.appendChild(c);var d=Vector2.getElementDimensions(c).y;setTimeout(bind(this,this._transition,c),5000);var f=DOM.scry(c,'img');var k=0;for(var b=0;b<f.length;b++)if(!f[b].fb_loaded){f[b].onload=bind(this,this._image_monitor,f.length);k++;}this._unloaded_count=k;this._try_transition(f.length);},_image_monitor:function(a){this._unloaded_count--;this._try_transition(a);},_try_transition:function(a){if(this._unloaded_count<(a/5)||this._unloaded_count<2){this._transition();this._fix_height();}},_transition:function(){if(!this.in_transition)return;animation(this.new_content).to('left',0).duration(ProfilePhotosTabPagerSection.ANIM_DURATION).ease(animation.ease.both).go();animation(this.old_content).to('left',0-parseInt(this.new_content.style.left)).duration(ProfilePhotosTabPagerSection.ANIM_DURATION).ondone(bind(this,this._finish)).ease(animation.ease.both).go();},_fix_height:function(){var a=Vector2.getElementDimensions(this.new_content).y;var b=Vector2.getElementDimensions(this.old_content).y;if(Math.abs(a-b)<=10){this.content_wrapper.style.height=a+'px';}else animation(this.content_wrapper).to('height',a).duration(ProfilePhotosTabPagerSection.ANIM_DURATION/2).go();},_finish:function(){this.content_wrapper.removeChild(this.old_content);this.in_transition=false;}});

if (window.Bootloader) { Bootloader.done(["js\/profile\/photos.js"]); }