function tpc_buyProduct(tpc_product_id)
{
	showLoadingScreen();
	
	//sc_hideElement('opc_success_table');
	//sc_showElement('opc_order_table');
	//sc_hideElement('opc_payment_method_detail'); // Reset Payment method
	xajax_trackGoal(14);
	xajax_write_tpc_product_id(tpc_product_id);
}

function opc_writeCustomerData()
{
	showLoadingScreen();
	
	a_opc_customer_billing = xajax.getFormValues('billing_form');
	use_different_delivery_address = document.getElementById('opc_use_different_delivery_address').checked;
	a_opc_customer_delivery = xajax.getFormValues('delivery_form');
	
	xajax_write_opc_customer_data(a_opc_customer_billing, use_different_delivery_address, a_opc_customer_delivery);
}

function tpc_setVoucherCode(voucher_code)
{
	showLoadingScreen();
	
	xajax_tpc_set_voucher_code(voucher_code);
}

function tpc_changeCountry(prefix, value)
{
	showLoadingScreen();
	
	//sc_hideElement('opc_payment_method_detail'); // Reset Payment method
	xajax_tpc_change_country(prefix, value);
}

function tpc_choosePaymentMethod(tpc_payment_method_id)
{
	showLoadingScreen();
	a_tpc_customer_billing = xajax.getFormValues('billing_form');
	use_different_delivery_address = document.getElementById('tpc_use_different_delivery_address').checked;
	a_tpc_customer_delivery = xajax.getFormValues('delivery_form');
	
	//sc_hideElement('opc_payment_method_detail'); // Reset Payment method
	xajax_write_tpc_payment_method_id(tpc_payment_method_id,a_tpc_customer_billing, use_different_delivery_address, a_tpc_customer_delivery);
	//document.location.href = '#opc_payment_method_spacer';
}

function tpc_checkout()
{
	showLoadingScreen();
	a_tpc_payment_method_detail_data = xajax.getFormValues('payment_data_form_id');
	accept_conditions = document.getElementById('tpc_accept_conditions').checked
	a_tpc_customer_billing = xajax.getFormValues('billing_form');
	use_different_delivery_address = document.getElementById('tpc_use_different_delivery_address').checked;
	a_tpc_customer_delivery = xajax.getFormValues('delivery_form');
	
	//xajax_trackGoal(15);
	xajax_write_tpc_order(a_tpc_payment_method_detail_data, accept_conditions,a_tpc_customer_billing, use_different_delivery_address, a_tpc_customer_delivery);
}

function tpc_showDeliveryAddressTable(checked)
{
	showLoadingScreen();
	
	//sc_hideElement('opc_payment_method_detail'); // Reset Payment method
	xajax_tpc_change_use_different_delivery_address(checked);
	
	if (checked)
		sc_showElement('delivery_form');
	else
		sc_hideElement('delivery_form')
}
