// JavaScript Document
/*----------------------------------------------------------------
DESCRIPCIN: Ejecuta un popUp con las dimensiones dadas
PARAMETROS: (la ruta del script, el ancho del popUp, el alto del popUp)
----------------------------------------------------------------*/
function abrirPopup(url,ancho,alto)
{
  var opciones="toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,width="+ancho+",height="+alto;
  var Nueva_ventana;
  var tiempo=new Date();
  var hora=tiempo.getHours();
  var minuto=tiempo.getMinutes();
  var segundo=tiempo.getSeconds();
  var nombre=hora+minuto+segundo;
  Nueva_ventana = window.open(url,nombre,opciones); 
  Nueva_ventana.moveTo(0,0); 
}
/*----------------------------------------------------------------
DESCRIPCIN: Asegura la insercin de solo numeros en los campos de texto
PARAMETROS: (Evento)
----------------------------------------------------------------*/
function soloNumeros(e)
{
   var key;
   
   
   if(window.event)
      key = window.event.keyCode;   //IE
   else
      key = e.which;                //firefox
      //alert(key);  key  es el codigo de la tecla
   if (!( (key >= 48 && key <= 57) || (key >= 96 && key <= 105) || key ==8 || key ==9 || key ==0 || key ==46 || key ==44 ))
      return false;
   else
      return true;
}

/*----------------------------------------------------------------
DESCRIPCIN: convierte un string en la notacion 1.000.000,15 a un numero Flotante 1000000,15
PARAMETROS: (Evento)
----------------------------------------------------------------*/

function flotante(numero)
{
	numero=numero.split(".").join("");
	numero=numero.split(",");
	numero=numero.join(".");

	return parseFloat(numero);
}

/*----------------------------------------------------------------
DESCRIPCIN: le pone el formato de  miles a un numero flotante
PARAMETROS: (Evento)
----------------------------------------------------------------*/
function number_format (number, decimals, dec_point, thousands_sep)
{
  var exponent = "";
  var numberstr = number.toString ();
  var eindex = numberstr.indexOf ("e");
  if (eindex > -1)
  {
    exponent = numberstr.substring (eindex);
    number = parseFloat (numberstr.substring (0, eindex));
  }
  
  if (decimals != null)
  {
    var temp = Math.pow (10, decimals);
    number = Math.round (number * temp) / temp;
  }
  var sign = number < 0 ? "-" : "";
  var integer = (number > 0 ? 
      Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
  
  var fractional = number.toString ().substring (integer.length + sign.length);
  dec_point = dec_point != null ? dec_point : ".";
  fractional = decimals != null && decimals > 0 || fractional.length > 1 ? 
               (dec_point + fractional.substring (1)) : "";
  if (decimals != null && decimals > 0)
  {
    for (i = fractional.length - 1, z = decimals; i < z; ++i)
      fractional += "0";
  }
  
  thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? 
                  thousands_sep : null;
  if (thousands_sep != null && thousands_sep != "")
  {
	for (i = integer.length - 3; i > 0; i -= 3)
      integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
  }
  
  return sign + integer + fractional + exponent;
}


