function opc_showProducts()
{
	sc_hideElement('opc_success_table');
	document.location.href = '#opc_product_table';
}

function opc_buyProduct(opc_product_id)
{
	showLoadingScreen();
	
	sc_hideElement('opc_success_table');
	sc_showElement('opc_order_table');
	sc_hideElement('opc_payment_method_detail'); // Reset Payment method
	xajax_write_opc_product_id(opc_product_id);
	document.location.href = '#opc_order_table';
}

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 opc_changeCountry(prefix, value)
{
	showLoadingScreen();
	
	sc_hideElement('opc_payment_method_detail'); // Reset Payment method
	xajax_opc_change_country(prefix, value);
}

function opc_choosePaymentMethod(opc_payment_method_id)
{
	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');
	
	sc_hideElement('opc_payment_method_detail'); // Reset Payment method
	xajax_write_opc_payment_method_id(opc_payment_method_id,a_opc_customer_billing, use_different_delivery_address, a_opc_customer_delivery);
	document.location.href = '#opc_payment_method_spacer';
}

function opc_checkout(a_opc_payment_method_detail_data, accept_conditions)
{
	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_order(a_opc_payment_method_detail_data, accept_conditions,a_opc_customer_billing, use_different_delivery_address, a_opc_customer_delivery);
}

function opc_showDeliveryAddressTable(checked)
{
	showLoadingScreen();
	
	sc_hideElement('opc_payment_method_detail'); // Reset Payment method
	xajax_opc_change_use_different_delivery_address(checked);
	
	if (checked)
		sc_showElement('opc_delivery_address_row');
	else
		sc_hideElement('opc_delivery_address_row')
}
