/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */

window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","esri.dijit.Gallery"],["require","esri.dijit._TouchBase"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.dijit.Gallery"]){_4._hasResource["esri.dijit.Gallery"]=true;_4.provide("esri.dijit.Gallery");_4.require("esri.dijit._TouchBase");_4.declare("esri.dijit.Gallery",null,{container:null,_items:[],_currentIndex:0,_left:0,_offset:10,_slideDiv:null,_thumbnailStyle:"default",_focusedIndex:null,_selectedIndex:-1,_slideStep:1,_showTitle:true,constructor:function(_7,_8){this.container=_4.byId(_8);this._touchBase=esri.dijit._TouchBase(this.container,null);this._slideDiv=_4.create("div",{"class":"slideContainer"},this.container,"first");this.events=[_4.connect(this._touchBase,"onTouchStart",this,this._onTouchStartHandler),_4.connect(this._touchBase,"onTouchMove",this,this._onTouchMoveHandler),_4.connect(this._touchBase,"onTouchEnd",this,this._onTouchEndHandler),_4.connect(this._touchBase,"onclick",this,this._onClickHandler)];this._resizeHandle=_4.connect(window,"onorientationchange",_4.hitch(this,this._onResizeHandler));this._items=_7.items;if(_7.thumbnailStyle&&_7.thumbnailStyle=="small"){this._thumbnailStyle="small";this._offset=4;this._slideStep=3;this._thumbnailWidth=100;}else{this._thumbnailStyle="default";this._offset=10;this._slideStep=1;this._thumbnailWidth=200;}if(_7.showTitle==false){this._showTitle=false;}this.container.setAttribute((document.all?"className":"class"),"esriMobileGallery");var _9,_a;for(var i=0;i<this._items.length;i++){var _b,_c,_d,_e;_b=_4.create("div",{"class":"thumbnailcontainer"},this._slideDiv);_e=_4.create("img",{"class":"thumbnail",src:this._items[i].thumbnailUrl},_b);_e._index=i;_e._item=this._items[i];_c=_4.create("div",{"class":"title","innerHTML":this._items[i].title},_b);_d=_4.create("div",{"class":"title"},_b);if(this._thumbnailStyle=="small"){_4.addClass(_b,"small");_4.addClass(_e,"small");_4.addClass(_c,"small");_4.addClass(_d,"small");_4.addClass(this._slideDiv,"small");}if(!this._showTitle){_c.style.display="none";}_a=_4.contentBox(_b).h;if(!_9){_9=_a;}if(_a>_9){_9=_a;}}for(var i=0;i<this._slideDiv.childNodes.length;i++){_4.contentBox(this._slideDiv.childNodes[i],{h:_9});}this._thumbnailWidth=_4.contentBox(this._slideDiv.childNodes[0]).w;this._slideDiv.style.width=this._items.length*(this._thumbnailWidth+this._offset)+"px";if(window.orientation){if(window.orientation==90||window.orientation==-90){_4.addClass(this.container,"galleryLandscape");}}this._calculateSlideStep();},startup:function(){this._focusedIndex=0;this.onFocus(this._items[this._focusedIndex]);},destroy:function(){_4.forEach(this.events,_4.disconnect);_4.disconnect(this._resizeHandle);this._touchBase=null;_4.query("img",this.container).forEach(function(_f){_f._index=null;_f._item=null;_4.destroy(_f);_f=null;});this._items=null;_4.destroy(this._slideDiv);_4.destroy(this.container);this.container=this._slideDiv=null;},setFocus:function(_10){if(!_10){return;}for(var i=0,il=this._items.length;i<il;i++){if(this._items[i]==_10){this._setFocus(i);this.onFocus(this._items[this._focusedIndex]);}}},select:function(_11){if(!_11){return;}for(var i=0,il=this._items.length;i<il;i++){if(this._items[i]==_11){if(this._selectedIndex!=-1){this.onUnSelect(this._items[this._selectedIndex]);}this._select(i);this.onSelect(this._items[this._selectedIndex]);break;}}},getFocusedItem:function(){return this._items[this._focusedIndex];},getSelectedItem:function(){return this._items[this._selectedIndex];},next:function(){this._next();this._startTransition();this.onFocus(this._items[this._currentIndex]);},previous:function(){this._previous();this._startTransition();this.onFocus(this._items[this._currentIndex]);},getTitleNode:function(_12){if(!_12){return;}for(var i=0,il=this._items.length;i<il;i++){if(this._items[i]==_12){return this._slideDiv.childNodes[i].childNodes[1];break;}}},getInfoNode:function(_13){if(!_13){return;}for(var i=0,il=this._items.length;i<il;i++){if(this._items[i]==_13){return this._slideDiv.childNodes[i].childNodes[2];break;}}},showTitle:function(_14){if(!_14){return;}for(var i=0,il=this._items.length;i<il;i++){if(this._items[i]==_14){this._slideDiv.childNodes[i].childNodes[1].style.display="block";break;}}},hideTitle:function(_15){if(!_15){return;}for(var i=0,il=this._items.length;i<il;i++){if(this._items[i]==_15){this._slideDiv.childNodes[i].childNodes[1].style.display="none";break;}}},onFocus:function(_16){},onSelect:function(_17){},onUnSelect:function(_18){},_onClickHandler:function(e){if(e.target instanceof HTMLImageElement){var _19=e.target._index;if(this._selectedIndex!=-1){this.onUnSelect(this._items[this._selectedIndex]);}this._select(_19);this.onSelect(this._items[this._selectedIndex]);}},_onTouchStartHandler:function(e){this._moveDirection=null;this._left=this._currentIndex*(-(this._thumbnailWidth)-this._offset);this._slideDiv.style.WebkitTransitionDuration="0s";},_onTouchMoveHandler:function(e){if(!this._moveDirection){if(Math.abs(e.curY)>Math.abs(e.curX)){this._moveDirection="vertical";}else{this._moveDirection="horizontal";}}if(this._moveDirection=="vertical"){if(!this._touchBase._preventDefault==false){this._touchBase._preventDefault=false;}return;}else{if(this._moveDirection=="horizontal"){if(!this._touchBase._preventDefault){this._touchBase._preventDefault=true;}var _1a=this._left+e.curX;this._slideDiv.style.webkitTransform="translate3d("+_1a+"px, 0, 0)";}}},_onTouchEndHandler:function(e){var _1b=this._currentIndex;this._slideDiv.style.WebkitTransitionDuration="0.5s";if(e.swipeDirection=="left"){this._next();}else{if(e.swipeDirection=="right"){this._previous();}}this._left=this._currentIndex*(-(this._thumbnailWidth)-this._offset);this._slideDiv.style.webkitTransform="translate3d("+this._left+"px, 0, 0)";if(_1b!=this._currentIndex){this.onFocus(this._items[this._currentIndex]);}},_onResizeHandler:function(e){var _1c=window.orientation;switch(_1c){case 0:_4.removeClass(this.container,"galleryLandscape");break;case 90:case -90:_4.addClass(this.container,"galleryLandscape");break;}this._calculateSlideStep();},_startTransition:function(){this._slideDiv.style.WebkitTransitionDuration="0.5s";this._left=this._currentIndex*(-(this._thumbnailWidth)-this._offset);this._slideDiv.style.webkitTransform="translate3d("+this._left+"px, 0, 0)";},_markUnSelected:function(_1d){_4.removeClass(_1d,"selected");_4.removeClass(_1d.parentNode,"selected");_4.removeClass(_1d.parentNode.childNodes[1],"selected");_4.removeClass(_1d.parentNode.childNodes[2],"selected");},_markSelected:function(_1e){_4.addClass(_1e,"selected");_4.addClass(_1e.parentNode,"selected");_4.addClass(_1e.parentNode.childNodes[1],"selected");_4.addClass(_1e.parentNode.childNodes[2],"selected");},_next:function(){if(this._currentIndex+this._slideStep<this._items.length){this._currentIndex+=this._slideStep;this._focusedIndex=this._currentIndex;}},_previous:function(){if(this._currentIndex-this._slideStep>=0){this._currentIndex-=this._slideStep;}this._focusedIndex=this._currentIndex;},_setFocus:function(_1f){this._focusedIndex=_1f;this._currentIndex=Math.floor(_1f/this._slideStep)*this._slideStep;this._startTransition();},_select:function(_20){if(this._selectedIndex!=-1){this._markUnSelected(this._slideDiv.childNodes[this._selectedIndex].childNodes[0]);}this._selectedIndex=_20;this._markSelected(this._slideDiv.childNodes[this._selectedIndex].childNodes[0]);},_calculateSlideStep:function(){var _21=_4.contentBox(this.container);var _22=Math.floor((_21.w+this._offset)/(this._thumbnailWidth+this._offset));if(_22>=1){var _23=_21.w-(this._thumbnailWidth+this._offset)*_22;if(_23>0){this._slideDiv.style.marginLeft=Math.floor(_23/2)+"px";}else{this._slideDiv.style.marginLeft="0px";}this._slideStep=_22;}else{this._slideStep=1;}if(this._selectedIndex!=-1){this._setFocus(this._selectedIndex);}else{this._setFocus(this._focusedIndex);}}});}}};});