﻿var _popup;

function Process() {
    Page_ClientValidate();

    if (Page_IsValid) {
       this._popup = $find(PopupControl);
       this._popup.show();
       
       var PaymentTypeID = document.getElementById(PaymentTypeControl).options[document.getElementById(PaymentTypeControl).selectedIndex].value;
       var PaymentType = document.getElementById(PaymentTypeControl).options[document.getElementById(PaymentTypeControl).selectedIndex].text;
       var Notes = document.getElementById(NotesControl).value;
       
       if (PaymentTypeID == "3") {
           var CCExpMonth = "";
           var CCExpYear = "";
           var CCType = "";
           var CCNumber = "";
           var CCCode = "";
       }
       else {
           var CCExpMonth = document.getElementById(CCExpMonthControl).options[document.getElementById(CCExpMonthControl).selectedIndex].text;
           var CCExpYear = document.getElementById(CCExpYearControl).options[document.getElementById(CCExpYearControl).selectedIndex].text;
           var CCType = document.getElementById(CCTypeControl).options[document.getElementById(CCTypeControl).selectedIndex].text;
           var CCNumber = document.getElementById(CCNumberControl).value;
           var CCCode = document.getElementById(CCCodeControl).value;
       }
       
       WSCheckOut.Process(PaymentTypeID, PaymentType, CCType, CCNumber, CCExpMonth, CCExpYear, CCCode, Notes, ProcessComplete);
    } 
    
    return false;
}

function ProcessComplete(result) {
    this._popup.hide();

    if (result == "OK")
        window.location = "ShowOrder.aspx";
    else {
        alert(result);
        //document.getElementById(MessageControl).innerHTML = result;
    }

    return false;
}


