	
	function validateBuy(product_id, other_forms_string)
	{
		if (other_forms_string.length>0)
		{
			other_forms = other_forms_string.split(",");
			
			for(i=0; i<other_forms.length; i++)
			{
				if (document.getElementById(other_forms[i]).value == "")
				{
					alert("Some fields are not correctly filled in!");
					return false;
				}
			}
		}
		
		if (document.getElementById('quantity_'+product_id+'').value == "")
		{
			alert("Some fields are not correctly filled in!");
			return false;
		}
		else
		{
			return true;
		}
	}

	
	function validateCheckout(checkoutform)
	{
		var validated = true;
		
		if (empty(checkoutform.name.value))
		{
			$('name_info').innerHTML = "Fill in your name!";
			validated = false;
		}
		else
			$('name_info').innerHTML = "";
			

		if (empty(checkoutform.full_adress.value))
		{
			$('full_adress_info').innerHTML = "Fill in your adress!";
			validated = false;
		}
		else
			$('full_adress_info').innerHTML = "";


		if (empty(checkoutform.country.value))
		{
			$('country_info').innerHTML = "Fill in which country you live in";
			validated = false;
		}
		else
			$('country_info').innerHTML = "";


		if (empty(checkoutform.email.value))
		{
			$('email_info').innerHTML = "Fill in your email-adress";
			validated = false;
		}
		else
		{
			if (!checkoutform.email.value.isValidEmail())
			{
				$('email_info').innerHTML = "Enter a valid email-adress!";
				validated = false;
			}
			else
				$('email_info').innerHTML = "";
		}
	
		return validated;
	}
	
	String.prototype.isValidEmail = function(){
		return !!this.match(/^([a-zA-Z0-9\_\-]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9\_-]{1})@([a-zA-Z0-9]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9]{1})\.([a-zA-Z]{2,4})$/)
	}
	
	function empty(text)
	{
		if (text == 0)
			return true;
		else
			return false;
	}
	
	
	function changeQty(object)
	{
		if (object.form.quantity.value.length > 0)
		{ 
			if (object.form.quantity.value == '0')
			{
				if (confirm('Are you sure you want to remove this item?'))
					return true;
				else
					return false;
			}
			else
				return true;
			
				object.form.submit(); 
		}
		else
		{
			return false;
		}
	}