// JavaScript Document
function mygate(PostTest) { 	

	if (PostTest.txtRecipient.value == '') {
		alert("Please enter your Full Name");
		PostTest.txtRecipient.focus();
		return false;
	}

	if (PostTest.txtShippingAddress1.value == '') {
		alert("Please enter your Street Address");
		PostTest.txtShippingAddress1.focus();
		return false;
	}	
	

	if (PostTest.txtShippingAddress2.value == '') {
		alert("Please enter your Area");
		PostTest.txtShippingAddress2.focus();
		return false;
	}


	if (PostTest.txtShippingAddress3.value == '') {
		alert("Please enter your Town");
		PostTest.txtShippingAddress3.focus();
		return false;
	}

	if (PostTest.txtShippingAddress4.value == '') {
		alert("Please enter your P.O Box");
		PostTest.txtShippingAddress4.focus();
		return false;
	}

	if (PostTest.txtShippingAddress5.value == '') {
		alert("Please enter your Country");
		PostTest.txtShippingAddress5.focus();
		return false;
	}	
	return true;

}


// checks for valid telephone characters

function validNum(telno) 
{

	var pattern = "0123456789+-)(. ";
	var i = 0;

	do 
	{
		var pos = 0;
		for ( var j = 0 ; j < pattern.length ; j++ )
			if ( telno.charAt(i) == pattern.charAt(j) )
				pos = 1;
		i++;
	}

	while ( pos == 1 && i < telno.length )

	if ( pos == 0 ) return false;
	return true;

}



// check email address pattern
function validEmail(addr) 
{

	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	if ( !regex.test(addr) ) 
	{
		return false;
	}
	return true;
}

	function doCalc() 
	{
		var total;
		total = 0;
		
		var qty_bottles =  0 ; 
		
		selected = window.document.getElementById("txtShippingAddress2").selectedIndex;
		
		if(selected == 0)
		{
		total += 0;
		}
		else
		{
		 qty_bottles =   window.document.getElementById("total_qty_hidden_ai").innerHTML;
		 amount_of_cases =  qty_bottles/6;
		 switch(amount_of_cases)
		{
			case 0:
				total += 0;
			break;
			case 1:
				total += 110;
			break;
			case 2:
				total += 160;
			break;
			case 3:
				total += 210;
			break;
			case 4:
				total += 240;
			break;
			case 5:
				total += 260;
			break;
			case 6:
				total += 0;
			break;
			case 7:
				total += 0;
			break;
			case 8:
				total += 0;
			break;	
			default:
			total += 0;
		}
		 
		 
		}
	/*	switch(selected)
		{
			case 0:
			default:
				total += 0;
			break;
			case 1:
				total += 110;
			break;
			case 2:
				total += 160;
			break;
			case 3:
				total += 210;
			break;
			case 4:
				total += 240;
			break;
			case 5:
				total += 260;
			break;
			case 6:
				total += 0;
			break;
			case 7:
				total += 0;
			break;
			case 8:
				total += 0;
			break;																					
		}
		
*/
		window.document.getElementById("Shipping_Amount_Lite").value = total + '00';
		window.document.getElementById("Shipping_Lite_Order_Amount").value = total + '00';
		window.document.getElementById("shipping_fee").innerHTML = '';
		window.document.getElementById("shipping_fee").innerHTML = ''+total+'';
		
	}

