function jssendmail()
{
    alert("Your password has been sent to your email account.");
}
function toggleDisplay(e, state)
{
    if (state == 'block' || state == 'none')
    {
        element = document.getElementById(e).style;
        element.display=state;
    }
}
function page3setup()
{
        WCClaims();
        GLClaims();
}
function WCClaims()
{

    if (document.forms[0]["txtYearsWorkersComp"].selectedIndex > 1)
    {
        toggleDisplay('tblWC', 'block');
        document.getElementById('toggleRow1').className='sep2';
        document.getElementById('toggleRow2').className='sep1';
    }
    else
    {
        toggleDisplay('tblWC', 'none');
        document.getElementById('toggleRow1').className='sep1';
        document.getElementById('toggleRow2').className='sep2';
    }
}
function GLClaims()
{
    if (document.forms[0]["txtYearsGeneralLiability"].selectedIndex > 1)
    {
        toggleDisplay('tblGL', 'block');
    }
    else
    {
        toggleDisplay('tblGL', 'none');
    }
}
function sameAs()
{
    if (document.forms[0]["chkSameAs"].checked)
    {
        document.forms[0]["txtLocAdd"].value = document.forms[0]["txtMaiAdd"].value;
        document.forms[0]["txtLocCit"].value = document.forms[0]["txtMaiCit"].value;
        document.forms[0]["txtLocSta"].value = document.forms[0]["txtMaiSta"].value;
        document.forms[0]["txtLocZip"].value = document.forms[0]["txtMaiZip"].value;
    }
    else
    {
        document.forms[0]["txtLocAdd"].value = '';
        document.forms[0]["txtLocCit"].value = '';
        document.forms[0]["txtLocSta"].value = '';
        document.forms[0]["txtLocZip"].value = '';
    }
}
function sameChange()
{
    if (document.forms[0]["chkSameAs"].checked)
    {
        document.forms[0]["txtLocAdd"].value = document.forms[0]["txtMaiAdd"].value;
        document.forms[0]["txtLocCit"].value = document.forms[0]["txtMaiCit"].value;
        document.forms[0]["txtLocSta"].value = document.forms[0]["txtMaiSta"].value;
        document.forms[0]["txtLocZip"].value = document.forms[0]["txtMaiZip"].value;
    }
}

var DisqPopup;
DisqPopup = 'Based on your answer to this question, you do NOT qualify to participate in this insurance program. Please discontinue your attempt to get your Quick Quote Indication and exit.';
function p3Qualified1()
{
    if (document.forms[0]["s3_1"][0].checked)
    {
        alert(DisqPopup);
        document.getElementById("Button1").click();
    }
}
function p3Qualified1a()
{
    if (document.forms[0]["s3_2"][0].checked)
    {
        alert(DisqPopup);
        document.getElementById("Button1").click();
    }
}
function p3Qualified3()
{
    if (document.forms[0]["txtYearsWorkersComp"].value > 0 && document.forms[0]["txtYearsWorkersComp"].value < 40)
    {
        if (document.forms[0]["radWCClaims"][0].checked)
        {
            alert(DisqPopup);
            document.getElementById("Button1").click();
        }
    }
}
function p3Qualified4()
{
    if (document.forms[0]["txtYearsGeneralLiability"].value > 0 && document.forms[0]["txtYearsGeneralLiability"].value < 40)
    {
        if (document.forms[0]["radGLClaims_0"].checked)
        {
            alert(DisqPopup);
            document.getElementById("Button1").click();
        }
    }
}
function p3Qualified5()
{
    if (document.forms[0]["txtYearsExperience"].selectedIndex == 1 || document.forms[0]["txtYearsExperience"].selectedIndex == 2 || document.forms[0]["txtYearsExperience"].selectedIndex == 3)
    {
        alert(DisqPopup);
        document.getElementById("Button1").click();
    }
}
function p4Calculate()
{
    if (!(IsNumber2(document.forms[0]["txtWorkersCompAdj"].value)))
    {
       document.forms[0]["txtWorkersCompAdj"].value = document.forms[0]["txtWorkersCompAdj"].value.substr(0, document.forms[0]["txtWorkersCompAdj"].value.length - 1);
    }
    else
    {
        document.forms[0]["txtWorkersCompAdj"].value = FormatDecimal(amount(document.forms[0]["txtWorkersCompAdj"].value));
    }
}
function amount (raw)

{
    raw = raw.replace(/,/g,'')
    if (IsNumber(raw))
    {
        return parseFloat(raw.slice(0));
    }
    else
    {
        if (IsNumeric(raw.slice(1)))
        {
            return parseFloat(raw.slice(1));
        }
        else
        {
            return 0;
        }
    }
    
}

function IsNumeric (strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789,$.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
function IsNumber (strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
function IsNumber2 (strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function FormatDecimal(inVal)
{
    var nPos = inVal.indexOf('.');
    if (nPos < 0)
    {
        inVal += '.00';
    }
    else
    {
        inVal = inVal.slice(0, nPos + 3);
        var nZero = 3 - (inVal.length - nPos);
        for (var i = 0; i < nZero; i++)
        {
            sCurrency += '0';
        }
    }
    return sCurrency;
}
function doRound(whichOne)
{
    if (!(IsNumber2(document.forms[0][whichOne].value)))
    {
        document.forms[0][whichOne].value = '';
    }
    else
    {
        document.forms[0][whichOne].value = Math.round(parseFloat(document.forms[0][whichOne].value) + 0.0001);
    }
}
function doFormat(whichOne)
{
    if (!(IsNumeric(document.forms[0][whichOne].value)))
    {
        document.forms[0][whichOne].value = document.forms[0][whichOne].value.substr(0, document.forms[0][whichOne].value.length - 1);
    }

   document.forms[0][whichOne].value = FormatCurrency(document.forms[0][whichOne].value);
}
function FormatCurrency(num) 
{
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
    {
        num = "0";
    }
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();

    if(cents<10)
    {
        cents = "0" + cents;
    }
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    {
        num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
    }
    return (((sign)?'':'-') + '$' + num);  //+ '.' + cents);
}
function doRefresh(page) 
{
  window.opener.location.href = page + '.aspx?act=CON';

  if (window.opener.payrollPop)
  {
    window.opener.payrollPop.close();
  }
  window.close();
}
function abRefresh() 
{
  window.opener.location.href = 'appbrowser.aspx';
}
