// middlesexpension.js 
// 
// 3/14/2009 (c)2009 GCK NEXTEON. All rights reserved
// Middlesex county Retirement Benefits Estimation Calculator Script
//1) Enter your date of birth (mm/dd/yyyy) *
//2) Enter your projected date of retirement (mm/dd/yyyy) *
//3) Select a group number 1, 2 or 4, default to group number 1*
//4) Are you a military veteran?*
//5) Enter your estimated total number of years of creditable service,
//6) Enter your estimated average three highest consecutive years of salary 
//7) OPTIONAL: Option C, 1)select calculate by Date of Birth or 2)select by Age and month
//Age of your retirement date will be (Automatic calculated)

<!-- hide this script tag's contents from old browsers

//check if the control can accept focus 
window.onload = initFormFieldFocus;

//Option A and C factor array
function InitFactorArrays() 
{
factorOptionC = 
new Array(
7164,7048,6927,6801,6672,6540,6408,6275,6143,6013,5885,5759,5638,5519,5405,5295,5189,
5088,4990,4897,4807,4722,4641,4563,4490,4419,4353,4289,4229,4171,4117,4065,4016,3969,
3925,3884,3845,3808,3774,3741,3711,3682,3656,3631,3608,3586,3566,3547,3529,3513,3497,
3483,3469,3457,3445,3434,3424,3414,3405,3397,3389,3382,3375,3369,3363,3357,3352,3347,
3343,3339,3335,3331,3328,3325,3323,3320,3318,3316,3314,3312,3310,3309,3308,3307,3306,
7344,7232,7115,6993,6867,6739,6609,6479,6349,6220,6093,5969,5847,5729,5615,5504,5397,
5295,5196,5102,5011,4924,4842,4762,4687,4615,4547,4482,4420,4361,4305,4251,4201,4153,
4107,4064,4024,3986,3950,3916,3885,3855,3827,3801,3777,3754,3733,3713,3695,3678,3661,
3646,3632,3619,3606,3595,3584,3574,3564,3555,3547,3539,3532,3525,3519,3513,3507,3502,
3497,3493,3489,3485,3481,3478,3475,3472,3470,3467,3465,3463,3461,3459,3458,3456,3455,
7527,7419,7306,7188,7066,6942,6815,6688,6560,6434,6308,6185,6064,5947,5832,5722,5615,
5512,5412,5317,5225,5137,5053,4972,4896,4822,4752,4686,4622,4562,4504,4449,4397,4348,
4301,4256,4215,4175,4138,4103,4070,4039,4011,3984,3958,3935,3913,3892,3872,3854,3837,
3821,3807,3793,3780,3767,3756,3745,3735,3726,3717,3709,3701,3694,3687,3680,3675,3669,
3664,3659,3655,3651,3647,3643,3640,3637,3634,3631,3629,3627,3625,3623,3621,3619,3618,
7706,7604,7496,7382,7265,7145,7022,6898,6774,6649,6526,6405,6285,6169,6055,5945,5838,
5734,5634,5538,5445,5357,5271,5190,5112,5037,4966,4898,4833,4771,4712,4655,4602,4551,
4503,4457,4414,4373,4335,4299,4265,4233,4203,4175,4149,4124,4101,4079,4059,4040,4023,
4006,3990,3976,3962,3949,3938,3926,3916,3906,3897,3888,3880,3872,3865,3858,3852,3846,
3840,3835,3831,3826,3822,3818,3815,3811,3808,3806,3803,3800,3798,3796,3794,3792,3791,
7881,7784,7681,7572,7460,7344,7226,7106,6985,6864,6744,6624,6507,6392,6279,6169,6063,
5959,5859,5763,5670,5580,5494,5412,5333,5257,5184,5115,5049,4986,4925,4868,4813,4761,
4711,4665,4620,4578,4539,4501,4466,4433,4402,4373,4346,4320,4296,4274,4253,4233,4215,
4197,4181,4166,4152,4139,4126,4114,4103,4093,4083,4074,4065,4057,4050,4043,4036,4030,
4024,4019,4014,4009,4005,4001,3997,3993,3990,3987,3984,3982,3979,3977,3975,3973,3971,
8048,7956,7858,7756,7648,7538,7424,7308,7192,7074,6957,6841,6726,6612,6501,6393,6287,
6185,6085,5988,5895,5805,5719,5636,5556,5479,5406,5336,5268,5204,5143,5084,5028,4975,
4924,4876,4830,4787,4747,4708,4672,4638,4606,4576,4548,4521,4496,4473,4451,4431,4412,
4394,4377,4361,4346,4333,4320,4307,4296,4285,4275,4265,4256,4248,4240,4233,4226,4219,
4213,4207,4202,4197,4193,4188,4184,4181,4177,4174,4171,4168,4166,4163,4161,4159,4157,
8207,8120,8028,7931,7829,7723,7615,7504,7392,7279,7165,7052,6940,6829,6720,6614,6509,
6408,6309,6213,6120,6030,5943,5860,5779,5702,5628,5557,5489,5424,5361,5302,5245,5190,
5139,5090,5043,4999,4957,4918,4881,4846,4813,4782,4753,4725,4700,4676,4653,4632,4612,
4593,4576,4560,4544,4530,4516,4504,4492,4480,4470,4460,4451,4442,4434,4426,4419,4412,
4406,4400,4394,4389,4384,4380,4376,4372,4368,4365,4361,4358,4356,4353,4351,4348,4346,
8356,8275,8188,8096,8000,7900,7797,7692,7584,7476,7366,7257,7148,7040,6934,6829,6727,
6627,6529,6434,6341,6252,6165,6082,6001,5924,5849,5778,5709,5643,5580,5520,5462,5407,
5354,5304,5257,5212,5169,5129,5090,5055,5021,4989,4959,4931,4904,4880,4856,4835,4814,
4795,4777,4760,4744,4729,4715,4702,4690,4678,4667,4657,4647,4638,4629,4621,4614,4607,
4600,4594,4588,4583,4578,4573,4569,4565,4561,4557,4554,4551,4548,4545,4543,4540,4538,
8496,8420,8339,8253,8162,8068,7971,7870,7768,7664,7560,7454,7349,7245,7142,7040,6939,
6841,6745,6651,6559,6471,6385,6301,6221,6143,6069,5997,5928,5862,5798,5737,5678,5622,
5569,5518,5470,5424,5381,5339,5301,5264,5229,5197,5166,5137,5110,5084,5060,5038,5017,
4997,4978,4961,4945,4929,4915,4901,4888,4876,4865,4855,4845,4835,4826,4818,4810,4803,
4796,4790,4784,4778,4773,4768,4763,4759,4755,4751,4748,4745,4742,4739,4736,4734,4731,
8627,8556,8480,8400,8315,8227,8135,8040,7943,7844,7744,7643,7543,7442,7342,7243,7145,
7049,6955,6862,6772,6685,6600,6517,6437,6360,6285,6213,6144,6077,6013,5952,5893,5837,
5783,5731,5682,5636,5592,5550,5510,5473,5437,5404,5372,5343,5315,5289,5264,5241,5220,
5199,5180,5162,5145,5129,5115,5101,5087,5075,5063,5052,5042,5032,5023,5015,5007,4999,
4992,4985,4979,4973,4968,4963,4958,4954,4950,4946,4942,4939,4936,4933,4930,4927,4925,
8749,8683,8612,8537,8458,8375,8289,8200,8108,8015,7920,7824,7727,7630,7534,7438,7344,
7250,7158,7068,6980,6893,6809,6728,6648,6572,6498,6426,6357,6290,6226,6164,6105,6048,
5994,5942,5893,5845,5801,5758,5718,5680,5644,5610,5578,5547,5519,5492,5467,5444,5421,
5400,5381,5362,5345,5329,5314,5299,5286,5273,5261,5250,5239,5229,5220,5211,5203,5195,
5187,5181,5174,5168,5163,5157,5153,5148,5144,5140,5136,5132,5129,5126,5123,5120,5118,
8860,8799,8733,8664,8590,8513,8432,8348,8262,8174,8084,7993,7901,7809,7716,7624,7533,
7442,7353,7265,7179,7094,7012,6931,6853,6777,6704,6633,6564,6497,6433,6372,6312,6255,
6201,6149,6099,6051,6006,5963,5922,5883,5847,5812,5780,5749,5720,5693,5667,5643,5620,
5599,5579,5560,5542,5525,5510,5495,5481,5468,5456,5444,5433,5423,5413,5404,5396,5388,
5380,5373,5367,5361,5355,5350,5344,5340,5335,5331,5327,5324,5320,5317,5314,5311,5309,
8962,8905,8845,8780,8712,8640,8565,8487,8406,8323,8238,8152,8065,7977,7889,7800,7713,
7625,7539,7454,7370,7287,7207,7128,7051,6976,6904,6833,6765,6699,6635,6573,6514,6457,
6403,6350,6300,6252,6207,6163,6122,6083,6046,6011,5978,5947,5917,5890,5863,5839,5816,
5794,5773,5754,5736,5719,5703,5688,5674,5660,5648,5636,5625,5614,5604,5595,5586,5578,
5570,5563,5556,5550,5544,5539,5533,5529,5524,5520,5516,5512,5508,5505,5502,5499,5496,
9055,9003,8947,8887,8824,8757,8687,8614,8539,8461,8382,8301,8218,8135,8051,7967,7883,
7799,7716,7633,7552,7472,7393,7316,7241,7168,7096,7027,6959,6894,6831,6769,6710,6654,
6599,6547,6497,6449,6403,6359,6318,6278,6241,6206,6172,6140,6111,6082,6056,6031,6007,
5985,5964,5944,5926,5909,5892,5877,5862,5849,5836,5824,5812,5802,5792,5782,5773,5765,
5757,5750,5743,5736,5730,5724,5719,5714,5709,5705,5701,5697,5693,5690,5687,5684,5681,
9140,9092,9041,8985,8927,8865,8800,8733,8662,8590,8515,8439,8361,8283,8203,8123,8043,
7963,7883,7804,7726,7648,7572,7497,7423,7351,7281,7213,7147,7082,7020,6959,6901,6844,
6790,6738,6688,6640,6594,6550,6508,6469,6431,6395,6361,6330,6299,6271,6244,6218,6195,
6172,6151,6131,6112,6094,6078,6062,6047,6033,6020,6008,5996,5985,5975,5965,5956,5948,
5940,5932,5925,5918,5912,5906,5901,5896,5891,5887,5882,5878,5875,5871,5868,5865,5862,
9219,9174,9127,9076,9022,8965,8905,8842,8777,8709,8640,8568,8495,8421,8346,8271,8194,
8118,8042,7966,7891,7816,7742,7669,7598,7528,7459,7393,7327,7264,7202,7142,7085,7029,
6975,6923,6873,6825,6779,6736,6694,6654,6616,6580,6546,6514,6484,6455,6428,6402,6378,
6355,6333,6313,6294,6276,6259,6243,6228,6214,6201,6188,6176,6165,6155,6145,6136,6127,
6119,6111,6104,6097,6091,6085,6079,6074,6069,6064,6060,6056,6052,6049,6045,6042,6039,
9291,9250,9206,9159,9109,9057,9001,8943,8883,8820,8755,8689,8621,8551,8480,8409,8337,
8265,8192,8119,8047,7975,7904,7834,7765,7697,7630,7565,7501,7439,7378,7320,7263,7207,
7154,7103,7053,7005,6960,6916,6874,6835,6797,6761,6727,6694,6663,6634,6607,6581,6556,
6533,6512,6491,6472,6453,6436,6420,6405,6391,6377,6364,6352,6341,6330,6320,6311,6302,
6294,6286,6279,6272,6265,6259,6253,6248,6243,6238,6234,6230,6226,6222,6219,6216,6213,
9357,9319,9279,9236,9190,9142,9091,9037,8981,8923,8863,8801,8737,8672,8606,8539,8471,
8402,8334,8265,8196,8127,8059,7991,7924,7859,7794,7730,7668,7607,7548,7490,7434,7380,
7327,7276,7227,7180,7135,7091,7050,7010,6972,6936,6902,6869,6839,6809,6782,6756,6731,
6708,6686,6665,6645,6627,6609,6593,6578,6563,6549,6536,6524,6513,6502,6492,6482,6473,
6465,6457,6449,6442,6436,6430,6424,6418,6413,6409,6404,6400,6396,6392,6389,6385,6382,
9418,9383,9346,9307,9265,9220,9173,9124,9072,9018,8963,8905,8846,8785,8723,8660,8597,
8532,8467,8402,8336,8270,8205,8140,8076,8013,7950,7889,7828,7769,7711,7655,7600,7546,
7494,7444,7396,7349,7304,7261,7220,7180,7142,7106,7072,7040,7009,6979,6952,6925,6900,
6877,6855,6834,6814,6795,6778,6761,6746,6731,6717,6704,6692,6680,6669,6659,6649,6640,
6632,6623,6616,6609,6602,6596,6590,6584,6579,6574,6570,6566,6562,6558,6554,6551,6548,
9474,9442,9408,9372,9333,9292,9249,9203,9156,9106,9055,9001,8947,8890,8832,8774,8714,
8653,8592,8530,8468,8406,8343,8281,8220,8159,8099,8039,7981,7923,7867,7812,7758,7706,
7655,7606,7558,7512,7467,7425,7384,7345,7307,7271,7237,7204,7174,7144,7116,7090,7065,
7041,7019,6998,6978,6959,6942,6925,6909,6894,6880,6867,6855,6843,6832,6821,6811,6802,
6794,6785,6778,6770,6764,6757,6751,6746,6741,6736,6731,6727,6723,6719,6715,6712,6709,
9525,9495,9464,9430,9395,9357,9318,9276,9232,9187,9139,9090,9039,8987,8933,8878,8822,
8766,8708,8650,8591,8532,8473,8414,8355,8297,8239,8182,8125,8070,8015,7962,7909,7858,
7808,7760,7713,7668,7624,7582,7542,7503,7465,7430,7396,7363,7332,7303,7275,7249,7224,
7200,7178,7157,7136,7118,7100,7083,7067,7052,7038,7025,7012,7000,6989,6978,6968,6959,
6950,6942,6934,6927,6920,6914,6908,6902,6897,6892,6887,6883,6878,6875,6871,6867,6864,
9572,9545,9516,9485,9453,9419,9382,9344,9304,9262,9218,9173,9126,9077,9028,8977,8925,
8871,8818,8763,8708,8652,8596,8540,8484,8428,8373,8318,8264,8210,8157,8105,8055,8005,
7956,7909,7863,7819,7776,7734,7694,7656,7619,7584,7550,7518,7487,7458,7430,7403,7378,
7355,7332,7311,7291,7272,7254,7237,7221,7206,7192,7178,7165,7153,7142,7132,7122,7112,
7103,7095,7087,7080,7073,7066,7060,7054,7049,7044,7039,7035,7030,7027,7023,7019,7016,
9615,9589,9563,9535,9505,9474,9440,9405,9369,9330,9290,9248,9205,9160,9114,9067,9019,
8969,8919,8868,8816,8763,8711,8658,8605,8552,8499,8446,8394,8343,8292,8242,8192,8144,
8097,8051,8006,7962,7920,7879,7840,7802,7766,7731,7698,7666,7635,7606,7578,7552,7527,
7503,7481,7459,7439,7420,7402,7385,7369,7354,7340,7326,7313,7301,7290,7279,7269,7259,
7251,7242,7234,7227,7220,7213,7207,7201,7196,7191,7186,7181,7177,7173,7169,7166,7163,
9653,9630,9605,9580,9553,9524,9493,9461,9428,9393,9356,9317,9277,9236,9194,9150,9105,
9059,9012,8965,8916,8867,8817,8768,8717,8667,8617,8567,8517,8468,8419,8370,8323,8276,
8230,8186,8142,8099,8058,8018,7980,7942,7907,7872,7839,7807,7777,7748,7721,7695,7670,
7646,7623,7602,7582,7563,7545,7528,7512,7496,7482,7468,7456,7443,7432,7421,7411,7401,
7392,7384,7376,7369,7361,7355,7349,7343,7337,7332,7327,7323,7318,7314,7311,7307,7304,
9688,9667,9644,9621,9596,9570,9542,9513,9482,9450,9416,9381,9344,9306,9267,9227,9185,
9143,9099,9055,9009,8964,8917,8870,8823,8775,8728,8680,8633,8585,8539,8492,8446,8401,
8357,8314,8271,8230,8190,8151,8113,8076,8041,8007,7975,7943,7914,7885,7858,7832,7807,
7783,7761,7740,7719,7700,7682,7665,7649,7634,7619,7606,7593,7581,7569,7558,7548,7538,
7529,7521,7513,7505,7498,7491,7485,7479,7474,7469,7464,7459,7455,7451,7447,7443,7440,
9722,9701,9681,9659,9636,9612,9587,9560,9532,9503,9472,9440,9406,9371,9335,9298,9260,
9221,9180,9139,9097,9054,9011,8967,8922,8877,8832,8787,8742,8697,8653,8608,8564,8521,
8478,8436,8395,8355,8316,8278,8241,8205,8171,8138,8106,8075,8045,8017,7990,7964,7939,
7916,7894,7873,7852,7833,7815,7798,7782,7767,7752,7739,7726,7714,7702,7691,7681,7671,
7662,7653,7645,7638,7631,7624,7618,7612,7606,7601,7596,7591,7587,7583,7579,7575,7572,
9752,9733,9714,9694,9674,9652,9629,9604,9579,9552,9524,9494,9464,9432,9399,9364,9329,
9293,9256,9217,9178,9139,9098,9057,9015,8973,8931,8888,8846,8803,8760,8718,8676,8635,
8594,8553,8513,8475,8437,8400,8364,8329,8295,8262,8231,8201,8172,8144,8117,8092,8067,
8044,8022,8001,7981,7962,7944,7927,7910,7895,7881,7867,7854,7842,7830,7819,7809,7799,
7790,7782,7773,7766,7759,7752,7746,7740,7734,7729,7724,7719,7715,7710,7707,7703,7700,
9780,9763,9745,9727,9708,9688,9667,9645,9621,9597,9571,9544,9516,9487,9457,9426,9393,
9360,9325,9290,9254,9217,9179,9141,9102,9063,9023,8983,8943,8902,8862,8822,8782,8742,
8703,8664,8626,8588,8551,8516,8481,8447,8414,8382,8351,8321,8293,8265,8239,8214,8190,
8167,8145,8124,8104,8085,8067,8050,8034,8019,8004,7991,7978,7965,7954,7943,7932,7923,
7914,7905,7897,7889,7882,7875,7869,7863,7857,7852,7847,7842,7838,7833,7830,7826,7822,
9807,9790,9774,9757,9740,9721,9702,9682,9661,9639,9615,9591,9565,9539,9511,9483,9453,
9422,9391,9358,9325,9290,9256,9220,9184,9147,9110,9072,9034,8996,8958,8920,8882,8844,
8806,8769,8732,8696,8661,8626,8592,8559,8527,8496,8466,8437,8409,8382,8356,8331,8308,
8285,8263,8242,8223,8204,8186,8169,8153,8138,8123,8110,8097,8085,8073,8062,8052,8042,
8033,8024,8016,8008,8001,7994,7988,7982,7976,7971,7966,7961,7957,7952,7949,7945,7941,
9831,9816,9800,9785,9769,9752,9735,9717,9698,9677,9656,9634,9611,9587,9561,9535,9508,
9480,9451,9421,9390,9359,9326,9293,9260,9225,9191,9156,9120,9084,9048,9012,8976,8940,
8904,8869,8834,8799,8765,8732,8699,8667,8636,8606,8576,8548,8520,8494,8469,8444,8421,
8398,8377,8356,8337,8318,8301,8284,8268,8253,8238,8225,8212,8199,8188,8177,8167,8157,
8148,8139,8131,8123,8116,8109,8103,8097,8091,8086,8080,8076,8071,8067,8063,8059,8056,
9854,9839,9825,9810,9796,9781,9765,9748,9731,9713,9694,9673,9652,9630,9607,9584,9559,
9533,9507,9479,9451,9422,9392,9361,9330,9299,9266,9233,9200,9167,9133,9099,9065,9031,
8997,8963,8929,8896,8863,8831,8800,8769,8739,8709,8681,8653,8627,8601,8576,8552,8529,
8507,8486,8465,8446,8428,8410,8393,8378,8363,8348,8335,8322,8310,8298,8287,8277,8267,
8258,8249,8241,8233,8226,8219,8213,8207,8201,8196,8191,8186,8181,8177,8173,8169,8166,
9874,9860,9846,9833,9820,9806,9792,9777,9761,9745,9727,9709,9690,9670,9649,9628,9605,
9582,9557,9532,9506,9480,9452,9424,9395,9366,9336,9305,9274,9243,9211,9179,9147,9115,
9083,9051,9019,8987,8956,8925,8895,8865,8836,8808,8780,8753,8727,8702,8678,8654,8632,
8610,8589,8569,8550,8532,8515,8498,8482,8467,8453,8440,8427,8415,8403,8392,8382,8372,
8363,8355,8346,8339,8331,8325,8318,8312,8306,8301,8296,8291,8287,8282,8278,8275,8271,
9892,9878,9866,9854,9841,9829,9816,9803,9788,9773,9758,9741,9724,9706,9687,9667,9647,
9626,9604,9581,9557,9533,9507,9482,9455,9428,9400,9372,9343,9314,9284,9254,9224,9194,
9163,9133,9103,9073,9043,9013,8984,8956,8928,8900,8874,8848,8822,8798,8774,8751,8729,
8708,8687,8668,8649,8631,8614,8598,8582,8567,8553,8540,8527,8515,8504,8493,8483,8473,
8464,8455,8447,8439,8432,8425,8419,8413,8407,8401,8396,8392,8387,8383,8379,8375,8372,
9908,9895,9883,9872,9860,9849,9837,9825,9812,9799,9785,9770,9754,9738,9721,9703,9685,
9665,9645,9624,9603,9581,9558,9534,9509,9484,9459,9433,9406,9379,9351,9323,9295,9267,
9238,9209,9181,9152,9124,9096,9068,9041,9014,8987,8962,8937,8912,8888,8865,8843,8821,
8800,8780,8761,8743,8725,8708,8692,8677,8662,8648,8635,8622,8610,8599,8588,8578,8568,
8559,8550,8542,8535,8527,8521,8514,8508,8502,8497,8492,8487,8483,8478,8474,8471,8467,
9922,9909,9898,9888,9877,9867,9856,9845,9834,9822,9809,9796,9782,9767,9752,9735,9719,
9701,9683,9664,9644,9624,9603,9581,9559,9536,9512,9488,9463,9438,9413,9387,9360,9334,
9307,9280,9253,9226,9199,9173,9146,9120,9094,9069,9044,9020,8996,8973,8951,8929,8908,
8888,8868,8849,8831,8814,8797,8781,8766,8752,8738,8725,8712,8700,8689,8678,8668,8659,
8650,8641,8633,8625,8618,8611,8605,8599,8593,8588,8582,8578,8573,8569,8565,8561,8558,
9935,9923,9912,9902,9893,9883,9873,9863,9853,9842,9831,9819,9806,9793,9779,9765,9750,
9734,9717,9700,9682,9664,9644,9625,9604,9583,9562,9539,9517,9493,9470,9445,9421,9396,
9371,9346,9320,9295,9270,9244,9219,9194,9170,9146,9122,9098,9076,9053,9032,9011,8990,
8970,8951,8933,8915,8898,8882,8866,8851,8837,8823,8810,8798,8786,8775,8765,8754,8745,
8736,8727,8719,8712,8704,8698,8691,8685,8679,8674,8669,8664,8660,8655,8651,8648,8644,
9946,9934,9924,9915,9906,9897,9889,9880,9870,9860,9850,9839,9828,9816,9804,9791,9777,
9763,9748,9732,9716,9700,9682,9664,9645,9626,9606,9586,9565,9544,9522,9499,9477,9453,
9430,9406,9383,9359,9335,9311,9287,9264,9240,9217,9194,9172,9150,9129,9108,9087,9067,
9048,9030,9012,8994,8978,8962,8947,8932,8918,8904,8892,8879,8868,8857,8846,8836,8827,
8818,8809,8801,8794,8786,8780,8773,8767,8761,8756,8751,8746,8742,8737,8733,8730,8726,
9956,9945,9935,9926,9918,9910,9902,9894,9885,9876,9867,9857,9847,9837,9826,9814,9802,
9789,9775,9761,9747,9731,9716,9699,9682,9665,9646,9628,9609,9589,9569,9548,9527,9506,
9484,9462,9440,9417,9395,9372,9350,9328,9305,9283,9262,9240,9219,9199,9178,9159,9140,
9121,9103,9086,9069,9052,9037,9022,9007,8994,8980,8968,8956,8944,8933,8923,8913,8904,
8895,8886,8878,8871,8863,8857,8850,8844,8839,8833,8828,8823,8819,8815,8811,8807,8803,
9965,9954,9944,9936,9928,9920,9913,9906,9898,9890,9882,9873,9864,9854,9844,9834,9823,
9811,9799,9787,9773,9760,9745,9730,9715,9699,9683,9665,9648,9630,9611,9592,9573,9553,
9533,9512,9492,9471,9450,9429,9408,9386,9365,9345,9324,9304,9283,9264,9244,9225,9207,
9189,9171,9154,9138,9122,9107,9092,9078,9065,9052,9039,9027,9016,9005,8995,8985,8976,
8967,8959,8951,8943,8936,8929,8923,8917,8911,8906,8901,8896,8892,8888,8884,8880,8876,
9973,9961,9952,9944,9936,9929,9923,9916,9909,9902,9894,9887,9878,9870,9861,9851,9842,
9831,9820,9809,9797,9785,9772,9758,9744,9730,9715,9699,9683,9667,9650,9632,9614,9596,
9577,9558,9539,9520,9500,9480,9460,9441,9421,9401,9381,9362,9343,9324,9305,9287,9269,
9252,9235,9219,9203,9187,9173,9158,9144,9131,9118,9106,9095,9083,9073,9063,9053,9044,
9035,9027,9019,9012,9004,8998,8991,8986,8980,8975,8970,8965,8960,8956,8952,8948,8945,
9980,9969,9959,9951,9944,9938,9932,9925,9919,9912,9906,9899,9891,9884,9876,9867,9858,
9849,9839,9829,9818,9807,9796,9783,9771,9758,9744,9730,9715,9700,9685,9669,9652,9635,
9618,9601,9583,9565,9546,9528,9509,9491,9472,9453,9435,9417,9398,9380,9363,9345,9328,
9311,9295,9279,9264,9249,9234,9220,9207,9194,9182,9170,9158,9147,9137,9127,9117,9108,
9100,9091,9084,9076,9069,9063,9056,9050,9045,9039,9034,9030,9025,9021,9017,9013,9010,
9987,9975,9966,9958,9951,9945,9939,9933,9928,9922,9916,9909,9903,9896,9889,9881,9873,
9865,9856,9847,9837,9827,9817,9806,9794,9782,9770,9757,9744,9730,9716,9701,9686,9671,
9655,9639,9622,9606,9589,9571,9554,9537,9519,9502,9484,9467,9449,9432,9415,9399,9382,
9366,9351,9335,9320,9306,9292,9278,9265,9253,9241,9229,9218,9207,9197,9187,9177,9168,
9160,9152,9144,9137,9130,9123,9117,9111,9106,9100,9095,9091,9086,9082,9078,9075,9071,
9992,9981,9971,9964,9957,9951,9946,9940,9935,9930,9924,9918,9912,9906,9900,9893,9886,
9878,9871,9862,9854,9845,9835,9825,9815,9804,9793,9781,9769,9757,9744,9730,9717,9703,
9688,9673,9658,9643,9627,9611,9595,9578,9562,9546,9529,9513,9496,9480,9464,9448,9433,
9417,9402,9388,9373,9359,9346,9332,9320,9307,9296,9284,9273,9263,9253,9243,9234,9225,
9216,9208,9201,9194,9187,9180,9174,9168,9163,9158,9153,9148,9144,9139,9136,9132,9128,
9998,9986,9976,9969,9962,9957,9951,9946,9941,9936,9931,9926,9921,9915,9909,9903,9897,
9890,9883,9876,9868,9860,9851,9843,9833,9824,9813,9803,9792,9781,9769,9757,9744,9731,
9718,9704,9690,9676,9661,9647,9632,9617,9601,9586,9570,9555,9540,9524,9509,9494,9479,
9464,9450,9436,9422,9409,9396,9383,9371,9359,9347,9336,9325,9315,9305,9296,9286,9278,
9270,9262,9254,9247,9240,9234,9228,9222,9217,9211,9206,9202,9197,9193,9189,9186,9182,
10000,9990,9981,9973,9967,9961,9956,9952,9947,9942,9938,9933,9928,9923,9918,9912,9907,
9901,9894,9888,9881,9874,9866,9858,9849,9841,9832,9822,9812,9802,9791,9780,9769,9757,
9745,9732,9719,9706,9693,9679,9665,9651,9637,9623,9608,9594,9579,9565,9551,9536,9522,
9508,9494,9481,9468,9455,9442,9430,9418,9406,9395,9384,9374,9364,9354,9345,9336,9327,
9319,9312,9304,9297,9291,9284,9278,9272,9267,9262,9257,9252,9248,9244,9240,9236,9233,
10000,9994,9985,9977,9971,9966,9961,9956,9952,9948,9944,9939,9935,9930,9925,9921,9915,
9910,9904,9898,9892,9885,9879,9871,9864,9856,9848,9839,9830,9821,9811,9801,9791,9780,
9769,9758,9746,9734,9721,9709,9696,9683,9670,9656,9643,9629,9616,9602,9589,9575,9562,
9549,9536,9523,9510,9498,9485,9474,9462,9451,9440,9430,9419,9410,9400,9391,9382,9374,
9366,9358,9351,9344,9338,9331,9325,9320,9314,9309,9305,9300,9296,9292,9288,9284,9281,
10000,9998,9989,9981,9975,9970,9965,9961,9957,9953,9949,9945,9941,9936,9932,9928,9923,
9918,9913,9908,9902,9896,9890,9883,9877,9870,9862,9854,9846,9838,9829,9820,9811,9801,
9791,9780,9770,9759,9747,9736,9724,9712,9700,9687,9675,9662,9649,9637,9624,9611,9599,
9586,9574,9561,9549,9537,9526,9514,9503,9492,9482,9472,9462,9452,9443,9434,9426,9418,
9410,9402,9395,9388,9382,9376,9370,9364,9359,9354,9349,9345,9340,9336,9333,9329,9326,
10000,10000,9992,9985,9978,9973,9969,9965,9961,9957,9953,9950,9946,9942,9938,9934,9930,
9925,9921,9916,9911,9906,9900,9894,9888,9882,9875,9868,9861,9853,9845,9837,9829,9820,
9810,9801,9791,9781,9771,9760,9749,9738,9727,9715,9704,9692,9680,9668,9656,9644,9632,
9621,9609,9597,9586,9574,9563,9552,9542,9531,9521,9511,9502,9492,9484,9475,9467,9459,
9451,9444,9437,9430,9424,9418,9412,9406,9401,9396,9391,9387,9383,9379,9375,9371,9368,
10000,10000,9996,9988,9982,9977,9972,9968,9964,9961,9958,9954,9951,9947,9944,9940,9936,
9932,9928,9923,9919,9914,9909,9904,9898,9893,9887,9880,9874,9867,9860,9852,9845,9837,
9828,9820,9811,9801,9792,9782,9772,9762,9752,9741,9730,9719,9708,9697,9686,9675,9664,
9653,9641,9630,9619,9609,9598,9588,9577,9567,9558,9548,9539,9530,9521,9513,9505,9497,
9490,9482,9476,9469,9463,9457,9451,9446,9440,9436,9431,9427,9422,9418,9415,9411,9408,
10000,10000,9999,9991,9985,9980,9975,9971,9968,9965,9961,9958,9955,9952,9948,9945,9941,
9938,9934,9930,9926,9922,9917,9912,9907,9902,9897,9891,9885,9879,9873,9866,9859,9852,
9844,9836,9828,9820,9811,9802,9793,9784,9774,9764,9754,9744,9734,9724,9713,9703,9692,
9682,9671,9661,9651,9640,9630,9620,9611,9601,9592,9583,9574,9565,9557,9548,9541,9533,
9526,9519,9512,9506,9499,9494,9488,9483,9478,9473,9468,9464,9460,9456,9452,9448,9445,
10000,10000,10000,9994,9988,9983,9978,9974,9971,9968,9965,9962,9959,9956,9953,9950,9946,
9943,9940,9936,9932,9928,9924,9920,9916,9911,9906,9901,9896,9890,9884,9878,9872,9865,
9858,9851,9844,9836,9828,9820,9812,9803,9795,9786,9776,9767,9758,9748,9738,9729,9719,
9709,9699,9689,9680,9670,9660,9651,9641,9632,9623,9615,9606,9598,9590,9582,9574,9567,
9560,9553,9546,9540,9534,9528,9523,9517,9512,9508,9503,9499,9495,9491,9487,9484,9480,
10000,10000,10000,9997,9990,9985,9981,9977,9974,9971,9968,9965,9962,9959,9957,9954,9951,
9948,9945,9941,9938,9934,9931,9927,9923,9919,9914,9910,9905,9900,9895,9889,9883,9877,
9871,9865,9858,9851,9844,9837,9829,9821,9813,9805,9796,9788,9779,9770,9761,9752,9743,
9734,9725,9715,9706,9697,9688,9679,9670,9661,9653,9644,9636,9628,9620,9613,9605,9598,
9591,9585,9578,9572,9566,9561,9555,9550,9545,9540,9536,9532,9528,9524,9520,9517,9513,
10000,10000,10000,9999,9993,9988,9983,9980,9976,9973,9971,9968,9965,9963,9960,9957,9955,
9952,9949,9946,9943,9940,9936,9933,9929,9925,9921,9917,9913,9908,9904,9899,9894,9888,
9883,9877,9871,9864,9858,9851,9844,9837,9830,9822,9814,9807,9799,9790,9782,9774,9765,
9757,9748,9739,9731,9722,9713,9705,9696,9688,9680,9672,9664,9656,9649,9641,9634,9627,
9621,9614,9608,9602,9596,9591,9586,9581,9576,9571,9567,9563,9559,9555,9551,9548,9545,
10000,10000,10000,10000,9995,9990,9986,9982,9979,9976,9973,9971,9968,9966,9963,9961,9958,
9956,9953,9950,9947,9945,9941,9938,9935,9932,9928,9924,9920,9916,9912,9907,9903,9898,
9893,9888,9882,9876,9871,9864,9858,9852,9845,9838,9831,9824,9816,9809,9801,9793,9785,
9777,9769,9761,9753,9745,9737,9729,9721,9713,9705,9698,9690,9683,9675,9668,9662,9655,
9648,9642,9636,9630,9625,9619,9614,9609,9604,9600,9596,9591,9588,9584,9580,9577,9574,
10000,10000,10000,10000,9997,9992,9988,9984,9981,9978,9976,9973,9971,9968,9966,9964,9961,
9959,9957,9954,9952,9949,9946,9943,9940,9937,9934,9930,9927,9923,9919,9915,9911,9907,
9902,9897,9892,9887,9882,9876,9871,9865,9859,9852,9846,9839,9832,9825,9818,9811,9804,
9796,9789,9781,9774,9766,9759,9751,9744,9736,9729,9721,9714,9707,9700,9693,9687,9680,
9674,9668,9662,9657,9651,9646,9641,9636,9631,9627,9623,9619,9615,9611,9608,9604,9601,
10000,10000,10000,10000,9999,9994,9990,9986,9983,9980,9978,9975,9973,9971,9969,9967,9964,
9962,9960,9958,9955,9953,9950,9948,9945,9942,9939,9936,9933,9930,9926,9922,9919,9915,
9911,9906,9902,9897,9892,9887,9882,9877,9871,9865,9859,9853,9847,9841,9834,9828,9821,
9814,9807,9800,9793,9786,9779,9772,9765,9757,9751,9744,9737,9730,9723,9717,9711,9704,
9698,9693,9687,9681,9676,9671,9666,9661,9657,9652,9648,9644,9641,9637,9634,9630,9627,
10000,10000,10000,10000,10000,9996,9992,9988,9985,9982,9980,9978,9976,9973,9971,9969,9967,
9965,9963,9961,9959,9957,9954,9952,9949,9947,9944,9941,9938,9935,9932,9929,9925,9922,
9918,9914,9910,9906,9902,9897,9892,9887,9882,9877,9872,9866,9860,9855,9849,9843,9836,
9830,9824,9817,9811,9804,9797,9791,9784,9777,9771,9764,9758,9751,9745,9739,9733,9727,
9721,9715,9710,9705,9699,9694,9690,9685,9681,9676,9672,9668,9665,9661,9658,9655,9652,
10000,10000,10000,10000,10000,9998,9994,9990,9987,9984,9982,9980,9978,9976,9974,9972,9970,
9968,9966,9964,9962,9960,9958,9956,9953,9951,9949,9946,9943,9941,9938,9935,9932,9928,
9925,9922,9918,9914,9910,9906,9902,9897,9893,9888,9883,9878,9873,9867,9862,9856,9851,
9845,9839,9833,9827,9821,9814,9808,9802,9796,9790,9783,9777,9771,9765,9759,9753,9748,
9742,9737,9731,9726,9721,9717,9712,9707,9703,9699,9695,9691,9688,9684,9681,9678,9675,
10000,10000,10000,10000,10000,10000,9996,9992,9989,9987,9984,9982,9980,9978,9976,9974,9973,
9971,9969,9967,9965,9963,9961,9959,9957,9955,9953,9951,9948,9946,9943,9940,9938,9935,
9932,9928,9925,9922,9918,9914,9910,9906,9902,9898,9893,9889,9884,9879,9874,9869,9864,
9858,9853,9847,9842,9836,9830,9824,9819,9813,9807,9801,9795,9790,9784,9778,9773,9767,
9762,9757,9752,9747,9742,9737,9733,9729,9724,9720,9716,9713,9709,9706,9702,9699,9696,
10000,10000,10000,10000,10000,10000,9998,9994,9991,9988,9986,9984,9982,9980,9979,9977,9975,
9973,9972,9970,9968,9966,9965,9963,9961,9959,9957,9955,9953,9950,9948,9945,9943,9940,
9937,9935,9932,9928,9925,9922,9918,9915,9911,9907,9903,9899,9894,9890,9885,9881,9876,
9871,9866,9861,9856,9850,9845,9840,9834,9829,9823,9818,9812,9807,9801,9796,9791,9786,
9781,9776,9771,9766,9761,9757,9753,9748,9744,9740,9737,9733,9729,9726,9723,9720,9717,
10000,10000,10000,10000,10000,10000,9999,9996,9993,9990,9988,9986,9984,9982,9981,9979,9978,
9976,9974,9973,9971,9969,9968,9966,9964,9962,9961,9959,9957,9955,9952,9950,9948,9945,
9943,9940,9938,9935,9932,9929,9926,9922,9919,9915,9912,9908,9904,9900,9896,9891,9887,
9882,9878,9873,9868,9863,9859,9854,9848,9843,9838,9833,9828,9823,9818,9813,9808,9803,
9798,9793,9789,9784,9780,9775,9771,9767,9763,9759,9756,9752,9749,9745,9742,9739,9736,
10000,10000,10000,10000,10000,10000,10000,9998,9995,9992,9990,9988,9986,9984,9983,9981,9980,
9978,9977,9975,9974,9972,9971,9969,9967,9966,9964,9962,9960,9958,9956,9954,9952,9950,
9948,9946,9943,9940,9938,9935,9932,9929,9926,9923,9920,9916,9912,9909,9905,9901,9897,
9893,9889,9884,9880,9875,9871,9866,9862,9857,9852,9847,9843,9838,9833,9828,9823,9819,
9814,9810,9805,9801,9797,9792,9788,9784,9781,9777,9773,9770,9767,9763,9760,9757,9755,
10000,10000,10000,10000,10000,10000,10000,9999,9996,9994,9991,9990,9988,9986,9985,9983,9982,
9980,9979,9977,9976,9975,9973,9972,9970,9969,9967,9965,9964,9962,9960,9958,9956,9954,
9952,9950,9948,9946,9943,9941,9938,9935,9933,9930,9927,9923,9920,9917,9913,9910,9906,
9902,9899,9895,9891,9886,9882,9878,9874,9869,9865,9860,9856,9851,9847,9842,9838,9833,
9829,9825,9821,9816,9812,9808,9804,9801,9797,9793,9790,9787,9783,9780,9777,9774,9772,
10000,10000,10000,10000,10000,10000,10000,10000,9997,9995,9993,9991,9989,9988,9986,9985,9983,
9982,9981,9979,9978,9977,9975,9974,9973,9971,9970,9968,9967,9965,9963,9962,9960,9958,
9956,9954,9952,9950,9948,9946,9943,9941,9938,9936,9933,9930,9927,9924,9921,9918,9914,
9911,9907,9904,9900,9896,9892,9888,9884,9880,9876,9872,9868,9864,9860,9855,9851,9847,
9843,9839,9835,9831,9827,9823,9819,9816,9812,9809,9805,9802,9799,9796,9793,9790,9788,
10000,10000,10000,10000,10000,10000,10000,10000,9999,9996,9994,9992,9990,9989,9987,9986,9985,
9984,9982,9981,9980,9979,9977,9976,9975,9973,9972,9971,9969,9968,9966,9965,9963,9961,
9960,9958,9956,9954,9952,9950,9948,9946,9943,9941,9939,9936,9933,9931,9928,9925,9922,
9919,9915,9912,9909,9905,9902,9898,9894,9891,9887,9883,9879,9875,9871,9867,9863,9859,
9855,9852,9848,9844,9840,9837,9833,9830,9826,9823,9820,9816,9813,9811,9808,9805,9802,
10000,10000,10000,10000,10000,10000,10000,10000,9999,9997,9995,9993,9991,9990,9989,9987,9986,
9985,9984,9982,9981,9980,9979,9978,9977,9975,9974,9973,9971,9970,9969,9967,9966,9964,
9963,9961,9959,9958,9956,9954,9952,9950,9948,9946,9944,9941,9939,9936,9934,9931,9928,
9925,9923,9919,9916,9913,9910,9907,9903,9900,9896,9893,9889,9885,9882,9878,9874,9871,
9867,9863,9860,9856,9853,9849,9846,9842,9839,9836,9833,9830,9827,9824,9821,9819,9816,
10000,10000,10000,10000,10000,10000,10000,10000,10000,9998,9996,9994,9992,9991,9990,9988,9987,
9986,9985,9984,9983,9981,9980,9979,9978,9977,9976,9975,9973,9972,9971,9970,9968,9967,
9965,9964,9962,9961,9959,9957,9956,9954,9952,9950,9948,9946,9944,9941,9939,9937,9934,
9932,9929,9926,9923,9920,9917,9914,9911,9908,9905,9902,9898,9895,9891,9888,9885,9881,
9878,9874,9871,9867,9864,9861,9857,9854,9851,9848,9845,9842,9839,9837,9834,9831,9829,
10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9996,9995,9993,9992,9990,9989,9988,
9987,9986,9985,9984,9983,9982,9981,9980,9978,9977,9976,9975,9974,9973,9972,9970,9969,
9968,9966,9965,9964,9962,9961,9959,9957,9956,9954,9952,9950,9948,9946,9944,9942,9939,
9937,9935,9932,9930,9927,9924,9921,9918,9916,9913,9910,9906,9903,9900,9897,9894,9891,
9887,9884,9881,9878,9875,9871,9868,9865,9862,9859,9856,9854,9851,9848,9846,9843,9841,
10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9997,9995,9994,9992,9991,9990,9989,
9988,9987,9986,9985,9984,9983,9982,9981,9980,9979,9978,9977,9976,9975,9973,9972,9971,
9970,9969,9967,9966,9965,9963,9962,9960,9959,9957,9955,9954,9952,9950,9948,9946,9944,
9942,9940,9937,9935,9933,9930,9928,9925,9922,9920,9917,9914,9911,9908,9905,9902,9899,
9896,9893,9890,9887,9884,9881,9878,9875,9873,9870,9867,9864,9862,9859,9857,9854,9852,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9998,9996,9994,9993,9992,9990,9989,
9988,9987,9986,9986,9985,9984,9983,9982,9981,9980,9979,9978,9977,9976,9975,9974,9973,
9972,9971,9969,9968,9967,9966,9964,9963,9962,9960,9959,9957,9955,9954,9952,9950,9948,
9946,9944,9942,9940,9938,9936,9933,9931,9928,9926,9923,9921,9918,9915,9913,9910,9907,
9904,9901,9899,9896,9893,9890,9887,9885,9882,9879,9877,9874,9872,9869,9867,9864,9862,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9998,9996,9995,9993,9992,9991,9990,
9989,9988,9987,9986,9985,9985,9984,9983,9982,9981,9980,9979,9978,9977,9976,9975,9974,
9973,9972,9971,9970,9969,9968,9967,9965,9964,9963,9961,9960,9958,9957,9955,9954,9952,
9950,9948,9946,9945,9943,9940,9938,9936,9934,9932,9929,9927,9924,9922,9919,9917,9914,
9912,9909,9906,9904,9901,9898,9896,9893,9891,9888,9886,9883,9881,9878,9876,9874,9872,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9997,9995,9994,9993,9992,9991,
9990,9989,9988,9987,9986,9985,9984,9984,9983,9982,9981,9980,9979,9979,9978,9977,9976,
9975,9974,9973,9972,9971,9970,9969,9967,9966,9965,9964,9963,9961,9960,9958,9957,9955,
9954,9952,9950,9949,9947,9945,9943,9941,9939,9937,9935,9932,9930,9928,9926,9923,9921,
9918,9916,9913,9911,9909,9906,9904,9901,9899,9896,9894,9892,9889,9887,9885,9883,9881,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9997,9996,9994,9993,9992,9991,
9990,9989,9988,9988,9987,9986,9985,9984,9984,9983,9982,9981,9980,9980,9979,9978,9977,
9976,9975,9974,9973,9973,9972,9970,9969,9968,9967,9966,9965,9964,9962,9961,9960,9958,
9957,9955,9954,9952,9951,9949,9947,9945,9943,9942,9940,9938,9935,9933,9931,9929,9927,
9925,9922,9920,9918,9915,9913,9911,9908,9906,9904,9902,9899,9897,9895,9893,9891,9889,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9998,9996,9995,9994,9993,9992,
9991,9990,9989,9988,9987,9987,9986,9985,9984,9984,9983,9982,9981,9981,9980,9979,9978,
9977,9977,9976,9975,9974,9973,9972,9971,9970,9969,9968,9967,9966,9965,9964,9962,9961,
9960,9958,9957,9956,9954,9952,9951,9949,9948,9946,9944,9942,9940,9938,9936,9934,9932,
9930,9928,9926,9924,9922,9920,9917,9915,9913,9911,9909,9907,9905,9903,9901,9899,9897,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9998,9997,9995,9994,9993,9992,
9991,9990,9990,9989,9988,9987,9987,9986,9985,9984,9984,9983,9982,9982,9981,9980,9979,
9979,9978,9977,9976,9975,9975,9974,9973,9972,9971,9970,9969,9968,9967,9966,9965,9964,
9962,9961,9960,9959,9957,9956,9954,9953,9951,9950,9948,9946,9945,9943,9941,9939,9937,
9935,9933,9931,9929,9927,9925,9923,9921,9919,9917,9915,9913,9911,9909,9908,9906,9904,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9997,9996,9995,9994,9993,
9992,9991,9990,9989,9989,9988,9987,9987,9986,9985,9985,9984,9983,9983,9982,9981,9980,
9980,9979,9978,9977,9977,9976,9975,9974,9973,9973,9972,9971,9970,9969,9968,9967,9966,
9965,9964,9962,9961,9960,9959,9957,9956,9955,9953,9952,9950,9949,9947,9945,9944,9942,
9940,9938,9937,9935,9933,9931,9929,9927,9925,9923,9921,9920,9918,9916,9914,9912,9911,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9998,9996,9995,9994,9993,
9992,9991,9991,9990,9989,9988,9988,9987,9987,9986,9985,9985,9984,9983,9983,9982,9981,
9981,9980,9979,9979,9978,9977,9976,9976,9975,9974,9973,9972,9972,9971,9970,9969,9968,
9967,9966,9965,9964,9963,9961,9960,9959,9958,9956,9955,9954,9952,9951,9949,9948,9946,
9944,9943,9941,9939,9938,9936,9934,9932,9931,9929,9927,9925,9924,9922,9920,9918,9917,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9998,9997,9996,9994,9994,
9993,9992,9991,9990,9990,9989,9988,9988,9987,9987,9986,9985,9985,9984,9984,9983,9982,
9982,9981,9980,9980,9979,9978,9978,9977,9976,9976,9975,9974,9973,9972,9972,9971,9970,
9969,9968,9967,9966,9965,9964,9963,9962,9961,9959,9958,9957,9956,9954,9953,9951,9950,
9948,9947,9945,9944,9942,9941,9939,9937,9936,9934,9932,9931,9929,9927,9926,9924,9923,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9997,9996,9995,9994,
9993,9992,9992,9991,9990,9990,9989,9988,9988,9987,9987,9986,9985,9985,9984,9984,9983,
9983,9982,9981,9981,9980,9979,9979,9978,9978,9977,9976,9975,9975,9974,9973,9972,9972,
9971,9970,9969,9968,9967,9966,9965,9964,9963,9962,9961,9960,9959,9957,9956,9955,9953,
9952,9951,9949,9948,9946,9945,9943,9942,9940,9939,9937,9936,9934,9933,9931,9930,9928,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9998,9996,9995,9994,
9994,9993,9992,9991,9991,9990,9990,9989,9988,9988,9987,9987,9986,9986,9985,9985,9984,
9983,9983,9982,9982,9981,9981,9980,9979,9979,9978,9977,9977,9976,9975,9975,9974,9973,
9972,9972,9971,9970,9969,9968,9967,9967,9966,9965,9964,9962,9961,9960,9959,9958,9957,
9955,9954,9953,9952,9950,9949,9947,9946,9945,9943,9942,9940,9939,9937,9936,9934,9933,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9998,9997,9996,9995,
9994,9993,9993,9992,9991,9991,9990,9989,9989,9988,9988,9987,9987,9986,9986,9985,9985,
9984,9984,9983,9983,9982,9981,9981,9980,9980,9979,9979,9978,9977,9977,9976,9975,9975,
9974,9973,9973,9972,9971,9970,9969,9969,9968,9967,9966,9965,9964,9963,9962,9961,9960,
9959,9957,9956,9955,9954,9952,9951,9950,9949,9947,9946,9944,9943,9942,9940,9939,9938,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9997,9996,9995,
9994,9994,9993,9992,9992,9991,9990,9990,9989,9989,9988,9988,9987,9987,9986,9986,9985,
9985,9984,9984,9983,9983,9982,9982,9981,9981,9980,9980,9979,9978,9978,9977,9977,9976,
9975,9975,9974,9973,9973,9972,9971,9970,9970,9969,9968,9967,9966,9965,9964,9963,9962,
9961,9960,9959,9958,9957,9956,9954,9953,9952,9951,9950,9948,9947,9946,9945,9943,9942,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9998,9997,9996,
9995,9994,9993,9993,9992,9991,9991,9990,9990,9989,9989,9988,9988,9987,9987,9986,9986,
9985,9985,9984,9984,9983,9983,9982,9982,9981,9981,9980,9980,9979,9979,9978,9978,9977,
9977,9976,9975,9975,9974,9973,9973,9972,9971,9971,9970,9969,9968,9967,9966,9966,9965,
9964,9963,9962,9961,9960,9959,9957,9956,9955,9954,9953,9952,9951,9949,9948,9947,9946,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9998,9997,9996,
9995,9994,9993,9993,9992,9992,9991,9990,9990,9989,9989,9989,9988,9988,9987,9987,9986,
9986,9985,9985,9984,9984,9983,9983,9983,9982,9982,9981,9981,9980,9980,9979,9979,9978,
9977,9977,9976,9976,9975,9975,9974,9973,9973,9972,9971,9971,9970,9969,9968,9967,9967,
9966,9965,9964,9963,9962,9961,9960,9959,9958,9957,9956,9955,9954,9953,9951,9950,9949,
10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,9999,9998,9997,9996,
9995,9994,9993,9993,9992,9992,9991,9991,9990,9990,9989,9989,9988,9988,9987,9987,9986,
9986,9986,9985,9985,9984,9984,9983,9983,9983,9982,9982,9981,9981,9980,9980,9979,9979,
9978,9978,9977,9977,9976,9976,9975,9974,9974,9973,9973,9972,9971,9970,9970,9969,9968,
9967,9967,9966,9965,9964,9963,9962,9961,9960,9959,9958,9957,9956,9955,9954,9953,9952
)

factorOptionA = new Array
(0,0,0,0,0,0,0,0,1,1,
	1,1,1,1,1,1,2,2,2,2,
	2,2,2,3,3,3,3,3,3,3,
	4,4,4,4,4,4,5,6,7,8,
	9,10,20,30,40,50,60,70,80,90,
	100,110,120,130,140,150,160,170,180,190,
	200,210,220,230,240,250);

} // End of function InitFactorArrays() 

