function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { 
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { 
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { 
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};
	
	function ___getPageScroll() {
		var xScroll, yScroll;
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
			xScroll = self.pageXOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {	 
			yScroll = document.documentElement.scrollTop;
			xScroll = document.documentElement.scrollLeft;
		} else if (document.body) {
			yScroll = document.body.scrollTop;
			xScroll = document.body.scrollLeft;	
		}
		arrayPageScroll = new Array(xScroll,yScroll);
		return arrayPageScroll;
	};


/*
    Lightbox video
*/

/*MODAL GENERICO*/
function modal(obj){
	
	/*CREATE ELEMENTS*/
	$('body').append('<div class="bg_modal close_modal"></div><div class="content_generic_modal"><!-- --></div> ');
	Dimensoes = ___getPageSize();

	$('.bg_modal').width(___getPageSize()[0]).height($('#global').height());
	/*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: topModal, 
						marginLeft: leftModal,
						left: 0,
						top: 0
					}
				);
			} else {
				$('.content_generic_modal').css({
						marginTop: - parseInt($('.content_generic_modal').height()/8), 
						marginLeft: -parseInt($('.content_generic_modal').width()/2)
					}
				);
			}			
						
			/*MODAL HIDE*/
			$('.content_generic_modal').fadeTo('fast', 1);
			
		});
	});

};

/*CLOSE MODAL*/
function close_modal(){
		$('.content_generic_modal').fadeTo('fast', 0, function(){
			$('.bg_modal').fadeTo('fast', 0, function(){
				$('.bg_modal').remove();
			});
			$('.content_generic_modal').remove();
		});
	$('select').css('visibility', 'visible');

};
/*
    Fim lightbox video
*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

// obtendo posicao do objeto
function getPosicaoElemento(obj){
	var offsetTrail = obj;
	var offsetLeft = 0;
	var offsetTop = 0;
	while (offsetTrail) {
		offsetLeft += offsetTrail.offsetLeft;
		offsetTop += offsetTrail.offsetTop;
		offsetTrail = offsetTrail.offsetParent;
	}
	if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") {
		offsetLeft += document.body.leftMargin;
		offsetTop += document.body.topMargin;
	}
	return {left:offsetLeft, top:offsetTop};
}

var leftModal = 0;
var topModal = 0;

function ajusteModal(obj,top,left){
	leftModal = getPosicaoElemento(obj).left + left;
	topModal = getPosicaoElemento(obj).top + top;
}

/*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(){

    
    $(".imprimir > a").click(function(){
        window.print();
        return false;
    });
    
	$(".voltar > a").click(function(){
		window.history.back(-1);
		return false;
	});
	
	$("a[class='linkPrint']").click(function(){
	    width = $("img[@rel='GraficoInvestimento']").width();
	    window.print();
	    return false;

	});
	
	//Modal video
	$("a[rel='viewMovie']").click(function(){
	    modalVideo($(this).attr('href'));
	    return false;
	});
	
	$("input[class='busca']").click(function(){
	    $(this).val("");
	});
	
});


/*          MOODAL VÍDEO        */

/*MODAL GENERICO*/
function modalVideo(obj){
	
	/*CREATE ELEMENTS*/
	$('body').append('<div class="bg_modal close_modal"></div><div class="modalVideo"><!-- --></div> ');
	Dimensoes = ___getPageSize();
	$('.bg_modal').width(___getPageSize()[0]).height($('#global').height());
	/*OPACITY*/
	$('.modalVideo').css('opacity', 0);
	$('.bg_modal').css('opacity', 0);
	
	/*SELECTS HIDE*/
	$('select').css('visibility', 'hidden');
     
	/*SHOW BACKGROUND*/
	$('.bg_modal').fadeTo('fast', 0.5, function() {
        
		$('.modalVideo').load(obj, function() {
	        
			/*CENTRALIZE MODAL*/
			if(leftModal != 0 || topModal != 0){
				$('.modalVideo').css({
						marginTop: topModal, 
						marginLeft: leftModal,
						left: 0,
						top: 0
					}
				);
			} else {
				$('.modalVideo').css({
						marginTop: - (parseInt($('.modalVideo').height()/2)), 
						marginLeft: -parseInt($('.modalVideo').width()/2)
					}
				);
			}			
			/*MODAL HIDE*/
			$('.modalVideo').fadeTo('fast', 1);
			
			/*CLOSE MODAL*/
			$("a[rel='close_modal']").livequery('click',
				function() {
				$("a[href*='modal']").bind('click',function(){
					$("a[href*='modal']").unbind('click');
					var url = $(this).attr('href').toLowerCase();
					modal(url);	
					return false;
				});
					close_modal();
					return false;
				}
			);
			
			$('.close_modalVideo').click ( function () {
			$('.close_modalVideo').unbind('click');
			$("a[href*='modal']").bind('click',function(){
				$("a[href*='modal']").unbind('click');
					var url = $(this).attr('href').toLowerCase();
					modal(url);	
					return false;
				});
			    close_modalVideo();
			});
			$('.bg_modal').click(function(){
			    close_modalVideo();
			});
		});
	});

};

function openPopup(u,n,w,h,o,c) {
	var l=t=18;
	if(c){
		l=(screen.availWidth-w)/2;
		t=(screen.availHeight-h)/2;
	}
	p=window.open(u,'pop_'+n,'left='+l+',top='+t+',width='+w+',height='+h,o);
}

function close_modalVideo(){
		$('.modalVideo').fadeTo('fast', 0, function(){
			$('.bg_modal').fadeTo('fast', 0, function(){
				$('.bg_modal').remove();
			});
			$('.modalVideo').remove();
		});
	$('select').css('visibility', 'visible');
}

/*          FIM MODAL VIDEO                   */