
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }



function ff()
{

var year=parseInt(document.rgs.year.value);
var ttyr=parseInt(document.rgs.tyr.value);
var gnm=parseInt(document.rgs.tmnth.value);
var dst=parseInt(document.rgs.tdys.value);

var dfr=year-ttyr;
bcsl=parseFloat(document.rgs.bcsl.value);

if(document.rgs.tyr.value == "")
{
alert("\u0627\u0644\u0631\u062c\u0627\u0621 \u0625\u062f\u062e\u0627\u0644 \u0645\u062c\u0645\u0648\u0639 \u0645\u062f\u062f \u0627\u0644\u062e\u062f\u0645\u0629");
document.rgs.tyr.focus();

}
else if(isNaN(document.rgs.tyr.value))
{
alert("\u0627\u0644\u0631\u062c\u0627\u0621 \u0625\u062f\u062e\u0627\u0644 \u0642\u064a\u0645\u0629 \u0631\u0642\u0645\u064a\u0629 \u0641\u064a \u062e\u0627\u0646\u0629 \u0645\u062c\u0645\u0648\u0639 \u0645\u062f\u062f \u0627\u0644\u062e\u062f\u0645\u0629");
document.rgs.tyr.focus();

}

else if(document.rgs.year.value == "")
{
alert("\u0627\u0644\u0631\u062c\u0627\u0621 \u0625\u062f\u062e\u0627\u0644 \u0627\u0644\u0639\u0645\u0631");
document.rgs.year.focus();

}
else if(isNaN(document.rgs.year.value))
{
alert("\u0627\u0644\u0631\u062c\u0627\u0621 \u0625\u062f\u062e\u0627\u0644 \u0642\u064a\u0645\u0629 \u0631\u0642\u0645\u064a\u0629 \u0641\u064a \u062e\u0627\u0646\u0629 \u0627\u0644\u0639\u0645\u0631");
document.rgs.year.focus();

}

else if(document.rgs.bcsl.value == "")
{
alert("\u0627\u0644\u0631\u062c\u0627\u0621 \u0625\u062f\u062e\u0627\u0644 \u0627\u0644\u0631\u0627\u062a\u0628");
document.rgs.bcsl.focus();

}
else if(IsNumeric(document.rgs.bcsl.value) == false)
{
alert("\u0627\u0644\u0631\u062c\u0627\u0621 \u0627\u0644\u062a\u0623\u0643\u062f \u0645\u0646 \u0627\u0644\u0642\u064a\u0645 \u063a\u064a\u0631 \u0627\u0644\u0631\u0642\u0645\u064a\u0629");
document.rgs.bcsl.focus();

}

else if(bcsl<100)
{
document.rgs.tot.value="";
alert("\u0639\u0641\u0648\u0627\u060c \u0623\u0646\u062a \u063a\u064a\u0631 \u0645\u0624\u0647\u0644 \u0644\u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634 \u0644\u0623\u0646 \u0631\u0627\u062a\u0628\u0643 \u0623\u0642\u0644 \u0645\u0646 100")
document.rgs.bcsl.focus();
}

else if(dfr<=15)
{
alert("\u0627\u0644\u0631\u062c\u0627\u0621 \u0627\u0644\u062a\u0623\u0643\u062f \u0645\u0646 \u062a\u0627\u0631\u064a\u062e \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u060c \u0644\u0623\u0646\u0647 \u064a\u062c\u0628 \u0623\u0646 \u064a\u0643\u0648\u0646 \u0647\u0646\u0627\u0643 \u0641\u0631\u0642  15 \u0639\u0627\u0645\u0627 \u0628\u064a\u0646 \u0627\u0644\u0639\u0645\u0631 \u0648 \u0645\u062c\u0645\u0648\u0639 \u0633\u0646\u0648\u0627\u062a \u0627\u0644\u062e\u062f\u0645\u0629");
document.rgs.tot.value="";
document.rgs.year.focus();

}

else
{
//alert(year)
var sx=document.rgs.sex.options[document.rgs.sex.selectedIndex].value
sx=sx.toUpperCase();

if(sx=="M")
{

if( ttyr<=14)
{
document.rgs.tot.value="";
alert("\u0639\u0641\u0648\u0627\u060c \u0623\u0646\u062a \u063a\u064a\u0631 \u0645\u0624\u0647\u0644 \u0644\u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634 \u0644\u0623\u0646 \u0645\u062c\u0645\u0648\u0639 \u0633\u0646\u0648\u0627\u062a \u0627\u0644\u062e\u062f\u0645\u0629 \u0623\u0642\u0644 \u0645\u0646 14 \u0639\u0627\u0645\u0627")
}
else if( ttyr>=14 && ttyr<=19 && year>=60)
{

ttl=1/40 * [(bcsl * ttyr) + (bcsl * gnm/12) + (bcsl * dst/365)] 
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;

}
else if(ttyr>19)
{

ttl=1/40 * [(bcsl * ttyr) + (bcsl * gnm/12) + (bcsl * dst/365)] 
if(year<45)
{
//ttl=ttl*80/100
//ttl=Math.round(ttl*1000)/1000
//document.rgs.tot.value=ttl;
document.rgs.tot.value="";
alert("\u0639\u0641\u0648\u0627\u060c \u0623\u0646\u062a \u063a\u064a\u0631 \u0645\u0624\u0647\u0644 \u0644\u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634 \u0644\u0623\u0646\u0647 \u0644\u0627 \u064a\u0646\u0637\u0628\u0642 \u0639\u0644\u064a\u0643 \u0634\u0631\u0648\u0637 \u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634")
}
// ************************************* Modified
else if(year>=45 && year<46)
{
ttl=ttl - ttl*30/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=46 && year<47)
{
ttl=ttl - ttl*28/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=47 && year<48)
{
ttl=ttl - ttl*26/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=48 && year<49 )
{
ttl=ttl - ttl*24/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=49 && year<50)
{
ttl=ttl - ttl*22/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=50 && year<51 )
{
ttl=ttl - ttl*20/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=51 && year<52)
{
ttl=ttl - ttl*18/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=52 && year<53)
{
ttl=ttl - ttl*16/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=53 && year<54)
{
ttl=ttl - ttl*14/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=54 && year<55)
{
ttl=ttl - ttl*12/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=55 && year<56)
{
ttl=ttl - ttl*10/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=56 && year<57)
{
ttl=ttl - ttl*9/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=57 && year<58)
{
ttl=ttl - ttl*8/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=58 && year<59)
{
ttl=ttl - ttl*7/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=59 && year<60)
{
ttl=ttl - ttl*6/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=60)
{
ttl=1/40 * [(bcsl * ttyr) + (bcsl * gnm/12) + (bcsl * dst/365)] 
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}

}

else
{
document.rgs.tot.value="";
alert("\u0639\u0641\u0648\u0627\u060c \u0623\u0646\u062a \u063a\u064a\u0631 \u0645\u0624\u0647\u0644 \u0644\u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634 \u0644\u0623\u0646\u0647 \u0644\u0627 \u064a\u0646\u0637\u0628\u0642 \u0639\u0644\u064a\u0643 \u0634\u0631\u0648\u0637 \u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634")
}

}


if(sx=="F")
{
//document.rgs.tot.value="";
//alert("Sorry you are not entitled to get pension because your total service period is below then 14 years")



if( ttyr<=9)
{
document.rgs.tot.value="";
alert("\u0639\u0641\u0648\u0627\u060c \u0623\u0646\u062a \u063a\u064a\u0631 \u0645\u0624\u0647\u0644 \u0644\u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634 \u0644\u0623\u0646\u0647 \u0644\u0627 \u064a\u0646\u0637\u0628\u0642 \u0639\u0644\u064a\u0643 \u0634\u0631\u0648\u0637 \u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634 \u0644\u0623\u0646 \u0645\u062c\u0645\u0648\u0639 \u0633\u0646\u0648\u0627\u062a \u0627\u0644\u062e\u062f\u0645\u0629 \u0623\u0642\u0644 \u0645\u0646 9 \u0633\u0646\u0648\u0627\u062a")
}
else if( ttyr>=9 && ttyr<=14 && year>=55)
{

ttl=1/40 * [(bcsl * ttyr) + (bcsl * gnm/12) + (bcsl * dst/365)] 
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;

}
else if(ttyr>14)
{

ttl=1/40 * [(bcsl * ttyr) + (bcsl * gnm/12) + (bcsl * dst/365)] 
if(year<45)
{
//ttl=ttl*80/100
//ttl=Math.round(ttl*1000)/1000
//document.rgs.tot.value=ttl;
document.rgs.tot.value="";
alert("\u0639\u0641\u0648\u0627\u060c \u0623\u0646\u062a \u063a\u064a\u0631 \u0645\u0624\u0647\u0644 \u0644\u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634 \u0644\u0623\u0646\u0647 \u0644\u0627 \u064a\u0646\u0637\u0628\u0642 \u0639\u0644\u064a\u0643 \u0634\u0631\u0648\u0637 \u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634")
}
// ***************************** Modified
else if(year>=45 && year<46)
{
ttl=ttl - ttl*25/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=46 && year<47)
{
ttl=ttl - ttl*23/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=47 && year<48)
{
ttl=ttl - ttl*21/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=48 && year<49)
{
ttl=ttl - ttl*19/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=49 && year<50)
{
ttl=ttl - ttl*17/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=50 && year<51)
{
ttl=ttl - ttl*15/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=51 && year<52)
{
ttl=ttl - ttl*13/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=52 && year<53)
{
ttl=ttl - ttl*11/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=53 && year<54)
{
ttl=ttl - ttl*9/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=54 && year<55)
{
ttl=ttl - ttl*7/100
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}
else if(year>=55)
{
ttl=1/40 * [(bcsl * ttyr) + (bcsl * gnm/12) + (bcsl * dst/365)] 
ttl=Math.round(ttl*1000)/1000
document.rgs.tot.value=ttl;
}

}

else
{
document.rgs.tot.value="";
alert("\u0639\u0641\u0648\u0627\u060c \u0623\u0646\u062a \u063a\u064a\u0631 \u0645\u0624\u0647\u0644 \u0644\u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634 \u0644\u0623\u0646\u0647 \u0644\u0627 \u064a\u0646\u0637\u0628\u0642 \u0639\u0644\u064a\u0643 \u0634\u0631\u0648\u0637 \u0625\u0633\u062a\u062d\u0642\u0627\u0642 \u0627\u0644\u0645\u0639\u0627\u0634")
}

}

//female finish...

}

return false; 

}
