function Chronoshop_Order_Form_Class()
{
	this.onAddProduct = function()
	{
		amount = document.getElementById('amount');

		if (amount.value == "")
		{
			alert("Zadejte prosím počet kusů produktu!");
			amount.focus();
			return false;
		}

		if (!(this.reInteger.test(amount.value) && amount.value > 0))
		{
			alert('Neplatná hodnota v poli "Počet kusů"!');
			amount.focus();
			return false;
		}

		return true;
	}

	this.submitForm = function()
	{
		orderform = document.getElementById('objednavka');
		orderform.submit();
	}

	this.onDeliverySelect = function(radio)
	{
		this.submitForm();
	}

	this.onPaymentSelect = function(radio)
	{
		this.submitForm();
	}

	this.onRemove = function(cpid)
	{
		cpf = document.getElementById('rcpid');
		cpf.value = cpid;
		this.submitForm();
		return false;
	}

	this.onSubmit = function()
	{
		pt = document.getElementById('chofpt_pay');
		ppemail = document.getElementById('chof_paypalemail');

		if (pt.checked)
		{
			if (ppemail.value == '')
			{
				alert('Vyplňte prosím položku "Email Paypal účtu"!');
				ppemail.focus();
				return false;
			}

			if (!this.reEmail.test(ppemail.value))
			{
				alert('Emailová adresa Paypal účtu není korektní!');
				ppemail.focus();
				return false;
			}
		}

		return true;
	}

	this.doProfileEdit = function()
	{
		eb = document.getElementById('lfedit');
		eb.click();
	}

	this.doLoginFocus = function()
	{
		un = document.getElementById('lfuser');
		un.focus();
	}

	this.reEmail = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/
	this.reInteger = /^\d+$/
}

var Chronoshop_Order_Form = new Chronoshop_Order_Form_Class();
