function checkOrderForm()
{
	var name = document.getElementById('name').value;
	var email = document.getElementById('email').value;
	var projectname = document.getElementById('projectname').value;
	var pages = document.getElementById('pages').value;
	var captchacode = document.getElementById('captchacode').value;
	var digits = /^([0-9])+$/;
	var emailformat = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if (name.length == 0)
	{
		alert('Please enter your name!');
		return false;
	}
	if (!emailformat.test(email))
	{
		alert('Enter a valid email address!');
		return false;
	}
	if (projectname.length == 0)
	{
		alert('Please enter project name!');
		return false;
	}
	if (!digits.test(pages))
	{
		alert('Enter a valid number of pages!');
		return false;
	}
	else if (pages < 1 || pages > 99)
	{
		alert('Enter a valid number of pages!');
		return false;
	}
	if (captchacode.length == 0)
	{
		alert('Please enter picture code!');
		return false;
	}

	return true;
}

function calcOrderForm()
{
	var turnaround1 = document.getElementById('turnaround1');
	var turnaround2 = document.getElementById('turnaround2');
	var turnaround3 = document.getElementById('turnaround3');
	var option1 = document.getElementById('option1');
	var option2 = document.getElementById('option2');
	var option3 = document.getElementById('option3');
	var option4 = document.getElementById('option4');
	var option5 = document.getElementById('option5');
	var option6 = document.getElementById('option6');
	var option7 = document.getElementById('option7');
	var pages = document.getElementById("pages").value;
	var cost;
	var days;
	var turnaround_text;

	if (pages > 0)
	{
		if (turnaround1.checked)
		{
			cost = 100 + (pages-1)*100/2;
			days = pages - 1;
			if (pages == 1) turnaround_text = "12 hours or less";
			else if (pages == 2) turnaround_text = "24 hours or less";
			else turnaround_text = days + " days or less";
		}
		else
		{
			cost = 45 + (pages-1)*45/2;
			if (pages == 1) turnaround_text = "24 hours or less";
			else turnaround_text = pages + " days or less";
		}

		if (option1.checked) cost = cost + 19;
		if (option2.checked) cost = cost + 19;
		if (option3.checked) cost = cost + 29;
		if (option4.checked) cost = cost + 39;
		if (option5.checked) cost = cost + 5*pages;
		if (option6.checked) cost = cost + 29;
		if (option7.checked) cost = cost + 39;
		document.getElementById("pricebox").innerHTML = "<p><span class='left'>Price:</span> <span class='red'>$"+cost+"</span> </p><p><span class='left'>Turnaround:</span> <span class='green'>"+turnaround_text+"</span></p>";
		document.getElementById("totalprice").value = cost;
		document.getElementById("totalturnaround").value = turnaround_text;
    }
}
