function calculate() { // Get the user's input from the form. Assume it is all valid. // Convert interest from a percentage to a decimal, and convert from // an annual rate to a monthly rate. Convert payment period in years // to the number of monthly payments. var principal = document.loandata.principal.value; var interest = document.loandata.interest.value / 100 / 12; var payments = document.loandata.years.value * 12; // Now compute the monthly payment figure, using esoteric math. var x = Math.pow(1 + interest, payments); var monthly = (principal*x*interest)/(x-1); // Check that the result is a finite number. If so, display the results if (!isNaN(monthly) && (monthly != Number.POSITIVE_INFINITY) && (monthly != Number.NEGATIVE_INFINITY)) { document.loandata.payment.value = round(monthly); document.loandata.total.value = round(monthly * payments); document.loandata.totalinterest.value = round((monthly * payments) - principal); } // Otherwise, the user's input was probably invalid, so don't // display anything. else { document.loandata.payment.value = ""; document.loandata.total.value = ""; document.loandata.totalinterest.value = ""; } } // This simple method rounds a number to two decimal places. function round(x) { return Math.round(x*100)/100; } function displayLoader(where) { document.getElementById(where).innerHTML = ''; return true; } function displaySubmit(where) { document.getElementById(where).innerHTML = '
'; return true; } function openWindow(windowFile, windowName, w, h) { //alert(w+' '+h); window.open(windowFile,windowName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,height="+h+",width="+w); } function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ //alert("Invalid E-mail ID") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ //alert("Invalid E-mail ID") return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ //alert("Invalid E-mail ID") return false } if (str.indexOf(at,(lat+1))!=-1){ //alert("Invalid E-mail ID") return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ //alert("Invalid E-mail ID") return false } if (str.indexOf(dot,(lat+2))==-1){ //alert("Invalid E-mail ID") return false } if (str.indexOf(" ")!=-1){ //alert("Invalid E-mail ID") return false } return true } /** * * @access public * @return void **/ function checkNewsletterForm(){ if (echeck(document.nlform.emailAddress.value) == false) { alert('Invalid email address'); return false; } else { return true; } } function checkRequestForm() { var alertmsg = ''; if (document.reqPropertyInfo.rname.value == '') { var alertmsg = 'Please complete your name.'; var error = 1; } if (document.reqPropertyInfo.remail.value == '' && document.reqPropertyInfo.rphone.value == '') { var alertmsg = alertmsg + '\nMissing contact details. Please complete either telephone number or email address.'; var error = 1; } if (document.reqPropertyInfo.remail.value != '') { if (echeck(document.reqPropertyInfo.remail.value)==false) { var alertmsg = alertmsg + '\nInvalid email address'; var error = 1; } } if (error == 1) { alert('Error: '+alertmsg); return false; } else { displaySubmit('morePInfo'); } } function checkSendPropertyForm() { var alertmsg = ''; if (document.emailPropertyForm.senderName.value == '') { var alertmsg = 'Please complete your name.'; var error = 1; } if (document.emailPropertyForm.rec.value == '') { var alertmsg = alertmsg + '\nPlease complete recipients email address'; var error = 1; } if (document.emailPropertyForm.senderEmail.value == '') { var alertmsg = alertmsg + '\nPlease complete your email address'; var error = 1; } if (document.emailPropertyForm.senderEmail.value != '') { if (echeck(document.emailPropertyForm.senderEmail.value)==false) { var alertmsg = alertmsg + '\nInvalid sender email address'; var error = 1; } } if (document.emailPropertyForm.rec.value != '') { if (echeck(document.emailPropertyForm.rec.value)==false) { var alertmsg = alertmsg + '\nInvalid recipient email address'; var error = 1; } } if (error == 1) { alert('Error: '+alertmsg); return false; } else { displaySubmit('emailProperty'); } } function checkCF(rt) { var error = 0; if (document.conform.name.value == '') { var error = 1; } if (document.conform.email.value == '') { var error = 1; } if (echeck(document.conform.email.value) == false) { alert('Invalid email address'); var error = 1; } if (rt == 1) { if (document.conform.propertyRequestType.value == '0') { var error = 1; } if (document.conform.selectAreaIDFromContactForm.value == '0') { var error = 1; } if (document.conform.propertyRequestType.value == '0') { var error = 1; } if (document.conform.priceFrom.value == '') { var error = 1; } if (document.conform.priceTo.value == '') { var error = 1; } if (document.conform.sizeFrom.value == '') { var error = 1; } if (document.conform.sizeTo.value == '') { var error = 1; } } if (error == 1) { alert('Please complete the contact form with all the required fields'); return false; } else { document.conform.submit() } } function requestPDF(pid) { var exfile = 'pdf.php?property='+pid; location = 'https://www.kazbar.gr/'+exfile; }