﻿function AddToCart(itemName, itemNumber, itemAmount, itemNo_shipping){
    add = 1;
    cmd = '_cart';
    business = 'fredi@briteyellow.com';
    no_note = '1';
    ok_return = 'http://www.briteyellow.com/Pages/Purchase%20Complete.aspx';
    cancel_return = 'http://www.briteyellow.com/Pages/Transaction%20Cancelled.aspx';
    currency_code = 'GBP';
    lc = 'GB';
    bm = 'PP-ShopCartBF';
   
    addInput('add', add);
    addInput('cmd', cmd);
    addInput('business', business);
    addInput('item_name', itemName);
    if(itemNumber != null)
        addInput('item_number', itemNumber);
    addInput('amount', itemAmount);
    addInput('no_shipping', add);
    addInput('no_shipping', itemNo_shipping);
    addInput('no_note', no_note);
    addInput('return', ok_return);
    addInput('cancel_return', cancel_return);
    addInput('currency_code', currency_code);
    addInput('lc', lc);
    addInput('bm', bm);
   
    var action = theForm.action;
    var method = theForm.method;
    var target = theForm.target;
    theForm.action = "https://www.paypal.com/cgi-bin/webscr";
    theForm.method="post";
    theForm.target="paypal";
    theForm.submit();
    theForm.action = action;    
    theForm.method = method;    
    theForm.target = target;
    
    disposeInput('add');
    disposeInput('cmd');
    disposeInput('business');
    disposeInput('item_name');
    if(itemNumber != null)
        disposeInput('item_number');
    disposeInput('amount');
    disposeInput('no_shipping');
    disposeInput('no_shipping');
    disposeInput('no_note');
    disposeInput('return');
    disposeInput('cancel_return');
    disposeInput('currency_code');
    disposeInput('lc');
    disposeInput('bm');
}

function addInput(name, value)
{
    var control = document.createElement('input');
    control.type = 'hidden';
    control.name = name;
    control.id = name + '_input';
    control.value = value;
    theForm.appendChild(control);
}

function disposeInput(name)
{
    var control = document.getElementById(name+'_input');
    //control[0].parentNode.removeChild(control[0]);
    control.parentNode.removeChild(control);
}    

function broadbandRegistration()
{
    addInput('cmd', '_s-xclick');
    addInput('hosted_button_id', '4885162');

    var action = theForm.action;
    var method = theForm.method;
    var target = theForm.target;
    theForm.action = "https://www.paypal.com/cgi-bin/webscr";
    theForm.method="post";
    theForm.target="paypal";
    theForm.submit();
    theForm.action = action;    
    theForm.method = method;    
    theForm.target = target;
    
    disposeInput('cmd');
    disposeInput('hosted_button_id');
}