InitFactorArrays() 

// general purpose function to see if an input value has been entered at all
function isEmpty(inputStr) {
	 if	(inputStr == ""	|| inputStr	== null) {
		return true;
	 }
	 return	false;
}


function initFormFieldFocus()
{
	focusField(document.getElementById("mb"));
	validateChkBox();
	return true;
}

function focusField(target)
{
	// The form elements that will be tested. Anything with a dot indicates the "type" attribute of the element
	var formElements = ["input.text", "input.checkbox", "input.radio", "select", "textarea"];
	var selectedNode = null;

	// IE's selection method
	if (typeof document.selection != "undefined" && document.selection != null && typeof window.opera == "undefined")
	{
		var theSelection = document.selection;
		var textRange = document.selection.createRange();

		selectedNode = textRange.parentElement();
	}
	// W3 selection method. Currently only Mozilla & Safari support it. However, neither of them support ranges inside form objects, so this part is redundant. Merely included in case they decide to include support in the future
	else if (typeof window.getSelection != "undefined")
	{
		var theSelection = window.getSelection();

		// The Safari way to get the node that a selection starts in
		if (typeof theSelection.baseNode != "undefined")
		{
			selectedNode = theSelection.baseNode;
		}
		// The Mozilla way to get the node that a selection starts in
		else if (typeof theSelection.getRangeAt != "undefined" && theSelection.rangeCount > 0)
		{
			selectedNode = theSelection.getRangeAt(0).startContainer;
		}
	}

	// If a selected node was found above, check whether it's a selection inside one of the specified form element types
	if (selectedNode != null)
	{
		for (var i = 0; i < formElements.length; i++)
		{
			if (selectedNode.nodeName.toLowerCase() == formElements[i].replace(/([^.]*)\..*/, "$1"))
			{
				return false;
			}
		}
	}

	var forms = document.forms;

	// Do a check of each form element on the page. If one of them has a value, do not focus
	for (var i = 0; i < forms.length; i++)
	{
		var formElements = forms[i];

		for (var j = 0; j < formElements.length; j++)
		{
			if (formElements[j].getAttribute("type") == "checkbox" || formElements[j].getAttribute("type") == "radio")
			{
				if (formElements[j].checked != formElements[j].defaultChecked)
				{
					return false;
				}
			}
			else
			{
				if (typeof formElements[j].defaultValue != "undefined" && formElements[j].value != formElements[j].defaultValue)
				{
					return false;
				}
			}
		}
	}

	// If no form elements were found to be focused -- or with values -- go ahead and focus
	//target.focus(); 
	//Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.
	
	try{
		target.focus();
		//element.focus();
		//blah blah whatever
	}
	catch(er){
		//ignore and continue, or do something else
	}
	
	return false;
}


