/*!
 * CKBE Cart Functions
 * http://www.ckbe.com/
 *
 * Copyright 2010, CKBE
 * All Rights Reserved.
 *
 * Requires jQuery JavaScript Library v1.4.2
 * Copyright 2010, John Resig
 * http://www.jquery.com/
 * Released under the MIT or GPL Version 2 licenses.
 *
 * Date: Sun Jun 06 18:57:26 2010
 */

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Get & Set (Calculated) Value Functions.

function ckbeCart_getValues() {
	
	var subtotal_amount_product = parseFloat(document.getElementById("subtotal_amount_product").value);
	var subtotal_amount_product_WH = parseFloat(document.getElementById("subtotal_amount_product_WH").value);
	var subtotal_amount_product_DS = parseFloat(document.getElementById("subtotal_amount_product_DS").value);
	var subtotal_amount_giftcard = parseFloat(document.getElementById("subtotal_amount_giftcard").value);
	var subtotal_amount_insurance = parseFloat(document.getElementById("subtotal_amount_insurance").value);
	var subtotal_amount_delivery = parseFloat(document.getElementById("subtotal_amount_delivery").value);
	var subtotal_amount_delivery_calculate = document.getElementById("subtotal_amount_delivery_calculate").value;
	var subtotal_amount_discount = parseFloat(document.getElementById("subtotal_amount_discount").value);
	var subtotal_amount = parseFloat(document.getElementById("subtotal_amount").value);
	var tax_calculate = document.getElementById("tax_calculate").value;
	var tax_rate = document.getElementById("tax_rate").value;
	var tax_amount = parseFloat(document.getElementById("tax_amount").value);
	var total_amount = parseFloat(document.getElementById("total_amount").value);
	
	return [subtotal_amount_product, subtotal_amount_product_WH, subtotal_amount_product_DS, subtotal_amount_giftcard, subtotal_amount_insurance, subtotal_amount_delivery, subtotal_amount_delivery_calculate, subtotal_amount_discount, subtotal_amount, tax_calculate, tax_rate, tax_amount, total_amount];
	
}

