function disappearInvoiceType()
{
	$('invoiceTypeDiv').style.display = 'none';
}

function appearInvoiceType()
{
	$('invoiceTypeDiv').appear();
}

function verifyCheckoutForm()
{
	new Ajax.Request
	(
		'/checkout/verification/ajax/true' ,
		{
			method: 'post',
			//parameters: 'customers_gender=' + $F('customers_gender') + '&customers_firstname=' + $F('customers_firstname') + '&customers_lastname=' + $F('customers_lastname') + '&customers_email_address=' + $F('customers_email_address') + '&customers_telephone=' + $F('customers_telephone') + '&customers_fax=' + $F('customers_fax') + '&anul=' + $F('anul') + '&luna=' + $F('luna') + '&ziua=' + $F('ziua'),
			parameters: Form.serialize($("checkoutForm")),
			onCreate: fullScreenLoading,
			onSuccess: verifyCheckoutFormSuccess
		}
	);

	
}

function verifyCheckoutFormSuccess(Response)
{	
	eval('Response = ' + Response.responseText);
	
	if(! Response['success']) {
	    endFullScreenLoading();
		displayErrorDiv(Response['message']);
	} else if(Response['epaymentRedirect']){
	    var epaymentFormContainer = document.createElement('div');
	    epaymentFormContainer.innerHTML = Response['epaymentRedirect'];
	    document.body.appendChild(epaymentFormContainer);
	    $('epaymentHiddenForm').submit();
	} else {
        window.location = '/checkout/success';
	}
}

function getShippingOptions(cityId, localitateId)
{
	new Ajax.Request
	(
		'/shipping/index/ajax/true/cityId/' + cityId + '/localitateId/' +  localitateId,
		{
			method: 'get',
//			onLoading: fullScreenLoading,
			onSuccess: getShippingOptionsSuccess
		}
	);
}

function getShippingOptionsSuccess(transport)
{
    endFullScreenLoading();
	$('paymentMethodsAjaxDiv').innerHTML = transport.responseText;
}


function selectShipping(option)
{	
	new Ajax.Request
	(
		'/shipping/select/ajax/true/option/' + option,
		{
			method: 'get',
			onCreate: fullScreenLoading,
			onSuccess: function(transport) { updateTotal(); endFullScreenLoading(); }
		}
	);
}
