function GoTo(URL)
		{window.location=URL;}
		
var Home="http://www.budgetcues.com/";
var Links="http://www.budgetcues.com/links.htm";

// Simple function to add hidden products to cart.
// addproduct('Bananas', 3.00, 2);
var prodnum = 88;
function addproduct(name, price, quantity) {
//if box is checked, then grab value of selected <option> and use .appendTo if box isn't checked onchange then what?

    prodnum++;
    return $('<INPUT TYPE="HIDDEN" NAME="product'+prodnum+'" VALUE="'+name+'" /><INPUT TYPE="HIDDEN" NAME="price'+prodnum+'" VALUE="'+price+'" /><INPUT TYPE="HIDDEN" NAME="qty'+prodnum+'" VALUE="'+quantity+'" />').appendTo('#shoppingcart form');
}

// Ready function. This stuff is executed immediately.
$(function () {
    // Ensures if someone hits the back button, the selected class still shows up.
    var checkedrows = $('tr[id$=row]').find(':checked').filter(':checked').parent().parent();
    checkedrows.addClass('selected');

    // Add "selected" class to row if checkbox is clicked.
    $('tr[id$=row]').find(':checkbox').click(function() {
        $(this).parent().parent().toggleClass('selected');
    });

    // If any of the #extras select dropdown's change, it iterates through
    // and updates all of the pricefields to the right.
    $("#extras select").change(function() {
        $(this).find(':selected').each(function() {
            var pricefield = $(this).parent().parent().find('.rowprice').text('meh');
            var selectedprice = this.value.match(/[0-9]+\.[0-9]{2}/);
            var endprice = pricefield.text('($'+selectedprice[0].replace('.00','')+')');
        });
    });

    // This event occurs when the submit button is clicked.
    $('#shoppingcart form').submit(function() {
       //Iterate through extras, see what they want added. 
        $('#extras').find('input[type=checkbox]').each(function() {
            if(this.checked == true) {
                //Add the product to the cart as a type=hidden
                addproduct(
                    //First the name.
                    $(this).parent().parent().find(':selected').attr('value').match(/^[^:]*/),
                    //Then the price.
                    $(this).parent().parent().find(':selected').attr('value').match(/[0-9]+\.[0-9]{2}/),
                    //Then the quantity, which is 1.
                    1);
            }
            
        });
      //  updatepricefields();
      // return false;
    });

// For testing -->  $('#shoppingcart > p').append(selectedprice[0]);
});
