﻿
function onprivate() {
    if (top.document.aspnetForm.ctl00_handlingtype.value == "link") {
        top.location.href = top.document.aspnetForm.ctl00_goonprivate.value;
    }
    else {
        top.document.aspnetForm.ctl00_answer.value = "private";
        top.document.aspnetForm.submit();
    }
}

function onpublic() {
    if (top.document.aspnetForm.ctl00_handlingtype.value == "link") {
        top.location.href = top.document.aspnetForm.ctl00_goonpublic.value;
    }
    else {
        top.document.aspnetForm.ctl00_answer.value = "public";
        top.document.aspnetForm.submit();
    }
}

function onclose() {
    //    top.location.href=top.document.aspnetForm.ctl00_goonclose.value;
    top.location.href = top.document.getElementById('ctl00_goonclose').value;
}

function sendMessage(handlingType, identifier, lpublic, lprivate, oksrc) {

    try {
        document.aspnetForm.ctl00_handlingtype.value = handlingType;

        if (handlingType == 'link') {
            document.aspnetForm.ctl00_goonpublic.value = lpublic;
            document.aspnetForm.ctl00_goonprivate.value = lprivate;
        }
        else if (handlingType == 'button') {
            document.aspnetForm.ctl00_identifier.value = identifier;
        }

        var ifr = document.getElementById('ctl00_pnlsendmessagepopup');
        ifr.src = oksrc;
    }
    catch (e) {
        alert('Error: sendMessage() : ' + e);
    }

}

function sendMessageWithPopup(handlingType, identifier, lpublic, lprivate) {

    try {
        var mpu = top.$find('ctl00_sendmessageMPE');
        mpu.show();

        document.aspnetForm.ctl00_handlingtype.value = handlingType;

        if (handlingType == 'link') {
            document.aspnetForm.ctl00_goonpublic.value = lpublic;
            document.aspnetForm.ctl00_goonprivate.value = lprivate;
        }
        else if (handlingType == 'button') {
            document.aspnetForm.ctl00_identifier.value = identifier;
        }
    }
    catch (e) {
        alert('Error: sendMessageWithPopup() : ' + e);
    }

}

function onaccept(url) {

    //var lprivate = top.document.aspnetForm.ctl00_goonprivate.value;
    var lprivate = top.document.getElementById('ctl00_goonprivate').value;

    if (lprivate != null && lprivate != '') {
        url = url + '&returnurl=' + lprivate;
        //alert('Payment URL = ' + url);
    }

    top.location.href = url;
}

function onacceptnoreturnurl(url) {
    top.location.href = url;
}

function sendMessageWithPaymentPopup(handlingType, identifier, lpublic, lprivate) {

    try {
        var mpu = top.$find('ctl00_sendmessagepaymentMPE');
        mpu.show();

        document.aspnetForm.ctl00_handlingtype.value = handlingType;

        if (handlingType == 'link') {
            document.aspnetForm.ctl00_goonpublic.value = lpublic;
            document.aspnetForm.ctl00_goonprivate.value = lprivate;
        }
        else if (handlingType == 'button') {
            document.aspnetForm.ctl00_identifier.value = identifier;
        }

        paymentClick();
    }
    catch (e) {
        alert('ERROR: sendMessageWithPaymentPopup() : ' + e);
    }
}

function paymentClick() {

    try {
        var xmlhttp;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        }
        else if (window.ActiveXObject) {
            xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
        }

        if (xmlhttp != null) {
            xmlhttp.open('GET', 'paymentclick.aspx?t=20&r=" & Date.Now.Ticks.ToString & "', true);
            xmlhttp.send(null);
        }
    }
    catch (e) {
        alert('ERROR: paymentClick() : ' + e);
    }
}