// function to determine if value is in acceptable range for this application
function inRange(inputStr, lo, hi) {
	var num = parseInt(inputStr, 10);
	if (num < lo || num > hi) {
	return false;
}
	return true;
}
// **END GENERIC VALIDATION FUNCTIONS** 

function checkNumber(input, min, max, msg)
{   
	msg = msg + " field has invalid data: " + input.value;
    var str = input.value;	
    for (var i = 0; i < str.length; i++) {
        var ch = str.substring(i, i + 1)
        if ((ch < "0" || "9" < ch) && ch != '.') {
            alert(msg);
			input.focus();
			//input.select();
            return false;
        }
    }
	
    var num = 0 + str
    if (num < min || max < num) {
        alert(msg + " not in range [" + min + ".." + max + "]");
        return false;
    }
    input.value = str;
    return true;
}

function custRound(x,places) {
    return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
}

function CurrencyFormatted(amount)
{
    var n = parseFloat(amount);
    if(isNaN(n)) { n = 0.00; }
    var minus = '';
    if(n < 0) { minus = '-'; }
    n = Math.abs(n);
    n = parseInt((n + .005) * 100);
    n = n / 100;
    s = new String(n);
    if(s.indexOf('.') < 0) { s += '.00'; }
    if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
    s = minus + s;
    return s;
} // function CurrencyFormatted()

