var xmlHttp

function compound(a)
{
var calcid=a;
var principal=document.form1.txtprincipal.value;
var intrate=document.form1.txtinterest.value;
var year=document.form1.txttime.value;
var period=document.form1.txtperiod.value;
flag=0;
if(principal=="")
{
	alert("Enter Principal Amount");
	document.form1.txtprincipal.focus();
	flag=1;
}
if(flag==0)
{
	if(intrate=="")
	{
		alert("Enter Interest Rate");
		document.form1.txtinterest.focus();
		flag=1	
	}
}
if(flag==0)
{
	if(year=="")
	{
		alert("Enter Time");
		document.form1.txttime.focus();
		flag=1	
	}
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
if(flag==0)
{
var url="calculator.php?calcid="+calcid+"&principal="+principal+"&intrate="+intrate+"&year="+year+"&period="+period;
xmlHttp.onreadystatechange = function(){ stateChanged(calcid); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
} 

function emicalc(b)
{
var calcid=b;
var principal=document.frmemi.txtprincipal.value;
var intrate=document.frmemi.txtinterest.value;
var year=document.frmemi.txttime.value;
flag=0;
if(principal=="")
{
	alert("Enter Principal Amount");
	document.frmemi.txtprincipal.focus();
	flag=1;
}
if(flag==0)
{
	if(intrate=="")
	{
		alert("Enter Interest Rate");
		document.frmemi.txtinterest.focus();
		flag=1	
	}
}
if(flag==0)
{
	if(year=="")
	{
		alert("Enter Period");
		document.frmemi.txttime.focus();
		flag=1	
	}
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
if(flag==0)
{
var url1="calculator.php?calcid="+calcid+"&principal="+principal+"&intrate="+intrate+"&year="+year;
xmlHttp.onreadystatechange = function(){ stateChanged(calcid); };
xmlHttp.open("GET",url1,true)
xmlHttp.send(null)
}
} 

function incometax(c)
{
	flag=0;
	var calcid=c;
	var category=document.frmincome.category.value;
	var taxincome=document.frmincome.txttaxincome.value;
	var deduct=document.frmincome.txtdeduct.value;
	var mediclaim=document.frmincome.txtmediclaim.value;
	var homeloan=document.frmincome.txthomeloan.value;
	var education=document.frmincome.txteducation.value;
	if(category=="")
	{
		alert("Select a Category")
		document.frmincome.category.focus();
		flag=1;
	}
	if(flag==0)
	{
			if(taxincome=="")
			{
					alert("Enter your Income");
					document.frmincome.txttaxincome.focus();
					flag=1;
			}
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if(flag==0)
	{
		var url2="calculator.php?calcid="+calcid+"&category="+category+"&taxincome="+taxincome+"&deduct="+deduct+"&mediclaim="+mediclaim+"&homeloan="+homeloan+"&education="+education;
		xmlHttp.onreadystatechange = function(){ stateChanged(calcid); };
		xmlHttp.open("GET",url2,true)
		xmlHttp.send(null)
	}
}
function stateChanged(param) 
{ 
		if(param==1)
		{
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
				document.getElementById("txtcompound").value=xmlHttp.responseText; 
			}
		}

		if(param==2)
		{
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
				document.getElementById("txtemi").value=xmlHttp.responseText; 
			}
		}
		if(param==3)
		{
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
				var value1=xmlHttp.responseText;
				var brokenstring=value1.split("-"); 
				document.getElementById("txtnetamt").value=brokenstring[0]; 
				document.getElementById("txttax").value=brokenstring[1];  
				document.getElementById("txtrate").value=brokenstring[2]; 
			}
		}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

