
function updateQty(whichField,howMuch,ref)
{
  var fv=whichField.value;
  for(zz=0; zz<fv.length; zz++)
  {
    var v = parseFloat(fv.substring(zz));
    if (isNaN(v) || (v != 0 && fv < howMuch))
    {
      if(confirm('Minimum Order Is '+howMuch))
      {
        whichField.value=howMuch;
        location.href='index.asp?session='+session+'&'+whichField.name+'='+howMuch;
      }
      else
      {
        location.href='index.asp?session='+session+'&'+whichField.name+'='+fv;
      }
      break;
    }
    else
    {
      location.href='index.asp?session='+session+'&'+whichField.name+'='+fv;
    }
  }
}

function checkMin(whichField,howMuch)
{
  var fv=whichField.value;
  for(zz=0; zz<fv.length; zz++)
  {
    var v = parseFloat(fv.substring(zz));
    if (isNaN(v) || (v != 0 && fv < howMuch))
    {
      if(confirm('Minimum Order Is '+howMuch))
      {
        whichField.value=howMuch;
        whichField.focus();
      }
      else
      {
        whichField.value=0;
        whichField.focus();
      }
      break;
    }
  }
}

function changeBilling(toWhat)
{
	var creditView = (toWhat == 'credit') ? 'block' : 'none';
	var accountView = (toWhat == 'account') ? 'block' : 'none';
	document.getElementById('checkOutCredit').style.display = creditView;
	document.getElementById('checkOutAccount').style.display = accountView;
}

function checkOut()
{
	var objForm = document.getElementById('cartForm');
	if(verify(objForm))
	{
		objForm.method = 'POST';
		objForm.action = 'checkout.asp';
		objForm.submit();
	}
}

function checkOutCredit()
{
	var objForm = document.getElementById('checkOutCredit');
	objForm.Credit_Card_Type.rx=true;
	objForm.Credit_Card_Type.pattern=/[^0-9]/;
	objForm.Credit_Card_Number.rx=true;
	objForm.Credit_Card_Number.pattern=/[^0-9]/;
	objForm.Credit_Card_Month.rx=true;
	objForm.Credit_Card_Month.pattern=/[^0-9]/;
	objForm.Credit_Card_Year.rx=true;
	objForm.Credit_Card_Year.pattern=/[^0-9]/;
	objForm.Credit_Card_Verification_Number.rx=true;
	objForm.Credit_Card_Verification_Number.pattern=/[^0-9]/;
	objForm.Credit_Card_Number.creditcard=true;
	if(verify(objForm))
	{
		objForm.method = 'POST';
		objForm.action = 'checkout2.asp';
		objForm.submit();
	}
}

function checkOutAccount()
{
	var objForm = document.getElementById('checkOutAccount');
	if(verify(objForm))
	{
		objForm.method = 'POST';
		objForm.action = 'checkout2.asp';
		objForm.submit();
	}
}

function submitInfo()
{
	var objForm = document.getElementById('infoForm');
	objForm.Billing_Address_2.optional=true;
	objForm.Billing_Fax_Number.optional=true;
	objForm.Billing_Phone_Extension.optional=true;
	objForm.Shipping_Address_2.optional=true;
	objForm.Shipping_Phone_Extension.optional=true;
	objForm.Shipping_County.conditional=true;
	objForm.Shipping_County.condition='Shipping_State';
	objForm.Shipping_County.conValue='FL';
	if(verify(objForm))
	{
		objForm.action = 'new-user.asp';
		objForm.method = 'post';
		objForm.submit();
	}
}

function orderForm(whichForm)
{
	var objForm = document.getElementById(whichForm);
	for(i=0;i<=dataObj.contCount;i++)
	{
		var fieldId = 'Q_' + i;
		objForm[fieldId].optional = true;
		if(objForm[fieldId].value != null && objForm[fieldId].value != '')
		{
			objForm[fieldId].numeric = true;
			objForm[fieldId].minValue = 36;
			objForm[fieldId].fTitle = 'Quantity';
		}
	}
	if(verify(objForm))
	{
		objForm.method = 'POST';
		objForm.action = '/order/index.asp';
		objForm.submit();
	}
}

function submitTerms()
{
	var objForm = document.getElementById('termsForm');
	objForm.action = 'approve-terms.asp';
	objForm.method = 'post';
	objForm.submit();
}

function lostInfo()
{
	var objForm = document.getElementById('lostInfo');
	objForm.Email.email=true;
	if(verify(objForm))
	{
		objForm.action = 'lost.asp';
		objForm.method = 'post';
		objForm.submit();
	}
}

function fillShipping(whatCheck)
{
  document.getElementById('Shipping_Address').value = document.getElementById('Billing_Address').value;
  document.getElementById('Shipping_Address_2').value = document.getElementById('Billing_Address_2').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_Code').value = document.getElementById('Billing_ZIP_Code').value;
  document.getElementById('Shipping_Phone_Number').value = document.getElementById('Billing_Phone_Number').value;
  document.getElementById('Shipping_Phone_Extension').value = document.getElementById('Billing_Phone_Extension').value;
  checkState(document.getElementById('Shipping_State').value);
}

function checkState(whatState)
{
	var countyObj = document.getElementById('counties');
  if(whatState == "FL")
  {  
    countyObj.style.display = 'block';
		countyObj.focus();
  }
  else
  {
    countyObj.style.display = 'none';
  }
}

function submitUpdate()
{
	var objForm = document.getElementById('updateForm');
	objForm.Company.optional=true;
	objForm.Billing_Address_2.optional=true;
	objForm.Billing_Phone_Extension.optional=true;
	objForm.Billing_Fax_Number.optional=true;
	objForm.Account_Number.optional=true;
	objForm.Tax_Certificate.optional=true;
	objForm.Broker.optional=true;
	objForm.Shipping_Phone_Extension.optional=true;
	objForm.Shipping_Address_2.optional=true;
	if(objForm.Shipping_State.value != 'FL'){objForm.Shipping_County.optional=true;}
	if(verify(objForm)){
		objForm.action = location.href;
		objForm.submit();
	}
}

function submitLogin()
{
	var objForm = document.getElementById('loginForm');
	objForm.User_Id.email = true;
	if(verify(objForm))
	{
		objForm.action = location.href;
		objForm.submit();
	}
}

var timeOutId = 0;
var intMins = 15;
var intSecs = 0;
function pageTimer()
{
	if(intSecs <= 0)
	{
		intMins -= 1;
		intSecs = 60;
	}
	intSecs -= 1;
	/*
	var strSecs = intSecs.toString();
	var strMins = intMins.toString();
	if(strSecs.length < 2){strSecs = '0' + strSecs;}
	if(strMins.length < 2){strMins = '0' + strMins;}
	var timeString = strMins + ":" + strSecs;
	document.getElementById('timeOutDisplay').innerHTML = timeString + ' to Save Form';
	if(intMins < 2){document.getElementById('timeOutDisplay').style.color='#f00';}
	*/
	if((intMins > 0) || (intSecs > 0))
	{
		timeOutId = setTimeout(pageTimer,1000);
	}
	else
	{
		alert('Your Session Is About To Time-Out');
		clearTimeout(timeOutId);
	}
}