//check customer information form
function checkCustomerForm()
{
    with (window.document.frmCustomer) {
		if (isEmpty(txtFName, 'Please Enter your First Name')) {
			return;
		} else if (isEmpty(txtLName, 'Please Enter your Last Name')) {
			return;
		} else if (isEmpty(txtAddress, 'Please Enter Address Details')){
			return;
		} else if (isEmpty(txtCity, 'Please Enter the City')){
			return;
		} else if (isEmpty(txtPhone, 'Please Enter your Telephone Number')){
			return;
		} else {
			submit();
		}
	}
}

/*
Strip whitespace from the beginning and end of a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Make sure that textBox only contain number
*/
function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
}

/*
	Check if a form element is empty.
	If it is display an alert box and focus
	on the element
*/
function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '' || formElement.value < 1) {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

/*
	Set one value in combo box as the selected value
*/
function setSelect(listElement, listValue)
{
	for (i=0; i < listElement.options.length; i++) {
		if (listElement.options[i].value == listValue)	{
			listElement.selectedIndex = i;
		}
	}	
}

function addCart(pdId, catId)
{
	pdQty = eval("window.document.frmAddCart.txtQty"+pdId+".value");
	pdSize = eval("window.document.frmAddCart.txtSize"+pdId+".value");
	window.location.href = "add.php?pdQty="+pdQty+"&pdId="+pdId+"&pdSize="+pdSize+"&catId="+catId;
}
