  function roundPrecen(number, X) {
    return Math.round(number * Math.pow(10,X)) / Math.pow(10,X);
  }

  function formateaPrecio(numero) {
    var cantidad = "" + numero;
    var decimales = "";
    if (cantidad.indexOf(",") != -1) {
      decimales = cantidad.substr(cantidad.indexOf(",")+1,2);
      cantidad = cantidad.substring(0,cantidad.indexOf(","));
    }
    if (cantidad.indexOf(".") != -1) {
      decimales = cantidad.substr(cantidad.indexOf(".")+1,2);
      cantidad = cantidad.substring(0,cantidad.indexOf("."));
    }
  	var formatNumero = "";
  	var j = 1;

  	while (j <= cantidad.length) {
  		formatNumero = cantidad.substring((cantidad.length-j),(cantidad.length-j+1)) + formatNumero;
  		if (((j%3) == 0) && (j < cantidad.length)) {
  		  formatNumero = "." + formatNumero;
  		}
  		j++;
  	}

    if (decimales != "")
      formatNumero = formatNumero + "," + decimales;

  	return formatNumero;
  }

  function comaPunto(valor) {
    var cadenaFinal = "" + valor;

    if (cadenaFinal.indexOf(',') != -1) {
      cadenaFinal = cadenaFinal.substring(0,cadenaFinal.indexOf(',')) + '.' + cadenaFinal.substring(cadenaFinal.indexOf(',')+1,cadenaFinal.length)
    }

    return cadenaFinal;
  }

  function soloEnteros(e) {
    var key = '';
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? e.which : e.keyCode;

    if (whichCode == 13) return true;
    key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
    return true;
  }

  function soloNumeros(e) {
    var key = '';
    if (e.keyCode== 44) e.keyCode = 46;
    var strCheck = '-0123456789.';
    var whichCode = (window.Event) ? e.which : e.keyCode;

    if (whichCode == 13) return true;
    key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
    return true;
  }

  function CantidadValida(Cantidad)
  {
    if (isNaN(Cantidad.value)){
     Cantidad.focus();
     alert('La cantidad introducida en ' + Cantidad.label + ' no es válida' );     
     return false;  
    }else {
     return true;
    }
  }

