/* 
	Comments
*/

/*
	Pop-up window with variable width / height, centered on screen
	Usage:
		<a href="link" onclick="popup('photo',widthpx,heightpx)" target="photo" title="title"><img src="image" alt="text" /></a>
*/
var win = null;
function popup(n,w,h){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,toolbar=no,resizable=no';
	win = window.open("",n,settings);
}

function checkCheckout() {
	var themessage = "Please note:\nYou are required to complete the following fields: \n\n";
	if (document.checkout.firstname.value=="")
		{
			themessage = themessage + " - First Name\n";
		}
	if (document.checkout.surname.value=="")
		{
			themessage = themessage + " - Surname\n";
		}
	if (document.checkout.email.value=="")
		{
			themessage = themessage + " - Email\n";
		}
	if (document.checkout.address1.value=="")
		{
			themessage = themessage + " - Address\n";
		}
	if (document.checkout.suburb.value=="")
		{
			themessage = themessage + " - Suburb\n";
		}
	if (document.checkout.state.value=="")
		{
			themessage = themessage + " - State\n";
		}
	if (document.checkout.postcode.value=="")
		{
			themessage = themessage + " - Postcode\n";
		}
	if (document.checkout.phone.value=="")
		{
			themessage = themessage + " - Contact phone number\n";
		}
	var stringemail = document.checkout.email.value;
		
	if (stringemail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
		{
			themessage = themessage + " - A Valid Email Address\n";
		}


	// Display alert message or continue if required fields are filled out
	if (themessage == "Please note:\nYou are required to complete the following fields: \n\n")
		{
			document.checkout.submit();
		}
	else
		{
			alert(themessage);
			return false;
		}
}

function checkPayment() {

for (var i=0; i < document.payment.method.length; i++)
{
	if (document.payment.method[i].checked)
	{
		var payment_method = document.payment.method[i].value;
	}
}
	var themessage = "Please note:\nYou are required to complete the following fields: \n\n";
	if (payment_method == "Post")
		{
			document.payment.submit();
		}
	else if (document.payment.cardName.value=="")
		{
			themessage = themessage + " - Name on Credit Card\n";
		}
	else if ((document.payment.cardNumber1.value=="") || (document.payment.cardNumber2.value=="") || (document.payment.cardNumber3.value=="") || (document.payment.cardNumber4.value=="") || (document.payment.cardExpiry.value==""))
		{
			themessage = themessage + " - Full Credit Card Details\n";
		}

	// Display alert message or continue if required fields are filled out
	if (themessage == "Please note:\nYou are required to complete the following fields: \n\n")
		{
			document.payment.submit();
		}
	else
		{
			alert(themessage);
			return false;
		}
}
