// JavaScript Document

//Formateo un numero con el numero de 0 que le pasamos por paramteros
function formatNumber(numero, tamano) {
    var resultado = "" + numero;
    while (resultado.length < tamano) {
        resultado = "0" + resultado
    }
    return resultado
}

function Decimales(Numero, Decimales) {

	pot = Math.pow(10,Decimales);
	num = parseInt(Numero * pot) / pot;
	nume = num.toString().split('.');

	entero = nume[0];
	decima = nume[1];

	if (decima != undefined) {
		fin = Decimales-decima.length; }
	else {
		decima = '';
		fin = Decimales; }

	for(i=0;i<fin;i++)
	  decima+=String.fromCharCode(48); 

	num=entero+'.'+decima;
	return num;
}
//FUNCION QUE PARALIZA LA EJECUCION DEL SCRIPT POR EL NUMERO DE MILISEGUNDOS QUE LE PASEMOS
function pause(millis) 
{
        var date = new Date();
        var curDate = null;

        do { curDate = new Date(); } 
        while(curDate-date < millis)
}
//FUNCIONQUE VALIDA UNA DIRECCION DE CORREO CON JQUERY
jQuery.fn.correo=function()
{
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($(this).val()))
	{
		return true;
	}
	else
	{
		return false;
	}
}


//FUNCIONES PARA VALIDAR INPUTS CON JQUERY
/*
sjorrillo = {
    //------------------------------------------------------   
    //Variables
    //------------------------------------------------------
     
    //Número de decimales en la caja de texto.
    NumeroDeDecimales: "3",
 
    //------------------------------------------------------   
    //Métodos
    //------------------------------------------------------
     
    // Permite solo ingresar enteros
    EnterosHandled: function(e) {
        if (e.which >= 48 & e.which <= 57 | e.which == 8) {
            return true;
        }
        else {
            e.preventDefault();
        }
    },
 
    // Permite ingresar decimales
    DecimalesHandled: function(e, text) {
        var decimales = 0;
 
        if (sjorrillo.ContarPuntos(text) > 0) {
            decimales = sjorrillo.CantidadDecimales(text);
        }
         
        if (e.which >= 48 & e.which <= 57 & 
           decimales < sjorrillo.NumeroDeDecimales | e.which == 8) {
            return true;
        }
        else {
            if (text != "" & e.which == 46 & sjorrillo.ContarPuntos(text) == 0)
                return true;
            else {
                e.preventDefault();
            }
        }
    },
 
    //Permite ingresar solo texto.
    SoloTextoHandled: function(e) {
        if ((e.which >= 97 & e.which <= 122) | (e.which >= 65 & e.which <= 90) |
            e.which == 32 | e.which == 8) {
            return true;
        }
        else {
            e.preventDefault();
        }
    },
 
    //Permite ingresar solo alfanumericos.
    AlfanumericoHandled: function(e) {
        if ((e.which >= 48 & e.which <= 57) | (e.which >= 97 & e.which <= 122) |
           (e.which >= 65 & e.which <= 90) | e.which == 32 | e.which == 8) {
            return true;
        }
        else {
            e.preventDefault();
        }
    },
 
    //Cuenta el número de puntos en una cadena.
    ContarPuntos: function(input) {
        var cant = 0;
        if (input != null) {
            for (var i = 0; i < input.length; i++) {
                if (input[i] == '.')
                    cant += 1;
            }
        }
        return cant;
    },
 
    //Cuenta el número de dígitos después de un punto.
    CantidadDecimales: function(input) {
        var cant = 0;
        if (input.indexOf(".") != -1)
            cant = input.substr(input.indexOf(".") + 1).length;
        return cant;
    },
};
*/
/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */

