// JavaScript Document

 function checksdate(str,id)
      {
          
          if (str == "")
          {
              $(document.getElementById(id)).dpDisplay();
              return false;
          }
          if (isDate(str))
          {
              //alert("Valid");
          }
          else
          {
              alert("Please Enter Valid Date.");
              //document.getElementById(id).value = "";
              document.getElementById(id).focus();
          }
      }
	  
	  
	  function getAmortization(a,n,p)
		{
			if (document.getElementById('terminY').checked)
			{
				n = n * 12;
			}

			var i=0;
			var sATline="";
			/*var oAmortizationTable=document.getElementById("amortizationtable");
			oAmortizationTable.style.visibility="visible";*/

			/* Calculate amortization and write table to text area **/
			var payment = getPayment(a,n,p);
			var oAmortizationTable=document.getElementById("amortizationtable");
			oAmortizationTable.value = "Your monthly payment for a " + n + " month(s) loan at " + p + "% would be " + (Math.round(payment*100)/100);
		}

	function getPayment(a,n,p) {
		/* Calculates the monthly payment from annual percentage
		   rate, term of loan in months and loan amount. **/
		var acc=0;
		var base = 1 + p/1200;
		for (i=1;i<=n;i++)
			{ acc += Math.pow(base,-i); }
		return a/acc;
	}
	function CheckYears()
	{
		document.getElementById('terminM').checked = "";
	}
	function CheckMonths()
	{
		document.getElementById('terminY').checked = "";
	}
	
	
	function chkprice(e)
{
//alert("testing");
   var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    //alert(_dom);
    if(_dom==2){                     // for NN4
        //alert(e.which);
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            //alert('Mozilla:' + e.charCode);
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }

    if(KeyID==46)
        {
            return true;
        }
    else if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
    {
        //alert("hello");
        return false;
    }


    return true;
}	