function check_yn(str)
{
	if(str=='NO')
	{
		document.getElementById("adv_amount").disabled=true;
		document.getElementById("adv_date").disabled=true;
	}
	else
	{
		document.getElementById("adv_amount").disabled=false;
		document.getElementById("adv_date").disabled=false;
	}
}
function check_marriage(str)
{
   if(str=='Single')
   {
   		document.getElementById("marriage").disabled=true;
		document.getElementById("wh_name").disabled=true;
		document.getElementById("sons").disabled=true;
		document.getElementById("daughters").disabled=true;
   }
   else if(str=='Married' || str=='000')
   {
   		document.getElementById("marriage").disabled=false;
		document.getElementById("wh_name").disabled=false;
		document.getElementById("sons").disabled=false;
		document.getElementById("daughters").disabled=false;
   }
   
}
function addressInfo(){

	if(document.getElementById("copy_add").checked==true)
	{
		document.getElementById('per_add1').value = document.getElementById('pre_add1').value;
		document.getElementById('per_add2').value = document.getElementById('pre_add2').value;
		document.getElementById('per_add3').value = document.getElementById('pre_add3').value;
		document.getElementById('per_city').value = document.getElementById('pre_city').value;
		document.getElementById('per_state').value = document.getElementById('pre_state').value;
		document.getElementById('per_country').value = document.getElementById('pre_country').value;
		document.getElementById('per_pincode').value = document.getElementById('pre_pincode').value;
		document.getElementById('per_mobile').value = document.getElementById('pre_mobile').value;
		document.getElementById('per_phone').value = document.getElementById('pre_phone').value;
		document.getElementById('per_alt_phone').value = document.getElementById('pre_alt_phone').value;
		document.getElementById('per_alt_mobile').value = document.getElementById('pre_alt_mobile').value;
		
	}else{
		document.getElementById('per_add1').value = '';
		document.getElementById('per_add2').value = '';
		document.getElementById('per_add3').value = '';
		document.getElementById('per_city').value = '';
		document.getElementById('per_state').value = '';
		document.getElementById('per_country').value = '';
		document.getElementById('per_pincode').value = '';
		document.getElementById('per_mobile').value = '';
		document.getElementById('per_phone').value = '';
		document.getElementById('per_alt_phone').value = '';
	}
}
function find_state(str)
{
	if(str.length==0)
  {
  document.getElementById("state_id").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("state_id").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","emp_state.php?country="+str,true);
xmlhttp.send();
}

function find_city(str)
{
	var cntry=document.getElementById("pre_country").value;
	if (str.length==0)
  {
  document.getElementById("city_id").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("city_id").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","emp_city.php?state="+str+"&country="+cntry,true);
xmlhttp.send();
}
function cal_alltot()
{
	var total_allowance=0;
	var count = document.getElementById("ctr").value;
	for(var j=1;j<count;j++)
	{
		var allowance = document.getElementById("allow_"+j).value;
		total_allowance=parseFloat(total_allowance)+parseFloat(allowance);
	}
	document.getElementById("allow_tot").value=total_allowance.toFixed(2);
}
function cal_dedtot()
{
	var tot_deduction=0;
	var count=document.getElementById("dctr").value;
	for(var j=1;j<count;j++)
	{
		var deduction = document.getElementById("deduction_"+j).value;
		tot_deduction=parseFloat(tot_deduction)+parseFloat(deduction);
	}
	document.getElementById("deduct_tot").value=tot_deduction.toFixed(2);
}
function cal_gross()
{
	var basic=document.getElementById("basic_salary").value;
	var allow_tot= document.getElementById("allow_tot").value;
	var deduct_tot= document.getElementById("deduct_tot").value;
	var gross=parseFloat(allow_tot)+parseFloat(deduct_tot)+parseFloat(basic);
	document.getElementById("gross_sal").value=gross.toFixed(2);
}
function cal_net()
{
	var basic=document.getElementById("basic_salary").value;
	var allow_tot= document.getElementById("allow_tot").value;
	var net=parseFloat(basic)+parseFloat(allow_tot);
	document.getElementById("net_sal").value=net;
}


function cal_dedvalue(str,j)
{
	var basic=document.getElementById("basic_salary").value;
	var totvalue=basic*((str)/100);
	document.getElementById("deduction_"+j).value=totvalue.toFixed(2);
}