		function form_sales_hosting_domain_error(frm) {
			if (!Validate_text(frm.Ecom_Domain_Name, "Please enter the domain name"))
				return false;
			return true;
		}

		function form_sales_account(frm) {
			if (frm.button_processing_login.value == "1"){
				alert('Currently processing login, please wait one moment');
				return false;
			}
			if (frm.button_client_new.value == "1"){
				if (!Validate_text(frm.Ecom_Acc_Online_Email, "Please enter your email address."))
					return false;
				// login details
				if (frm.Ecom_Acc_Password.type == "password"){
					if (!Validate_password(frm.Ecom_Acc_Password, frm.button_password_verify, "Please specify your Account Manager password."))
						return false;
				}
				// client details
				if (!Validate_text(frm.Ecom_Acc_Security_Answer, "Please enter the security answer."))
					return false;
				if (!Validate_text(frm.Ecom_Acc_Postal_Company, "Please enter the organisation name."))
					return false;
				if (!Validate_text(frm.Ecom_Acc_Postal_Name_First, "Please enter the first name."))
					return false;
				if (!Validate_text(frm.Ecom_Acc_Postal_Name_Last, "Please enter the last name."))
					return false;
				if (!Validate_phone(frm.Ecom_Acc_Telecom_Phone_Number, "Please enter the phone number."))
					return false;
				if (!Validate_text(frm.Ecom_Acc_Postal_Street_Line1, "Please enter the street address."))
					return false;
				if (!Validate_text(frm.Ecom_Acc_Postal_City, "Please enter the suburb."))
					return false;
				if (!Validate_text(frm.Ecom_Acc_Postal_StateProv, "Please enter the state."))
					return false;
				if (!Validate_text(frm.Ecom_Acc_Postal_PostalCode, "Please enter the postcode."))
					return false;
			}
		}


		// 'same details as account holder'
		function domainRegistrantDetails(frm, frmCaller){
			//alert(frm.fowner_same_as_technical.type);

			if (!frm.button_use_account_holder.checked && frmCaller == "dropdown")
				return 0;

			for (j=0; j<frm.length;j++){ // loop through the elements in the form

				if (frm.button_use_account_holder.checked && frm.elements[j].name.indexOf("Ecom_ShipTo") >= 0){ // check to see that its tech details
					iname = frm.elements[j].name;
					ioppositename = iname.replace(/ShipTo/i, "BillTo");

					iobj = eval("frm." + ioppositename);
					if (iobj != undefined){
						if (frm.elements[j].type == "text"){
							frm.elements[j].value = iobj.value;
							grayOutField(frm.elements[j]);
						}
						else if (frm.elements[j].type == "select-one"){
							if (iobj.type == "hidden") // in case its transferring from a hidden field
								iVal = iobj.value;
							else
								iVal = iobj.options[iobj.selectedIndex].value;

							for (i=0; i<frm.elements[j].length; i++){
								if (frm.elements[j].options[i].value == iVal)
									frm.elements[j].selectedIndex = i;
							}
							// grayOutField(frm.elements[j]);
						}
					}
				}

				else if (!frm.button_use_account_holder.checked && frm.elements[j].type == "text"  && frm.elements[j].name.indexOf("Ecom_ShipTo_") >= 0){ // check that its not hidden
					normaliseField(frm.elements[j]);
				}

			}
			/*
			if (!frm.button_use_account_holder.checked){
				// frm.fowner_address_type[0].checked = true;
				if (frm.Ecom_BillTo_Postal_Company.type == "text")
					frm.Ecom_BillTo_Postal_Company.focus();
			}
			*/
		}
	// content.php?page=sales/hosting_eligibility_details
		function form_sales_hosting_eligibility_details(frm) {
			if (frm.Ecom_Domain_Name_Suffix.value == "id.au")
				return true;
			// otherwise
			if (!Validate_text(frm.Ecom_Domain_Eligibility_Legal_Name, "Please enter the registrant legal name."))
				return false;


			// ABN
			if (frm.Ecom_Domain_Eligibility_Registrant_Number_Id.options[frm.Ecom_Domain_Eligibility_Registrant_Number_Id.selectedIndex].value == "ABN"){
				frm.Ecom_Domain_Eligibility_Registrant_Number.value = frm.Ecom_Domain_Eligibility_Registrant_Number.value.replace(/\D/g, "");
				if (frm.Ecom_Domain_Eligibility_Registrant_Number.value.length != 11){
					alert("Incorrect ABN length.\nMust be 11 digits");
					frm.Ecom_Domain_Eligibility_Registrant_Number.focus();
					return false;
				}
				else if (!checkABN(frm.Ecom_Domain_Eligibility_Registrant_Number.value)){
					alert("Invalid ABN\nPlease enter again");
					frm.Ecom_Domain_Eligibility_Registrant_Number.focus();
					return false;
				}
			} // ACN
			else if (frm.Ecom_Domain_Eligibility_Registrant_Number_Id.options[frm.Ecom_Domain_Eligibility_Registrant_Number_Id.selectedIndex].value == "ACN"){
				frm.Ecom_Domain_Eligibility_Registrant_Number.value = frm.Ecom_Domain_Eligibility_Registrant_Number.value.replace(/\D/g, "");
				if (frm.Ecom_Domain_Eligibility_Registrant_Number.value.length != 9){
					alert("Incorrect ACN length.\nMust be 9 digits");
					frm.Ecom_Domain_Eligibility_Registrant_Number.focus();
					return false;
				}
				else if (!checkACN(frm.Ecom_Domain_Eligibility_Registrant_Number.value)){
					alert("Invalid ACN\nPlease enter again");
					frm.Ecom_Domain_Eligibility_Registrant_Number.focus();
					return false;
				}
			}
			else if (frm.Ecom_Domain_Eligibility_Registrant_Number_Id.options[frm.Ecom_Domain_Eligibility_Registrant_Number_Id.selectedIndex].value != "15" && frm.Ecom_Domain_Eligibility_Registrant_Number.value.length < 3){ // if its not 'none of the above'
				alert("Please enter the registrant identification number");
				frm.Ecom_Domain_Eligibility_Registrant_Number.focus();
				return false;
			}

			if (frm.domain_eligibility.value == "1" && frm.Ecom_Domain_Eligibility_Registrant_Number_Id.options[frm.Ecom_Domain_Eligibility_Registrant_Number_Id.selectedIndex].value == "15"){
				if (!Validate_text(frm.Ecom_Domain_Eligibility_Name, "Please enter the business name that makes you eligible for the domain name."))
					return false;
				if (frm.Ecom_Domain_Eligibility_Number_Id.selectedIndex == 0){
					alert("Please choose an eligibility type");
					frm.Ecom_Domain_Eligibility_Number_Id.focus();
					return false;
				}
				if (!Validate_text(frm.Ecom_Domain_Eligibility_Number, "Please enter the eligibility number.\nEg: trademark number or business number"))
					return false;
			}
			return true;
		}

	// content.php?page=sales/hosting_summary
		function form_sales_terms(frm) {
			// check that they have agreed to the terms and conditions
			if (!frm.button_termsandconditions_agree.checked){
				alert("You have to agree to the Ilisys Terms & Conditions to continue!");
				return false;
			}
			return true;
		}

	// content.php?page=sales/hosting_payment
		function form_sales_hosting_payment(frm) {
			if (ival == "creditcard"){ // if credit card payment has been chosen
				if (!Validate_text(frm.Ecom_Payment_Card_Name, "Please enter the name on the card."))
					return false;
				if (!Validate_text(frm.Ecom_Payment_Card_Number, "Please enter the card number."))
					return false;
				if (frm.Ecom_Payment_Card_Number.value.length < 13){
					alert("Please enter the card number.\n(at least 13 digits)");
					return false;
				}
				if (!Validate_text(frm.Ecom_Payment_Card_Expiry, "Please enter the card expiry.\n (mmyy)"))
					return false;
			}
			return true;
		}


