// for the benefit of the sidebar links...submit the order entry form when they are clicked on, then redirect
//   to the url passed in as a parameter... -rjf

function swfSubmitForm(redirectURL,skipValidation) {
	// change the hidden input tag's value so we know where to go after processing the form... -rjf
	document.orderEditingForm.dummy.name = '_eventId_' + redirectURL;
	document.orderEditingForm.submit();
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
function submitOnce(b)
{
   b.disabled = true;
}
function selectThisField(thisForm)
{
	thisForm.value = trim(thisForm.value);
	thisForm.select();
}
function stateCheck(txtName)
{
	var alphaExp = /^[a-zA-Z]+$/;
   if (txtName.value.match(alphaExp) || trim(txtName.value) == "")
   {
		txtName.style.backgroundColor = "white";
		return true;
   }
   else
   {
		alert("State Abbreviation can be only letters!");
		txtName.value = "";
		txtName.select();
		txtName.style.backgroundColor = "yellow";
		txtName.focus();
		return false;
   }
}

function submitForm(redirectURL,skipValidation) {
	// change the hidden input tag's value so the servlet will know where to go after processing the form... -rjf
	var targetPage = document.orderEditingForm.redirect;
	targetPage.value = redirectURL;
	var isSkipValidation = document.orderEditingForm.skipValidation;
	isSkipValidation.value = skipValidation;
	document.orderEditingForm.submit();
}
function openWindow (url) {
	windowprops = "top=0,left=0,menubar=yes ,toolbar=yes,resizable=yes,scrollbars=yes,width=" + screen.width + ",height=" + screen.height;
	myWindowHandle = window.open( url, "popupPage", windowprops);
}
function numberOnly(txtName,qty)
{
   if (isNaN(txtName.value) == true || txtName.value < 0 || trim(txtName.value) == "")
   {
      alert("Please enter a valid number greater than 0");
      txtName.value = qty;
      txtName.style.backgroundColor = "yellow";
      txtName.focus();
      txtName.select();
      return false;
   }
   else
   {
       txtName.style.backgroundColor = "white";
       return true;
   }
}
function numberValidator(txtName)
{
   if (trim(txtName.value) != "" && (isNaN(txtName.value) == true || txtName.value < 0))
   {
      alert("This field accepts numbers only. '" + txtName.value + "' is not a valid number");
      txtName.value = "";
      txtName.select();
      txtName.style.backgroundColor = "yellow";
      txtName.focus();
      return false;
   }
   else
   {
		txtName.value = trim(txtName.value);
		txtName.style.backgroundColor = "white";
		return true;
   }
}
function getDateNeeded(form, dateNeeded)
{
	if(isNs7)
	{
		document.orderEditingForm.inputDateNeeded.value = dateNeeded;
	}
	else
	{
		document.getElementById("label_dateNeeded").innerHTML = dateNeeded;
	}
}
function shipping_call_or_deliver(s)
{
	if(s == "D")
	{
		var theDeliverySection = eval('deliverySection');
		var theShippingCallSection = eval('shippingCallSection');
		theShippingCallSection.style.display = 'none';
		theDeliverySection.style.display = '';
	}
	else
	{
		var theDeliverySection = eval('deliverySection');
		var theShippingCallSection = eval('shippingCallSection');
		theDeliverySection.style.display = 'none';
		theShippingCallSection.style.display = '';
	}
}
function setSelected(lToChange, len)
{
	var theLableToChange = eval("shippingType_" + lToChange);
	theLableToChange.style.color = 'blue';
	theLableToChange.check = true;
	for(i=0; i<=len; i++)
	{
		if(i != lToChange)
		{
			try{
				theLableToChange = eval("shippingType_" + i);
				theLableToChange.style.color = 'black';
			}catch(e){}
		}
	}
}
function quantityByType_check(form)
{
	form.locationId.disabled = true;
	form.region.disabled = true;

	if(form.quantityByType[3].checked)
	{
		//alert(form.quantityByType[2].checked);
		form.locationId.disabled = false
	}
	if(form.quantityByType[2].checked)
	{
		form.region.disabled = false
	}
	return true;
}
function entsub(txtName, qty) {
  if (window.event && window.event.keyCode != 13000000){
  	if(numberOnly(txtName,qty)){
    	return true;
    }else
    	return false;
  }
  else
    return true;
}

