/*
 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
 */
//>>built
define("esri/dijit/Print",["dojo/_base/declare","dojo/_base/lang","dojo/_base/connect","dojo/_base/array","dojo/has","dojo/dom","dojo/dom-class","dojo/dom-construct","dijit/Menu","dijit/MenuItem","dijit/form/Button","dijit/form/ComboButton","esri/tasks/PrintTask","esri/tasks/PrintParameters","esri/kernel","esri/domUtils","esri/Evented","dojo/i18n!esri/nls/jsapi"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f,_10,_11,_12){var _13=_1([_11],{declaredClass:"esri.dijit.Print",_eventMap:{"print-complete":["result"],"error":true,"print-start":true},onPrintComplete:function(){},onError:function(){},onPrintStart:function(){},constructor:function(_14,_15){_14=_14||{};this.url=_14.url;this.async=_14.async;this.map=_14.map;this.templates=_14.templates;this.extraParams=_14.extraParameters;var _16=_12.widgets.print;this._printText=_16.NLS_print;this._printingText=_16.NLS_printing;this._printoutText=_16.NLS_printout;if(!this.templates){this.templates=[{label:this._printText,format:"PNG32",layout:"MAP_ONLY",exportOptions:{width:800,height:1100,dpi:96}}];}this.printDomNode=_8.create("div");_7.add(this.printDomNode,"esriPrint");_15=_6.byId(_15);_15.appendChild(this.printDomNode);},startup:function(){this._createPrintButton();},destroy:function(){this.map=null;_8.destroy(this.printDomNode);},hide:function(){_10.hide(this.printDomNode);},show:function(){_10.show(this.printDomNode);},printMap:function(_17){this.onPrintStart();this._printButton.setAttribute("label",this._printingText);this._printButton.setAttribute("disabled",true);var map=this.map;var _18=new _d(this.url,{async:this.async});var _19=new _e();_19.map=map;_19.template=_17;_19.extraParameters=this.extraParams;_18.execute(_19,_2.hitch(this,this._printComplete),_2.hitch(this,this._printError));},_createPrintButton:function(){var _1a=this.templates;if(_1a.length===1){this._printButton=new _b({label:this._printText,onClick:_2.hitch(this,function(){this.printMap(_1a[0]);})});this.printDomNode.appendChild(this._printButton.domNode);}else{this._printButton=new _c({label:this._printText,onClick:_2.hitch(this,function(){this.printMap(_1a[0]);})});this.printDomNode.appendChild(this._printButton.domNode);var _1b=new _9({style:"display: none;"});_4.forEach(_1a,function(_1c){var _1d=new _a({label:_1c.label,onClick:_2.hitch(this,function(){this.printMap(_1c);})});_1b.addChild(_1d);},this);this._printButton.setAttribute("dropDown",_1b);}_7.add(this._printButton.domNode,"esriPrintButton");},_printComplete:function(_1e){this.onPrintComplete(_1e);var _1f=window.location.host.split(".");var _20=_1f.length>1?_1f[_1f.length-2]+"."+_1f[_1f.length-1]:window.location.host;var _21=_1e.url.split("://")[1].split("/")[0].split(".");var _22=_21.length>1?_21[_21.length-2]+"."+_21[_21.length-1]:_1e.url.split("://")[1].split("/")[0];if(_20.toLowerCase()===_22.toLowerCase()){window.open(_1e.url);this._removeAllChildren(this.printDomNode);this._createPrintButton();}else{this._printButton.domNode.style.display="none";var _23=_8.create("a",{href:_1e.url,target:"_blank",innerHTML:this._printoutText});_3.connect(_23,"onclick",_2.hitch(this,this._hyperlinkClick));this._removeAllChildren(this.printDomNode);_7.add(_23,"esriPrintout");this.printDomNode.appendChild(_23);}},_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(_24){while(_24.hasChildNodes()){_24.removeChild(_24.lastChild);}}});if(_5("extend-esri")){_2.setObject("dijit.Print",_13,_f);}return _13;});