// END SALES

function form_domain_password_change(frm) {
	if(frm.fpassword.value.length < 2){
		alert("Please enter the new password");
		frm.fpassword.focus();
		return false;
	}
	if (!Validate_password(frm.fpassword, frm.fpassword_verify, "Please enter the password."))
		return false;
	return true;
}



function form_client_details(frm) {
	if (!Validate_email(frm.Ecom_BillTo_Online_Email, "You didn't provide a valid email address.\nWe'll need it to communicate with you about the status of your orders.\nAlso, when you visit us again, you'll need it to access your account."))
		return false;
	if (frm.Ecom_BillTo_Password.type == "password"){
		if (!Validate_password(frm.Ecom_BillTo_Password, frm.button_password_verify, "Please specify your Account Manager password."))
			return false;
	}
	if (!Validate_text(frm.Ecom_BillTo_Security_Answer, "Please enter the security answer."))
		return false;
	// client details
	if (!Validate_text(frm.Ecom_BillTo_Postal_Company, "Please enter the organisation name."))
		return false;
	if (!Validate_text(frm.Ecom_BillTo_Postal_Name_First, "Please enter the first name."))
		return false;
	if (!Validate_text(frm.Ecom_BillTo_Postal_Name_Last, "Please enter the last name."))
		return false;
	if (!Validate_phone(frm.Ecom_BillTo_Telecom_Phone_Number, "Please enter the phone number."))
		return false;
	if (!Validate_text(frm.Ecom_BillTo_Postal_Street_Line1, "Please enter the street address."))
		return false;
	if (!Validate_text(frm.Ecom_BillTo_Postal_City, "Please enter the suburb."))
		return false;
	if (!Validate_text(frm.Ecom_BillTo_Postal_StateProv, "Please enter the state."))
		return false;
	if (!Validate_text(frm.Ecom_BillTo_Postal_PostalCode, "Please enter the postcode."))
		return false;
	return true;
}

