function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

function openFoto(foto){

	var http = getHTTPObject();
	var href = 'foto.php?foto='+foto;
	var time = new Date();

	http.open("GET", href, true);
	http.onreadystatechange = function(){
		if(http.readyState==4){
			document.getElementById('foto').className = 'visible';
			document.getElementById('foto').innerHTML = http.responseText;
		}
	}
	http.send(null);
	return;
}

function closeFoto(){
	document.getElementById('foto').className = 'novisible';
}


function number_format(num){

	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function floor(number){
	return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}

function showpay() {
	if(isNaN(document.calc.amount.value)){
		alert('El monto solo puede ser numerica');
		return false;
	}

	if(isNaN(document.calc.years.value)){
		alert('La duracion solo puede ser numerica');
		return false;
	}

	if (isNaN(document.calc.interes.value)){
		alert('El interes solo puede ser numerico');
		return false;
	}

	var ir = document.calc.interes.value / 1200;
	var base = 1;
	var mbase = 1 + ir;
	var amount = document.calc.amount.value;
	// var inicial = document.prestamo.inicial.value;
	// var amount = precio;

	document.calc.amount.value = amount;

	for (i=0; i<document.calc.years.value * 12; i++){
    	base = base * mbase;
	}
	document.getElementById('quotes').innerHTML = number_format(floor(amount * ir / ( 1 - (1/base))))
}