function Execute() {
	switch (GetValue("param_script")) {
		case "viewitem":
			if (objForm["itemtypeid"]) {
				SetFocus("itemtypeid")
			}
			break
		case "emailfriend":
			SetFocus("emailfrom")
			break
		case "emailfriendconfirmation":
			setTimeout("LoadPage('photo/gallery')", 7000)
			break
		case "viewcheckout":
			if (objForm["email"]) {
				SetFocus("email")
			}
			break
		case "storeconfirmation":
			setTimeout("LoadPage('photo/gallery')", 7000)
			break
	}
}
function AddItem() {
	SetValue("param_dispatch", "additem")
	objForm.submit()
}
function AddSelectedItems() {
	bol = false
	for (var i = 0; i < GetValue("param_itemstotal"); i++) {
		if (!IsBlank(GetValue("item" + (i+1) + ".quantity"))) {
			bol = true
			break
		}
	}
	if (bol) {
		SetValue("param_dispatch", "addselecteditems")
		objForm.submit()
	} else {
		alert(GetCaption("alert-quantitycannotbeblank"))
	}
}
function Checkout(param_dispatch) {
	if (ValidateForm()) {
		SetValue("param_dispatch", param_dispatch)
		objForm.submit()
	}
}
function CurrencyConverter() {
	OpenAuxWindow("http://www.xe.net/ecc/input.cgi", 650, 125, "")
}
function RemoveAll() {
	if (confirm(GetCaption("alert-updatecart"))) {
		SetValue("param_dispatch", "removeall")
		objForm.submit()
	}
}
function RemoveItem(id) {
	if (confirm(GetCaption("alert-updatecart"))) {
		SetValue("param_dispatch", "removeitem")
		SetValue("param_id", id)
		objForm.submit()
	}
}
function UpdateCart() {
	SetValue("param_dispatch", "updatecart")
	objForm.submit()
}
function UpdateCartAlert() {
	if (confirm(GetCaption("alert-updatecart"))) {
		SetValue("param_dispatch", "updatecart")
		objForm.submit()
	}
}
function ValidateForm() {
	switch (objForm.name) {
		case "EmailFriend":
			objField = objForm["emailfrom"]
			if (!IsEmail(objField.value)) {
				alert(GetCaption("alert-emailformat"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["emailto"]
			if (!IsEmail(objField.value)) {
				alert(GetCaption("alert-emailformat"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["subject"]
			if (IsBlank(objField.value)) {
				alert(GetCaption("alert-cannotbeblank"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["message"]
			if (objField.value.length > 255) {
				alert(GetCaption("alert-maxfieldlength"))
				SetFocus(objField.name)
				return false
			}
			//objField.value = TrimLineBreaks(objField.value)
			break
		case "CheckoutStep2":
			objField = objForm["email"]
			if (!IsEmail(objField.value)) {
				alert(GetCaption("alert-emailformat"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["confirmemail"]
			if (!IsEmail(objField.value)) {
				alert(GetCaption("alert-emailformat"))
				SetFocus(objField.name)
				return false
			}
			if (objForm["email"].value != objForm["confirmemail"].value) {
				alert(GetCaption("alert-emailformat"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["customername"]
			if (IsBlank(objField.value)) {
				alert(GetCaption("alert-cannotbeblank"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["address"]
			if (IsBlank(objField.value)) {
				alert(GetCaption("alert-cannotbeblank"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["city"]
			if (IsBlank(objField.value)) {
				alert(GetCaption("alert-cannotbeblank"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["state"]
			if (IsBlank(objField.value)) {
				alert(GetCaption("alert-cannotbeblank"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["zip"]
			if (IsBlank(objField.value)) {
				alert(GetCaption("alert-cannotbeblank"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["country"]
			if (IsBlank(objField.value)) {
				alert(GetCaption("alert-cannotbeblank"))
				SetFocus(objField.name)
				return false
			}
			objField = objForm["notes"]
			if (objField.value.length > 1000) {
				alert(GetCaption("alert-maxfieldlength"))
				SetFocus(objField.name)
				return false
			}
			//objField.value = TrimLineBreaks(objField.value)
			break
	}
	return true
}
function ViewLargeSize(id) {
	OpenAuxWindow('../store/viewlargesize.asp?param_itemid=' + id, 625, 625)
}
