function changeSalary()
{
 ApplA1.txtGross.value = 0;
 var num=ApplA1.lbxEmploymentStatus.selectedIndex;
 if ((num==3)||(num==7)||(num==5)||(num==6))
 {
 ApplA1.txtEmployerName.disabled=true;
 ApplA1.lbxIndustry.disabled=true;
 ApplA1.lbxProfession.disabled=true;
 ApplA1.lbxCountry.disabled=true;
 ApplA1.lbxEmplCity.disabled=true;
 ApplA1.txtPhone1.disabled=true;
 }
 else
 {
 ApplA1.lbxBusinessType.disabled=false;
 ApplA1.txtEmployerName.disabled=false;
 ApplA1.lbxIndustry.disabled=false;
 ApplA1.lbxProfession.disabled=false;
 ApplA1.lbxCountry.disabled=false;
 ApplA1.lbxEmplCity.disabled=false;
 ApplA1.txtPhone1.disabled=false;
 }
}
function isBlank(fieldValue)
{
	var flag; 
 if (fieldValue.length == 0) return true;
 for(i=0;i<fieldValue.length;i++)
 {
 if (fieldValue.charAt(i) == " ")
 flag=1;
 else
 return false;
 }
 if (flag == 1)
 return true;
}
function isPlainNumber(fieldValue)
{
 if (isNaN(fieldValue)) return false;
 return true;
}
function isPositiveInteger(fieldValue)
{
 if(isBlank(fieldValue)) 
 {
 alert("Enter Correct Value");
 return false;
 }
 if (isNaN(fieldValue))
 {
 alert("Enter Correct Value");
 return false;
 }
 if(parseFloat(fieldValue)<0)
 {
 alert("Enter Correct Value");
 return false;
 }
 if(fieldValue.indexOf('+')!=-1||fieldValue.indexOf('.')!=-1)
 {
 alert("Enter Correct Value");
 return false;
 }
 return true;
}
function isChar(field)
{
 if (field.length == 0) return true;
 var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ."
 var ok = "yes";
 var temp;
 for (var i=0; i<field.length; i++)
 {
 temp = "" + field.substring(i, i+1);
 if (valid.indexOf(temp) == "-1") ok = "no";
 }
 if (ok == "no")
 {
 return false;
 }
 else
 {
 return true;
 }
}
function isCharOrNumber(field)
{
 if (field.length == 0) return true;
 var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ."
 var ok = "yes";
 var temp;
 for (var i=0; i<field.length; i++)
 {
 temp = "" + field.substring(i, i+1);
 if (valid.indexOf(temp) == "-1") ok = "no";
 }
 if (ok == "no")
 {
 return false;
 }
 else
 {
 return true;
 }
}
function populate(regform,selectIndex)
{
 timeA = new Date(regform.year.options[regform.year.selectedIndex].text, regform.month.selectedIndex+1,1);
 timeDifference = timeA - 86400000;
 timeB = new Date(timeDifference);
 var daysInMonth = timeB.getDate();
 for (var i = 0; i < regform.day.length; i++)
 {
 regform.day.options[0] = null;
 }
 for (var i = 0; i < daysInMonth; i++)
 {
 regform.day.options[i] = new Option(i+1,i+1);
 }
 regform.day.options[0].selected = true;
}
function checkPinLength(fieldValue,minLength)
{
 var length = fieldValue.length;
 if(length==0)
 return true;
 if(length < 6)
 return false;
 return true;
}
function emailCheck(emailStr)
 {

 if (emailStr.length == 0) return true;
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:#`!~$\\^&*+\\?{}'\\|/\\\\\\\"\\.\\[\\]"
var validCharsUser="\[^\\s" + specialChars + "\]"
var validCharsDomain="\[^\\s" + specialChars + "\[^_" + "\]"
var atomUser=validCharsUser + '+'
var atomDomain=validCharsDomain + '+'
var word="(" + atomUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atomDomain + "(\\." + atomDomain+")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null)
{
 alert("Email address seems incorrect (check @ and .'s)")
 return false;
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
 alert("The username doesn't seem to be valid.")
 return false
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
 alert("The domain name of Email doesn't seem to be valid.")
 return false
}
var atomPat=new RegExp(atomDomain,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
 domArr[domArr.length-1].length>3) {
 alert("The address must end in a three-letter domain, or two letter country.")
 return false
}
var endWord="\[^0123456789\]+"
var endPat=new RegExp("^(" + endWord + ")+$","g")
var endDom = domArr[domArr.length-1].match(endPat)
if (endDom==null) {
 alert("The domain name doesn't seem to be valid. It can end only with alphabets.")
 return false
}
if (len<2) {
 var errStr="This address is missing a hostname!"
 alert(errStr)
 return false
}
return true;
}
function CalcAmt(number)
 {
 var v_number = "";
 var v_length = 0;
 var v_result = "";
 var v_valid_char_set = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ",", ".")
 var v_valid_char_test = "";
 var go_ahead_flag = "Y";
 var v_final = "";
 var v_dotval = "";
 var v_wihtoutdot = "";
 var v_dotexist = "N";
 var v_tempstr = "";
 var v_sk = "";
 var neg = false;
 if (Math.abs(parseFloat(number))!=parseFloat(number)) {
 neg = true;
 v_number = number.substring(1);
 }
 else v_number = number;
 v_length = v_number.length;
 v_result = IsNegativeNumber(v_number);
 for ( i=v_length - 1; i>= 0; i--)
 {
 v_result = "";
 v_result = v_number.charAt(i);
 go_ahead_flag = "N";
 for (var j=0; j<12; j++){
 if (v_result==v_valid_char_set[j]){
 v_result = "";
 go_ahead_flag = "Y";
 break;
 }
 }
 if (go_ahead_flag=="N"){
 v_result = v_valid_char_test;
 break;
 }
 }
 if (go_ahead_flag=="Y"){
 v_final = "";
 for ( i=0; i<= v_length - 1; i++){
 v_result = v_number.charAt(i);
 if (v_result==","){
 }
 else{
 v_final = v_final + v_result;
 }
 }
 }
 if (go_ahead_flag=="Y"){
 v_tempstr = v_final;
 v_length = v_tempstr.length;
 for (var i=0; i<= v_length - 1; i++){
 v_result = v_tempstr.charAt(i);
 if (v_result=="0"){
 v_final = v_tempstr.substring(i+1);
 }
 else{
 break;
 }
 }
 }
 if (go_ahead_flag=="Y"){
 v_length = v_final.length;
 v_dotval = "";
 v_tempstr = "";
 for ( i=v_length - 1; i >= 0; i--){
 v_result = v_final.charAt(i);
 if (v_result=="."){
 v_wihtoutdot = "";
 v_tempstr = v_final.substring(0,i);
 v_length = v_tempstr.length;
 for ( j=v_length - 1; j>= 0; j--){
 v_result = v_tempstr.charAt(j);
 if (v_result=="."){
 var jk=1;
 jk++;
 }
 else{
 v_wihtoutdot = v_result + v_wihtoutdot;
 }
 }
 v_dotexist = "Y";
 break;
 }
 else{
 v_dotval = v_result + v_dotval;
 }
 }
 }
 if (go_ahead_flag=="Y"){
 if (v_dotexist=="N"){
 v_wihtoutdot = v_dotval;
 v_dotval = "";
 }
 }
 if (go_ahead_flag=="Y"){
 v_length = v_wihtoutdot.length;
 v_result = "";
 for ( i=v_length - 1, j=1; i>=0; i--,j++){
 v_result = v_wihtoutdot.charAt(i) + v_result;
 if (j == 3) {
 if(i != 0){
 v_result = "," + v_result;
 }
 j = 0 ;
 }
 }
 }
 var newdots= v_dotval.charAt(0);
 newdots+= v_dotval.charAt(1);
 if (v_dotval==""){
 v_result= v_result + ".00";
 }
 else{
 v_result= v_result + "." + newdots;
 }
 if (v_result==".00") v_result = "0.00";
 if (neg) v_result = "-"+v_result ;
 return v_result;
 }
 function RevCal(number) {
 var v_number = "";
 var v_length = 0;
 var v_result = "";
 var v_final = "";
 v_number = number;
 v_length = v_number.length;
 v_final = "";
 for (i=0; i<= v_length - 1; i++){
 v_result = v_number.charAt(i);
 if (v_result==","){
 }
 else{
 v_final = v_final + v_result;
 }
 }
 v_result = v_final;
 return v_result;
 }
 function IsNegativeNumber(theInput)
 {
 if (theInput == "")
 {
 return(true);
 }
 var orgnlvalue = "";
 var totallength = theInput.length;
 for(i=0;i<=totallength;i++)
 {
 if(theInput.charAt(i)!=',' && theInput.charAt(i)!='.')
 {
 orgnlvalue+=theInput.charAt(i);
 }
 }
 theInput = orgnlvalue;
 var theLength = theInput.length;
 for (var i = 0; i <= (theLength-1); i++)
 {
 var theChar = theInput.substring(i,i+1);
 if ((theChar < "0" || theChar > "9")&(i!=0 && theChar=="-"))
 {
 alert ('Please Enter Correct Value.');
 return(false);
 }
 }
 return true;
 }
 function Redirect()
 {
  num = ApplA1.lbxEmploymentStatus.selectedIndex;
  if(num==0)
  {
  alert('Please select Employment Status.');
  return;
  }
  if(num>4)
  {
  alert('No Income Calculator for Student, Housewife and Unemployed');
  return;
  }
  if (!window.child || window.child.close)
  {
  window.child = window.open("","child","menubar=no, resizable=yes,scrollbars=yes,status=0, alwaysraised=yes, height=470, width=800, top=0, left=0");
  window.child.document.open("text/html");
  window.child.document.writeln('<DIV STYLE="position:absolute;left:10;font-Family:Sans-Serif;font-Size:18pt;visibility:show;"><CENTER><IMG SRC="images/POPUP.GIF" alt="POPUP" border="0" align=bottom ><br><FONT COLOR="green"><B>Loading....</B></FONT></CENTER></DIV>');
  window.child.document.close();
  window.child.focus();
  if(num==1)
  {
  window.child.document.location.href = '/routerServlet/hlsalcalc.ext?reqId=hlap0008&CalledForm=ApplA1&Fld=txtGross';
  }
  if(num==2)
  {
  window.child.location.href = '/routerServlet/hlselfempcalc.ext?reqId=hlap0009&CalledForm=ApplA1&Fld=txtGross';
  }
  if(num==3)
  {
  window.child.document.location.href = '/routerServlet/hlsalcalc.ext?reqId=hlap0008&CalledForm=ApplA1&Fld=txtGross';
  }
  if(num==4)
  {
  window.child.location.href = '/routerServlet/hlselfempcalc.ext?reqId=hlap0009&CalledForm=ApplA1&Fld=txtGross';
  }
  }
 }
 function callPage(target)
 {
  Validate_Data("A");
 }

