// JavaScript Document
function validate_input(form) {
	product = form.product.value
	quantity = form.quantity.value

	if (product == '') {
		alert("Please Select a Product!")
		form.product.focus()
		return false
	} else if (!isInteger(quantity) || quantity < 0 || quantity == '') {
		alert("Please enter a valid Quantity!")
		form.quantity.focus()
		return false
	}

	return true
}

function isInteger(input) {
	inputStr = input.toString()
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i)			
		if ((oneChar < "0" || oneChar > "9") && oneChar != "/") {
			return 0;
		}
	}
	return 1;
}

function popupWindow(url, w, h) { 					
window.open(url,'popupWindow','scrollbars=yes,resizable=yes,titlebar=yes,statusbar=yes,width=' + w + ',height=' + h + ',top=150,left=150')
}

function billling2shipping() {
	document.getElementById("shipping_fname").value=document.getElementById("billing_fname").value
	document.getElementById("shipping_lname").value=document.getElementById("billing_lname").value
	document.getElementById("shipping_address1").value=document.getElementById("billing_address1").value
	document.getElementById("shipping_address2").value=document.getElementById("billing_address2").value
	document.getElementById("shipping_city").value=document.getElementById("billing_city").value
	document.getElementById("shipping_state").value=document.getElementById("billing_state").value
	document.getElementById("shipping_zip").value=document.getElementById("billing_zip").value
	document.getElementById("shipping_country").value=document.getElementById("billing_country").value
	document.getElementById("shipping_phone").value=document.getElementById("billing_phone").value
}

function comfirm_action(msg, url){
	if(confirm(msg)) {
		location.href = url;
	}
}