/*
	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;
	});
});


// Galería de imágenes
// http://www.no-margin-for-errors.com/projects/prettyPhoto/
$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
	});
});

$(document).ready(function(){
	$(".simula_boton").click (function(){
		$("a.galeria_primera").trigger("click");
	});
});



