﻿// Highslide:
hs.lang = {
	cssDirection: "ltr",
	focusTitle : "Trazer a imagem para frente.",
	loadingText : "Carregando imagem.",
	loadingTitle : "Cancelar o carregamento da imagem.",
	resizeTitle : "Redimensionar a imagem.",
	number: "Imagem %1 de %2.",
	restoreTitle : "Clique para fechar a imagem, clique e arraste para mover a imagem ou use as setas do teclado para ver a imagem anterior ou a próxima.",
	creditsText : "http://highslide.com/",
	creditsTitle : "Ir para a página inicial do Highslide.",
	previousText : "&lt;",
	previousTitle : "Ir para a imagem anterior (seta para esquerda).",
	playText : "►",
	playTitle : "Iniciar uma apresentação das imagens em sequência (barra de espaço).",
	pauseText : "■",
	pauseTitle : "Parar a apresentação de imagens (barra de espaço).",
	nextText : "&gt;", 
	nextTitle : "Ir para a próxima imagem (seta para direita).",
	moveText : "+",
	moveTitle : "Mover imagem.",
	fullExpandText : "F",
	fullExpandTitle : "Ver a imagem no tamanho original (F).",
	closeText : "X",
	closeTitle : "Fechar a imagem (Esc)."
};
hs.captionEval = "this.thumb.alt";
hs.graphicsDir = "highslide/";
hs.expandCursor = null;
hs.restoreCursor = null;
hs.marginLeft = 20;
hs.marginRight = 20;
hs.marginTop = 20;
hs.marginBottom = 20;
hs.loadingOpacity = 1;
hs.align = "center";
hs.transitions = ["expand", "crossfade", "fade"];
hs.dimmingOpacity = 0.9;
hs.outlineStartOffset = 0;
hs.outlineType = "drop-shadow";
hs.allowSizeReduction = true;
hs.allowMultipleInstances = false;
hs.showCredits = false;
if (hs.addSlideshow) {
	hs.addSlideshow({
		interval: 5000,
		useControls: true,
		fixedControls: "fit",
		overlayOptions: {
			position: "bottom center",
			hideOnMouseOut: true
		}
	});
};
// Ajusta o tamanho das prévias swfs:
function adjustPreviasHeight(id, height) {
	$("#"+id).attr("height", height);
};
// Quando o JQuery estiver carregado:
$(document).ready(function() {
	// Dividindo o topo em dois swfs:
	$("div#topo").attr("id","topo-background");
	$("<div></div>").attr("id","topo").insertBefore("div#topo-background");
	$("div#topo-background p:first-child").appendTo("div#topo");
	// Inserindo os dois swfs do topo:
swfobject.embedSWF("swfs/topo.swf", "topo", "1010", "930", "8.0.0", "swfobject/expressinstall.swf", {page: page ? page : ""}, {base: "swfs/", menu: "false", quality: "best", salign: "t", wmode: "transparent"}, {id: "topo"});
	swfobject.embedSWF("swfs/topo-background.swf", "topo-background", "1010", "375", "8.0.0", "swfobject/expressinstall.swf", {page: page ? page : ""}, {base: "swfs/", menu: "false", quality: "best", salign: "t", scale: "noscale", wmode: "transparent"}, {id: "topo-background"});
	// Inserindo a flor antes do menu:
	$("<div></div>").attr("id","flor").insertBefore("ul#menu");
	// Inserindo o hífen antes de casa link:
	$("ul#menu li ul li a").append(" -");
	// Inserindo as flores depois do conteúdo:
	$("<div></div>").attr("id","flores").insertAfter("div#conteudo");
	// Adicionando elementos vazios para a estilização correta do título:
	$("div#conteudo > h1:first-child").attr("id","titulo").wrapInner("<span><span><span></span></span></span>");
	// Highslide:
	$("ul.miniaturas-emolduradas li img, ul.previas-emolduradas li img, p.previa-emoldurada img").after("<span></span>");
	$("ul.miniaturas-emolduradas li a, ul.miniaturas li a, ul.previas-emolduradas li a, ul.previas li a").each(function() {
		this.title = "Ampliar imagem.";
		this.onclick = function() {
			return hs.expand(this, {slideshowGroup: this.parentNode.parentNode.id});
		};
	});
	$("p.previa-emoldurada a, p.previa a").each(function() {
		this.title = "Ampliar imagem.";
		this.onclick = function() {
			return hs.expand(this);
		};
	});
	var previaId = 1;
	var previaMinWidth = 147;
	var previaMaxWidth = 550;
	var previaMinHeight = 110;
	var previaMaxHeight = 413;
	$("ul.previas-emolduradas li.previa, p.previa-emoldurada").each(function() {
		var a = $(this).find("a:first-child");
		var href = a.attr("href");
		var target = a.attr("target");
		var img = $(this).find("img:first-child");
		var alt = img.attr("alt");
		var src = img.attr("src");
		var width = img.attr("width");
		if(width) {
			if(width < previaMinWidth) {
				width = previaMinWidth;
			} else if(width > previaMaxWidth) {
				width = previaMaxWidth;
			};
		};
		var height = img.attr("height");
		if(height) {
			if(height < previaMinHeight) {
				height = previaMinHeight;
			} else if(height > previaMaxHeight) {
				height = previaMaxHeight;
			};
		};
		var id = "previa-"+(previaId++);
		if(href) {
			a.attr("id", id);
		} else {
			img.attr("id", id);
		}
		swfobject.embedSWF("swfs/previas.swf", id, "550", height ? height : previaMaxHeight, "8.0.0", "swfobject/expressinstall.swf", {src: src ? src : "", width: width ? width : "", height: height ? height : "", alt: alt ? alt : "", href: href ? href : "", target: target ? target : "", id: id}, {allowScriptAccess: "always", base: "swfs/", menu: "false", quality: "best", scale: "noBorder", wmode: "transparent"}, {id: id});
	});
});
