/*
 * Scripts for registration section
 * GH - 2007/06/27
 * 
 */

/*
 * registration/shopping/iBillingForm.cfm methods
 */
function validateBillingForm() {
	var theForm = getForm('billingForm');
	if (!theForm) return false;
	
	if (theForm.vEmail && !checkStrField(theForm.vEmail,'E-mail Address')) return false;
	if (theForm.vRepeatEmail && !checkStrField(theForm.vRepeatEmail,'Repeat E-mail')) return false;
	if (theForm.vEmail && theForm.vRepeatEmail && theForm.vEmail.value!=theForm.vRepeatEmail.value) {
		alert("Please enter the same E-mail address than Repeat E-mail.");
	 	theForm.vEmail.focus();
	 	return false;
	}
	if (!checkStrField(theForm.vFirstName,'First Name')) return false;
	if (!checkStrField(theForm.vLastName,'Last Name')) return false;
	if (!checkStrField(theForm.vAddress1,'Address')) return false;
	if (!checkStrField(theForm.vCity,'City')) return false;
	
	if (getSelectIndex('billingForm','cStateCode')==0) {
		 alert("Please select a State/Province.");
	 	theForm.cStateCode.focus();
	 	return false;
	}
	
	if (!checkStrField(theForm.vZipCode,'Zip Code')) return false;
	
	if (getSelectIndex('billingForm','iCountryID')==0) {
		 alert("Please select a Country.");
	 	theForm.iCountryID.focus();
	 	return false;
	}
	
	if (!checkStrField(theForm.vTel,'Telephone')) return false;
	
	theForm.bJavaScript.value="1";
	
	return true;
}

function submitBillingForm() {
	var theForm = getForm('billingForm');
	if (!theForm) return;
	if (validateBillingForm()) theForm.submit();
}


/*
 * registration/shopping/iShippingForm.cfm methods
 */
function validateShippingForm() {
	var theForm = getForm('shippingForm');
	if (!theForm) return false;
	
	if (!checkStrField(theForm.vShippingFirstName,'First Name')) return false;
	if (!checkStrField(theForm.vShippingLastName,'Last Name')) return false;
	if (!checkStrField(theForm.vShippingAddress1,'Address')) return false;
	if (!checkStrField(theForm.vShippingCity,'City')) return false;
	
	if (getSelectIndex('shippingForm','cShippingStateCode')==0) {
		 alert("Please select a State/Province.");
	 	theForm.cShippingStateCode.focus();
	 	return false;
	}
	
	if (!checkStrField(theForm.vShippingZipCode,'Zip Code')) return false;
	
	if (getSelectIndex('shippingForm','iShippingCountryID')==0) {
		 alert("Please select a Country.");
	 	theForm.iShippingCountryID.focus();
	 	return false;
	}
	
	theForm.bJavaScript.value="1";
	
	return true;
}

function submitShippingForm() {
	var theForm = getForm('shippingForm');
	if (!theForm) return;
	if (validateShippingForm()) theForm.submit();
}


/*
 * registration/shopping/iCreditCardForm.cfm methods
 */
function validateCreditCardForm() {
	var theForm = getForm('creditCardForm');
	if (!theForm) return false;
	
	if (!checkStrField(theForm.vCardName,'Name on Credit Card')) return false;
	if (!checkStrField(theForm.vCardNumber,'Card Number')) return false;
	
	theForm.bJavaScript.value="1";
	
	return true;
}

function submitCreditCardForm() {
	var theForm = getForm('creditCardForm');
	if (!theForm) return;
	if (validateCreditCardForm()) theForm.submit();
}