function CommaFormatted(amount)
{
    var delimiter = ",";
    var a = amount.split('.',2)
    var d = a[1];
    var i = parseInt(a[0]);
    if(isNaN(i)) { return ''; }
    var minus = '';
    if(i < 0) { minus = '-'; }
    i = Math.abs(i);
    var n = new String(i);
    var a = [];
    while(n.length > 3)
    {
        var nn = n.substr(n.length-3);
        a.unshift(nn);
        n = n.substr(0,n.length-3);
    }
    if(n.length > 0) { a.unshift(n); }
    n = a.join(delimiter);
    if(d.length < 1) { amount = n; }
    else { amount = n + '.' + d; }
    amount = minus + amount;
    return amount;
} // function CommaFormatted()

function validateAgeFactor(field) {
 var input = field.value;
    //if ((!input == null || !input.length == 0)){
    if (!input.value <= '0.00')
        {
        alert("Please select AgeFactor drop downd menu." + input);
        document.frmCal.YRofServices.value = "0.0.0";        
        select(field);
    }
    computeForm();
    return true;
}// function validateAgeFactor(field)

function validateYRofServices(field, varVeteran) {
 var input = field.value;
 var varMV = varVeteran
//= document.frmCal.militaryveteran.value;
		 if ((!input == null || !input.length == 0) && (varMV == "Yes")){
				if (!checkNumber(document.frmCal.YRofServices, 10, 45, "5. Enter your years of service"))
					{
					document.frmCal.YRofServices.value = "Invalid";			 
					}
		}else if ((!input == null || !input.length == 0) && (varMV == "No")){
				if (!checkNumber(document.frmCal.YRofServices, 10, 45, "5. Enter your years of service"))
					{
					document.frmCal.YRofServices.value = "Invalid";			 
					}
		}else{
				alert("5. Enter your years of service is a required field")		
		}//if ((!input == null || !input.length == 0) && (varMV == "Yes"))
  
	field.focus();	
    computeForm();
    return true;
}// function validateYRofServices(field)

