/*CLOSE MODAL*/
function closeModal(){
	/*HIDE MODAL*/
	$('.view_modal').fadeTo('fast', 0, function() {
		$('.view_modal').remove();
	});
	
	/*HIDE BACKGROUND*/
	$('.bg_modal').fadeTo('fast', 0, function() {
		/*SHOW SELECT*/
		$('select').css('visibility', 'visible');
		$('#organograma').css('visibility', 'visible');
		$('#banner_mdc').css('visibility', 'visible');
		$($(this)).remove();
	});
}

/*MODAL FLASH*/
function openModalFlash(obj){
	/*CREATE ELEMENTS*/
	$('body').append('<div class="bg_modal"></div><div class="view_modal"></div>');
	$('.bg_modal').width($('html')[0].scrollWidth).height($('html')[0].scrollHeight);
	
	/*OPACITY*/
	$('.view_modal').css('opacity', 0);
	$('.bg_modal').css('opacity', 0);
	
	/*SELECTS HIDE*/
	$('select').css('visibility', 'hidden');
	$('#organograma').css('visibility', 'hidden');
    $('#banner_mdc').css('visibility', 'hidden');
    
    
	/*SHOW BACKGROUND*/
	$('.bg_modal').fadeTo('fast', 0.5, function() {

		$('.view_modal').load(obj, function() {
		
			/*REMOVE LOAD*/
			$('.load').remove();
			
			/*CENTRALIZE MODAL*/
			//$('.view_modal').css({marginTop: -$('.view_modal').height()/2 + 'px', marginLeft: -$('.view_modal').width()/2 + 'px'});
			
			/*MODAL HIDE*/
			$('.view_modal').fadeTo('fast', 1);
			
			/*CLOSE MODAL*/
			$("a[@rel='modalclose']").click(function() {
				closeModal();
				return false;
			});
		});
	});
}



/*MODAL GENERICO*/
function modal(obj){
	var arrPageSizes = ___getPageSize();
	var arrPageScroll = ___getPageScroll();
	size = ($.browser.msie) ? arrPageSizes[1]+(arrPageSizes[1]/1.25) : arrPageSizes[1] ;
	var margem = arrPageSizes[1]/8;
	
	//alert(arrPageSizes[0]+"-"+arrPageSizes[1]+"-"+arrPageScroll[0]+"-"+arrPageScroll[1]);
	/*CREATE ELEMENTS*/
	$('body').append('<div class="bg_modal close_modal"></div><div class="content_generic_modal"><!-- --></div> ');
	$('.bg_modal').width(arrPageSizes[0]).height(size);;
	
	/*OPACITY*/
	$('.content_generic_modal').css('opacity', 0);
	$('.bg_modal').css('opacity', 0);
	
	/*SELECTS HIDE*/
	$('select').css('visibility', 'hidden');

	/*SHOW BACKGROUND*/
	$('.bg_modal').fadeTo('fast', 0.5, function() {

		$('.content_generic_modal').load(obj, function() {
	        
			/*CENTRALIZE MODAL*/
			if(leftModal != 0 || topModal != 0){
				$('.content_generic_modal').css({
						marginTop: margem , 
						marginLeft: arrPageScroll[0],
						left: 0,
						top: margem
					}
				);
			} else {
				$('.content_generic_modal').css({
						marginTop:  parseInt($('.content_generic_modal').height()/2)+margem, 
						marginLeft: -parseInt($('.content_generic_modal').width()/2)
					}
				);
			}			
						
			/*MODAL HIDE*/
			$('.content_generic_modal').fadeTo('fast', 1);
			
			
		});
	});

};

/*CLOSE MODAL*/
function close_modal(){
	/*HIDE BACKGROUND*/
	$('.content_generic_modal').fadeTo('fast', 0, function(){
		$(this).remove();
		$('.bg_modal').fadeTo('fast', 0, function(){
			$('.bg_modal').remove();
		});
	});
	$('select').css('visibility', 'visible');
};

/*Funcoes para fonte*/
var min = 8;
    var s = 10;
    var max = 16;

    function aumentaFonte(){
    txt = $("div[@rel='texto']");
    if(s != max){
    s += 2;}
    txt.css('font-size',s+'px');
    }        

    function diminuiFonte(){
    txt = $("div[@rel='texto']");
    if(s != min){
    s -= 2;}
        txt.css('font-size',s+'px');               
    }
//fim funcoes fonte


$(document).ready ( function () {
    $("a[rel*='modalBancoDeImagens']").click(function(){
		var url = $(this).attr('href').toLowerCase();
		modal(url);	
        return false;
    });
    $("a[rel='close_modal']").click(function(){
        close_modal();
    });
    
});
function ToggleEmbed(){
    style = $('embed').css('display');
    newstyle = "";
    if(style == "none"){
        newstyle = "block";
    }else{
        newstyle = "none";
    }
    $('embed').css('display',newstyle)
    return false;
}
