// Funções auxiliares /////////////////////////////////////////////////////////////



// Instancia todas as funções /////////////////////////////////////////////////////
$(function(){

 	// Animação hover logo - topo
	$("#baselogo img").bind("mouseenter", function() {
  		$(this).animate({ marginTop: "12px" }, 500);
  	}).bind("mouseleave", function() {
 		$(this).animate({ marginTop: "8px" }, 500);
  	})
	

	// Animação menu topo
	$("#m_top_institucional").hover(function() {
  		$(this).css({ backgroundColor: "#da251c" });
  	}).bind("mouseleave", function() {
 		$(this).animate({ backgroundColor: "#222" }, 350);
  	})

	$("#m_top_ensino").hover(function() {
  		$(this).css({ backgroundColor: "#008c3e" });
  	}).bind("mouseleave", function() {
 		$(this).animate({ backgroundColor: "#222" }, 350);
  	})

	$("#m_top_contato").hover(function() {
  		$(this).css({ backgroundColor: "#f9800b" });
  	}).bind("mouseleave", function() {
 		$(this).animate({ backgroundColor: "#222" }, 350);
  	})

	$("#m_top_blog").hover(function() {
  		$(this).css({ backgroundColor: "#004C99" });
  	}).bind("mouseleave", function() {
 		$(this).animate({ backgroundColor: "#222" }, 350);
  	})

	$("#m_top_paisealunos").hover(function() {
  		$(this).css({ backgroundColor: "#fcd200" });
  	}).bind("mouseleave", function() {
 		$(this).animate({ backgroundColor: "#222" }, 350);
  	})


	// Animação links do rodapé
	$("#rodape ul li").hover(function() {
  		$(this).animate({ paddingLeft: "5px" }, 200);
  	}).bind("mouseleave", function() {
 		$(this).animate({ paddingLeft: "0px" }, 200);
  	})
    // Hack para animacao do rodapé
    $("input").bind("mouseenter", function() {
        $("#rodape ul li").animate({ paddingLeft: "0px" }, 200);
    })


    // Instancia efeito scroll calendário - pagina principal
    $("#scrollable").scrollable({
        clickable: false,
        loop: true,
        items: "#items",
        next: "#navi .next",
        prev: "#navi .prev",
        size: 3,
        vertical: false
    }).circular()


    // Instancia efeito scroll da galeria - todas as paginas
    $("#fotos").scrollable({
        clickable: true,
        loop: false,
        items: ".g_items",
        next: ".vai",
        prev: ".volta",
        size: 4,
        vertical: false,
        disabledClass: "disabled"
    })

    $("#fotos .g_items span img").click(function() {

        // calclulate large image's URL based on the thumbnail URL (flickr specific)
        var url = $(this).attr("src");

        // get handle to element that wraps the image and make it semitransparent
        var wrap = $("#image_wrap").fadeTo("medium", 0.5);

        // the large image from flickr
        var img = new Image();

        // call this function after it's loaded
        img.onload = function() {

            // make wrapper fully visible
            wrap.fadeTo("fast", 1);

            // change the image
            wrap.find("img").attr("src", url);

        };

        // begin loading the image from flickr
        img.src = url;

    // when page loads simulate a "click" on the first image
    }).filter(":first").click();

});
