/*
 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.Print"],["require","dijit.Menu"],["require","dijit.form.Button"],["require","esri.tasks.PrintTask"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.dijit.Print"]){_4._hasResource["esri.dijit.Print"]=true;_4.provide("esri.dijit.Print");_4.require("dijit.Menu");_4.require("dijit.form.Button");_4.require("esri.tasks.PrintTask");_4.declare("esri.dijit.Print",null,{onPrintComplete:function(){},onError:function(){},onPrintStart:function(){},constructor:function(_7,_8){_7=_7||{};this.url=_7.url;this.map=_7.map;this.templates=_7.templates;var _9=esri.bundle.widgets.print;this._printText=_9.NLS_print;this._printingText=_9.NLS_printing;this._printoutText=_9.NLS_printout;if(!this.templates){this.templates=[{label:this._printText,format:"PNG32",layout:"MAP_ONLY",exportOptions:{width:800,height:1100,dpi:96}}];}this.printDomNode=_4.create("div");_4.addClass(this.printDomNode,"esriPrint");_8=_4.byId(_8);_8.appendChild(this.printDomNode);},startup:function(){this._createPrintButton();},destroy:function(){this.map=null;_4.destroy(this.printDomNode);},hide:function(){esri.hide(this.printDomNode);},show:function(){esri.show(this.printDomNode);},printMap:function(_a){this.onPrintStart();this._printButton.setAttribute("label",this._printingText);this._printButton.setAttribute("disabled",true);var _b=this.map;var _c=new esri.tasks.PrintTask(this.url);var _d=new esri.tasks.PrintParameters();_d.map=_b;_d.template=_a;_c.execute(_d,_4.hitch(this,this._printComplete),_4.hitch(this,this._printError));},_createPrintButton:function(){var _e=this.templates;if(_e.length===1){this._printButton=new _5.form.Button({label:this._printText,onClick:_4.hitch(this,function(){this.printMap(_e[0]);})});this.printDomNode.appendChild(this._printButton.domNode);}else{this._printButton=new _5.form.ComboButton({label:this._printText,onClick:_4.hitch(this,function(){this.printMap(_e[0]);})});this.printDomNode.appendChild(this._printButton.domNode);var _f=new _5.Menu({style:"display: none;"});_4.forEach(_e,function(_10){var _11=new _5.MenuItem({label:_10.label,onClick:_4.hitch(this,function(){this.printMap(_10);})});_f.addChild(_11);},this);this._printButton.setAttribute("dropDown",_f);}_4.addClass(this._printButton.domNode,"esriPrintButton");},_printComplete:function(_12){this.onPrintComplete(_12);var _13=window.location.host.split(".");var _14=_13.length>1?_13[_13.length-2]+"."+_13[_13.length-1]:window.location.host;var _15=_12.url.split("://")[1].split("/")[0].split(".");var _16=_15.length>1?_15[_15.length-2]+"."+_15[_15.length-1]:_12.url.split("://")[1].split("/")[0];if(_14.toLowerCase()===_16.toLowerCase()){window.open(_12.url);this._removeAllChildren(this.printDomNode);this._createPrintButton();}else{this._printButton.domNode.style.display="none";var _17=_4.create("a",{href:_12.url,target:"_blank",innerHTML:this._printoutText});_4.connect(_17,"onclick",_4.hitch(this,this._hyperlinkClick));this._removeAllChildren(this.printDomNode);_4.addClass(_17,"esriPrintout");this.printDomNode.appendChild(_17);}},_printError:function(err){this._removeAllChildren(this.printDomNode);this._createPrintButton();console.error(err);this.onError(err);},_hyperlinkClick:function(){this._removeAllChildren(this.printDomNode);this._createPrintButton();},_removeAllChildren:function(_18){while(_18.hasChildNodes()){_18.removeChild(_18.lastChild);}}});}}};});