function validateYRAverageSalary(field){
 var input = field.value;
    if ((!input == null || !input.length == 0)){
        if (!checkNumber(document.frmCal.YRAverageSalary, 1, 2000000, "6. Enter your highest 3-year salary average"))
        {
        document.frmCal.YRAverageSalary.value = "Invalid";		
        }
    }
	field.focus();
    computeForm();
    return true;
}// function validateYRAverageSalary(field)

function validateisYear(field){
 var input = field.value;
    if ((!input == null || !input.length == 0)){
        if (!checkNumber(document.frmCal.yb, 1900, 2200, "1. your date of birth (year)"))//range 1900 - 2200 years
        {
        document.frmCal.yb.value = "Invalid";					
        }
    }
	field.focus();
    computeForm();
    return true;
}//function validateisYear(field)


function validateisYearyp(field){
 var input = field.value;
	if ((!input == null || !input.length == 0)){	
		if (!checkNumber(document.frmCal.yp, 1900, 2200, "2. Your projected date of retirement (year)"))//range 1900 - 2200 years
		{
			document.frmCal.yp.value = "Invalid";		
		}
	}
	field.focus();
    computeForm();
    return true;
}//function validateisYearyp(field)


function validateisYearybBeny(field){
 var input = field.value;
	if ((!input == null || !input.length == 0)){	
		if (!checkNumber(document.frmCal.ybBeny, 1900, 2200, "Your beneficiary's age (year)"))//range 1900 - 2200 years
		{
			document.frmCal.ybBeny.value = "Invalid";		
		}
	}
	field.focus();
    computeForm();
    return true;
}//function validateisYearybBeny(field)


/** For calendar ***/
function getMonthLength(month,year,julianFlag)
{
   var ml;
   if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
      {ml = 31;}
   else {
       if(month==2) {
          ml = 28;
          if(!(year%4) && (julianFlag==1 || year%100 || !(year%400)))
             ml++;
       }
       else
          {ml = 30;}
   }
   return ml;
}//function getMonthLength(month,year,julianFlag)

//work with UTC (Universal Time Coordinated) time, or GMT, rather than the computer's local time.
function useCurrentDate(field)
{   //var input = field.value;
	var months = new Array(13);
	months[1]="January"; 
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	var time = new Date(); //creates a new Date object 
	//var lmonth=months[time.getMonth() + 1];
	var lmonth = time.getMonth() + 1; //Retrieves the month component of the date as a number from 0 to 11 (0=January, 1=February, etc)
	var date = time.getDate(); //Retrieves the day-of-month component of the date as a number from 1 to 31
	var year = time.getFullYear(); // Retrieves the year component of the date as a 4-digit number
	if (year < 2000)
	year = year + 1900;
	
	document.frmCal.yp.value = year;
	document.frmCal.mp.selectedIndex = lmonth;
	document.frmCal.dp.value = date;
	computeForm();
	return true;
}


function validateChkBox()
{ 
  if (true){  // I agree, disable = false
		//alert("Thank You");
		document.frmCal.mb.disabled = false;
		document.frmCal.db.disabled = false;
		document.frmCal.yb.disabled = false;
		document.frmCal.mp.disabled = false;
		document.frmCal.dp.disabled = false;
		document.frmCal.yp.disabled = false;
		document.frmCal.groupmember[0].disabled = false;
		document.frmCal.groupmember[1].disabled = false;
		document.frmCal.groupmember[2].disabled = false;
		document.frmCal.militaryveteran[0].disabled = false;
		document.frmCal.militaryveteran[1].disabled = false;
		document.frmCal.YRofServices.disabled = false;
		document.frmCal.yrserMM.disabled = false;
		document.frmCal.YRAverageSalary.disabled = false;
		//document.frmCal.R7q.disabled = false;
		document.frmCal.yaAdisplayonly.disabled = false;
		document.frmCal.OpAyaservicedisplay.disabled = false;
		document.frmCal.PercentFactor.disabled = false;
		document.frmCal.YRAverageSalarydisplay.disabled = false;
		document.frmCal.Aveteranbenf.disabled = false;
		document.frmCal.AmountOptionA.disabled = false;
		document.frmCal.MonthlyBenefit.disabled = false;
		document.frmCal.txtOptionB.disabled = false;
		document.frmCal.txtOptionBmonthly.disabled = false;
		document.frmCal.myResultOptionC.disabled = false;
		document.frmCal.myResultOptionCmonthly.disabled = false;
		document.frmCal.myResultOptionCTwoThirdYearly.disabled = false;
		document.frmCal.myResultOptionCTwoThirdMonthly.disabled = false;
		document.frmCal.R7q.disabled = false;	
  }else{		
		if (!document.frmCal.checkboxAgree.checked){      //I do not agree, disable = true
			alert("To use the calculator, please check  'I Agree, continue filling form. '");
			document.frmCal.checkboxAgree.focus()
			document.frmCal.mb.disabled = true;
			document.frmCal.db.disabled = true;
			document.frmCal.yb.disabled = true;
			document.frmCal.mp.disabled = true;
			document.frmCal.dp.disabled = true;
			document.frmCal.yp.disabled = true;
			document.frmCal.groupmember[0].disabled = true;
			document.frmCal.groupmember[1].disabled = true;
			document.frmCal.groupmember[2].disabled = true;
			document.frmCal.militaryveteran[0].disabled = true;
			document.frmCal.militaryveteran[1].disabled = true;
			document.frmCal.YRofServices.disabled = true;
			document.frmCal.yrserMM.disabled = true;
			document.frmCal.YRAverageSalary.disabled = true;
			//document.frmCal.R7q.disabled = true;
			document.frmCal.yaAdisplayonly.disabled = true;
			document.frmCal.OpAyaservicedisplay.disabled = true;
			document.frmCal.PercentFactor.disabled = true;
			document.frmCal.YRAverageSalarydisplay.disabled = true;
			document.frmCal.Aveteranbenf.disabled = true;
			document.frmCal.AmountOptionA.disabled = true;
			document.frmCal.MonthlyBenefit.disabled = true;
			document.frmCal.txtOptionB.disabled = true;
			document.frmCal.txtOptionBmonthly.disabled = true;
			document.frmCal.myResultOptionC.disabled = true;
			document.frmCal.myResultOptionCmonthly.disabled = true;
			document.frmCal.myResultOptionCTwoThirdYearly.disabled = true;
			document.frmCal.myResultOptionCTwoThirdMonthly.disabled = true;
			document.frmCal.R7q.disabled = true;
			
			blankRequiredvalue();
			blankRetireeDOB();
			blankBeneficiaryDOB();
			blankOptionAvalue();
			blankOptionCvalue();
			blankCalbyDOB();
			blankCalbyAge();
		}//if (!document.frmCal.checkboxAgree.checked) 
    //chk.checked = 1; // open the code to check for client
   }//if (chk.checked == 1) else
}//function validateChkBox(chk)



function blankRequiredvalue(){
	document.frmCal.mb.value = "null";
	document.frmCal.db.value = "null";
	document.frmCal.yb.value = "";
	document.frmCal.mp.value = "null";
	document.frmCal.dp.value = "null";
	document.frmCal.yp.value = "";
	document.frmCal.groupmember.value = 1;
	document.frmCal.militaryveteran.value = "No";
	document.frmCal.YRofServices.value = 10;
	document.frmCal.yrserMM.value = 0;
	document.frmCal.YRAverageSalary.value = "";
	return;
}//function blankRequiredvalue()

function blankOptionAvalue(){
	//Option A blank
	document.frmCal.grpmember.value = "";
	document.frmCal.yaAdisplayonly.value = "";
	document.frmCal.yaC6690.value = "";
	document.frmCal.yaA.value = "";
	document.frmCal.AmountOptionAbeforeVeteranBenf.value = "";
	document.frmCal.txtOptionBbeforeVeteranBenf.value = "";	
	//document.frmCal.YRAverageSalary.value = "";	
	
	document.frmCal.AgeFactor.value = ""; //Option A age factor array		
	document.frmCal.PercentFactor.value = "";
	document.frmCal.OpAyaservicedisplay.value = "";
	document.frmCal.OpAyaservice.value = "";
	document.frmCal.OpAyaserviceVeteran.value = "";			
	document.frmCal.AmountOptionA.value = "";
	document.frmCal.Aveteranbenf.value = "";
	document.frmCal.MonthlyBenefit.value = "";
	
	// Option B blank
	
	document.frmCal.YRAverageSalarydisplay.value = "";
	document.frmCal.txtOptionB.value = "";
	document.frmCal.txtOptionBmonthly.value = "";		
	//Option C blank
	document.frmCal.myResultOptionCfator.value = "";
	document.frmCal.AmountOptionAC.value = "";		
	document.frmCal.myResultOptionC.value = "";
	document.frmCal.myResultOptionCmonthly.value = "";
	//Option C blank 2/3 of option A	
	document.frmCal.yaBenydispay.value = "";										
	document.frmCal.maBenydisplay.value = "";				
	document.frmCal.OptCbenfAge.value = ""			
	document.frmCal.myResultOptionCTwoThirdYearly.value = "";
	document.frmCal.myResultOptionCTwoThirdMonthly.value = "";	
	return;
}//function blankOptionAvalue(){

// clear the values if <option value="0" selected>Select Beneficiary's Age</option>
function blankOptionCvalue(){ 	
	//Option C blank
	document.frmCal.yaCfromYadisplay.value = "";
	document.frmCal.yaC.value = "";
	document.frmCal.AmountOptionAC.value = "";
	document.frmCal.myResultOptionCfator.value = "";		
	document.frmCal.myResultOptionC.value = "";
	document.frmCal.AmountOptionACbeforeVeteranBenf.value = "";
	document.frmCal.myResultOptionCmonthly.value = "";
	//Option C blank 2/3 of option A	
	document.frmCal.yaBenydispay.value = "";										
	document.frmCal.maBenydisplay.value = "";				
	document.frmCal.OptCbenfAge.value = ""				
	document.frmCal.myResultOptionCTwoThirdYearly.value = "";
	document.frmCal.myResultOptionCTwoThirdMonthly.value = "";
	return;
}

function blankRetireeDOB(){
	document.frmCal.ya.value = ""; 
	document.frmCal.ma.value = "";
	document.frmCal.da.value = "";
	return;
	}
	
function blankBeneficiaryDOB(){
	document.frmCal.maBeny.value = ""; 
	document.frmCal.yaBeny.value = "";
	document.frmCal.daBeny.value = "";
	return;
}

function blankCalbyDOB(){	 //blankCalbyBeneficiaryDOBSelectionfield
	document.frmCal.ybBeny.value = "";
	document.frmCal.mbBeny.value = "null";
	document.frmCal.dbBeny.value = "null";
	return;
}

function blankCalbyAge(){  //blankCalbyAgeBeneficiarySelectionfield
	document.frmCal.BenefAgeYY.value = 0;
	document.frmCal.BenefAgeMM.value = 0;
	return;
}

function fdisable(OnOff) { //disable or enable radiobutton
	var varR7q; //document.frmCal.R7q[i].value
	var varV1;
	var varV2;
	//var varOnOfffalse = ; 
	varV1 = "V1"; // cal by DOB
	varV2 = "V2"; // cal by age		
	//varradioOptional7q
	var frmR7 = document.frmCal;
	for (var i = 0; i < frmR7.R7q.length; i++){ // loop through the form radiobutton values
		if (frmR7.R7q[i].checked){
			varR7q =  frmR7.R7q[i].value;
			break;	//varR7q = i;
		}
	}

	if (varR7q == varV1){
		if (OnOff = true ){
				document.frmCal.R7q.value = "V1";
				document.frmCal.BenefAgeYY.disabled = OnOff;
				document.frmCal.BenefAgeMM.disabled = OnOff;	
				document.frmCal.mbBeny.disabled = false;
				document.frmCal.dbBeny.disabled = false;
				document.frmCal.ybBeny.disabled = false;	
			}
	}else{
			if (varR7q == varV2){
				if (OnOff = true){					
					document.frmCal.R7q.value = "V2";
					document.frmCal.ybBeny.disabled = OnOff;
					document.frmCal.mbBeny.disabled = OnOff;
					document.frmCal.dbBeny.disabled = OnOff;	
					document.frmCal.BenefAgeYY.disabled = false;
					document.frmCal.BenefAgeMM.disabled = false;				
				}//if (OnOff = true)
			}//if (varR7q == varV2)
	}//if (varR7q == varV1)
}//function fdisable(OnOff)


