// JavaScript Document

 function validate()
		{
		if( document.f1.r_period.selectedIndex==0)
		{
		alert("Select Repayment Period !");
		document.f1.r_period.focus();
		return false;
		}
		if (document.f1.loan_amount.value=="")
		{
		alert("Enter Loan Amount !");
		document.f1.loan_amount.focus();
		return false;
		}
		if (isNaN(document.f1.loan_amount.value))
		{
		alert("Enter valid Loan Amount !");
		document.f1.loan_amount.focus();
		return false;
		}
		if ((parseInt(document.f1.loan_amount.value)>250000)||(parseInt(document.f1.loan_amount.value)<2000))
		{
		alert("Go for the amount between 2000 to 250000 !");
		document.f1.loan_amount.focus();
		return false;
		}
		LOAN_CALCULATOR();
		return false;
		}


var xmlHttpmodelnamexmlHttp

function LOAN_CALCULATOR()
{ 		
    var loanamt = parseInt(document.f1.loan_amount.value);
	var loanperiod = document.f1.r_period.selectedIndex;
	
	xmlHttpmodelnamexmlHttp=GetXmlHttpObject()
	
	if (xmlHttpmodelnamexmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url = "loan_result.asp?loan_amount=" + loanamt + "&r_period=" + loanperiod;

	xmlHttpmodelnamexmlHttp.onreadystatechange=stateChangedmodel 
	xmlHttpmodelnamexmlHttp.open("GET",url,true)
	xmlHttpmodelnamexmlHttp.send(null)
}

function stateChangedmodel() 
{ 
	if (xmlHttpmodelnamexmlHttp.readyState==4 || xmlHttpmodelnamexmlHttp.readyState=="complete")
	{ 
		document.getElementById("showcalc").style.display = "";
	    document.getElementById("showcalc").innerHTML = xmlHttpmodelnamexmlHttp.responseText;		
	} 
} 

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

function windowClose()
{
	document.getElementById("showcalc").style.display = "none";
}


