/*
 * ABRIR IMAGEM
 *
 * Este é uma espécie de efeito "Shadowbox", que permite ampliar uma
 * foto sem sair da página. Ele não oferece tantos recursos como o
 * Shadowbox, entretanto está funcionando de maneira equilibrada com
 * o restante do site - o Shadowbox estava apresentando problemas
 * anteriormente.
 * 
 */
var estaAbrindoImagem = "nao";
var estaAbrindoMapa = "nao";
function abrirImagem(imagem) {
    if (estaAbrindoImagem == "nao") {

	estaAbrindoImagem = "sim";

	var carregando = "Carregando...";
	var botao = "/images/capa_nova/fechar.gif";
	var larguraInicial = 150;
	var alturaInicial = 35;
	var borda = 5;

	// se a janela nao existe
	if (!$("#janelinha_iframe").attr("id") && !$("#janelinha_div").attr("id")) {
	    //alert("se a janela nao existe");
	    // cria iframe, para selects no IE, na dimensão final
	    $(document.createElement("iframe")).appendTo(document.body)
	    .attr({
		id: "janelinha_iframe",
		frameborder: '0',
		scrolling: 'no'
	    })
	    .css({
		position: 'absolute',
		zIndex: '9998',
		top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) )  + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) )+'px',
		width: larguraInicial + (borda*2) + 'px',
		height: alturaInicial + (borda*2) + 'px',
		backgroundColor: 'transparent',
		border: '0px',
		borderStyle: 'none',
		overflow: 'hidden',
		display: 'none'
	    });
	    // IE iframe border FIX
	    document.getElementById('janelinha_iframe').style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
	    // cria	janela na dimensão inicial
	    $(document.createElement("div")).appendTo(document.body)
	    .attr({
		id: "janelinha_div"
	    })
	    .css({
		position: 'absolute',
		zIndex: '9998',
		top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) )+'px',
		width: larguraInicial+'px',
		height: alturaInicial+'px',
		backgroundColor: '#e7e7e7',
		border: '5px solid #cccccc',
		color: '#ffffff',
		display: 'none'
	    });
	    // cria texto de carregando
	    $(document.createElement("p")).appendTo("#janelinha_div")
	    .attr("id","janelinha_texto")
	    .text(carregando)
	    .css({
		position: 'absolute',
		top: '10px',
		left: '10px',
		margin: '0',
		padding: '0',
		fontFamily: 'Arial,sans-serif',
		fontSize: '11px',
		fontWeight: 'bold',
		color: '#636363'
	    });
	    // faz aparecer
	    $("#janelinha_iframe").fadeIn("fast");
	    $("#janelinha_div").fadeIn("fast");

	    // carrega imagem
	    var img = new Image();
	    $(img).load(function(){

		$(img).appendTo($("#janelinha_div"));

		$("#janelinha_div").css({
		    position: 'absolute',
		    zIndex: '9998'
		}).animate({
		    top: Math.round(( $(document).scrollTop() + ($(window).height()/2) - (img.height/2) - (borda*2) )) + 'px',
		    left: Math.round(( $(document).scrollLeft() + ($(document).width()/2) - (img.width/2) ))+'px',
		    width: img.width+'px',
		    height: img.height+'px',
		    speed: 'fast'
		}, function(){
		    $("#janelinha_texto").fadeOut("fast",function(){
			estaAbrindoImagem="nao";
			$(img).fadeIn("fast");
			carregaFechar(botao);
		    });
		});
		$("#janelinha_iframe").css({
		    position: 'absolute',
		    zIndex: '9998'
		}).animate({
		    top: Math.round(( $(document).scrollTop() + ($(window).height()/2) - (img.height/2) - (borda*2) ))+ 'px',
		    left: Math.round(( $(document).scrollLeft() + ($(document).width()/2) - (img.width/2) ))+'px',
		    width: img.width + (borda*2) + 'px',
		    height: img.height + (borda*2) + 'px',
		    speed: 'fast'
		});
		$(this).unbind("load");

	    });
	    img.src='';
	    $(img).attr({
		id: 'janelinha_imagem',
		src: imagem
	    }).css("display","none");

	    // fecha imagem
	    $(img).click(function() {
		fechaImagem();
	    });
	    // fecha iamgem botao
	    $("#janelinha_fechar").click(function(){
		$("#janelinha_iframe").fadeOut("fast");
		$("#janelinha_imagem").fadeOut("fast");
		$("#janelinha_div").fadeOut("fast");
	    });
	}
	// se a janela ja existe
	else {
	    //alert("se a janela ja existe");
	    // se a janela esta aberta
	    if ($("#janelinha_iframe").css("display")!="none" && $("#janelinha_div").css("display")!="none") {
		//alert("se a janela esta aberta");
		$("#janelinha_fechar").fadeOut("fast");
		$("#janelinha_iframe").fadeOut("fast");
		$("#janelinha_div").fadeOut("fast",function(){
		    // esconde imagem antiga
		    $("#janelinha_imagem").css({
			display: 'none'
		    });
		    // reposiciona iframe
		    $("#janelinha_iframe").css({
			position: 'absolute',
			zIndex: '9998',
			top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
			left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) ) + 'px',
			width: larguraInicial + (borda*2) + 'px',
			height: alturaInicial + (borda*2) + 'px'
			});
		    // reposiciona div
		    $("#janelinha_div").css({
			position: 'absolute',
			zIndex: '9998',
			top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
			left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) ) + 'px',
			width: larguraInicial+'px',
			height: alturaInicial+'px'
			});
		    $("#janelinha_iframe").fadeIn("fast");
		    $("#janelinha_div").fadeIn("fast");
		    $("#janelinha_texto").fadeIn("fast");

		    // carrega imagem
		    teste = new Image();
		    teste.onload = function(){
			novaLargura = teste.width;
			novaAltura = teste.height;
			$("#janelinha_imagem").attr({
			    width: novaLargura,
			    height: novaAltura
			});
			$("#janelinha_imagem").load(function(){
			    $("#janelinha_imagem").appendTo($("#janelinha_div"));
			    $("#janelinha_div").css({
				position: 'absolute',
				zIndex: '9998'
			    }).animate({
				top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_imagem").height()/2) - (borda*2) ) + 'px',
				left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_imagem").width()/2) )+'px',
				width: $("#janelinha_imagem").width()+'px',
				height: $("#janelinha_imagem").height()+'px',
				speed: 'fast'
			    }, function(){
				$("#janelinha_texto").fadeOut("fast",function(){
				    estaAbrindoImagem="nao";
				    $("#janelinha_imagem").fadeIn("fast", function() {
					mostraFechar();
				    });
				});
			    });
			    $("#janelinha_iframe").css({
				position: 'absolute',
				zIndex: '9998'
			    }).animate({
				top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_imagem").height()/2) - (borda*2) ) + 'px',
				left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_imagem").width()/2) )+'px',
				width: $("#janelinha_imagem").width() + (borda*2) + 'px',
				height: $("#janelinha_imagem").height() + (borda*2) + 'px',
				speed: 'fast'
			    });
			    $(this).unbind("load");
			});
			$("#janelinha_imagem").src='';
			$("#janelinha_imagem").attr({
			    src: imagem
			}).css("display","none");
		    }
		    teste.src='';
		    teste.src = imagem;
		});
	    }
	    // se a janela esta fechada
	    else {
		//alert("se a janela esta fechada");
		// esconde imagem antiga
		$("#janelinha_imagem").css({
		    display: 'none'
		});
		// reposiciona iframe
		$("#janelinha_iframe").css({
		    position: 'absolute',
		    zIndex: '9998',
		    top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
		    left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) ) + 'px',
		    width: larguraInicial + (borda*2) + 'px',
		    height: alturaInicial + (borda*2) + 'px'
		    });
		// reposiciona div
		$("#janelinha_div").css({
		    position: 'absolute',
		    zIndex: '9998',
		    top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
		    left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) ) + 'px',
		    width: larguraInicial+'px',
		    height: alturaInicial+'px'
		    });

		// mostra todos
		$("#janelinha_iframe").fadeIn("fast");
		$("#janelinha_div").fadeIn("fast");
		$("#janelinha_texto").fadeIn("fast");

		// carrega imagem
		teste = new Image();
		teste.onload = function(){
		    novaLargura = teste.width;
		    novaAltura = teste.height;
		    $("#janelinha_imagem").attr({
			width: novaLargura,
			height: novaAltura
		    });
		    $("#janelinha_imagem").load(function(){
			$("#janelinha_div").css({
			    position: 'absolute',
			    zIndex: '9998'
			}).animate({
			    top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_imagem").height()/2) - (borda*2) ) + 'px',
			    left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_imagem").width()/2) )+'px',
			    width: $("#janelinha_imagem").width()+'px',
			    height: $("#janelinha_imagem").height()+'px',
			    speed: 'fast'
			}, function(){
			    $("#janelinha_texto").fadeOut("fast",function(){
				estaAbrindoImagem="nao";
				$("#janelinha_imagem").fadeIn("fast", function() {
				    mostraFechar();
				});
			    });
			});
			$("#janelinha_iframe").css({
			    position: 'absolute',
			    zIndex: '9998'
			}).animate({
			    top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_imagem").height()/2) - (borda*2) ) + 'px',
			    left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_imagem").width()/2) )+'px',
			    width: $("#janelinha_imagem").width() + (borda*2) + 'px',
			    height: $("#janelinha_imagem").height() + (borda*2) + 'px',
			    speed: 'fast'
			});
			$(this).unbind("load");
		    });
		    $("#janelinha_imagem").src='';
		    $("#janelinha_imagem").attr({
			src: imagem
		    }).css("display","none");
		}
		teste.src='';
		teste.src = imagem;
	    }
	}

	// se o scroll mexer, segue
	$(window).scroll(function(){
	    $("#janelinha_iframe").css({
		position: 'absolute',
		zIndex: '9998',
		top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_iframe").height()/2) ) + 0 + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_iframe").width()/2) ) + 5 + 'px'
		});
	    $("#janelinha_div").css({
		position: 'absolute',
		zIndex: '9998',
		top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_iframe").height()/2) ) + 0 + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_iframe").width()/2) ) + 5 + 'px'
		});
	    $("#janelinha_fechar").css({
		position: 'absolute',
		zIndex: '9999',
		top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_imagem").height()/2) - (5*2) ) + ($("#janelinha_imagem").height() + 15) + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_imagem").width()/2) ) + ($("#janelinha_imagem").width() + 10 - 56) + 'px'
		});
	});
    }
}
function carregaFechar(botao) {

    var fechar = new Image();
    $(fechar).load(function() {
	$(fechar).css({
	    position: 'absolute',
	    zIndex: '9999',
	    top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_imagem").height()/2) - (5*2) ) + ($("#janelinha_imagem").height()+10) + 'px',
	    left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_imagem").width()/2) ) + ($("#janelinha_imagem").width() + 10 - 56) + 'px',
	    cursor: 'pointer'
	})
	.fadeIn("fast"); // 56 = botao width
	$(fechar).click(fechaImagem);
    });
    $(fechar).attr({
	id: 'janelinha_fechar',
	src: botao
    }).appendTo(document.body).css({
	dispay: "none"
    });
}
function mostraFechar() {
    $("#janelinha_fechar").css({
	position: 'absolute',
	zIndex: '9999',
	top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_imagem").height()/2) - (5*2) ) + ($("#janelinha_imagem").height()+10) + 'px',
	left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_imagem").width()/2) ) + ($("#janelinha_imagem").width() + 10 - 56) + 'px',
	cursor: 'pointer'
    })
    .fadeIn("fast"); // 56 = botao width
    $("#janelinha_fechar").click(fechaImagem);
}
function fechaImagem() {
    $("#janelinha_fechar").fadeOut("fast");
    $("#janelinha_div").fadeOut("fast");
    $("#janelinha_iframe").fadeOut("fast");
    $("#janelinha_imagem").fadeOut("fast");
    $(window).unbind("scroll");
}
function abrirImagem2(imagem) {

    //alert(imagem);

    if (estaAbrindoImagem == "nao") {

	estaAbrindoImagem = "sim";

	var carregando = "Carregando...";
	var botao = "/images/capa_nova/fechar.gif";
	var larguraInicial = 150;
	var alturaInicial = 35;
	var borda = 5;

	// se a janela nao existe
	if (!$("#janelinha_iframe").attr("id") && !$("#janelinha_div").attr("id")) {
	    //alert("se a janela nao existe");
	    // cria iframe, para selects no IE, na dimensão final
	    $(document.createElement("iframe")).appendTo(document.body)
	    .attr({
		id: "janelinha_iframe",
		frameborder: '0',
		scrolling: 'no'
	    })
	    .css({
		position: 'absolute',
		zIndex: '9998',
		top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) )  + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) )+'px',
		width: larguraInicial + (borda*2) + 'px',
		height: alturaInicial + (borda*2) + 'px',
		backgroundColor: 'transparent',
		border: '0px',
		borderStyle: 'none',
		overflow: 'hidden',
		display: 'none'
	    });
	    // IE iframe border FIX
	    document.getElementById('janelinha_iframe').style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
	    // cria	janela na dimensão inicial
	    $(document.createElement("div")).appendTo(document.body)
	    .attr({
		id: "janelinha_div"
	    })
	    .css({
		position: 'absolute',
		zIndex: '9998',
		top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) )+'px',
		width: larguraInicial+'px',
		height: alturaInicial+'px',
		backgroundColor: '#e7e7e7',
		border: '5px solid #cccccc',
		color: '#ffffff',
		display: 'none'
	    });
	    // cria texto de carregando
	    $(document.createElement("p")).appendTo("#janelinha_div")
	    .attr("id","janelinha_texto")
	    .text(carregando)
	    .css({
		position: 'absolute',
		top: '10px',
		left: '10px',
		margin: '0',
		padding: '0',
		fontFamily: 'Arial,sans-serif',
		fontSize: '11px',
		fontWeight: 'bold',
		color: '#636363'
	    });
	    // faz aparecer
	    $("#janelinha_iframe").fadeIn("fast");
	    $("#janelinha_div").fadeIn("fast");

	    // carrega imagem
	    var img = new Image();
	    $(img).load(function(){
		$(img).appendTo($("#janelinha_div"));
		$("#janelinha_div").css({
		    position: 'absolute',
		    zIndex: '9998'
		}).animate({
		    top: ( $(document).scrollTop() + ($(window).height()/2) - (480/2) - (borda*2) ) + 'px',
		    left: ( $(document).scrollLeft() + ($(document).width()/2) - (640/2) )+'px',
		    width: '640px',
		    height: '480px',
		    speed: 'fast'
		}, function(){
		    $("#janelinha_texto").fadeOut("fast",function(){
			estaAbrindoImagem="nao";
			$(img).fadeIn("fast");
			carregaFechar2(botao);
		    });
		});
		$("#janelinha_iframe").css({
		    position: 'absolute',
		    zIndex: '9998'
		}).animate({
		    top: ( $(document).scrollTop() + ($(window).height()/2) - (480/2) - (borda*2) ) + 'px',
		    left: ( $(document).scrollLeft() + ($(document).width()/2) - (640/2) )+'px',
		    width: 640 + (borda*2) + 'px',
		    height: 480 + (borda*2) + 'px',
		    speed: 'fast'
		});
		$(this).unbind("load");
	    });
	    img.src='';
	    $(img).attr({
		id: 'janelinha_imagem',
		src: imagem,
		width: 640,
		height: 480
	    }).css({
		display:"none",
		width:'640px',
		height:'480px'
	    });
	    img.width=640;
	    img.height=480;

	    // fecha imagem
	    $(img).click(function() {
		fechaImagem();
	    });
	    // fecha iamgem botao
	    $("#janelinha_fechar").click(function(){
		$("#janelinha_iframe").fadeOut("fast");
		$("#janelinha_imagem").fadeOut("fast");
		$("#janelinha_div").fadeOut("fast");
	    });
	}
	// se a janela ja existe
	else {
	    //alert("se a janela ja existe");
	    // se a janela esta aberta
	    if ($("#janelinha_iframe").css("display")!="none" && $("#janelinha_div").css("display")!="none") {
		//alert("se a janela esta aberta");
		$("#janelinha_fechar").fadeOut("fast");
		$("#janelinha_iframe").fadeOut("fast");
		$("#janelinha_div").fadeOut("fast",function(){
		    // esconde imagem antiga
		    $("#janelinha_imagem").css({
			display: 'none'
		    });
		    // reposiciona iframe
		    $("#janelinha_iframe").css({
			position: 'absolute',
			zIndex: '9998',
			top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
			left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) ) + 'px',
			width: larguraInicial + (borda*2) + 'px',
			height: alturaInicial + (borda*2) + 'px'
			});
		    // reposiciona div
		    $("#janelinha_div").css({
			position: 'absolute',
			zIndex: '9998',
			top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
			left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) ) + 'px',
			width: larguraInicial+'px',
			height: alturaInicial+'px'
			});
		    $("#janelinha_iframe").fadeIn("fast");
		    $("#janelinha_div").fadeIn("fast");
		    $("#janelinha_texto").fadeIn("fast");

		    // carrega imagem
		    teste = new Image();
		    teste.onload = function(){
			novaLargura = teste.width;
			novaAltura = teste.height;
			$("#janelinha_imagem").attr({
			    width: novaLargura,
			    height: novaAltura
			});
			$("#janelinha_imagem").load(function(){
			    $("#janelinha_imagem").appendTo($("#janelinha_div"));
			    $("#janelinha_div").css({
				position: 'absolute',
				zIndex: '9998'
			    }).animate({
				top: ( $(document).scrollTop() + ($(window).height()/2) - (480/2) - (borda*2) ) + 'px',
				left: ( $(document).scrollLeft() + ($(document).width()/2) - (640/2) )+'px',
				width: 640+'px',
				height: 480+'px',
				speed: 'fast'
			    }, function(){
				$("#janelinha_texto").fadeOut("fast",function(){
				    estaAbrindoImagem="nao";
				    $("#janelinha_imagem").fadeIn("fast", function() {
					mostraFechar2();
				    });
				});
			    });
			    $("#janelinha_iframe").css({
				position: 'absolute',
				zIndex: '9998'
			    }).animate({
				top: ( $(document).scrollTop() + ($(window).height()/2) - (480/2) - (borda*2) ) + 'px',
				left: ( $(document).scrollLeft() + ($(document).width()/2) - (640/2) )+'px',
				width: 640 + (borda*2) + 'px',
				height: 480 + (borda*2) + 'px',
				speed: 'fast'
			    });
			    $(this).unbind("load");
			});
			document.getElementById('janelinha_imagem').src='';
			$("#janelinha_imagem").attr({
			    src: imagem,
			    width: 640,
			    height: 480
			}).css({
			    display:"none",
			    width:'640px',
			    height:'480px'
			});
		    }
		    teste.src='';
		    teste.src = imagem;
		    teste.width=640;
		    teste.height=480;
		});
	    }
	    // se a janela esta fechada
	    else {
		//alert("se a janela esta fechada");
		// esconde imagem antiga
		$("#janelinha_imagem").css({
		    display: 'none'
		});
		// reposiciona iframe
		$("#janelinha_iframe").css({
		    position: 'absolute',
		    zIndex: '9998',
		    top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
		    left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) ) + 'px',
		    width: larguraInicial + (borda*2) + 'px',
		    height: alturaInicial + (borda*2) + 'px'
		    });
		// reposiciona div
		$("#janelinha_div").css({
		    position: 'absolute',
		    zIndex: '9998',
		    top: ( $(document).scrollTop() + ($(window).height()/2) - (alturaInicial/2) - (borda*2) ) + 'px',
		    left: ( $(document).scrollLeft() + ($(document).width()/2) - (larguraInicial/2) ) + 'px',
		    width: larguraInicial+'px',
		    height: alturaInicial+'px'
		    });

		// mostra todos
		$("#janelinha_iframe").fadeIn("fast");
		$("#janelinha_div").fadeIn("fast");
		$("#janelinha_texto").fadeIn("fast");

		// carrega imagem
		teste = new Image();
		teste.onload = function(){
		    novaLargura = teste.width;
		    novaAltura = teste.height;
		    $("#janelinha_imagem").attr({
			width: novaLargura,
			height: novaAltura
		    });
		    $("#janelinha_imagem").load(function(){
			$("#janelinha_div").css({
			    position: 'absolute',
			    zIndex: '9998'
			}).animate({
			    top: ( $(document).scrollTop() + ($(window).height()/2) - (480/2) - (borda*2) ) + 'px',
			    left: ( $(document).scrollLeft() + ($(document).width()/2) - (640/2) )+'px',
			    width: 640+'px',
			    height: 480+'px',
			    speed: 'fast'
			}, function(){
			    $("#janelinha_texto").fadeOut("fast",function(){
				estaAbrindoImagem="nao";
				$("#janelinha_imagem").fadeIn("fast", function() {
				    mostraFechar2();
				});
			    });
			});
			$("#janelinha_iframe").css({
			    position: 'absolute',
			    zIndex: '9998'
			}).animate({
			    top: ( $(document).scrollTop() + ($(window).height()/2) - (480/2) - (borda*2) ) + 'px',
			    left: ( $(document).scrollLeft() + ($(document).width()/2) - (640/2) )+'px',
			    width: 640 + (borda*2) + 'px',
			    height: 480 + (borda*2) + 'px',
			    speed: 'fast'
			});
			$(this).unbind("load");
		    });
		    document.getElementById('janelinha_imagem').src='';
		    $("#janelinha_imagem").attr({
			src: imagem
		    }).css("display","none");
		    document.getElementById("janelinha_imagem").width=640;
		    document.getElementById("janelinha_imagem").height=480;
		}
		teste.src='';
		teste.src = imagem;
	    }
	}

	// se o scroll mexer, segue
	$(window).scroll(function(){
	    $("#janelinha_iframe").css({
		position: 'absolute',
		zIndex: '9998',
		top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_iframe").height()/2) ) + 0 + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_iframe").width()/2) ) + 5 + 'px'
		});
	    $("#janelinha_div").css({
		position: 'absolute',
		zIndex: '9998',
		top: ( $(document).scrollTop() + ($(window).height()/2) - ($("#janelinha_iframe").height()/2) ) + 0 + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - ($("#janelinha_iframe").width()/2) ) + 5 + 'px'
		});
	    $("#janelinha_fechar").css({
		position: 'absolute',
		zIndex: '9999',
		top: ( $(document).scrollTop() + ($(window).height()/2) - (480/2) - (5*2) ) + (480 + 15) + 'px',
		left: ( $(document).scrollLeft() + ($(document).width()/2) - (640/2) ) + (640 + 10 - 56) + 'px'
		});
	});
    }
}
function carregaFechar2(botao) {
    var fechar = new Image();
    $(fechar).load(function() {
	$(fechar).css({
	    position: 'absolute',
	    zIndex: '9999',
	    top: ( $(document).scrollTop() + ($(window).height()/2) - (480/2) - (5*2) ) + (480+10) + 'px',
	    left: ( $(document).scrollLeft() + ($(document).width()/2) - (640/2) ) + (640 + 10 - 56) + 'px',
	    cursor: 'pointer'
	})
	.fadeIn("fast"); // 56 = botao width
	$(fechar).click(fechaImagem);
    });
    $(fechar).attr({
	id: 'janelinha_fechar',
	src: botao
    }).appendTo(document.body).css({
	dispay: "none"
    });
}
function mostraFechar2() {
    $("#janelinha_fechar").css({
	position: 'absolute',
	zIndex: '9999',
	top: ( $(document).scrollTop() + ($(window).height()/2) - (480/2) - (5*2) ) + (480+10) + 'px',
	left: ( $(document).scrollLeft() + ($(document).width()/2) - (640/2) ) + (640 + 10 - 56) + 'px',
	cursor: 'pointer'
    })
    .fadeIn("fast"); // 56 = botao width
    $("#janelinha_fechar").click(fechaImagem);
}