/*
 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.layers.dynamic"],["require","esri.layers.layer"],["require","esri.geometry"],["require","dojox.xml.parser"],["require","dojox.gfx.matrix"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.layers.dynamic"]){_4._hasResource["esri.layers.dynamic"]=true;_4.provide("esri.layers.dynamic");_4.require("esri.layers.layer");_4.require("esri.geometry");_4.require("dojox.xml.parser");_4.require("dojox.gfx.matrix");_4.declare("esri.layers.DynamicMapServiceLayer",esri.layers.Layer,{constructor:function(_7,_8){this.useMapTime=(_8&&_8.hasOwnProperty("useMapTime"))?(!!_8.useMapTime):true;var _9=_4.hitch;this._exportMapImageHandler=_9(this,this._exportMapImageHandler);this._imgSrcFunc=_9(this,this._imgSrcFunc);this._divAlphaImageFunc=_9(this,this._divAlphaImageFunc);this._tileLoadHandler=_9(this,this._tileLoadHandler);this._tileErrorHandler=_9(this,this._tileErrorHandler);},opacity:1,isPNG32:false,_setMap:function(_a,_b,_c){this._map=_a;var d=(this._div=_4.create("div",null,_b)),_d=esri._css.names,_e={position:"absolute",width:_a.width+"px",height:_a.height+"px",overflow:"visible",opacity:this.opacity},_f=_4.isIE,_10=_4.connect,vd=_a.__visibleDelta;if(_f&&_f>7){delete _e.opacity;}if(_a.navigationMode==="css-transforms"){_e[_d.transform]=esri._css.translate(vd.x,vd.y);_4.style(d,_e);this._onScaleHandler_connect=_10(_a,"onScale",this,this._onScaleHandler);this._left=vd.x;this._top=vd.y;}else{_e.left="0px";_e.top="0px";_4.style(d,_e);this._onZoomHandler_connect=_10(_a,"onZoom",this,"_onZoomHandler");this._left=this._top=0;}_4.style(d,_e);this._onPanHandler_connect=_10(_a,"onPan",this,"_onPanHandler");this._onExtentChangeHandler_connect=_10(_a,"onExtentChange",this,"_onExtentChangeHandler");this._onResizeHandler_connect=_10(_a,"onResize",this,"_onResizeHandler");this._opacityChangeHandler_connect=_10(this,"onOpacityChange",this,"_opacityChangeHandler");this._visibilityChangeHandler_connect=_10(this,"onVisibilityChange",this,"_visibilityChangeHandler");this._toggleTime();this._layerIndex=_c;this._img_loading=null;this._dragOrigin={x:0,y:0};if(!this.visible){this._visibilityChangeHandler(this.visible);}else{if(_a.extent&&_a.loaded){this._onExtentChangeHandler(_a.extent);}}return d;},_unsetMap:function(map,_11){if(_11){this._div=_11.removeChild(this._div);}_4.destroy(this._div);this._map=this._layerIndex=this._div=null;var _12=_4.disconnect;_12(this._onPanHandler_connect);_12(this._onExtentChangeHandler_connect);_12(this._onZoomHandler_connect);_12(this._onScaleHandler_connect);_12(this._onResizeHandler_connect);_12(this._opacityChangeHandler_connect);_12(this._visibilityChangeHandler_connect);this._toggleTime();},_onResizeHandler:function(_13,_14,_15){_4.style(this._div,{width:_14+"px",height:_15+"px"});this._onExtentChangeHandler(_13);},_visibilityChangeHandler:function(v){var _16=_4.connect,_17=_4.disconnect,map=this._map;this._toggleTime();if(v){this._onExtentChangeHandler(map.extent);this._onPanHandler_connect=_16(map,"onPan",this,"_onPanHandler");this._onExtentChangeHandler_connect=_16(map,"onExtentChange",this,"_onExtentChangeHandler");if(map.navigationMode==="css-transforms"){this._onScaleHandler_connect=_16(map,"onScale",this,this._onScaleHandler);}else{this._onZoomHandler_connect=_16(map,"onZoom",this,"_onZoomHandler");}}else{esri.hide(this._div);_17(this._onPanHandler_connect);_17(this._onExtentChangeHandler_connect);_17(this._onZoomHandler_connect);_17(this._onScaleHandler_connect);}},_toggleTime:function(){var map=this._map;if(this.timeInfo&&this.useMapTime&&map&&this.visible){if(!this._timeConnect){this._timeConnect=_4.connect(map,"onTimeExtentChange",this,this._onTimeExtentChangeHandler);}this._setTime(map.timeExtent);}else{_4.disconnect(this._timeConnect);this._timeConnect=null;this._setTime(null);}},_setTime:function(_18){if(this._params){this._params.time=_18?_18.toJson().join(","):null;}},_onPanHandler:function(_19,_1a){this._panDx=_1a.x;this._panDy=_1a.y;var _1b=this._dragOrigin,vd=this._map.__visibleDelta,img=this._img;if(img){if(this._map.navigationMode==="css-transforms"){this._left=vd.x+_1a.x;this._top=vd.y+_1a.y;_4.style(this._div,esri._css.names.transform,esri._css.translate(this._left,this._top));}else{_4.style(img,{left:(_1b.x+_1a.x)+"px",top:(_1b.y+_1a.y)+"px"});}}},_onExtentChangeHandler:function(_1c,_1d,_1e){if(!this.visible){return;}var _1f=this._map,_20=this._img,_21=_20&&_20.style,_22=this._dragOrigin;if(_1d&&!_1e&&_20&&(_1d.x!==this._panDx||_1d.y!==this._panDy)){if(_1f.navigationMode==="css-transforms"){var vd=_1f.__visibleDelta;this._left=vd.x;this._top=vd.y;_4.style(this._div,esri._css.names.transform,esri._css.translate(this._left,this._top));}else{_4.style(_20,{left:(_22.x+_1d.x)+"px",top:(_22.y+_1d.y)+"px"});}}if(_20){_22.x=parseInt(_21.left,10);_22.y=parseInt(_21.top,10);}else{_22.x=(_22.y=0);}if(_1f.navigationMode==="css-transforms"){if(_1e&&_20){_4.style(_20,esri._css.names.transition,"none");_20._multiply=_20._multiply?_6.gfx.matrix.multiply(_20._matrix,_20._multiply):_20._matrix;}}this._fireUpdateStart();var _23=this._img_loading;if(_23){_4.disconnect(_23._onload_connect);_4.disconnect(_23._onerror_connect);_4.disconnect(_23._onabort_connect);_4.destroy(_23);this._img_loading=null;var _24=this._jsonRequest;if(_24){try{_24.cancel();}catch(e){}this._jsonRequest=null;}}if(this.version>=10&&_1f.wrapAround180){_1c=_1c._normalize(true);}if(this.isPNG32){var div=(this._img_loading=_4.create("div"));div.id=_1f.id+"_"+this.id+"_"+new Date().getTime();_4.style(div,{position:"absolute",left:"0px",top:"0px",width:_1f.width+"px",height:_1f.height+"px"});var _25=div.appendChild(_4.create("div"));_4.style(_25,{opacity:0,width:_1f.width+"px",height:_1f.height+"px"});this.getImageUrl(_1c,_1f.width,_1f.height,this._divAlphaImageFunc);div=null;}else{var img=(this._img_loading=_4.create("img")),_26=esri._css.names,_27=_4.isIE,css={position:"absolute",width:_1f.width+"px",height:_1f.height+"px"};if(_27&&_27>7){css.opacity=this.opacity;}if(_1f.navigationMode==="css-transforms"){css[_26.transform]=esri._css.translate(-this._left,-this._top);img._tdx=-this._left;img._tdy=-this._top;css[_26.transition]=_26.transformName+" "+esri.config.defaults.map.zoomDuration+"ms ease";}else{css.left="0px";css.top="0px";}img.id=_1f.id+"_"+this.id+"_"+new Date().getTime();_4.style(img,css);img._onload_connect=_4.connect(img,"onload",this,"_onLoadHandler");img._onerror_connect=_4.connect(img,"onerror",this,"_onErrorHandler");img._onabort_connect=_4.connect(img,"onabort",this,"_onErrorHandler");this._startRect={left:_22.x,top:_22.y,width:_20?parseInt(_21.width,10):_1f.width,height:_20?parseInt(_21.height,10):_1f.height,zoom:(_21&&_21.zoom)?parseFloat(_21.zoom):1};this.getImageUrl(_1c,_1f.width,_1f.height,this._imgSrcFunc);img=null;}},_onTimeExtentChangeHandler:function(_28){if(!this.visible){return;}this._setTime(_28);this.refresh(true);},getImageUrl:function(_29,wd,ht,_2a){},_imgSrcFunc:function(src){this._img_loading.src=src;},_divAlphaImageFunc:function(src){_4.style(this._img_loading,"filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')");this._onLoadHandler({currentTarget:this._img_loading});},_onLoadHandler:function(evt){var img=evt.currentTarget,_2b=_4.disconnect,_2c=this._map;_2b(img._onload_connect);_2b(img._onerror_connect);_2b(img._onabort_connect);if(!_2c||_2c.__panning||_2c.__zooming){_4.destroy(img);this._fireUpdateEnd();return;}_6.xml.parser.removeChildren(this._div);this._img=img;this._startRect={left:0,top:0,width:_2c.width,height:_2c.height,zoom:1};this._div.appendChild(img);if(this.visible){esri.show(this._div);}img._onload_connect=img._onerror_connect=img._onabort_connect=this._img_loading=null;var _2d=this._dragOrigin;_2d.x=(_2d.y=0);this.onUpdate();this._fireUpdateEnd();},_onErrorHandler:function(evt){var img=evt.currentTarget,_2e=_4.disconnect;_4.style(img,"visibility","hidden");_2e(img._onload_connect);_2e(img._onerror_connect);_2e(img._onabort_connect);img._onload_connect=img._onerror_connect=img._onabort_connect=null;var _2f=new Error(esri.bundle.layers.dynamic.imageError+": "+img.src);this.onError(_2f);this._fireUpdateEnd(_2f);},setUseMapTime:function(use,_30){this.useMapTime=use;this._toggleTime();if(!_30){this.refresh(true);}},refresh:function(){if(this._map){this._onExtentChangeHandler(this._map.extent);}},_onScaleHandler:function(mtx,_31){var css={},_32=esri._css.names,img=this._img;if(!img){return;}_4.style(img,_32.transition,_31?"none":(_32.transformName+" "+esri.config.defaults.map.zoomDuration+"ms ease"));img._matrix=mtx;mtx=img._multiply?_6.gfx.matrix.multiply(mtx,img._multiply):mtx;if(img._tdx||img._tdy){mtx=_6.gfx.matrix.multiply(mtx,{"xx":1,"xy":0,"yx":0,"yy":1,"dx":img._tdx,"dy":img._tdy});}css[_32.transform]=esri._css.matrix(mtx);_4.style(img,css);},_onZoomHandler:function(_33,_34,_35){var _36=this._startRect,_37=_36.width*_34,_38=_36.height*_34,img=this._img,_39=_4.isIE;if(img){if(_39&&_39<8){_4.style(img,{left:(_36.left-((_37-_36.width)*(_35.x-_36.left)/_36.width))+"px",top:(_36.top-((_38-_36.height)*(_35.y-_36.top)/_36.height))+"px",zoom:_34*_36.zoom});}else{_4.style(img,{left:(_36.left-((_37-_36.width)*(_35.x-_36.left)/_36.width))+"px",top:(_36.top-((_38-_36.height)*(_35.y-_36.top)/_36.height))+"px",width:_37+"px",height:_38+"px"});}}},_exportMapImage:function(url,_3a,_3b){var _3c=this._exportMapImageHandler;_3a.token=this._getToken();esri.request({url:url,content:_3a,callbackParamName:"callback",load:function(){_3c(arguments[0],arguments[1],_3b);},error:esri.config.defaults.io.errorHandler});},_exportMapImageHandler:function(_3d,io,_3e){var _3f=new esri.layers.MapImage(_3d);this.onMapImageExport(_3f);if(_3e){_3e(_3f);}},onMapImageExport:function(){},setOpacity:function(o){if(this.opacity!=o){this.onOpacityChange(this.opacity=o);}},onOpacityChange:function(){},_opacityChangeHandler:function(_40){_4.style(this._div,"opacity",_40);}});}}};});