var paypalform;
var creditform;
var paypalcontent;
var creditcontent;

var initpage = function() {
    // global creditcontent;
    // global paypalcontent;
    
    paypalform = document.getElementById("paypalpay");
    creditform = document.getElementById("creditcardpay");
    document.getElementById("paypaltype").onclick = showPayPal;
    document.getElementById("credittype").onclick = hidePayPal;
    
    paypalcontent = paypalform.innerHTML;
    creditcontent = creditform.innerHTML;
    
    if ( document.getElementById("paypaltype").checked ) {
        showPayPal();
    } else {
        hidePayPal();
    }
}

var showPayPal = function() {
    // alert("Show PayPal");
    creditform.innerHTML = "";
    paypalform.innerHTML = paypalcontent;
}

var hidePayPal = function() {
    // alert("Show Credit Card");
    paypalform.innerHTML = "";
    creditform.innerHTML = creditcontent;
}

window.onload = initpage;