// domain check facility
	function form_domain_check(frm) {
		if (!Validate_text(frm.Ecom_Domain_Name, "Please enter the domain name")){
			//alert("returning false");
			return false;
		}
		// clean the suffix of a cost
			tmpArray = frm.Ecom_Domain_Name_Suffix.options[frm.Ecom_Domain_Name_Suffix.selectedIndex].value.split("|"); // split the value of the selected option
		return true;
	}

// quote tool
	function form_quote_tool(frm) {
		if (frm.Ecom_BillTo_Online_Email.value.length)
			frm.button_quote.value = 1;
		if (parseInt(frm.button_quote.value)){
			if (!Validate_email(frm.Ecom_BillTo_Online_Email, "Please enter a valid email address"))
				return false;
			frm.action = "pcs.php?page=sales/quote";
		} else {
			frm.action = frm.button_ssl_target.value;
		}
		// clean the suffix of a cost
		tmpArray = frm.Ecom_Domain_Name_Suffix.options[frm.Ecom_Domain_Name_Suffix.selectedIndex].value.split("|"); // split the value of the selected option

		// transfer the tabbed options and platform to the main variable name

		intMaxField = 0;
		for (m=0; m<frm.length;m++){
			if (frm.elements[m].name.indexOf("button_Ecom_Order_Option_Array" + frm.button_calc_tab_index.value) != -1){
				arrMatch = frm.elements[m].name.match(/\d+/gi);
				strTmp = new String(arrMatch[1]);
				if (!isNaN(parseInt(arrMatch[1]))){
					frm.elements[m].name = 'Ecom_Order_Option_Array[' + parseInt(arrMatch[1]) + ']';
					if (parseInt(arrMatch[1]) > intMaxField)
						intMaxField = parseInt(arrMatch[1]);
				}
			}
		}

		objPlatform = eval('frm.button_Ecom_Order_Option_Platform' + frm.button_calc_tab_index.value);
		objPlatform.name = 'Ecom_Order_Option_Platform';
		// objPlatform.name = 'Ecom_Order_Option_Array[' + (intMaxField + 1) + ']';

		// alert(objPlatform.name + ' | ' + objPlatform.value);

		/*
		alert(intMaxField + ' ' + frm.Ecom_Order_Option_Array[8]);

		for (m=0; m<frm.length;m++){
			if (frm.elements[m].name.indexOf("Ecom_Order_Option_Array") != -1 && frm.elements[m].name.indexOf("button") == -1)
				alert(frm.elements[m].name);
		}
		*/

		// return false;
		return true;
	}