//function f_calOptionA(yrA, varGroup, varVeteran){ 
function f_calOptionA(OptA, varGroup, varVeteran){ 
	//document.frmCal.yaA.value = ya;
	var ya = OptA;
	var varLessthan36 = false;
	var varGroupmember = varGroup;
	var varOnOfffalse = false;	
	if ((ya >= 55) && (varGroupmember == 2)){
  			 ya = (ya + 5);	//add 5 years for option A group #2
	}
	if ((ya >= 45) && (varGroupmember == 4)){
			ya = (ya + 10);	//add 10 years for option A group #4
	}	
	if (ya >= 65){
		ya = 65
		var OptionAARRY = "0.025";
		document.frmCal.AgeFactor.value = OptionAARRY; //Option A age factor array
		document.frmCal.yaA.value = 65;
		document.frmCal.grpmember.value = varGroupmember;
	}else if (ya < 36){ //less than 36
		blankOptionAvalue();		
		alert("Sorry, your age entered is less than the minumin age of 36. Please check the date or the Benefit Guide for more details.");
	}else{ // between age 36 and 65				
			//alert("ARRY[ya] " + ARRY[ya])
			if (isNaN(ya)){
				blankOptionAvalue();
				blankOptionCvalue();
			}else{
				var OptionAARRY = factorOptionA[ya] * 0.0001;
				document.frmCal.AgeFactor.value = OptionAARRY; //Option A age factor array
				document.frmCal.yaA.value = ya; //year +  months
				document.frmCal.grpmember.value = varGroupmember;
			}//if (isNaN(ya))
	}//if (ya >= 65)
}//function f_calOptionA(OptA, varGroup, varVeteran)

//Option C factor calculation
function f_calOptionC(yrAforC, varGroup, OptC_ma, OptC_OptionA_yaA){
	var ya = yrAforC;
	var varGroupmember = varGroup;	
	var ma = OptC_ma
   	ma = (ma / 12)  
	ya = custRound((ya + ma),0);	
	if ((ya >= 55) && (varGroupmember == 2)){
  			 //ya = (ya + 5);	
			 ya = (ya);	// don't add 5 for Option C			 
	}	
	if ((ya >= 45) && (varGroupmember == 4 )){
			//ya = (ya + 10);
			ya = (ya);  // don't add 10 for Option C
	}	
	if (ya < 36){
		blankOptionCvalue();		
	}else if (ya >= 90){
		ya = 90
	}else{
		if ((ya >= 36) && (ya < 90)){							
		ya = ya;			
		}
	}//if (ya < 36){		
		document.frmCal.yaC.value = ya; 
		document.frmCal.yaC6690.value = ya; 
}//function f_calOptionC(yrAforC, varGroup, OptC_ma, OptC_OptionA_yaA)

// calculation by beneficiary's Date of Birth
function f_cal_beneficiaryDOB(dp, mp, yp, isJulian, var_ybBeny, var_mbBeny, var_dbBeny, OptC_OptionA_yaA, rowCvar_yaC6690){
	var varzero = "0";
	var ya = parseInt(rowCvar_yaC6690);		
	var OptC_OptionA_yaA = parseInt(OptC_OptionA_yaA);
	//	IsNaN Number.NaN
	if (isNaN(ya)){
		blankOptionCvalue();
	}else{
		dp = parseInt(dp);
		mp = parseInt(mp);
		yp = parseInt(yp);
		var_ybBeny = parseInt(var_ybBeny);
		var_mbBeny = parseInt(var_mbBeny); 
		var_dbBeny = parseInt(var_dbBeny);
		mLength = 0;
		
// for Calculate Beneficiary DOB   
		if (!checkNumber(document.frmCal.dbBeny,1, getMonthLength(var_mbBeny,var_ybBeny,isJulian), "Beneficiary's Date of Birth"))
			//if (!checkNumber(document.frmCal.YRofServices, 10, 45, "5. Enter your years of service"))
		{		
			return;
		}
		if ((var_ybBeny != "") && (var_ybBeny > 0) && (var_mbBeny != "null") && (var_dbBeny != "null"))
		{	
			   var_daBeny = dp - var_dbBeny // Age = (Projected date - Benef's DOB) WJL
			   if(var_daBeny<0) //day-Age 
			   {
				  mp--;
				  // Borrow months from the year if necesssary.
				  if(mp<1){
						yp--;
						// Determine no. of months in year
					 if(mLength){
						 mp=mp+parseInt(365/mLength);
						 }
					 else{
						 mp=mp+12;
						 }
					  }
					  if(mLength==0) {// Use real month length if no fixed
									  // length is indicated - note that we add a leap day if necessary.
						 ml=getMonthLength(mp,yp,isJulian);
						 var_daBeny=var_daBeny+ml; //WJL
					  }else{
						  var_daBeny+=mLength;
					  } // Use fixed month length WJL
			   }//if(var_daBeny<0)
			   
				var_maBeny = mp - var_mbBeny; //WJL
			   // Month borrowing code - borrows months from years.
			   if(var_maBeny<0) //WJL
			   {
				  yp--;
				  if(mLength!=0)
				 {
					 var_maBeny=var_maBeny+parseInt(365/mLength);//WJL
					//alert("{var_maBeny=var_maBeny+parseInt(365/mLength);" + var_maBeny)
				 }
				  else
				 {var_maBeny=var_maBeny+12;}//WJL
			   } //if(var_maBeny<0)
				var_yaBeny = yp - var_ybBeny; 						
				varzero = parseInt(varzero);//var varzero = "0";
										
				//if ((var_yaBeny < varzero) || (( var_yaBeny == "0") && (var_maBeny <= "0"))) {							
				if ((var_yaBeny <= varzero) && (var_maBeny <= "0") || (var_yaBeny < varzero)) {							
					//alert(" var_yaBeny is: "  + var_yaBeny + " , var_maBeny: " + var_maBeny)
					alert("Beneficiary's date of birth cannot be later than your projected retirement date. ");
					
					blankBeneficiaryDOB();
					
				}else {
						//document.frmCal.ma.value = ma; //WJL
						document.frmCal.yaBeny.value = var_yaBeny;
						document.frmCal.maBeny.value = var_maBeny; 
						document.frmCal.daBeny.value = var_daBeny;				
						var_yaBenyDOB = document.frmCal.yaBeny.value;
						var_maBenyDOB = document.frmCal.maBeny.value;
						var_daBenyDOB = document.frmCal.daBeny.value;
						//var rowC = document.frmCal.yaC6690.value;
						var rowC = ya;
						var colC = parseInt(var_yaBenyDOB);
						var colCMM = parseInt(var_maBenyDOB);
						var colCDD = parseInt(var_daBenyDOB);
						var varyaBenydispay = parseInt(var_yaBenyDOB);
						var varmaBenydisplay = parseInt(var_maBenyDOB);								
						if ((colC <= 0) && (colCMM <= 0)) { // both YY and MM is 0	
								//alert("716 colC: " + colC + ", colCMM:" + colCMM);
								blankOptionCvalue();	
						}else{
								//var varrealcolC;
								document.frmCal.yaCfromYadisplay.value = OptC_OptionA_yaA;
								document.frmCal.yaC.value =  ya;
								document.frmCal.yaBenydispay.value = varyaBenydispay;
								document.frmCal.maBenydisplay.value = varmaBenydisplay;
								colC = parseInt(colC); //var_yaBenyDOB
								if (colCMM > 5){
									colC = colC + 1;
									//alert("724 colC = parseInt(colC) + 1; " + colC )										
								}else {									
									colC = colC ;
									}											
								if ((colC >= 0) && (colC < 6)){ // 0 to 6
									colC = 6;											
								}									
								if (colC > 90){								
									colC = 90;
								}					
								if ((rowC >= 6) && (rowC <=90)){
										rowC = rowC;
									}else if (rowC > 90){
										rowC = 90; 
									}else {
										rowC = 6;				  
									} //if ((rowC >= 6) && (rowC <=90)){
								
								colC = (colC - 5) // the beneficiary's age start from age 6 instead of age 1 so colC(6) - 5 = age 1
								//aryC[rowC].substr(((colC-1)*6)+2, 6)
								//age colC = 6 - 5 = 1
								//aryC[55].substr(((1-1)*6)+2, 6) = aryC[55].substr(2, 6)
								//age colC = age7 - 5 = 2
								//aryC[55].substr(((2-1)*6)+2, 6) = aryC[55].substr(8, 6)
//var benefAryCfactor = aryC[rowC].substr(((colC-1)*6)+2, 6); // ary[60].substr(((7-1)*6)+2, 6)= 0.8191  factor
								var benefAryCfactor = factorOptionC[7225-(rowC-6)*85-colC] * 0.0001;
								//Ex. MultiArray[60].Beneficiaree(col=7) = at position 38 and takes 6 string = 0.8191	
								document.frmCal.myResultOptionCfator.value = benefAryCfactor;	//
								//	var OptionATotal = document.frmCal.AmountOptionA.value; //Avg of 3 years salary
								colC = (colC + 5)// for display	add 5 years back to the age for the actual age 6 + 5 = age 11 for benee
								if (colC >= 90 ){
									colC += "+";										
									}
								document.frmCal.OptCbenfAge.value = colC; // cal age
						}//if (colC < 0) 
				}//if ((var_yaBeny < varzero) || (( var_yaBeny == "0") && (var_maBeny == "0"))) 
		}else{ 
		blankOptionCvalue();				
		}//if ((var_ybBeny != "") && (var_ybBeny > 0) && (var_mbBeny != "null") && (var_dbBeny != "null"))
	} // if else(isNaN(ya)){
} //function f_cal_beneficiaryDOB(dp, mp, yp, isJulian, var_ybBeny, var_mbBeny, var_dbBeny, OptC_OptionA_yaA, rowCvar_yaC6690)


// Calculate by AGE and months //Example rowC = ya = 36 , colC = BenefAge = 30
//=============================================================================
//getArrayOptionC(yaC6690.value, BenefAgeYY.value, BenefAgeMM.value, yaAdisplayonly.value)
function getArrayOptionC(rowCvar_yaC6690, colCvar_BenefAgeYY, colCMMvar_BenefAgeMM, OptC_OptionA_yaA){
	//alert("function getArrayOptionC(rowC, colC, colCMM){" + " colC: >" + colC + "< colCMM: "  + colCMM );
	rowC = parseInt(rowCvar_yaC6690);
	colC = parseInt(colCvar_BenefAgeYY); //BenefAgeYY.value
	colCMM = parseInt(colCMMvar_BenefAgeMM); //BenefAgeMM.value
	OptC_OptionA_yaA = parseInt(OptC_OptionA_yaA);
	var varyaBenydispay = parseInt(colC);
	var varmaBenydisplay = parseInt(colCMM);
	if ( ((rowC > 0) && (colC > 0)) || ( (rowC > 0) && ((colC > 0) || (colCMM > 0)) ) ) {    
			if (colC < 0) { // negative number age
					blankOptionCvalue();
			}else if ((colC == 0) && (colCMM == 0)) { // both YY and MM is 0						
					blankOptionCvalue();						
			}else{
					document.frmCal.yaCfromYadisplay.value = OptC_OptionA_yaA;
					document.frmCal.yaC.value =  rowC;
					document.frmCal.yaBenydispay.value = varyaBenydispay;
					document.frmCal.maBenydisplay.value = varmaBenydisplay;

					colC = parseInt(colC); //var_yaBenyDOB
					if (colCMM > 5){
						colC = colC + 1;						
					}else {									
						colC = colC ;
					}					
					if ((colC >= 0) && (colC < 6)){ // 0 to 6
						colC = 6;
					}				
					if (colC > 90){								
						colC = 90;
					}	
					if ((rowC >= 6) && (rowC <=90)){
						rowC = rowC;
					}else if (rowC > 90){
						rowC = 90; 
					}else {
						rowC = 6;				  
					} //if ((rowC >= 6) && (rowC <=90)){
					
					colC = (colC - 5) // the beneficiary's age start from age 6 instead of age 1 so colC(6) - 5 = age 1
					//aryC[rowC].substr(((colC-1)*6)+2, 6)
					//age colC = 6 - 5 = 1
					//aryC[55].substr(((1-1)*6)+2, 6) = aryC[55].substr(2, 6)
					//age colC = age7 - 5 = 2
					//aryC[55].substr(((2-1)*6)+2, 6) = aryC[55].substr(8, 6)
					var benefAryCfactor = factorOptionC[7225-(rowC-6)*85-colC]*0.0001;
					//Ex. MultiArray[60].Beneficiaree(col=7) = at position 38 and takes 6 string = 0.8191	
					document.frmCal.myResultOptionCfator.value = benefAryCfactor;	//
					//	var OptionATotal = document.frmCal.AmountOptionA.value; //Avg of 3 years salary
					colC = (colC + 5)// for display	add 5 years back to the age for the actual age 6 + 5 = age 11 for benee					
					if (colC >= 90 ){
						colC += "+";	
						}
					document.frmCal.OptCbenfAge.value = colC; // cal age
			}//if (colC < 0) 
	}else{ 
			blankOptionCvalue();				
	}//if ( ((rowC > 0) && (colC > 0)) || ( (rowC > 0) && ((colC > 0) || (colCMM > 0)) ) )
}//function getArrayOptionC(rowCvar_yaC6690, colCvar_BenefAgeYY, colCMMvar_BenefAgeMM, OptC_OptionA_yaA)


