/*
	Versión 1.0
*/
/* ELEMENTOS COMUNES */
// Enlace en ventana nueva.
// Quitar el &nbsp; de inputs tipo texto, password y textareas.
$(document).ready( function(){
	// Enlace en ventana nueva.
	$("a[rel='external']").attr("target","_blank");

	// Quitar el &nbsp; de inputs tipo texto, password y textareas.
	$("input[type='text'], input[type='password'], textarea").focus( function() {
		if (($(this).attr("value")) && ($(this).attr("value").charCodeAt(0) == 32 || $(this).attr("value").charCodeAt(0) == 160) && ($(this).attr("value").length == 1)) {
			this.value = "";
			return false;
		}
	});
});

// Resaltar input(text-password)/textarea seleccionado
$(document).ready(function(){
	$("input[type='text'], input[type='password'], textarea").focus( function() {
		if ($(this).attr("readonly")) {
			// Nada
		} else {
			$(this).addClass("enfocado");
		}
		return false;
	});
	$("input[type='text'], input[type='password'], textarea").blur( function() {
		$(this).removeClass("enfocado");
	});
	$("input[type='text'], input[type='password'], textarea").each( function() {
		if ($(this).attr("readonly")) {
			$(this).addClass("solo_lectura");
		}
	});
});

// Enviar formulario
$(document).ready(function(){
	$("a.enviar_formulario").click(function(){
		$(this).parents("form:first").submit();
		return false;
	});
});

// Imprimir página
$(document).ready(function(){
	$("a.imprimir").click( function() {
		window.print();
		return false;
	});
});
