function CountryListOnChange(CmbCountryID, CmbStateID, ValidatorUSAID, TxtStateID, ValidatorOtherID) 
{
	var CmbCountry = document.getElementById(CmbCountryID);
	var CountrySelected = CmbCountry.options[CmbCountry.selectedIndex].text;
	
	var TxtState = document.getElementById(TxtStateID);
	var StateValidatorOther = document.getElementById(ValidatorOtherID);
	
	var CmbState = document.getElementById(CmbStateID);
	var StateValidatorUSA = document.getElementById(ValidatorUSAID);
	
	if (CountrySelected.toUpperCase() == "UNITED STATE OF AMERICA")
	{
		TxtState.value="-";
		TxtState.style.display = 'none';
		StateValidatorOther.style.display = 'none';
		CmbState.value=0;
		CmbState.style.display = 'block';
		//StateValidatorUSA.style.display = 'block';
	} else {
		TxtState.value="";
		TxtState.style.display = 'block';
		//StateValidatorOther.style.display = 'block';
		CmbState.value=1;
		CmbState.style.display = 'none';
		StateValidatorUSA.style.display = 'none';
	}
}

function CountryInfoOnChange(CmbCountryID, CmbStateID, ValidatorUSAID, TxtStateID, ValidatorOtherID) 
{
	var CmbCountry = document.getElementById(CmbCountryID);
	var CountrySelected = CmbCountry.options[CmbCountry.selectedIndex].text;
	
	var TxtState = document.getElementById(TxtStateID);
	var StateValidatorOther = document.getElementById(ValidatorOtherID);
	
	var CmbState = document.getElementById(CmbStateID);
	var StateValidatorUSA = document.getElementById(ValidatorUSAID);
	
	var DivUS = document.getElementById("DivUS");
	var DivOther = document.getElementById("DivOther");
	
	if (CountrySelected.toUpperCase() == "UNITED STATE OF AMERICA" | CountrySelected.toUpperCase() == "UNITED STATES"  | CountrySelected.toUpperCase() == "U.S.A.")
	{
		TxtState.value="-";
		DivOther.style.display = "none";
		StateValidatorOther.style.display = "none";
		//CmbState.value=0;
		DivUS.style.display = "";
		//StateValidatorUSA.style.display = "";
	} else {
		if (TxtState.value=="-") TxtState.value="";
		TxtState.display="";
		DivOther.style.display = ""
		//StateValidatorOther.style.display = "";
		//CmbState.value=1;
		DivUS.style.display = "none";
		StateValidatorUSA.style.display = "none";
	}
}

function KnowUsOnChange(CmbKnowUs, ValidatorKnowUsID, TxtKnowUsID, ValidatorOtherID) 
{
	var KnowUsSelected = CmbKnowUs.options[CmbKnowUs.selectedIndex].text;
	
	var TxtKnowUs = document.getElementById(TxtKnowUsID);
	var ValidatorKnowUs = document.getElementById(ValidatorKnowUsID);
	var ValidatorOther = document.getElementById(ValidatorOtherID);
	
	if (KnowUsSelected.toUpperCase() != "OTHER")
	{
		TxtKnowUs.value="-";
		TxtKnowUs.style.display = 'none';
		ValidatorOther.style.display = 'none';
	} else {
		TxtKnowUs.value="";
		TxtKnowUs.style.display = 'block';
		ValidatorKnowUs.style.display = 'none';
	}
}

function ShowPage(id)
{
	var theForm;
	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
		theForm = document.forms["aspnetForm"];
	}
	else {
		theForm = document.aspnetForm;
	}
	var TxtPageNumber = document.getElementById("ctl00_CphPageBody_TxtPageNumber");
	TxtPageNumber.value = id;
	theForm.submit();
}

function CheckQtyAddToCart(TextObject, NumberType, QuantityMinimum, QuantityMaximum, QuantityUnit)
{
	var NumericExpression;
	if (NumberType == "Integer")
	{
	  NumericExpression = /^[0-9]+$/;
	} else
	{
	  NumericExpression = /^\d*\.?\d{0,2}$/;
	}
	var IsValid = false;
	var ShowError = document.getElementById('Err' + TextObject);
	
	var TxtQuantity = document.getElementById("Txt" + TextObject);
	var Quantity = TxtQuantity.value;
	if (Quantity.length == 0)
	{
		IsValid = false;
		ShowError.innerHTML = "* Please Input Quantity";
	} else
	{
		if(Quantity.match(NumericExpression)){
			if (Quantity < QuantityMinimum)
			{
				IsValid = false;
				ShowError.innerHTML = "* Start From " + QuantityMinimum + " " + QuantityUnit;
			} else if (Quantity > QuantityMaximum)
			{
				IsValid = false;
				ShowError.innerHTML = "* Not Over " + QuantityMaximum + " " + QuantityUnit;
			} else
			{
				IsValid = true;
				var BtnAddCart = document.getElementById('Btn' + TextObject);
				BtnAddCart.href = "AddToCart.aspx?ProductID=" + TextObject + "&Quantity=" + TxtQuantity.value;
			}
		}else{
			IsValid = false;
			ShowError.innerHTML = "* Invalid Format Number";
		}
	}
	
	return IsValid;
}

function InputNumeric (TextObject, CodeAscii, NumberType)
{
	if (CodeAscii==13)
	{
		return false;
	} else
	{
		if (NumberType == "Integer")
		{
			return (CodeAscii>=48 && CodeAscii<=57);
		} else
		{
			var TxtQuantity = document.getElementById("Txt" + TextObject);
			var Quantity = TxtQuantity.value;
			if (CodeAscii>=48 && CodeAscii<=57)
			{
				return true;
			} else if(CodeAscii == 46)
			{
				if (Quantity.indexOf(".") >= 0) return false;
			} else
			{
				return false;
			}
		}
	}
}