//function computeForm(form) { ===============================================================
function computeForm(form) {
		
	   // var ml={31,28,31,30,31,30,31,31,30,31,30,31}; // For calendar 
	   var MNames = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	
	  if(  (document.frmCal.yp.value == "" || document.frmCal.yp.value.length == 0) ||
		   (document.frmCal.mp.value == null || document.frmCal.mp.value.length == 0) ||
		   (document.frmCal.dp.value == null || document.frmCal.dp.value.length == 0) ||
		   (document.frmCal.yb.value == "" || document.frmCal.yb.value.length == 0) ||
		   (document.frmCal.mb.value == null || document.frmCal.mb.value.length == 0) ||
		   (document.frmCal.db.value == null || document.frmCal.db.value.length == 0))
   	   {
		  return;
	   }		   
	   var yb = document.frmCal.yb.value;	//1) Enter your date of birth (mm/dd/yyyy) 
	   var mb = document.frmCal.mb.options[document.frmCal.mb.selectedIndex].value;
	   var db = document.frmCal.db.value;

	   var yp = document.frmCal.yp.value;   //2) Enter your projected date of retirement (mm/dd/yyyy) 
	   var mp = document.frmCal.mp.options[document.frmCal.mp.selectedIndex].value;
	   var dp = document.frmCal.dp.value;  
		// Month length 0->use calendar length
	   // 0 if Gregorian, 1 is Julian   
	   var mLength = 0; ///(document.frmCal.monthLength.options[document.frmCal.monthLength.selectedIndex].value);
		// var isJulian = document.frmCal.isJulian.options[document.frmCal.isJulian.selectedIndex].value;
		var isJulian = 1; // document.frmCal.isJulian.options[document.frmCal.isJulian.selectedIndex].value;
	   if( 
		  !checkNumber(document.frmCal.mb,1, getMonthLength(mb,yb,isJulian), "1. Your date of birth (month)") ||
		  !checkNumber(document.frmCal.db,1, getMonthLength(mb,yb,isJulian), "1. Your date of birth (day)") ||		  
		  !checkNumber(document.frmCal.dp,1, getMonthLength(mp,yp,isJulian), "2. Your projected day of retirement(day)")) 		   
	   {
		  return;
	   }

	  	// var varOnOfffalsecounter;// = true ;// = alert("1020 false");	
		var ma = 0;
		var ya = 0;
		var var_yaBeny; //WJL
		var var_maBeny; //WJL	  
		var var_daBeny; //WJL
	   
		var var_yaBenyDOB;
		var var_maBenyDOB;
		var var_daBenyDOB;
		var da = dp-db; //Age = (Projected date - Retiree's DOB) 
		
		var displayAmountOptionAC;
		
		//var	frmYRAverageSalary; //for YRAverageSalary 
		var varYRAverageSalarydisplay //for display YRAverageSalary 
		var OptC_OptionA_yaA; // for option C display
		var myResultOptionCdisplay; //document.frmCal.myResultOptionC.value
		var NonMax_YRAOptionC_Max_YRAOptionCdisplay;
		var varOpAyaservicedisplay;
		var varR7q;  //radionOptional7q
		var varV1;
		var varV2;
		// This is the all-important day borrowing code.
	   if(da<0) //day-Age
	   {
		  mp--;
		  // Borrow months from the year if necesssary.
		  if(mp<1)
		  {
		 yp--;
		 // Determine no. of months in year
		 if(mLength)
			{mp=mp+parseInt(365/mLength);}
		 else
			{mp=mp+12;}
		  }
		  if(mLength==0) // Use real month length if no fixed
		  {              // length is indicated - note that we add a leap day if necessary.
			 ml=getMonthLength(mp,yp,isJulian);
		 	 da=da+ml;
		  }
		  // For this case, everything works like it is.
		  else
		 {da+=mLength;} // Use fixed month length
	   }//if(da<0)   
	
	   ma = mp - mb; //Age of Retirement //WJL
	   //mser = mp - mbs; //WJL
	   // Month borrowing code - borrows months from years.
	   if(ma<0) 
	   {
		  yp--;
		  if(mLength!=0)
		 {ma=ma+parseInt(365/mLength);
		 //alert("{ma=ma+parseInt(365/mLength);" + ma)
		 }
		  else
		 {ma=ma+12;}
	   }//if(ma<0)
	  	   
	ya = yp - yb;		   	
	document.frmCal.da.value = da; //Day
	document.frmCal.ma.value = ma; //Month	  		
	document.frmCal.ya.value = ya; //year
	document.frmCal.yaAdisplayonly.value = ya; //display the year of the age only

	//var varVeteran = document.frmCal.militaryveteran.value;
	var varVeteran = get_veteran_value(); 
	var varGroup =  get_group_value();
	//frmYRAverageSalary = document.frmCal.YRAverageSalary.value;		
	//YRAverageSalarydisplay = document.frmCal.YRAverageSalary.value;
	//document.frmCal.YRAverageSalarydisplay.value = varYRAverageSalarydisplay;
		
	//Begin calculator formulas	//////////////////////////////////////////////////
	/// SERVICE and VETERAN 
    var YRofS = document.frmCal.YRofServices.value; // 5) Enter your estimated total number of years of creditable service,
	///YRofS= custRound((YRofS),2);	
	var varyrserMM = document.frmCal.yrserMM.value;
	if ((YRofS >=45) && (varyrserMM >= 1)) {
		varyrserMM = 0;		
		document.frmCal.yrserMM.value = varyrserMM;
		}		
	
	if ((varVeteran == "No") && (ya >= 36)){	
		varYRofS = parseInt(YRofS)
		YRofS = parseInt(YRofS)
		varyrserMM = parseInt(varyrserMM)
		if ((YRofS >= 10) && (varyrserMM == 0)){
			YRofS = YRofS;				
		}else if ((YRofS >= 10) && (varyrserMM >= 1)){				
			YRofS = custRound((YRofS + (varyrserMM/12)),5)
		}else{
			alert("You entered creditable service is less than 10, please check the benefit quide for more detail." )
		}
		document.frmCal.OpAyaservicedisplay.value = (varYRofS + "." + varyrserMM); // varyrserMM //varYRofS ; ///802 wjl			
		document.frmCal.OpAyaservice.value = YRofS
		document.frmCal.OpAyaserviceVeteran.value = YRofS
		document.frmCal.Aveteranbenf.value = "0.00"
		//document.frmCal.OpAyaservicedisplay.value = YRofS; // varyrserMM //varYRofS ; // wjl			
	}//if (varVeteran == "No"){
	
	var varVetBenefit;
	var vetbenefitperyear = 15; //$15 for each Mil. service until 20 yrs and add $300 after each yr
	var varYRofS
	var varYRofSAddoneyear
	if ((varVeteran == "Yes") && (ya >= 36)){
		//alert("729 varVeteran : " + varVeteran )
		YRofS = parseInt(YRofS)
		varYRofS = YRofS;
		varyrserMM = parseInt(varyrserMM)
		vetbenefitperyear = parseInt(vetbenefitperyear)		
		if ((varYRofS >= 10) && (varyrserMM == 0)){				
			if (varYRofS <= 20 ){							
				//YRofS = custRound((YRofS + (varyrserMM/12)),2)
				YRofS = (YRofS + varyrserMM)							
				vetbenefitperyear = YRofS * vetbenefitperyear;					
			}else {
				//varYRofSAddoneyear = YRofS;
				YRofS = (YRofS + varyrserMM)	
				vetbenefitperyear = 300
			}
			document.frmCal.Aveteranbenf.value = vetbenefitperyear;
			document.frmCal.OpAyaservicedisplay.value = (varYRofS + "." + varyrserMM);			
			document.frmCal.OpAyaserviceVeteran.value = YRofS
			document.frmCal.OpAyaservice.value = YRofS;				
		}else if ((varYRofS >= 10) && (varyrserMM >= 1)){										
			YRofS = custRound((varYRofS + (varyrserMM/12)),5)
			varYRofSAddoneyear = varYRofS;
			if (varYRofS < 20){
					varYRofSAddoneyear = (varYRofSAddoneyear + 1)					
					vetbenefitperyear = varYRofSAddoneyear * vetbenefitperyear;
			}else {
					varYRofSAddoneyear = YRofS;
					vetbenefitperyear = 300
			}
			document.frmCal.OpAyaservice.value = varYRofSAddoneyear;
			document.frmCal.Aveteranbenf.value = vetbenefitperyear;
			document.frmCal.OpAyaservicedisplay.value = (varYRofS + "." + varyrserMM);
			document.frmCal.OpAyaserviceVeteran.value = YRofS
		}else{ //}else if ((YRofS >= 10) && (varyrserMM >= 1)){	
			document.frmCal.Aveteranbenf.value = ""
			alert("You entered creditable service is less than 10, please check the benefit quide for more details." )
		}//if ((varYRofS >= 10) && (varyrserMM == 0))
	}else{
		vetbenefitperyear = 0;
		vetbenefitperyear = parseInt(vetbenefitperyear);
		document.frmCal.Aveteranbenf.value = vetbenefitperyear;
	}//if ((varVeteran == "Yes") && (ya >= 36))		
	// END OF SERVICE and VETERAN

	   var OptA = ya;	
	   //var varLessthan36 = false;
	   f_calOptionA(OptA, varGroup, varVeteran); // Option A factor
	   var OptC = ya;
	   var OptC_ma = ma	   
	   OptC_OptionA_yaA = document.frmCal.yaAdisplayonly.value; //f_cal_beneficiaryDOB()
	   f_calOptionC(OptC, varGroup, OptC_ma, OptC_OptionA_yaA); // Option C factor

		// var rowC = ya;
		//7) OPTIONAL: beneficiary's date of birth (mm/dd/yyyy)
		var var_ybBeny = document.frmCal.ybBeny.value; //WJL
		var var_mbBeny = document.frmCal.mbBeny.options[document.frmCal.mbBeny.selectedIndex].value;
		//var var_dbBeny = document.frmCal.dbBeny.value;
		var var_dbBeny = document.frmCal.dbBeny.options[document.frmCal.dbBeny.selectedIndex].value;	
		var	yyDOB = document.frmCal.ybBeny.value;
		var	MMDOB = document.frmCal.mbBeny.options[document.frmCal.mbBeny.selectedIndex].value;
		var	DDDOB = document.frmCal.dbBeny.options[document.frmCal.dbBeny.selectedIndex].value;

		//for age and month calculation
		var var_yaC6690 = document.frmCal.yaC6690.value;
		var var_BenefAgeYY = document.frmCal.BenefAgeYY.options[document.frmCal.BenefAgeYY.selectedIndex].value;
		var var_BenefAgeMM =  document.frmCal.BenefAgeMM.options[document.frmCal.BenefAgeMM.selectedIndex].value;
		var_yaC6690 = parseInt(var_yaC6690);
		var_BenefAgeYY = parseInt(var_BenefAgeYY);
		var_BenefAgeMM = parseInt(var_BenefAgeMM);		
		var rowCvar_yaC6690 = var_yaC6690;		
		var colCvar_BenefAgeYY = var_BenefAgeYY;
		var colCMMvar_BenefAgeMM  = var_BenefAgeMM;

		myResultOptionCdisplay = document.frmCal.myResultOptionC.value;
		NonMax_YRAOptionC_Max_YRAOptionCdisplay = document.frmCal.AmountOptionACbeforeVeteranBenf.value;
		//display alert
		var yaAgeCheck = document.frmCal.yaAdisplayonly.value 		
		var YRA = document.frmCal.YRAverageSalary.value; // 4) Enter your highest 3-year salary average (Example: 30000 without '$' or ',') 
		varYRAverageSalarydisplay = document.frmCal.YRAverageSalary.value;
		document.frmCal.YRAverageSalarydisplay.value = CommaFormatted(CurrencyFormatted(varYRAverageSalarydisplay));
		//document.frmCal.PercentFactor.value = custRound((i * YRofS),2);
		var i = document.frmCal.AgeFactor.value; // 1. Enter AgeFactor
		if (i > 1.0) {
			i = i / 100.0;
			document.frmCal.AgeFactor.value = i;
		}
		var PF = custRound((i * YRofS),5); //Percentage factor round to 2 decimal places	
		var parseFloatPFvalue = parseFloat(PF) 
			//document.frmCal.PercentFactor.value = (PFvalue);
			
		//end of display alert	
		
		//Radio button options question #7 
		var frmR7q = document.frmCal;	
		for (var i = 0; i < frmR7q.R7q.length; i++){
			if (frmR7q.R7q[i].checked){
				varR7q =  frmR7q.R7q[i].value;
				break;
			}
		}		
		varV1 = "V1"; // cal by DOB
		varV2 = "V2"; // cal by age						
		if (varR7q == varV1){
			blankCalbyAge();
			blankOptionCvalue();				
			if ((var_ybBeny != "") && (var_ybBeny > 0) && (var_mbBeny != "null") && (var_dbBeny != "null"))
			{						
				f_cal_beneficiaryDOB(dp, mp, yp, isJulian, var_ybBeny, var_mbBeny, var_dbBeny, OptC_OptionA_yaA, rowCvar_yaC6690);				
			}
		}else{
			if (varR7q == varV2){					
				blankCalbyDOB();
				blankBeneficiaryDOB();
				blankOptionCvalue();				
				if ( ((rowCvar_yaC6690 > 0) && (colCvar_BenefAgeYY > 0)) || ( (rowCvar_yaC6690 > 0) && ((colCvar_BenefAgeYY > 0) || (colCMMvar_BenefAgeMM > 0)) ) ) {
					/// getArrayOptionC(rowC, colC, colCMM, varVeteran, displayAmountOptionAC, frmYRAverageSalary, OptC_OptionA_yaA, myResultOptionCdisplay, NonMax_YRAOptionC_Max_YRAOptionCdisplay)
					getArrayOptionC(rowCvar_yaC6690, colCvar_BenefAgeYY, colCMMvar_BenefAgeMM, OptC_OptionA_yaA);
				}
			}			
		}//if (varR7q == varV1){
		
		var MaxPF = 0.80; // Yearly Benefit Amount if PF>=80% then use 80% only
		var Max_YRA; // for calculation Max Yearly Average
		var Max_YRATotal;
		
		//var optA; //for Option B
		var Max_YRAOptionB99; //for Option B
		var  Max_YRAOptionBTotal; //for Option B
		
		var Max_YRAyOptionCfactor; // for Option C
		var Max_YRAOptionC // for Option C
		
		var NonMax_YRA; // for Option A calculation Non Max Yearly Average 
		var NonMax_YRAOptionB99;; //for Option B
		var NonMax_YRAOptionC;//for Option C
		var NonMax_YRAOptionC_Max_YRAOptionCdisplay;
		var NonMax_YRA_Total; // for calculation Non Max Yearly Average
		var NonMax_YRAOptionBTotal; //for calculation Non Max Option B  Yearly Average total
		var PFparseFloat36; 
		var displayPercentFactor;
	var varzerotext = "0";
    if (PF >= MaxPF) {// Option A PecentFactor reach to Maxium 80%		
			//for Option A
			displayPercentFactor = (0.80 * 100) + "%" ;
			document.frmCal.PercentFactor.value = displayPercentFactor;
			//document.frmCal.PercentFactor.value = (0.80 * 100) + "%" ; // If PercentFactor >= 80% maximum then use display 0.80
			//document.frmCal.PercentFactor.value = custRound((0.80 * 100),; // If PercentFactor >= 80% maximum then use display 0.80
				if (varVeteran == "Yes"){// for Option A				
					Max_YRA = (MaxPF * YRA); // for calculation (Ex. 0.20 * 10000.00 = 2000.00 )
					Max_YRATotal =  (Max_YRA + vetbenefitperyear) 		
					//Line 5. = 3. x 4. for display on the AmountOptionA text field (Ex. $2,000.00)  
				}else{
					Max_YRA = (MaxPF * YRA);
					Max_YRATotal = (MaxPF * YRA); // for calculation (0.80 * 10,000.00)
						//5. for display on the AmountOptionA text field
					} //if (varVeteran == "Yes"){// for Option A	
			///Max_YRA = (MaxPF * YRA); // for calculation (0.80 * 10,000.00)
			//for display on the AmountOptionA text field
			document.frmCal.OpAyaservice.value = YRofS; //Option A review display
			
			if (varyrserMM < 10) {
				 varyrserMM = varzerotext + varyrserMM;				
				}
			//document.frmCal.OpAyaservicedisplay.value = (parseInt(YRofS) + "." + varyrserMM); // varyrserMM //varYRofS ; ///802 wjl
			document.frmCal.AmountOptionAbeforeVeteranBenf.value = Max_YRA; //display the opntionA amount before Veteran's benenefits
			displayAmountOptionAC = CommaFormatted(CurrencyFormatted(Max_YRATotal)); 		
			document.frmCal.AmountOptionA.value = displayAmountOptionAC; //WJL
			//Option A Monthly Benefit Amount = (Max_YRA/12);			
			document.frmCal.MonthlyBenefit.value = CommaFormatted(CurrencyFormatted(Max_YRATotal / 12)); 
			
			//for Option B
			//Option B Pension Yearly
			//document.frmCal.txtOptionB.value = CommaFormatted(CurrencyFormatted(Max_YRATotal * 0.99));
				if (varVeteran == "Yes"){//for Option B						
					Max_YRAOptionB99 = (Max_YRA * 0.99); // for calculation (Ex. 0.20 * 10000.00 = 2000.00 )
					//document.frmCal.txtOptionBbeforeVeteranBenf.value = Max_YRAOptionB99; //display only for Option B Amount before veteran's benefits
					Max_YRAOptionBTotal =  (Max_YRAOptionB99 + vetbenefitperyear) 								
					//Line 5. = 3. x 4. for display on the AmountOptionA text field (Ex. $2,000.00)  
				}else{
						Max_YRAOptionB99 = (Max_YRA * 0.99);
						Max_YRAOptionBTotal = (Max_YRA *0.99); // for calculation (0.80 * 10,000.00)
						//5. for display on the AmountOptionA text field
					}//if (varVeteran == "Yes"){//for Option B
			document.frmCal.txtOptionBbeforeVeteranBenf.value = Max_YRAOptionB99; //display only for Option B Amount before veteran's benefits
			document.frmCal.txtOptionB.value = CommaFormatted(CurrencyFormatted(Max_YRAOptionBTotal));			
			//Option B txtOptionBmonthly
			//document.frmCal.txtOptionBmonthly.value = CommaFormatted(CurrencyFormatted((Max_YRATotal * 0.99)/12));
			document.frmCal.txtOptionBmonthly.value = CommaFormatted(CurrencyFormatted((Max_YRAOptionBTotal)/12));
	
			// for Option C
			var yOptionCfactor = document.frmCal.myResultOptionCfator.value;	//Option C chart
			var OptionATotal = document.frmCal.AmountOptionA.value; //Avg of 3 years salary from Option A 
			
			if ((yOptionCfactor > 0) && (yOptionCfactor <= 1)){
				//displayAmountOptionAC = CommaFormatted(CurrencyFormatted(Max_YRA));
				document.frmCal.AmountOptionAC.value = displayAmountOptionAC;
					if (varVeteran == "Yes"){//for Option C										
							Max_YRAOptionC = (Max_YRA * yOptionCfactor); // for calculation (Ex. 0.20 * 10000.00 = 2000.00 )
							NonMax_YRAOptionC_Max_YRAOptionCdisplay = Max_YRAOptionC; //display only for OptionC before veteran's benefits
							//document.frmCal.AmountOptionACbeforeVeteranBenf.value = NonMax_YRAOptionC_Max_YRAOptionCdisplay;
							Max_YRAyOptionCfactor =  (Max_YRAOptionC + vetbenefitperyear); 		
							//Line 5. = 3. x 4. for display on the AmountOptionA text field (Ex. $2,000.00)  
					}else{
							NonMax_YRAOptionC_Max_YRAOptionCdisplay = (Max_YRA * yOptionCfactor);
							Max_YRAyOptionCfactor = (Max_YRA * yOptionCfactor); // for calculation (0.80 * 10,000.00)
							//5. for display on the AmountOptionA text field
						}//if (varVeteran == "Yes"){//for Option C	
				document.frmCal.AmountOptionACbeforeVeteranBenf.value = NonMax_YRAOptionC_Max_YRAOptionCdisplay;
				myResultOptionCdisplay = CommaFormatted(CurrencyFormatted(Max_YRAyOptionCfactor));
				document.frmCal.myResultOptionC.value = myResultOptionCdisplay;	// Yearly document.arrayForm.myResult2.value=MultiArray[row];
				document.frmCal.myResultOptionCmonthly.value = CommaFormatted(CurrencyFormatted((Max_YRAyOptionCfactor)/12)); //monthly
				//2/3 of the Option C in yearly
				document.frmCal.myResultOptionCTwoThirdYearly.value = CommaFormatted(CurrencyFormatted((Max_YRAyOptionCfactor * 2)/3)); // 2/3 in Yearly
				//2/3 of the Option C in monthly
				document.frmCal.myResultOptionCTwoThirdMonthly.value = CommaFormatted(CurrencyFormatted(((Max_YRAyOptionCfactor * 2)/3)/12)); // 2/3 in monthly
			}else{
				blankOptionCvalue();		
			} //if (yOptionCfactor > 0 )
    }else{	// Lease than 80% PercentFactor
		  	if (ya < 36){ //less than 36 year of age 
			  	blankOptionCvalue();			
				//varOnOfffalsecounter = 2;			
				//alert("1462 Sorry, your age entered is less than the minumin age of 36. Please check the date or the Benefit Guide for more details.");
			}else if (ya >= 36){ //greater than and equal to 36
					///document.frmCal.OpAyaservice.value = YRofS; //Option A review display
					//document.frmCal.PercentFactor.value = PF;
					PFparseFloat36 =  parseFloat(PF)					
					if (PFparseFloat36 < 1) {									
						PFparseFloat36 = custRound((PFparseFloat36 * 100), 2); //WJL 2
					}					
					displayPercentFactor = PFparseFloat36 + "%" ;
					document.frmCal.PercentFactor.value = displayPercentFactor;
					// document.frmCal.PercentFactor.value = PFparseFloat36 + "%" ; // If ya >= 36 for display in percentage
					if (varVeteran == "Yes"){// for Option A				
						NonMax_YRA = (PF * YRA); // for calculation (Ex. 0.20 * 10000.00 = 2000.00 )
						document.frmCal.AmountOptionAbeforeVeteranBenf.value = NonMax_YRA; //display the opntionA amount before Veteran's benenefits
						NonMax_YRA_Total =  (NonMax_YRA + vetbenefitperyear);
						//Line 5. = 3. x 4. for display on the AmountOptionA text field (Ex. $2,000.00)  
					}else{
						NonMax_YRA = (PF * YRA); // for calculation (Ex. 0.20 * 10000.00 = 2000.00 )		
						NonMax_YRA_Total = (PF * YRA); // for calculation (0.80 * 10,000.00)
						document.frmCal.AmountOptionAbeforeVeteranBenf.value = NonMax_YRA_Total; //display the opntionA amount before Veteran's benenefits
						//5. for display on the AmountOptionA text field
					} //if (varVeteran == "Yes"){// for Option A	
							
					if (varyrserMM < 10) {
					 varyrserMM = varzerotext + varyrserMM;				
					}
					//document.frmCal.OpAyaservicedisplay.value = (parseInt(YRofS) + "." + varyrserMM) // varyrserMM //varYRofS ; ///802 wjl
					displayAmountOptionAC = CommaFormatted(CurrencyFormatted(NonMax_YRA_Total)); 		
					document.frmCal.AmountOptionA.value = displayAmountOptionAC; //WJL
					//Option A Monthly Benefit Amount = (Max_YRA/12);			
					document.frmCal.MonthlyBenefit.value = CommaFormatted(CurrencyFormatted(NonMax_YRA_Total / 12)); 
			
					//for Option B
					//Option B Pension Yearly
					//document.frmCal.txtOptionB.value = CommaFormatted(CurrencyFormatted(Max_YRATotal * 0.99));
					if (varVeteran == "Yes"){//for Option B		
						NonMax_YRAOptionB99 = (NonMax_YRA * 0.99); // for calculation (Ex. 0.20 * 10000.00 = 2000.00 )
						//document.frmCal.txtOptionBbeforeVeteranBenf.value = NonMax_YRAOptionB99; //display only for Option B Amount before veteran's benefits
						NonMax_YRAOptionBTotal =  (NonMax_YRAOptionB99 + vetbenefitperyear) ;	
						//Line 5. = 3. x 4. for display on the AmountOptionA text field (Ex. $2,000.00)  
					}else{
						NonMax_YRAOptionB99 = (NonMax_YRA * 0.99);
						NonMax_YRAOptionBTotal = (NonMax_YRA * 0.99); // for calculation (0.80 * 10,000.00)
						//document.frmCal.txtOptionBbeforeVeteranBenf.value = NonMax_YRAOptionBTotal; //display only for Option B Amount before veteran's benefits					
					}//if (varVeteran == "Yes"){//for Option B			
					document.frmCal.txtOptionBbeforeVeteranBenf.value = NonMax_YRAOptionB99
					document.frmCal.txtOptionB.value = CommaFormatted(CurrencyFormatted(NonMax_YRAOptionBTotal));			
					//Option B txtOptionBmonthly
					//document.frmCal.txtOptionBmonthly.value = CommaFormatted(CurrencyFormatted((Max_YRATotal * 0.99)/12));
					document.frmCal.txtOptionBmonthly.value = CommaFormatted(CurrencyFormatted((NonMax_YRAOptionBTotal)/12));			
	
					// for Option C
					var yOptionCfactor = document.frmCal.myResultOptionCfator.value;	//Option C chart
					//alert("yOptionCfactor: " + yOptionCfactor)
					var OptionATotal = document.frmCal.AmountOptionA.value; //Avg of 3 years salary from Option A 					
					if ((yOptionCfactor > 0) && (yOptionCfactor <= 1)){
						//displayAmountOptionAC = CommaFormatted(CurrencyFormatted(Max_YRA));
						document.frmCal.AmountOptionAC.value = displayAmountOptionAC;					
						if (varVeteran == "Yes"){//for Option C			
							//from option A NonMax_YRA = (PF * YRA);
							NonMax_YRAOptionC = (NonMax_YRA * yOptionCfactor); // for calculation (Ex. 0.20 * 10000.00 = 2000.00 )
							NonMax_YRAOptionC_Max_YRAOptionCdisplay = NonMax_YRAOptionC;
							document.frmCal.AmountOptionACbeforeVeteranBenf.value = NonMax_YRAOptionC_Max_YRAOptionCdisplay ; //display only for OptionC before veteran's benefits
							NonMax_YRAOptionBTotal =  (NonMax_YRAOptionC + vetbenefitperyear); 		
							//Line 5. = 3. x 4. for display on the AmountOptionA text field (Ex. $2,000.00)  
						}else{
							NonMax_YRAOptionBTotal = (NonMax_YRA * yOptionCfactor); // for calculation (0.80 * 10,000.00)
							document.frmCal.AmountOptionACbeforeVeteranBenf.value = NonMax_YRAOptionBTotal; //display only for OptionC before veteran's benefits
							//5. for display on the AmountOptionA text field							
						}//if (varVeteran == "Yes"){//for Option C	
						//from option A NonMax_YRA = (PF * YRA);
						myResultOptionCdisplay = CommaFormatted(CurrencyFormatted(NonMax_YRAOptionBTotal));
						document.frmCal.myResultOptionC.value = myResultOptionCdisplay;	// Yearly document.arrayForm.myResult2.value=MultiArray[row];
						document.frmCal.myResultOptionCmonthly.value = CommaFormatted(CurrencyFormatted((NonMax_YRAOptionBTotal)/12)); //monthly
						//2/3 of the Option C in yearly
						document.frmCal.myResultOptionCTwoThirdYearly.value = CommaFormatted(CurrencyFormatted((NonMax_YRAOptionBTotal * 2)/3)); // 2/3 in Yearly
						//2/3 of the Option C in monthly
						document.frmCal.myResultOptionCTwoThirdMonthly.value = CommaFormatted(CurrencyFormatted(((NonMax_YRAOptionBTotal * 2)/3)/12)); // 2/3 in monthly
						}//if ((yOptionCfactor > 0) && (yOptionCfactor <= 1))
		    }else{ //else if (ya >= 36)
				blankOptionCvalue();//Option C blank
		    } // if (ya < 36){ //less than 36 year of age 			
    } //}else{	// Lease than 80% PercentFactor			
}// function computeForm(form)

