var creditcalc_http = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false)); function creditcalc_HTTPParam() { } creditcalc_HTTPParam.prototype.create = function( credit_procent, credit_full_sum, credit_first_payment, credit_term, credit_calc_method, credit_comission_1, credit_comission_2, bank_id, credit_id, procent_id ) { this.result = 'option=com_bankstore'; this.insert('command', 'ajax_creditcalc'); this.insert('credit_procent', credit_procent); this.insert('credit_full_sum', credit_full_sum); this.insert('credit_first_payment', credit_first_payment); this.insert('credit_term', credit_term); this.insert('credit_calc_method', credit_calc_method); this.insert('credit_comission_1', credit_comission_1); this.insert('credit_comission_2', credit_comission_2); this.insert('bank_id', bank_id); this.insert('credit_id', credit_id); this.insert('procent_id', procent_id); this.insert('calctype', 'ajax'); return this.result; } creditcalc_HTTPParam.prototype.insert = function(name, value) { this.result += '&' + name + '=' + value; return this.result; } creditcalc_HTTPParam.prototype.encode = function(name, value) { return this.insert(name, encodeURIComponent(value)); } function creditcalc_ajaxSend(data, onReadyStateChange) { creditcalc_http.open("POST", '/creditcalcproxy.php', true); creditcalc_http.onreadystatechange = onReadyStateChange; creditcalc_http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); creditcalc_http.send(data); } function creditcalc_ajaxReady() { if (creditcalc_http.readyState == 4) { if (creditcalc_http.status == 200) { return true; } } return false; } function creditcalc_make_calculation( ) { document.getElementById("bankstore_creditcalc_calc_button").disabled = true; document.getElementById("bankstore_creditcalc_calc_button").value = "Идёт расчёт..."; var data = new creditcalc_HTTPParam().create( document.getElementById( "credit_procent" ).value, document.getElementById( "credit_full_sum" ).value, document.getElementById( "credit_first_payment" ).value, document.getElementById( "credit_term" ).value, document.getElementById( "credit_calc_method" ).value, document.getElementById( "credit_comission_1" ).value, document.getElementById( "credit_comission_2" ).value, document.getElementById( "credit_calc_bank" ) ? document.getElementById( "credit_calc_bank" ).value : 0, document.getElementById( "credit_calc_credit" ) ? document.getElementById( "credit_calc_credit" ).value : 0, document.getElementById( "credit_calc_procent" ) ? document.getElementById( "credit_calc_procent" ).value : 0 ); creditcalc_ajaxSend( data, function() { if( creditcalc_ajaxReady() ) { document.getElementById("bankstore_creditcalc_calc_button").value = "Расчитать"; document.getElementById("bankstore_creditcalc_calc_button").disabled = false; if( creditcalc_http.responseText != '' ) document.getElementById("bankstore_creditcalc_result_container").innerHTML = creditcalc_http.responseText; } } ); } function creditcalc_print_calculation( ) { val_credit_procent = parseFloat( document.getElementById("credit_procent").value ); if( isNaN( val_credit_procent ) ) val_credit_procent = 0; val_credit_full_sum = parseInt( document.getElementById("credit_full_sum").value ); if( isNaN( val_credit_full_sum ) ) val_credit_full_sum = 0; val_credit_first_payment = parseInt( document.getElementById("credit_first_payment").value ); if( isNaN( val_credit_first_payment ) ) val_credit_first_payment = 0; val_credit_term = parseInt( document.getElementById("credit_term").value ); if( isNaN( val_credit_term ) ) val_credit_term = 0; val_credit_calc_method = parseInt( document.getElementById("credit_calc_method").value ); if( isNaN( val_credit_calc_method ) ) val_credit_calc_method = 0; val_credit_comission_1 = parseInt( document.getElementById("credit_comission_1").value ); if( isNaN( val_credit_comission_1 ) ) val_credit_comission_1 = 0; val_credit_comission_2 = parseInt( document.getElementById("credit_comission_2").value ); if( isNaN( val_credit_comission_2 ) ) val_credit_comission_2 = 0; val_credit_calc_bank = 0; if( document.getElementById("credit_calc_bank") ) { val_credit_calc_bank = parseFloat( document.getElementById("credit_calc_bank").value ); if( isNaN( val_credit_calc_bank ) ) val_credit_calc_bank = 0; } val_credit_calc_credit = 0; if( document.getElementById("credit_calc_credit") ) { val_credit_calc_credit = parseFloat( document.getElementById("credit_calc_credit").value ); if( isNaN( val_credit_calc_credit ) ) val_credit_calc_credit = 0; } val_credit_calc_procent = 0; if( document.getElementById("credit_calc_procent") ) { val_credit_calc_procent = parseFloat( document.getElementById("credit_calc_procent").value ); if( isNaN( val_credit_calc_procent ) ) val_credit_calc_procent = 0; } newWindow = window.open( "/index2.php?option=com_bankstore" + "&command=ajax_creditcalc&credit_procent=" + val_credit_procent + "&credit_full_sum=" + val_credit_full_sum + "&credit_first_payment=" + val_credit_first_payment + "&credit_term=" + val_credit_term + "&credit_calc_method=" + val_credit_calc_method + "&credit_comission_1=" + val_credit_comission_1 + "&credit_comission_2=" + val_credit_comission_2 + "&bank_id=" + val_credit_calc_bank + "&credit_id=" + val_credit_calc_credit + "&procent_id=" + val_credit_calc_procent + "&calctype=ajax" + "&remote_addr=3.145.183.137" + "&http_x_forwarded_for=3.145.183.137" + "&fullhtml=1&referer=" + document.domain, "_blank", "directories=no, height=550, width=750, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=yes", false ); }