﻿function ModalPopupsCustom1(Path) {
    ModalPopups.Custom("idCustom1",
        "Preencha a finalidade do download",
        "<div style='padding: 25px;'>" + 
        "<table>" + 
        "<caption></caption>" + 
        "<tr>" + 
        "    <td>" + 
        "        <textarea id=\"inputCustom1Name\" name=\"inputCustom1Name\" style=\"width:294px; height:67px;\" ></textarea>" +
        "    <input type=\"hidden\" id=\"inputCustom1Name2\" name=\"inputCustom1Name2\" value=\"" + Path + "\" /></td>" + 
        "</tr>" + 
        "</table>" + 
        "</div>",
        {
            width: 400,
            buttons: "ok,cancel",
            okButtonText: "Download",
            cancelButtonText: "Cancelar",
            onOk: "ModalPopupsCustom1Save()",
            onCancel: "ModalPopupsCustom1Cancel()"
        }
    );

    ModalPopups.GetCustomControl("inputCustom1Name").focus();
}
function ModalPopupsCustom1Save() {
    var custom1Name = ModalPopups.GetCustomControl("inputCustom1Name");
    var custom2Name = ModalPopups.GetCustomControl("inputCustom1Name2");
    if (custom1Name.value == "") {
        alert("Preencha a finalidade do download!");
        custom1Name.focus();
    }
    else {
        // alert("Your name is: " + custom1Name.value);
        ModalPopups.Close("idCustom1");
        window.open(custom2Name.value + "&motivo=" + custom1Name.value, "download", "scrollbars=no, status=no, location=no, toolbar=no, menubar=no, left=10, screenX=10, top=10, screenY=10, width=10px, height=10px", "");
    }
}

function ModalPopupsCustom1Cancel() {
    // alert('You pressed Cancel');
    ModalPopups.Cancel("idCustom1");
}  


/* historico de downloads */
function ModalPopupsCustom2(idimagem) {
    ModalPopups.Custom("idCustom2",
        "Histórico de Downloads da Imagem",
        "<div style='padding: 25px;'>" +
        "<iframe borders=no width=350px height=300px src=" + "/HistoricoDownloads.aspx?id=" + idimagem + "></iframe>" + 
        "</div>",
        {
            width: 400,
            buttons: "cancel",
            cancelButtonText: "Fechar",
            onCancel: "ModalPopupsCustom2Cancel()"
        }
    );
}

function ModalPopupsCustom2Cancel() {
    // alert('You pressed Cancel');
    ModalPopups.Cancel("idCustom2");
}
