$(document).ready(function()
{
	
	rights = $(".projetos_repete .oculta .right");
	//alert($(divs[0]).html());
	for(i = 0; i < rights.length; i++)
	{
		hai = $(rights[i]).height();
		//$(rights[i]).prev().text($(rights[i]).height());
		$(rights[i]).prev().height(hai);
	}
	
	
	$(".detalhe_proj").hide();
	$(".oculta").hide();
	$(".clique_volta").hide();
	/*$(".clique_veja").click(function()
	{
		$(this).parent().parent().parent().parent().parent().parent().parent().parent().parent().find(".clique_volta:visible").trigger('click');
		$(this).parent().parent().parent().parent().parent().parent().find(".detalhe_proj").slideDown(1000);
		$(this).hide();
		$(this).parent().find(".clique_volta").show();
	});
	$(".clique_volta").click(function()
	{
		$(this).parent().parent().parent().parent().parent().parent().find(".detalhe_proj").slideUp(1000);
		$(this).hide();
		$(this).parent().find(".clique_veja").show();
	});*/
	
	$(".clique_veja").click(function()
	{
		$(this).parent().parent().parent().parent().parent().parent().find(".clique_volta:visible").trigger('click');
		$(this).parent().parent().find(".oculta").slideDown(1000);
		$(this).hide();
		$(this).parent().find(".clique_volta").show();
	});
	$(".clique_volta").click(function()
	{
		$(this).parent().parent().find(".oculta").slideUp(1000);
		$(this).hide();
		$(this).parent().find(".clique_veja").show();
	});
	
	//$(".show_evento:first").hide();
	//$(".show_evento:first").parent().parent().parent().parent().hide();
	
	$(".show_evento:first").parent().parent().find("td").css("background-color", "#DFEADB");
	
	$(".show_evento").click(function()
	{
		$("#masterTitulo").fadeTo(500, 0.1);
		$("#masterData").fadeTo(500, 0.1);
		$("#lblSite").fadeTo(500, 0.1);
		$("#masterSite").fadeTo(500, 0.1);
		
		$(".show_evento").parent().parent().find("td").css("background-color", "#EEF4EC");
		$(this).parent().parent().find("td").css("background-color", "#DFEADB");
		
		var este = $(this).parent().parent().parent().parent().parent();
		$("#masterTexto").fadeTo(500, 0.1, function()
		{
			$("#masterTitulo").text($(este).find(".tituloRepete").text());
			$("#masterData").text($(este).find(".dataRepete").text());
			$("#masterSite").html($(este).find(".siteRepete").html());
			$("#masterTexto").text($(este).find(".textoRepete").text());	
			
			$("#masterTitulo").fadeTo(500, 1);
			$("#masterData").fadeTo(500, 1);
			$("#lblSite").fadeTo(500, 1);
			$("#masterSite").fadeTo(500, 1);
			$("#masterTexto").fadeTo(500, 1);
													
		});
		
		//$(this).parent().parent().parent().parent().slideUp(1000);
		//$(this).hide();
		//$(".show_evento:hidden").show();
		//$(".show_evento:hidden").parent().parent().parent().parent().slideDown(1000);
		
	});
	
	divs = $(".projetos_repete .first");
	
	for(i = 0; i < divs.length; i++)
	{
		hei = $(divs[i]).height();
		$(divs[i]).parent().height(hei);
	}
	
});

function toPage(url, pag)
{
	try
	{
		//window.location = "<?php echo basename($_SERVER['PHP_SELF']); ?>?pag="+pag;
		window.location = url + "?pag=" + pag;
	}
	catch (e)
	{
		alert(e);
	}

}

function enviaFormEx(fml)
{
	if (( fml['ddd3'].value.length<2 ||fml['celular'].value.length<8 ) && ( fml['ddd'].value.length<2 ||fml['telefone'].value.length<8 ))
	{
		alert('Preencha o celular ou telefone');
		return false;
	}
				
	return enviaForm(fml);
}

//tour virtual----------------------------------------

function tour (url) 
{
window.open(url,'tour','width=405,height=390,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0');
}

//funções imagem noticia ----------------------------------------------

function hab_proximo()
					{
						document.getElementById('proximo').innerHTML = '<a href="javascript:proximo();"><img src="img/but_proximo.jpg" alt="" /></a>';
					}
					function des_proximo()
					{
						document.getElementById('proximo').innerHTML = '';
					}
					function hab_anterior()
					{
						document.getElementById('anterior').innerHTML = '<a href="javascript:anterior();"><img src="img/but_anterior.jpg" alt="" /></a>';
					}
					function des_anterior()
					{
						document.getElementById('anterior').innerHTML = '';
					}
					function proximo()
					{
						imgatual++;
						troca_img();
						
						if(imgatual==1)
							hab_anterior();
					
						if(imgatual==(imagens.length-1))
							des_proximo();
						
					}
					function anterior()
					{
						imgatual--;
						troca_img();
						
							if(imgatual==0)
							des_anterior();
							
							if(imgatual==(imagens.length-2))
							hab_proximo();
					}
					function verimg(img)
					{
						abriu = window.open('ver_img.php?imagem=admIN/upload/noticias_fotos/'+img,'imagem','width=1,height=1,top=0,left=0');
						if(!abriu)
						alert('Desative seu Anti-popup');
					}
					function troca_img()
					{
						var img = imagens[imgatual];
						
						document.getElementById("fotogrande").innerHTML = "<img src='admIN/upload/noticias_fotos/"+img[0]+"' border=\"0\" class=\"borda\"  alt=\"\">";
					}
					
//funções galerias----------------------------------------------------------------

var lista = document.getElementById('lista');
					
					function troca_img(thumb,img,leg)
					{
						document.getElementById('thumb_maior').style.backgroundImage = "url(admIN/upload/galerias_fotos/"+thumb+")";
						img_atual = img;
						
						document.getElementById('legenda').innerHTML = leg;
						leg_atual = leg;
						
					}
					function verimg()
					{
						abriu = window.open('popimg.php?imagem=admIN/upload/galerias_fotos/'+img_atual,'imagem','width=1,height=1,top=0,left=0,scrollbars=yes');
						if(!abriu)
						alert('Desative seu Anti-popup');
					}
					function subtrai()
					{
						var el = document.getElementById("miniaturas");
						el.scrollLeft-=1;
					}
					function soma()
					{
						var el = document.getElementById("miniaturas");
						el.scrollLeft+=1;
					}
					function direita()
					{
						//soma();
						
						for(i=0;i<172;i++)
						{
							setTimeout('soma()',50);
						}
						//var a = Math.round((el.scrollLeft/152)+3);
					}
					function esquerda(){
						
						//subtrai();
						
						for(i=0;i<172;i++)
						{
							setTimeout('subtrai()',50);
						}
					}