/*
	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;
		}
	});
});

/*   FUNCIONAMIENTO DEL MENÚ   */
$(document).ready(function(){
	$(".menu li.fijo").parents("ul").show();
	$(".menu a").click(function() {
		var elemento_clickado = $(this);
		if (elemento_clickado.parent("li").find("ul:first").length > 0) {
			if (elemento_clickado.parent("li").find("ul:first").hasClass("visible")) {
				elemento_clickado.parent("li").find("ul:first").removeClass("visible").slideUp("slow");
			} else {
				if ($("ul.visible").length > 0 && elemento_clickado.parents("ul.visible").length == 0) {
					$("ul.visible").removeClass("visible").slideUp("slow", function() {
						elemento_clickado.parent("li").find("ul:first").addClass("visible").slideDown("slow");
					});
				} else {
					elemento_clickado.parent("li").find("ul:first").addClass("visible").slideDown("slow");
				}
			}
			return false;
		}
	});
});


// http://www.no-margin-for-errors.com/projects/prettyPhoto/
$(document).ready(function(){
	$(".gallery a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 0, /* padding for each side of the picture */
		opacity: 0.65, /* 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 */
	});
});
