//------------------------------------------------------------------------
//|  Author: sky                                                         |
//|  Version: 0.0.1                                                      |
//|  Copyright: Shenzhen Haiweike Electronics Co., Ltd                   |
//|  Last modified: 09-01-17 10:05:00                                    |
//------------------------------------------------------------------------
function CheckQuantity() {
	var error_msg = "";
	if ((document.form_get_cost.quantity.value == "" && document.form_get_cost.quantity2.value == "" && document.form_get_cost.quantity3.value == "") || document.form_get_cost.destination.value == "") {
		error_msg = "Please input phone quantity and choose destination country!";
	} else {
		if (document.form_get_cost.quantity.value != "") {
			if (isNaN(document.form_get_cost.quantity.value) || (!isNaN(document.form_get_cost.quantity.value) && document.form_get_cost.quantity.value < 1)) {
				if (error_msg != "")
					error_msg = error_msg + "\r\nPlease input phone quantity1!";
				else
					error_msg = "Please input phone quantity1!";
			}
		}
		
		if (document.form_get_cost.quantity2.value != "") {
			if (isNaN(document.form_get_cost.quantity2.value) || (!isNaN(document.form_get_cost.quantity2.value) && document.form_get_cost.quantity2.value < 1)) {
				if (error_msg != "")
					error_msg = error_msg + "\r\nPlease input phone quantity2!";
				else
					error_msg = "Please input phone quantity2!";
			}
		}
		
		if (document.form_get_cost.quantity3.value != "") {
			if (isNaN(document.form_get_cost.quantity3.value) || (!isNaN(document.form_get_cost.quantity3.value) && document.form_get_cost.quantity3.value < 1)) {
				if (error_msg != "")
					error_msg = error_msg + "\r\nPlease input phone quantity3!";
				else
					error_msg = "Please input phone quantity3!";
			}
		}
		
		if (document.form_get_cost.destination.value == "") {
			if (error_msg != "")
				error_msg = error_msg + "\r\nPlease choose destination country!";
			else
				error_msg = "Please choose destination country!";
		}
	}
	
	//if (!isNaN(document.form_get_cost.quantity.value) && document.form_get_cost.quantity.value > 0 && document.form_get_cost.destination.value != "") {
	if (error_msg == "") {
		return true;
	} else {
		alert(error_msg);
		return false;
	}
}

function GetShippingCost() {
	if (CheckQuantity()) {
		var quantity = document.form_get_cost.quantity.value;
		var quantity2 = document.form_get_cost.quantity2.value;
		var quantity3 = document.form_get_cost.quantity3.value;
		var destination = document.form_get_cost.destination.value;
		window.location = "index.php?controller=generate_shipping_cost&quantity=" + quantity + "&quantity2=" + quantity2 + "&quantity3=" + quantity3 + "&destination=" + destination;
	}
}