// ILISYS SALES
	// content.php?page=sales/hosting_payment
		function form_sales_payment(frm) {
			if (frm.fpayment_method != undefined && !frm.fpayment_method.checked){ // means its not 'invoice me'
				if (!Validate_text(frm.Ecom_Payment_Card_Name, "Please enter the name on the card."))
					return false;
				if (!Validate_text(frm.Ecom_Payment_Card_Number, "Please enter the card number."))
					return false;
				fld = frm.Ecom_Payment_Card_Number;
				if (!fld.value.match(/\d{4}X+\d{1,4}/gi)){
					re = /\D/gi;
					frm.Ecom_Payment_Card_Number.value = frm.Ecom_Payment_Card_Number.value.replace(re, "");
					iTempNo = frm.Ecom_Payment_Card_Number.value;
					if (!iTempNo.match(/\d{13,17}/gi)){
			        	alert( "Please, enter the full account number.\n(13-17 digits)");
			        	fld.focus();
						return false;
			   	  	}
				}


				frm.Ecom_Payment_Card_Expiry.value = frm.Ecom_Payment_Card_Expiry_Month[frm.Ecom_Payment_Card_Expiry_Month.selectedIndex].value + frm.Ecom_Payment_Card_Expiry_Year[frm.Ecom_Payment_Card_Expiry_Year.selectedIndex].value;
				// if (!Validate_text(frm.fcc_expiry, "Please enter the card expiry.\n (mmyy)"))
				//	return false;
			}
			return true;
		}

// TOOLKIT
	// make payment
		function form_make_payment(frm){
			if (frm.payment_amount.value == "" || frm.payment_amount.value == "0") {
		    	alert( "Please, enter the payment amount.");
				frm.payment_amount.focus();
				return false;
		   	}

			if (!form_cc_details(frm))
				return false;

			if (frm.payment_amount.value == "0.00") {
		    	alert( "Please, select the invoice/s you wish to pay for");
				frm.payment_amount.focus();
				return false;
		   	}
		}
	// update cc profile
		function form_cc_details(frm){
			if (!Validate_text(frm.card_name, "Please enter the name on the card."))
				return false;
			// if (!Validate_text(frm.Ecom_Payment_Card_Number, "Please enter the card number."))
			fld = frm.card_number;
			re = / /gi;
			iTempNo = frm.card_number.value.replace(re, "");
			if ((!iTempNo.match(/\d+x+\d+/gi)  &&  !iTempNo.match(/\d{15,18}/gi) ) || iTempNo.length > 18 || iTempNo.length < 15){
	        	alert( "Please, enter the full account number.\n(15-18 digits)");
	        	fld.focus();
				return false;
	   	  	}

			frm.card_expiry.value = frm.expiry_month.value + frm.expiry_year.value;
			return true;
		}
	// Camtech Virtual Terminal
		function form_virtual_terminal(frm){
			$intAmount = frm.payment_amount.value;
			if (frm.payment_amount.value == "" || frm.payment_amount.value == "0" || !$intAmount.match(/^\d+\.\d{2,2}$/)) {
		    	alert("Please, enter the payment amount.\n\n Note: Payment amounts must be formatted with dollars and cents\n eg. 19.95");
				frm.payment_amount.focus();
				return false;
		   	}
			if (!Validate_text(frm.card_name, "Please enter the name on the card."))
				return false;
			iTempNo = frm.card_number.value.replace(/\s/gi, "");
			if (!iTempNo.match(/\d{15,18}/gi) || frm.card_number.value.length > 18){
	        	alert( "Please, enter the full credit card number.\n(15-18 digits)");
	        	frm.card_number.focus(); return false;
	   	  	}
			if (frm.order_number.value == "") {
				if (confirm("You have not entered an order number, would you like to the system to generate one or enter it manually")) {
					generateOrderNum();
				} else {
					return false;
				}
			}
			return true;
		}
	// Camtech Virtual Terminal Reports
		function form_report_date_range(frm) {
			if (!Validate_date(frm.name,"fdate_start", "Please select a valid start date."))
				return false;
			if (!Validate_date(frm.name,"fdate_end", "Please select a valid end date."))
				return false;
			return true;
		}
// MISC
	// used by the make payment screens to clear the credit card number if they click on a prefilled number
	function onClickNumber (fld){
		if (fld.value.match(/\d+x+\d+/gi)){
			fld.value = "";
		}
	}
	function formHandler(form){
		var URL = form.site.options[form.site.selectedIndex].value;
		if (URL!="null")
			document.location.href = URL;
	}
	function grayOutField(iName){
		iName.readOnly = true;
		iName.style.color = "777777";
		iName.style.background = "whitesmoke";
	}
	function normaliseField(iName){
		iName.readOnly = false;
		if (normaliseField.arguments.length > 1)
			iName.style.color = normaliseField.arguments[1];
		else
			iName.style.color = "black";
		iName.style.background = "white";
	}

	function checkOneclickInstall (frm){
		if (!Validate_text(frm.Ecom_Application_Install_Dir, "Please enter the address you would like to install to."))
			return false;
		return true;
	}