function ckbeCart_setValues(subtotal_amount_product, subtotal_amount_giftcard, subtotal_amount_insurance, subtotal_amount_delivery, subtotal_amount_delivery_calculate, subtotal_amount_discount, tax_calculate, tax_rate) {
	
	var subtotal_amount = 0;
	var tax_amount = 0;
	var total_amount = 0;
	var taxable_amount = (subtotal_amount_product + subtotal_amount_insurance + subtotal_amount_delivery) - subtotal_amount_discount;
	
	subtotal_amount = (subtotal_amount_product + subtotal_amount_giftcard + subtotal_amount_insurance + subtotal_amount_delivery) - subtotal_amount_discount;
	
	document.getElementById("subtotal_amount").value = subtotal_amount;
	document.getElementById("summary_cell_subtotal_amount").innerHTML = "$" + ckbeCart_formatCurrency(subtotal_amount);
	
	if (tax_calculate == "true") {
		
		if (subtotal_amount_product > 0 || subtotal_amount_delivery > 0) {
			
			if (tax_rate.toString().indexOf("|") > -1) {
				
				var tax_list = tax_rate.split(",");
				
				var this_floor = 0.00;
				var this_amount = 0.00;
				var this_tax = 0.00;
				
				for (i = 0; i < tax_list.length; i++) {
					
					if (taxable_amount >= this_floor) {
					
						var this_item = tax_list[i].split("|");
						
						var this_rate = parseFloat(this_item[0] / 100);
						var this_ceiling = parseFloat(this_item[1]);
						
						if (taxable_amount >= this_ceiling) {
							
							this_amount = this_ceiling - this_floor;
							
						}
						
						if (taxable_amount < this_ceiling) {
							
							this_amount = taxable_amount - this_floor;
							
						}
						
						this_tax = this_amount * this_rate;
						tax_amount = tax_amount + this_tax;
						
						this_floor = this_ceiling + 0.01;
						
					}
					
				}
				
				if (taxable_amount > this_floor) {
				
					this_amount = taxable_amount - this_floor;
					
					this_tax = this_amount * 0.07;
					tax_amount = tax_amount + this_tax;
				
				}
				
			} else {
			
				tax_amount = taxable_amount * parseFloat(tax_rate);
			
			}
			
		}
		
	}
	
	document.getElementById("tax_amount").value = tax_amount;
	document.getElementById("summary_cell_tax_amount").innerHTML = "$" + ckbeCart_formatCurrency(tax_amount);
	
	total_amount = subtotal_amount + tax_amount;
	
	document.getElementById("total_amount").value = total_amount;
	document.getElementById("summary_cell_total_amount").innerHTML = "$" + ckbeCart_formatCurrency(total_amount);
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Currency Functions.

function ckbeCart_formatCurrency(num) {
	
	num = num.toString().replace(/\$|\,/g,'');
	
	if(isNaN(num))
		
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		
	if(cents<10)
	
		cents = "0" + cents;
		
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+','+
			num.substring(num.length-(4*i+3));
	
	return (((sign)?'':'-') + num + '.' + cents);

}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Update Count Functions.

function ckbeCart_updateCount_product(recID, newCount, lastCount, pricePer, containerObj, containerGrp, typeCount, allCount) {
	
	var newCount_val = 0;
	
	if (newCount != null) {
		newCount_val = document.getElementById(newCount).value;
	}
	
	if (newCount_val == "") {
		newCount_val = 0;
	}
	
	var lastCount_val = document.getElementById(lastCount).value;
	var pricePer_val = document.getElementById(pricePer).value;
	
	var count_change = 0;
	
	var bad_character_found = false;
	var bad_character_list = "abcdefghijklmnopqrstuvwxyz,<.>/?;:'\"[{]}\\|`~!@#$%^&*()-_=+ ";
	
	var message_remove = "Are you sure you want to remove this product from the shopping cart?";
	
	if (newCount != null) {
	
		for (i = 0; i < bad_character_list.length; i++) {
			
			if (document.getElementById(newCount).value.toLowerCase().indexOf(bad_character_list[i]) > -1) {
				bad_character_found = true;
			}
		}
		
	}
	
	if (bad_character_found == true) {
		
		document.getElementById(newCount).value = lastCount_val;
		document.getElementById(newCount).focus();
		
	} else {
		
		if (newCount_val < 1) {
			
			if (confirm(message_remove)) {
				
				document.getElementById(typeCount).value = document.getElementById(typeCount).value - lastCount_val;
				document.getElementById(allCount).value = document.getElementById(allCount).value - lastCount_val;
				
				document.getElementById(containerObj).style.display = "none";
				
				if (document.getElementById(typeCount).value == 0) {
					document.getElementById(containerGrp).style.display = "none";
				}
				
				if (document.getElementById(allCount).value == 0) {
					document.getElementById("cartFull").style.display = "none";
					document.getElementById("cartClear").style.display = "block";
				}
				
				document.getElementById("frm_action").src="/frame/frame_action_cart_item_remove.html?type=Product&id=" + recID;
				
				ckbeCart_updateSummary_product(lastCount_val, newCount_val, pricePer_val);
				
			} else {
				
				if (newCount != null) {
					document.getElementById(newCount).value = lastCount_val;
				}
			
			}
		
		} else {
			
			if (newCount_val != lastCount_val) {
				
				if (newCount_val > lastCount_val) {
					count_change = newCount_val - lastCount_val;
					document.getElementById(typeCount).value = parseInt(document.getElementById(typeCount).value) + count_change;
					document.getElementById(allCount).value = parseInt(document.getElementById(allCount).value) + count_change;
				}
				
				if (newCount_val < lastCount_val) {
					count_change = lastCount_val - newCount_val;
					document.getElementById(typeCount).value = parseInt(document.getElementById(typeCount).value) - count_change;
					document.getElementById(allCount).value = parseInt(document.getElementById(allCount).value) - count_change;
				}
				
				document.getElementById(lastCount).value = newCount_val;
				
				document.getElementById("frm_action").src="/frame/frame_action_cart_item_update_qty.html?type=Product&id=" + recID + "&qty=" + newCount_val;
				
				ckbeCart_updateSummary_product(lastCount_val, newCount_val, pricePer_val);
				
			}
			
		}
		
	}
	
}

function ckbeCart_updateCount_product_byKey(e, recID, newCount, lastCount, pricePer, containerObj, containerGrp, typeCount, allCount) {
	
	var key;
	
	if (window.event) {
		key = window.event.keyCode; // IE & Safari.
	} else {
		key = e.which; // Firefox.
	}
	
	if (key == 13) {
		
		if (newCount != null) {
			document.getElementById(newCount).blur();
		}
		
		return false;
		
	} else {
		return true;
	}
	
}

function ckbeCart_updateCount_giftcard(recID, pricePer, containerObj, containerGrp, typeCount, allCount) {
	
	// DevNote: This is type of object ALWAYS has a quantity of "1" and can ONLY be removed.
	
	var message_remove = "Are you sure you want to remove this gift card from the shopping cart?";
	
	if (confirm(message_remove)) {
				
		document.getElementById(typeCount).value = document.getElementById(typeCount).value - 1;
		document.getElementById(allCount).value = document.getElementById(allCount).value - 1;
		
		document.getElementById(containerObj).style.display = "none";
		
		if (document.getElementById(typeCount).value == 0) {
			document.getElementById(containerGrp).style.display = "none";
		}
		
		if (document.getElementById(allCount).value == 0) {
			document.getElementById("cartFull").style.display = "none";
			document.getElementById("cartClear").style.display = "block";
		}
		
		document.getElementById("frm_action").src="/frame/frame_action_cart_item_remove.html?type=Gift Card&id=" + recID;
		
		ckbeCart_updateSummary_giftcard(pricePer);
		
	}
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Update Summary Functions.

function ckbeCart_updateSummary_product(lastCount_val, newCount_val, pricePer_val) {
	
	var summary_vals = ckbeCart_getValues();
	
	var subtotal_amount_product = summary_vals[0];
	var subtotal_amount_product_WH = summary_vals[1];
	var subtotal_amount_product_DS = summary_vals[2];
	var subtotal_amount_giftcard = summary_vals[3];
	var subtotal_amount_insurance = summary_vals[4];
	var subtotal_amount_delivery = summary_vals[5];
	var subtotal_amount_delivery_calculate = summary_vals[6];
	var subtotal_amount_discount = summary_vals[7];
	var subtotal_amount = summary_vals[8];
	var tax_calculate = summary_vals[9];
	var tax_rate = summary_vals[10];
	var tax_amount = summary_vals[11];
	var total_amount = summary_vals[12];
	
	var count_change = 0;
	var cost_change = 0;
	
	if (newCount_val > lastCount_val) {
		
		count_change = newCount_val - lastCount_val;
		cost_change = count_change * pricePer_val;
		
		subtotal_amount_product = subtotal_amount_product + cost_change;
		
	}
	
	if (newCount_val < lastCount_val) {
		
		count_change = lastCount_val - newCount_val;
		cost_change = count_change * pricePer_val;
		
		subtotal_amount_product = subtotal_amount_product - cost_change;
		
	}
	
	document.getElementById("subtotal_amount_product").value = subtotal_amount_product;
	document.getElementById("summary_cell_subtotal_amount_product").innerHTML = "$" + ckbeCart_formatCurrency(subtotal_amount_product);
	
	ckbeCart_setValues(subtotal_amount_product, subtotal_amount_giftcard, subtotal_amount_insurance, subtotal_amount_delivery, subtotal_amount_delivery_calculate, subtotal_amount_discount, tax_calculate, tax_rate);
	
}

function ckbeCart_updateSummary_giftcard(pricePer) {
	
	var summary_vals = ckbeCart_getValues();
	
	var subtotal_amount_product = summary_vals[0];
	var subtotal_amount_product_WH = summary_vals[1];
	var subtotal_amount_product_DS = summary_vals[2];
	var subtotal_amount_giftcard = summary_vals[3];
	var subtotal_amount_insurance = summary_vals[4];
	var subtotal_amount_delivery = summary_vals[5];
	var subtotal_amount_delivery_calculate = summary_vals[6];
	var subtotal_amount_discount = summary_vals[7];
	var subtotal_amount = summary_vals[8];
	var tax_calculate = summary_vals[9];
	var tax_rate = summary_vals[10];
	var tax_amount = summary_vals[11];
	var total_amount = summary_vals[12];
	
	var cost_change = pricePer;
	
	subtotal_amount_giftcard = subtotal_amount_giftcard - cost_change;
	
	if (subtotal_amount_giftcard == 0) {
		document.getElementById("summary_row_subtotal_amount_giftcard").style.display = "none";	
	}
	
	document.getElementById("subtotal_amount_giftcard").value = subtotal_amount_giftcard;
	document.getElementById("summary_cell_subtotal_amount_giftcard").innerHTML = "$" + ckbeCart_formatCurrency(subtotal_amount_giftcard);
	
	ckbeCart_setValues(subtotal_amount_product, subtotal_amount_giftcard, subtotal_amount_insurance, subtotal_amount_delivery, subtotal_amount_delivery_calculate, subtotal_amount_discount, tax_calculate, tax_rate);
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Set Simple Value Functions.

function ckbeCart_setTax(obj) {
	
	var val = ckbeForm_stringTrim(obj.value);
	
	var summary_vals = ckbeCart_getValues();
	
	var subtotal_amount_product = summary_vals[0];
	var subtotal_amount_product_WH = summary_vals[1];
	var subtotal_amount_product_DS = summary_vals[2];
	var subtotal_amount_giftcard = summary_vals[3];
	var subtotal_amount_insurance = summary_vals[4];
	var subtotal_amount_delivery = summary_vals[5];
	var subtotal_amount_delivery_calculate = summary_vals[6];
	var subtotal_amount_discount = summary_vals[7];
	var subtotal_amount = summary_vals[8];
	var tax_calculate = summary_vals[9];
	var tax_rate = summary_vals[10];
	var tax_amount = summary_vals[11];
	var total_amount = summary_vals[12];
	
	<!--- DevNote: "document.getElementById("delivery_method_1")" is the radio button for pick-up which are always taxed. --->
	if (val.length == 2 && val.toLowerCase() == document.getElementById("tax_state").value.toLowerCase() || document.getElementById("delivery_method_1").checked == true) {
		
		tax_calculate = "true";
		
		document.getElementById("tax_calculate").value = true;
		
	} else {
		
		tax_calculate = "false";
		
		document.getElementById("tax_calculate").value = false;
	
	}
	
	ckbeCart_setValues(subtotal_amount_product, subtotal_amount_giftcard, subtotal_amount_insurance, subtotal_amount_delivery, subtotal_amount_delivery_calculate, subtotal_amount_discount, tax_calculate, tax_rate);
	
}

function ckbeCart_setDelivery(obj) {
	
	var val = ckbeForm_stringTrim(obj.value);
	
	var summary_vals = ckbeCart_getValues();
	
	var subtotal_amount_product = summary_vals[0];
	var subtotal_amount_product_WH = summary_vals[1];
	var subtotal_amount_product_DS = summary_vals[2];
	var subtotal_amount_giftcard = summary_vals[3];
	var subtotal_amount_insurance = summary_vals[4];
	var subtotal_amount_delivery = summary_vals[5];
	var subtotal_amount_delivery_calculate = summary_vals[6];
	var subtotal_amount_discount = summary_vals[7];
	var subtotal_amount = summary_vals[8];
	var tax_calculate = summary_vals[9];
	var tax_rate = summary_vals[10];
	var tax_amount = summary_vals[11];
	var total_amount = summary_vals[12];
	
	if (subtotal_amount_delivery_calculate == "true") {
	
		if (val.length >= 5 && ckbeForm_checkFormat_zip(obj) == true) {
			
			document.getElementById("div_activity_delivery").style.display = "block";
			
			document.getElementById("frm_action").src="/frame/frame_action_cart_set_value_delivery.html?zip=" + val;
			
		} else {
			
			subtotal_amount_delivery = 0;
			
			document.getElementById("delivery_available").value = "";
			window.parent.ckbeMotion_fadeSwap("div_message_delivery_unavailable", "div_message_delivery_undefined", 400);
			document.getElementById("delivery_date").options.length = 0;
			document.getElementById("delivery_date_list").value = "";
			document.getElementById("div_activity_delivery").style.display = "none";
			
			document.getElementById("subtotal_amount_delivery").value = subtotal_amount_delivery;
			document.getElementById("summary_cell_subtotal_amount_delivery").innerHTML = "$" + parent.ckbeCart_formatCurrency(subtotal_amount_delivery);
			
			document.getElementById("tax_rate").value = 0.07;
			
			ckbeCart_setTax(document.getElementById("acp_state"));
			
		}
		
	}
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Option Select Functions.

function ckbeCart_optionDeliveryMethod_delivery() {
	
	document.getElementById("subtotal_amount_delivery_calculate").value = true;
	
	ckbeForm_errorClear_simple("fieldErrorMarker_delivery_date");
	
	ckbeCart_setDelivery(document.getElementById("acp_zip"));
	
	ckbeCart_setTax(document.getElementById("acp_state"));
	
}

function ckbeCart_optionDeliveryMethod_pickup() {
	
	var summary_vals = ckbeCart_getValues();
	
	var subtotal_amount_product = summary_vals[0];
	var subtotal_amount_product_WH = summary_vals[1];
	var subtotal_amount_product_DS = summary_vals[2];
	var subtotal_amount_giftcard = summary_vals[3];
	var subtotal_amount_insurance = summary_vals[4];
	var subtotal_amount_delivery = summary_vals[5];
	var subtotal_amount_delivery_calculate = summary_vals[6];
	var subtotal_amount_discount = summary_vals[7];
	var subtotal_amount = summary_vals[8];
	var tax_calculate = summary_vals[9];
	var tax_rate = summary_vals[10];
	var tax_amount = summary_vals[11];
	var total_amount = summary_vals[12];
	
	subtotal_amount_delivery = 0;
	
	document.getElementById("subtotal_amount_delivery").value = subtotal_amount_delivery;
	document.getElementById("summary_cell_subtotal_amount_delivery").innerHTML = "$" + parent.ckbeCart_formatCurrency(subtotal_amount_delivery);
	
	document.getElementById("subtotal_amount_delivery_calculate").value = false;
	
	document.getElementById("tax_rate").value = 0.07;
	
	ckbeCart_setTax(document.getElementById("tax_state"));
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Check Form Functions.

function ckbeCart_checkForm_product(form) {

	var error = null;
	var obj = null;
	
	obj = form.quantity;
	error = ckbeForm_checkField_min(obj, form.minimum, error);
	
	if (error != null) {
		
		error.focus();
		return false;
		
	}
	
	window.location.href = form.cart.value + "?add=true&type=Product&pID=" + form.pID.value + "&quantity=" + form.quantity.value;
	return false;

}

function ckbeCart_checkForm_giftcard(form) {
	
	var error = null;
	var obj = null;
	
	obj = form.sender;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_null(obj), error);
	
	obj = form.recipient;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_null(obj), error);
	
	obj = form.amount;
	error = ckbeForm_checkField_min(obj, form.minimum, error);
	
	if (error != null) {
		
		error.focus();
		return false;
		
	}
	
	window.location.href = form.cart.value + "?add=true&type=Gift Card&sender=" + form.sender.value + "&recipient=" + form.recipient.value + "&amount=" + form.amount.value + "&quantity=1";
	return false;
	
}

function ckbeCart_checkForm_cart(form) {

	if (form.total_item_count.value == 0) {
	
		return false;
	
	} else {
	
		return true;
	
	}

}

function ckbeCart_checkForm_info(form) {
	
	var error = null;
	var obj = null;
	
	obj = form.acp_email;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_email(obj), error);
	
	obj = form.acp_email2;
	error = ckbeForm_checkField_match(obj, form.acp_email, error);
	
	obj = form.acp_phone;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_phone(obj), error);
	
	obj = form.acp_name;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_name(obj), error);
	
	obj = form.acp_address;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_address(obj), error);
	
	obj = form.acp_city;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_text(obj), error);
	
	obj = form.acp_state;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_state(obj), error);
	
	obj = form.acp_zip;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_zip(obj), error);
	
	obj = form.acp_country;
	error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_text(obj), error);
	
	obj = form.delivery_available;
	error = ckbeForm_checkField_delivery(obj, form.delivery_method, form.delivery_date, error);
	
	if (form.payment_method.value == "Credit Card") {
	
		obj = form.acb_cc_name;
		error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_name(obj), error);
		
		obj = form.acb_dtc_id;
		error = ckbeForm_checkField_select(obj, error);
		
		obj = form.acb_cc_number;
		error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_ccNum(obj), error);
		
		obj = form.acb_cc_exp_month;
		error = ckbeForm_checkField_ccExp(obj, form.acb_cc_exp_year, error);
		
		obj = form.acb_cc_csc;
		error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_ccCsc(obj), error);
		
		obj = form.acb_cc_address;
		error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_address(obj), error);
		
		obj = form.acb_cc_city;
		error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_text(obj), error);
		
		obj = form.acb_cc_state;
		error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_state(obj), error);
		
		obj = form.acb_cc_zip;
		error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_zip(obj), error);
		
		obj = form.acb_cc_country;
		error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_text(obj), error);
		
		if (form.split_sale.value == "true") {
		
			obj = form.split_acb_cc_name;
			error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_name(obj), error);
			
			obj = form.split_acb_dtc_id;
			error = ckbeForm_checkField_select(obj, error);
			
			obj = form.split_acb_cc_number;
			error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_ccNum(obj), error);
			
			obj = form.split_acb_cc_exp_month;
			error = ckbeForm_checkField_ccExp(obj, form.split_acb_cc_exp_year, error);
			
			obj = form.split_acb_cc_csc;
			error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_ccCsc(obj), error);
			
			obj = form.split_acb_cc_address;
			error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_address(obj), error);
			
			obj = form.split_acb_cc_city;
			error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_text(obj), error);
			
			obj = form.split_acb_cc_state;
			error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_state(obj), error);
			
			obj = form.split_acb_cc_zip;
			error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_zip(obj), error);
			
			obj = form.split_acb_cc_country;
			error = ckbeForm_checkField_value(obj, ckbeForm_checkFormat_text(obj), error);
			
			obj = form.split_amount;
			error = ckbeForm_checkField_split(obj, form.total_amount, error);
		
		}
	
	}
	
	// ---------- Error ---------- //
	
	if (error != null) {
		
		error.focus();
		return false;
		
	}
	
}

function ckbeCart_checkForm_terms(form) {
	
	if (form.step.value == "back") {
		
		return true;
		
	} else {
		
		if (form.terms.checked == true) {
			
			return true;
			
		} else {
			
			alert(form.message.value)
			form.terms.focus();
			return false;
			
		}
		
	}
	
}