// slide
//On load page, init the timer which check if the there are anchor changes each 300 ms
$().ready(function(){
	setInterval("checarPaginaAtual()", 300);
});
var pagAtual = null;
//Function which chek if there are anchor changes, if there are, sends the ajax petition
function checarPaginaAtual(){
	//Check if it has changes
	if(pagAtual != document.location.hash){
		pagAtual = document.location.hash;
		//if there is not anchor, the loads the default section
		if(!pagAtual)
			query = "pagina=home";
		else
		{
			//Creates the  string callback. This converts the url URL/#main&id=2 in URL/?section=main&id=2
			var splits = pagAtual.substring(1).split('&');
			//Get the section
			var section = splits[0];
			delete splits[0];
			//Create the params string
			var params = splits.join('&');
			var query = "pagina=" + section + params;
		}
		//Send the petition
		$("#loading").show();
		$.get("_private/url.class.php",query, function(data){
			$("#cont").html(data);
			$("#loading").hide();
		});
	}
}
$(function() {
	$('#slider').nivoSlider({
        effect: 'random', // Specify sets like: 'fold,fade,sliceDown'
        animSpeed: 500, // Slide transition speed
        pauseTime: 3000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: true, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: false, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        keyboardNav: true, // Use left & right arrows
        pauseOnHover: true, // Stop animation while hovering
        manualAdvance: true, // Force manual transitions
        captionOpacity: 0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
    });
});
// Login Form
$(function() {
    var button = $('#loginButton');
    var box = $('#loginBox');
    var form = $('#loginForm');
    button.removeAttr('href');
    button.mouseover(function(login) {
        box.fadeIn();
        button.toggleClass('active');
    });
    form.mouseup(function() { 
        return false;
    });
    $(this).mouseup(function(login) {
        if(!($(login.target).parent('#loginButton').length > 0)) {
            button.removeClass('active');
            box.fadeOut();
        }
    });
});


