$(document).ready(function() {
	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 | e.which == 0 ) {
				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 | e.which == 9  | e.which == 0) {
	
				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 | e.which == 0) {
				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 | e.which ==0) {
				return true;
			}
			else {
				e.preventDefault();
			}
		},
		
		AlfanumericoSinEspacioHandled: function(e) {
			if ((e.which >= 48 & e.which <= 57) | (e.which >= 97 & e.which <= 122) |
			   (e.which >= 65 & e.which <= 90) |  e.which == 8 | e.which ==0) {
				return true;
			}
			else {
				e.preventDefault();
			}
		},
		
		AlfanumericoCaracterHandled: 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 | e.which ==0 | e.which == 45 | e.which ==46 | e.which ==47) {
				return true;
			}
			else {
				e.preventDefault();
			}
		},
		
		AlfanumericoCaracterLatinoHandled: 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 | e.which ==0 | e.which == 13 | e.which == 44| e.which == 45 | e.which ==46 | e.which ==47 | e.which ==225 | e.which ==233 | e.which ==237 | e.which ==243 | e.which ==250 | e.which ==241 | e.which ==209 | e.which ==193| e.which ==201 | e.which ==205 | e.which ==211 | e.which ==218 | e.which ==40 | e.which ==41 | e.which ==64 | e.which ==58 | e.which ==59 | e.which ==191 | e.which ==63) {
				return true;
			}
			else {
				e.preventDefault();
			}
		},
		
		EmailHandled: function(e) {
			if ((e.which >= 48 & e.which <= 57) | (e.which >= 97 & e.which <= 122) |
			   ( e.which >= 65 & e.which <= 90) |  e.which == 8 | e.which ==0 | e.which == 64 | e.which == 95 | e.which == 46 ) {
				return true;
			}
			else {
				e.preventDefault();
			}
		},
		
		SecuenciaTelefonicaHandled: function(e) {
			if (e.which >= 48 & e.which <= 57 | e.which == 8 | e.which == 0 | e.which == 32 | e.which == 40 | e.which == 41 | e.which ==45) {
				return true;
			}
			else {
				e.preventDefault();
			}
		},
		
		EnterosPuntosHandled: function(e) {
			if (e.which >= 48 & e.which <= 57 | e.which == 8 | e.which == 0 | e.which == 46) {
				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;
		}
	};

	sjorrillo.NumeroDeDecimales = 2;
	$(".only_dec").keypress(function(e) { sjorrillo.DecimalesHandled(e, $(this).val()); });
	$(".only_enteros").keypress(function(e) { sjorrillo.EnterosHandled(e); });
	$(".only_alphaNumber").keypress(function(e) { sjorrillo.AlfanumericoHandled(e); });
	$(".only_alphaNumberSinEspacio").keypress(function(e) { sjorrillo.AlfanumericoSinEspacioHandled(e); });
	
	$(".only_alphaNumberCaracter").keypress(function(e) { sjorrillo.AlfanumericoCaracterHandled(e); });
	$(".only_alphaNumberCaracterLatino").keypress(function(e) { sjorrillo.AlfanumericoCaracterLatinoHandled(e); });
	$(".only_nroTelefonico").keypress(function(e) { sjorrillo.SecuenciaTelefonicaHandled(e); });
	$(".only_email").keypress(function(e) { sjorrillo.EmailHandled(e); });
	
	//---------------------------
	
	$(".onlyText").keypress( function(e){
		//$(".onlyText").text($(".onlyText").text().toUpperCase());

		if ((e.which >= 97 & e.which <= 122) | (e.which >= 65 & e.which <= 90) |
	            e.which == 32 | e.which == 8) {
	            return true;
	        }
	        else {
	            e.preventDefault();
	        }						   
	});
	
	$('.banner_effect').click(function(){
		if($(".banner_effect").is(":hidden"))
			$(".banner_effect").show('slow');
		else
			$(".banner_effect").hide('slow');
	});
	
	/* $('input[type=text]').bind('copy paste', function (e) {
         e.preventDefault();
		 alert("You cannot paste text into this textbox!");
      });*/
	/*$('input[type=text]').bind('paste', function (e) {
         e.preventDefault();
		 //jAlert("La opci\xF3n de pegado est\xE1 deshabilitada.\n");
     });
	$('input[type=password]').bind('paste', function (e) {
         e.preventDefault();
		 //jAlert("La opci\xF3n de pegado est\xE1 deshabilitada.\n");
     });
	
	$('textarea').bind('paste', function (e) {
         e.preventDefault();
		 //jAlert("La opci\xF3n de pegado est\xE1 deshabilitada.\n");
     });*/
});
