function setPaymentInfo(isChecked)
{
	with (window.document.frmCheckout) {
		if (isChecked) {
			
			txtPaymentFirstName.value  = txtShippingFirstName.value;
			txtPaymentLastName.value   = txtShippingLastName.value;
			txtPaymentAddress1.value   = txtShippingAddress1.value;
			txtPaymentAddress2.value   = txtShippingAddress2.value;
			txtPaymentPhone.value      = txtShippingPhone.value;
			txtPaymentState.value      = txtShippingState.value;			
			txtPaymentCity.value       = txtShippingCity.value;
			txtPaymentPostalCode.value = txtShippingPostalCode.value;
			
			txtPaymentFirstName.readOnly  = true;
			txtPaymentLastName.readOnly   = true;
			txtPaymentAddress1.readOnly   = true;
			txtPaymentAddress2.readOnly   = true;
			txtPaymentPhone.readOnly      = true;
			txtPaymentState.readOnly      = true;			
			txtPaymentCity.readOnly       = true;
			txtPaymentPostalCode.readOnly = true;			
		} else {
			txtPaymentFirstName.readOnly  = false;
			txtPaymentLastName.readOnly   = false;
			txtPaymentAddress1.readOnly   = false;
			txtPaymentAddress2.readOnly   = false;
			txtPaymentPhone.readOnly      = false;
			txtPaymentState.readOnly      = false;			
			txtPaymentCity.readOnly       = false;
			txtPaymentPostalCode.readOnly = false;			
		}
	}
}

function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}
function isEmptyNoMsg(formElement) {
	formElement.style.background = '#ffffff' ;
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		 formElement.style.background = '#F4BAA8';
		_isEmpty = true;
	}
	
	return _isEmpty;
}


function checkShippingAndPaymentInfo()
{

  var errMsg = '';
	with (window.document.frmCheckout) {
		
		if( isEmptyNoMsg(txtPaymentFirstName) ){errMsg = "Error";}		
		if( isEmptyNoMsg(txtPaymentLastName) ){errMsg = "Error";}
		if( isEmptyNoMsg(txtPaymentAddress1) ){errMsg = "Error";}
		if( isEmptyNoMsg(txtPaymentCity) ){errMsg = "Error";}
		if( isEmptyNoMsg(txtPaymentState) ){errMsg = "Error";}
		if( isEmptyNoMsg(txtPaymentPostalCode)){errMsg = "Error";}
		if( isEmptyNoMsg(txtPaymentPhone) ){errMsg = "Error";}
		if( isEmptyNoMsg(txtShippingEmail)){errMsg = "Error";}

	}
	
	
	 if(errMsg == "Error"){
	 	  alert('You must fill in all of the highlighted fields before proceeding!');
	 	  return false;
	  }
	 
	 return true;
}


function checkShippingAndPaymentInfoOLD()
{

/*
No longer required

                            } else if (isEmpty(txtShippingState, 'Please enter a shipping address state')) {
			return false;
		} else if (isEmpty(txtShippingCity, 'Please enter a  shipping address city')) {
			return false;

		} else if (isEmpty(txtPaymentState, 'Please enter a payment address state')) {
			return false;
		} else if (isEmpty(txtPaymentCity, 'Please enter a payment address city')) {
			return false;
*/
	with (window.document.frmCheckout) {
		if (isEmpty(txtShippingFirstName, 'Please enter the shipping first name')) {
			return false;
		} else if (isEmpty(txtShippingLastName, 'Please enter the shipping last name')) {
			return false;
		} else if (isEmpty(txtShippingAddress1, 'Please enter the shipping address')) {
			return false;
		} else if (isEmpty(txtShippingPostalCode, 'Please enter the shipping address postal/zip code')) {
			return false;
		} else if (isEmptyNoMsg(txtShippingPhone) && isEmptyNoMsg(txtShippingEmail)) {
                                          alert('You must enter either a phone number and/or an email address');
			return false;		
		} else if (isEmpty(txtPaymentFirstName, 'Please enter the payment first name')) {
			return false;
		} else if (isEmpty(txtPaymentLastName, 'Please enter the payment last name')) {
			return false;
		} else if (isEmpty(txtPaymentAddress1, 'Please enter the payment address')) {
			return false;
		} else if (isEmpty(txtPaymentPostalCode, 'Please enter the payment address postal/zip code')) {
			return false;
		} else if (isEmpty(txtPaymentPhone, 'Please enter the payment phone number')) {
			return false;
		} else {
			return true;
		}
	}
}
