
if($(document))
{
$(document).ready(function() {
	if($(".menu"))
	{
		 /* inicio menu animacao e eventos */
		$(".menu a").hover(function() {
			$(this).next("em").animate({opacity: "show", top: "-75"}, "slow");
		}, function() {
			$(this).next("em").animate({opacity: "hide", top: "-85"}, "fast");
		});
		/*  menu1 eventos  */
		$('#btnMenu1').click(function(){
			window.location.href = "admin.php";
		});

		
		if(document.getElementById("tbpublic"))
		{
			stripe('tbpublic', '#fff', '#edf3fe');	
		}
	}	

}); //end body
}


function buildPSWD()
{

	var pswd  = $('#pswd').val();
	var rswd  = $('#rswd').val();
	
	$.post("pswd.php", {pswd:pswd,rswd:rswd},
	
	function(data){
		if (pswd == "" || pswd.length < 4) 
		{
			$('#message').hide("slow");
			$('#message').html("<p class='error'>Informe a nova senha com 4 dígitos!</p>");
			$('#message').show("slow");
			return false;
		} 
		if(data == 0)
		{
			$('#message').hide("slow");
			$('#message').html("<p class='success'>Dados atualizados com sucesso!!!</p>");
			$('#message').show("slow");			
			$('#f_elem').hide("slow");
		}
		else{
			$('#message').hide("slow");
			$('#message').html(data);
			$('#message').show("slow");
			return false;			
		}		
	});

}
	
function formPost()
{
		if(document.f1.titulo.value == "" )
		{
			alert('Preencha o campo [titulo]!')
			document.f1.titulo.focus()
			return false;
		}
}

function showGall(id)
{
	window.location = 'gallery.php?id='+id;
}

function showPost(id)
{
	window.location = 'post.php?pageid='+id;
}

function editGall(id)
{
	window.location = 'steps.php?step=2&edit='+id+'&id='+id;
}

function editPost(id)
{
	window.location = 'admin.php?edit='+id;
}


function delPost(id)
{
	if(confirm('Deseja realmente apagar este post?'))
	{
		window.location = 'publicadas.php?delete=true&id='+id;
	}
}

arrfotos = new Array();

function selFoto(id)
{
    f = 0;
	for(i=0; i<=arrfotos.length-1; i++)
	{
		if(arrfotos[i] == id)
		{
			arrfotos.splice(i,1)
			f = 1;
			document.getElementById(id).className = 'photo sample2';
		}
	}
	if(f == 0)
	{
		arrfotos.push(id)
		document.getElementById(id).className = 'photo sample20';
	}
}

function delFotos(mat)
{
	if(arrfotos.length == 0)
	{
		alert('Nenhuma foto foi selecionada para exclusão.\nClique na foto para seleciona-la.')
	}
	else{
		if(confirm('Tem certeza que deseja remover a(s) foto(s) selecionada(s)?'))
		{
			ids = "";
			for(i=0; i<=arrfotos.length-1; i++)
			{			
				ids += arrfotos[i] + "|";
			}
			
			link = "removefoto.php?gallery="+mat+"&ids="+ids;
			window.location = link;
		}
	}
}

function beauty(id)
{
	obj = document.getElementById(id);
	if(obj.className == 'out')
	{
		obj.className = 'in';
	 }
	 else{
		 obj.className = 'out';
	 }	
}


function setCapa(id,foto)
{
	$.post("capa.php", {id:id,url:foto},
	function(data)
	{
		if(data == 0)
		{
			alert('Capa definida com sucesso!');
		}
	}
	)
}

function setDestaque(id,act)
{
	if(act == 1)
	{
		$.post("destaque.php", {id:id,add:true},
			function(data)
			{
				if(data == 1)
				{
					alert('Destaque definido com sucesso!');
				}
			}
		)
	}
	
	if(act == 2)
	{
		$.post("destaque.php", {id:id,rem:true},
			function(data)
			{
				if(data == 1)
				{
					alert('Destaque removido com sucesso!');
				}
			}
		)
	}	
}


function showOldEntry()
{
	document.getElementById("pageNavPosition").style.display = 'block';
	window.location = '#start';
	document.getElementById("linkAll").innerHTML ='<a href="index.php" class="link"><<< apenas destaques</a>';
}


