function Calcula_Total(){

	if (document.getElementById('txtcantm').value!= "" && document.getElementById('txtpreciom').value != ""){

		document.getElementById('txttotal').value = Formato_Moneda((document.getElementById('txtcantm').value * document.getElementById('txtpreciom').value) + parseInt(document.getElementById('txtregistrationfee').value));

	}

	if ((document.getElementById('txtcantm').value== "" || document.getElementById('txtpreciom').value== "") && (document.getElementById('txttotal').value!="")){

		document.getElementById('txttotal').value = "";

	}

}

function Pon_Precio(tipo){

	if (tipo==1){

		document.getElementById('txtpreciom').value=320;	

	}else if (tipo ==2){	

		document.getElementById('txtpreciom').value=350;

	}else{
		document.getElementById('txtpreciom').value=380;	
	}

	Calcula_Total();

}

function validar(e) { 

    tecla = (document.all) ? e.keyCode : e.which; 

    if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 

    // dejar la línea de patron que se necesite y borrar el resto 

    //patron =/[A-Za-z]/; // Solo acepta letras 

    patron = /\d/; // Solo acepta números 

    //patron = /\w/; // Acepta números y letras 

    //patron = /\D/; // No acepta números 

    // 

    te = String.fromCharCode(tecla); 

    return patron.test(te);  

}

function Formato_Moneda(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);

}