function checkForm(form) {
    if (validateAgeFactor(form.AgeFactor)) {
        if (validateYRofServices(form.YRofService)){
            if (validateYRAverageSalary(form.YRAverageSalary)) {				
				if (validateisYear(form.yb)){
					if (validateisYear(form.yp)){
						if (validateisYearybBeny(form.ybBeny)){
								if (validateChkBox(form.checkboxAgree)){
									return true;
								}//if (checkAll(form.checkboxAgree))
						} //if (validateisYearybBeny(form.ybBeny))
					}//if (validateisYear(form.yp))
				}//if (validateisYear(form.yb))
            }//if (validateYRAverageSalary(form.YRAverageSalary))
        }//if (validateYRofServices(form.YRofService))
    }//if (validateAgeFactor(form.AgeFactor))
    return false;
}// function checkForm(form)


function get_group_value()
{
for (var i=0; i < document.frmCal.groupmember.length; i++)
   {
   if (document.frmCal.groupmember[i].checked)
      {
      	return document.frmCal.groupmember[i].value;
      }
   }
}

function get_veteran_value()
{
for (var i=0; i < document.frmCal.militaryveteran.length; i++)
   {
   if (document.frmCal.militaryveteran[i].checked)
      {
      	return document.frmCal.militaryveteran[i].value;
      }
   }
}



// End of retirement estimator scripts

//done hiding from old browsers -->





