﻿

//Submit Pay Your Bill Form
function submitPayYourBillForm(action) {
    submitForm({ 'form': {
        'method': 'POST',
        'action': action
    },
        'data': { 'productCode': 'lovesexpress', 'billerId': 'EXP', 'billerGroupId': 'LVS' }
    });
}


// Dynamically create a form and submit it.
function submitForm(input) {

    //create dom form object
    var f = getForm(input.form.method, input.form.action);

    //create dom hidden field objects and attach to form
    for (var e in input.data) {
        f.appendChild(getHiddenField(e, input.data[e]));
    }

    //attach form to page dom (after the main form because forms cannot be nested).
    document.getElementById("Body").appendChild(f);

    //call submit() on the form
    f.submit();

}

function getForm(method, action) {
    var f = document.createElement('form');

    f.setAttribute('method', method);
    f.setAttribute('action', action);
    f.setAttribute('target', '_blank');

    return f;
}

function getHiddenField(key, value) {
    var i = document.createElement('input');

    i.setAttribute('type', 'hidden');
    i.setAttribute('name', key);
    i.setAttribute('value', value);

    return i;
}

