

function exportPDF (evt) 
{
    dojo.style("pdfRequestFinished", "display", "none");
    dojo.style("pdfRequestError", "display", "none");
    dojo.style("pdfRequest", "display", "block");
    dijit.byId("exportPDFBtn").set("disabled", true);
    
    var PrintUrl = _ExportWebMapURL;
    var PrintTask = new esri.tasks.PrintTask(PrintUrl);
    
    var params = new esri.tasks.PrintParameters();
    params.map = map;
    
    var template = new esri.tasks.PrintTemplate();
    template.exportOptions = {width: 500, height: 400, dpi: 200};
    template.format = "PDF";
    template.layout = "Letter ANSI A Landscape";
    template.preserveScale = true;
    
    LayoutOptionsParam = new Object();
    LayoutOptionsParam.titleText = dijit.byId("mapTitle").value;
    LayoutOptionsParam.scalebarUnit = "Feet";
    LayoutOptionsParam.legendLayers = [];  
            
    template.layoutOptions = LayoutOptionsParam;  
    
    params.template = template;
  
    PrintTask.execute(params, PrintCompleteCallBack, PrintErrorCallBack);    
}

function PrintCompleteCallBack(result) {
    dijit.byId("exportPDFBtn").set("disabled", false);
    dojo.style("pdfRequest", "display", "none");
    dojo.style("pdfRequestError", "display", "none");
    dojo.style("pdfRequestFinished", "display", "block");
    dojo.byId("pdfLink").href = result.url;
}

function PrintErrorCallBack(error) {
    dijit.byId("exportPDFBtn").set("disabled", false);
    dojo.style("pdfRequest", "display", "none");
    dojo.style("pdfRequestFinished", "display", "none");
    dojo.style("pdfRequestError", "display", "block");
}

function showPrintingTooltipDialog() {
    var tooltipdialog = dijit.byId('ttd');
    dijit.popup.open({ popup: tooltipdialog, around: dojo.byId("print") });
    tooltipdialog.focus();
}


