// Search
var txtPesquisaValue="";
 function clearTxtPesquisa(txt,limpar){
     if (limpar){
        txtPesquisaValue = txt.value;
        txt.value="";
     }else{
        txt.value=txtPesquisaValue;
     } 
 }
 
 
 // Favorite
function addFav(){
    var url      = "http://www.fav.ufg.br/";
    var title    = "Faculdade de Artes Visuais - FAV | UFG";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}




// jquery.pngFix
$(document).ready(function(){
		//  $(document).pngFix(); "Executa" o pngFix em todos os elementos do site
		$('#icon').pngFix();
		$('#next').pngFix();
		$('#prev').pngFix();
	});


// Modal Windows
$(document).ready(function() {	

	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});




// Menu Dropdown
var timeout         = 20;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);});

document.onclick = jsddm_close;

//FOOTER
$(document).ready(function(){
	// Lets make the top panel toggle based on the click of the show/hide link	
	$("#arrowFooter").click(function(){
		// Toggle the bar up 
		$("#containerFooter").slideToggle();	
		// Settings
		var el = $("#shText");  
		// Lets us know whats inside the element
		var state = $("#shText").html();
		// Change the state  
		state = (state == '<span class="abrir"></span>' ? '<span id="shText"><span class="fechar"></span></span>' : '<span id="shText"><span class="abrir"></span></span>');					
		// Finally change whats insdide the element ID
		el.replaceWith(state); 
	}); // end sub panel click function
}); // end on DOM
