function print_popup() {
print_win = window.open('print.html','orderform','width=700,height=550,top=100,left=100,status=yes,scrollbars=yes,resizable=yes');
}

// Verifies that the supplied credit card number is comprised of 16 digits only
// By Mark Brydon, Squiz.net
function validateCCNumber() {
	var f = document.credit_details;
	var success = false;
		
	var s = new String(f.cardNumber.value);
	if (s.length == 16) {
		var i = parseInt(s);
		if ((i >= 1000000000000000) && (s == parseInt(s))) {
			success = true;
		}
	}
														
	if (!success) {
		alert('Credit Card Number must not contain spaces and must be 16 digits in length.');
		f.cardNumber.focus();
	}
	
	return success;
}
																				
function check_credit_form() {
	f = document.credit_details;
	var success = false;

	success = validateCCNumber();
	if (success) {
		if( f.expiryMonth.options.selectedIndex == 0) {
			alert('Please select expiry month');
			f.expiryMonth.focus();
			success = false;
		} else 	
		if( f.expiryYear.options.selectedIndex == 0) {
			alert('Please select expiry year');
			f.expiryYear.focus();
			success = false;
		}
	}
	
	return success;
}

function check_form() {
	f = document.details;
	if (f.fname.value <= 0) {
		alert('Please enter your first name');
		f.fname.focus();
		return false;
	}
	if (f.sname.value <= 0) {
		alert('Please enter your surname');
		f.sname.focus();
		return false;
	}
	if (f.stnumber.value <= 0) {
		alert('Please enter your street number');
		f.stnumber.focus();
		return false;
	}
	if (f.stname.value <= 0) {
		alert('Please enter your street name');
		f.stname.focus();
		return false;
	}
	if (f.suburb.value <= 0) {
		alert('Please enter your suburb');
		f.suburb.focus();
		return false;
	}
	if (f.state.value <= 0) {
		alert('Please enter your state');
		f.state.focus();
		return false;
	}
	if (f.postcode.value <= 0) {
		alert('Please enter your postcode');
		f.postcode.focus();
		return false;
	}
	if( f.country.options.selectedIndex == 0) {
		alert('Please select your country');
		f.country.focus();
		return false;
	}
	if (f.email.value <= 0) {
		alert('Please enter your email');
		f.email.focus();
		return false;
	}
	if (f.zoobabiesqty.value == '' && f.creativelittleqty.value == '' && f.classiclacecollectionqty.value == '' && f.endearingembroiderydesignqty.value=='' && f.floralgardendsqty.value=='' && f.embroideryfavouritesqty.value=='' && f.swanspecialtylaceqty.value=='' && f.sparklingchristmasqty.value=='' && f.designerlaceqty.value == '' && f.embroideryinspirationsqty.value == '' && f.woodlandtreasuresqty.value == '' && f.homesgardensqty.value == '' && f.justlaceqty.value == '' && f.fairytreasuresqty.value == '' && f.goldenqty.value == '' && f.teddybearqty.value == '' && f.everlastingqty.value == '' && f.floralqty.value == '' && f.romanticeraqty.value == '') {
		alert('Please ensure you have entered a CD quantity');
		f.woodlandtreasuresqty.focus();
		return false;
	}

	//if (f.homesgardensqty <= 0 && f.justlaceqty.value <= 0 && f.fairytreasuresqty.value <= 0 && f.goldenqty.value <= 0 && f.teddybearqty.value <= 0 && f.everlastingqty.value <= 0) {
	//	alert('Please ensure you have entered a CD quantity');
	//	f.homesgardensqty.focus();
	//	return false;
	//}
	return true;
}
