<!-- hide from JavaScript-challenged browsers
var g_FormOk = true;

function calcAmt()
{
	// validate quantity field
	if (((!isPositiveInteger(document.PREORDERFORM.QuantityVax.value) && 
		  !isPositiveInteger(document.PREORDERFORM.QuantityVaxRenew.value)) || 
		 (document.PREORDERFORM.QuantityVax.value == 0 && 
		  document.PREORDERFORM.QuantityVaxRenew.value == 0)) &&
		(!document.PREORDERFORM.VaxPersonal || !document.PREORDERFORM.VaxPersonal.checked))
	{
		document.PREORDERFORM.QuantityVax.focus();
		if (document.PREORDERFORM.VaxPersonal)
			alert("Please enter a valid order quantity or click Personal license.");
		else
			alert("Please enter a valid order quantity.");
		g_FormOk = false;
		return false;
	}
	return true;
}

function IsOKtoPost()
{
	// save status before reset
	var retval = g_FormOk;
	// reset status for the next invocation
	g_FormOk = true;
	// return old status
	return retval;
}

function isPositiveInteger(s)
{
	var i;
	if ((s == null) || (s.length == 0)) 
		return false;
	
	// Search through string's characters one by one
	// until we find a non-numeric character.
	// When we do, return false; if we don't, return true.
	for (i = 0; i < s.length; i++)
	{   
	    // Check that current character is number.
	    var c = s.charAt(i);
	    if (!(c >= "0" && c <= "9"))
	    	return false;
	}
	// All characters are numbers.
	return true;
}

// VA will call this URL with product and quantity params if the user chooses
// to buy a license or a renewal from the Buy/Try dialog.
function parseArgs()
{
	var anonymousArgs = new Array();
	var vaxQuantity = 0, vaxrenewQuantity = 0, isVaxpe = false;
	var ref = window.location.href;
	// strip everything up to and including the '?'
	var pos = ref.search("[?]");
	if (pos != -1)
	{
		ref = ref.substring(pos + 1, ref.length);
		var pairs = ref.split("&");
		var idx;
		var qty = 0;
		var product = "default";
		for (idx = 0; idx < pairs.length; ++idx)
		{
			var curSet = pairs[idx].split("=");
			if (curSet.length == 2)
			{
				if (curSet[0] == "product")
				{
					product = curSet[1];
				}
				else if (curSet[0] == "quantity")
				{
					qty = curSet[1];
				}
				else if (curSet[0] == "v")
				{
					vaxQuantity = curSet[1];
				}
				else if (curSet[0] == "r")
				{
					vaxrenewQuantity = curSet[1];
				}
				else if (curSet[0] == "c")
				{
					// shortcut for case.  Can also specify "case", which will be picked up in anonymous args
					anonymousArgs[anonymousArgs.length] = { name: "case", value: curSet[1] }; 
				}
				else
				{
					// handle Anonymous Args
					var anonymousArg = 
					{
						name: curSet[0],
						value: curSet[1]
					};
					anonymousArgs[anonymousArgs.length] = anonymousArg;
				}
			}
			else if (curSet[0] == "p")
				isVaxpe = true;
		}


		if (qty < 1)
			qty = 1;
			
		// backward compatibility
		if (product == "vaxrenew" || product == "vaxrenewal")
		{
			document.PREORDERFORM.QuantityVax.value = "";
			document.PREORDERFORM.QuantityVaxRenew.value = qty; 
		}
		else if (product == "vax")
		{
			document.PREORDERFORM.QuantityVax.value = qty;
			document.PREORDERFORM.QuantityVaxRenew.value = "";
		}
		
		// new parameters 2011-06-17 KDS
		if (vaxQuantity > 0)
			document.PREORDERFORM.QuantityVax.value = vaxQuantity;
			
		if (vaxrenewQuantity > 0)
			document.PREORDERFORM.QuantityVaxRenew.value = vaxrenewQuantity; 
			
		// perform this check last to zero out other fields if conflicting args were passed
		if (isVaxpe)
		{
			document.PREORDERFORM.QuantityVax.value = "";
			document.PREORDERFORM.QuantityVaxRenew.value = "";
			document.PREORDERFORM.VaxPersonal.checked = true;
		}
		
	}

	if (anonymousArgs.length)
	{
		var str = "";
		var i;
		for (i = 0; i < anonymousArgs.length; i++)
		{
			var tmpStr;
			tmpStr = '<input type="hidden" name="' 
				+ anonymousArgs[i].name
				+ '" value="'
				+ anonymousArgs[i].value
				+ '">';
			str += tmpStr;
		}
		var extraArgsDiv = document.getElementById("extraArgs");
		extraArgsDiv.innerHTML = str;
	}

	return true;
}


// done hiding -->

