<!--

function wpop(winopen) {
var winw = 300;
var winh = 350;
var winl = (screen.width - winw) / 2;
var wint = (screen.height - winh) / 2;
wintarget = window.open(winopen,"terms","top=" + wint + ",left=" + winl + ",status=no,resizable=no,height=" + winh + ",width=" + winw + ",toolbar=no,menubar=no,location=no,scrollbars=yes");
if (parseInt(navigator.appVersion) >= 4) { wintarget.window.focus(); }
}

function validateQTY()
{
	var num = "0123456789";
	var form = document.forms["basketfrm"];
	var max = form.itemcount.value;
	var txt;
	for (i = 1; i<=max; i++){
		txt = eval("form.quantity_" + i);
		if (checkparameters(txt.value,num) == false){
			alert("The value entered as the quantity must be numeric (0-9).");
			txt.focus();
			return false;
		}
	}
	return true;
}

function chk(frmElement,errMsg) {
	if (trim(frmElement.value)=="") {
	 alert (errMsg);
	 frmElement.focus;
	 return false;
	}
	else return true;
}

function trim(str) {
	if (str=="") return ""
	var str0=new Array(' ','\t','\n').toString()
	if (str0.indexOf(str.charAt(0))!=-1) return trim(str.slice(1))
	if (str0.indexOf(str.charAt(str.length-1))==-1) return str
	return trim(str.slice(0,str.length-1))
}

function isemail(str) {
	var pt1,pt2,address,re
	address=str.split("@");
	if (address.length==2) {
		pt1 = address[0];
		pt2 = address[1];
  		if (pt2.split(".").length>1) {
			if (pt1.split(" ").length==1 && pt2.split(" ").length==1) {
				return true;
			}
			return false;
		}
		return false;
	}
	return false;
}

function checkparameters(str,matchstr) {
	var cnt;
	for (cnt = 1; cnt <= str.length; cnt++){
		if (matchstr.split(str.charAt(cnt-1)).length==1){
			return false;
		}
	}
	return true;
}

function validate() {
	var telnum = "0123456789()- +";
	var cardnum = "0123456789- ";
	var postcode = "0123456789ABCDEFGHIJKLMONPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
	var dt = new Date();
	var dcompare_y = dt.getFullYear();
	var dcompare_m = dt.getMonth()+1;

// invoice details	
	if (trim(d('first_name').value) == "") {
		alert("Please enter your first name or intial.");
		d('first_name').focus();
		return false;
	}
	if (trim(d('last_name').value) == "") {
		alert("Please enter your last name.");
		d('last_name').focus();
		return false;
	}
	if (trim(d('password').value).length < 6) {
		alert("Please enter a password (min 6 chars).");
		d('password').focus();
		return false;
	}
	if (trim(d('password').value) != trim(d('password2').value)) {
		alert("The passwords are not the same.");
		d('password2').value = '';
		d('password').focus();
		return false;
	}
	if (trim(d('email_address').value) == "") {
		alert("Please enter your email address.");
		d('email_address').focus();
		return false;
	}
	if (isemail(d('email_address').value) == false) {
		alert("Your email address appears to be entered incorrectly. Please re-check.");
		d('email_address').focus();
		return false;
	}
	if (trim(d('email_address').value).indexOf('@mail.ru') > 0){
		alert("Your email address appears to be invalid. Please re-enter.");
		return false;
	}
	if (d('abn').value.length > 0 && checkparameters(d('abn').value,cardnum) == "") {
		alert("Your ABN appears to contain invalid characters.");
		d('abn').focus();
		return false;
	}
	if (trim(d('telephone').value) == "") {
		alert("Please enter your telephone number.");
		d('telephone').focus();
		return false;
	}
	if (checkparameters(d('telephone').value,telnum) == "") {
		alert("The phone number field accepts digits 0-9, -, (, ) and space characters.");
		d('telephone').focus();
		return false;
	}
	if (checkparameters(d('alt_telephone').value,telnum) == "") {
		alert("The mobile number field accepts digits 0-9, -, (, ) and space characters.");
		d('alt_telephone').focus();
		return false;
	}
	if (d('agreement').checked == false){
		alert("Please agree to the terms and conditions of registration by checking the checkbox. Thank you.");	
		return false;
	}
	alert("We are about to process your registration. This process may take a few moments. Please do not refresh the page or click 'back' on your browser during this time. Thank you.")
	return true;
}

function domainvalidate() {
	var keyword = "0123456789ABCDEFGHIJKLMONPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-";

	if (trim(d('prefname').value) == "") {
		alert("Please enter your subdomain keyword.");
		d('prefname').focus();
		return false;
	}
	if (trim(d('prefname').value).length > 0 && checkparameters(trim(d('prefname').value),keyword) == "") {
		alert("Your keyword appears to contain invalid characters.");
		d('prefname').focus();
		return false;
	}
	if (trim(d('prefname').value).length < 3) {
		alert("Domain keyword must be a minimum 3 characters.");
		d('prefname').focus();
		return false;
	}
	if (trim(d('title').value).length > 100) {
		alert("Page title is maximum 100 characters.");
		d('title').focus();
		return false;
	}
	var conf = confirm("We are about to process your submission. This process may take a few moments. Please do not refresh the page or click 'back' on your browser during this time. Thank you.")
	return conf;
}
//-->