﻿//LIMPA CAMPO
function clTxt(thefield){
	if (thefield.defaultValue==thefield.value){
		thefield.value = "";
	}else if(thefield.value == ""){
		thefield.value=thefield.defaultValue;
	}
}
//Impressão
var Today = new Date();
var MonthAtual = (Today.getMonth()+1);
if (MonthAtual<10){MonthAtual = '0'+MonthAtual;}
function imprimir(ttlElement,printElement,urlElement,lang){
	popimpressao = window.open('', '', 'width=751,height=450,left=0,top=0,scrollbars=yes,resizable=no,menubar=no,toolbar=no');
	if(lang=="langPt"){
		var langIn = '';
		var txtRelatorio = 'BRADESCO - Relatório Anual Online 2007';
		var printFooter = Today.getDate()+'/'+MonthAtual+'/'+Today.getFullYear()+'<br />'+urlElement;
		var txtCopyright = 'Bradesco - Relatório Anual Online. Todos os direitos reservados - 2008';
	}else if(lang=="langEn"){
		var langIn = '_en';
		var txtRelatorio = 'BRADESCO - 2007 Online Annual Report';
		var printFooter = MonthAtual+'/'+Today.getDate()+'/'+Today.getFullYear()+'<br />'+urlElement;
		var txtCopyright = 'Bradesco - Online Annual Report. 2008 - All Rights Reserved';
	}else if(lang=="langEs"){
		var langIn = '_es';
		var txtRelatorio = 'BRADESCO - Informe Anual Online 2007';
		var printFooter = Today.getDate()+'/'+MonthAtual+'/'+Today.getFullYear()+'<br />'+urlElement;
		var txtCopyright = 'Bradesco - Informe Anual Online. Todos los Derechos Reservados - 2008';
	}
	with(popimpressao.document){
		write('<html><head><title>'+txtRelatorio+'</title>');
		write('<link rel="stylesheet" href="../css/print.css" type="text/css">');
		write('</head>');
		write('<body class="'+lang+'">');
		write('<h1><img src="../../imagens/img_cabecalho_impressao'+langIn+'.jpg" width="532" height="57" alt="'+txtRelatorio+'" /></h1>');
		write('<h2>'+ttlElement+'</h2>');
		write($('#'+printElement).html());
		write('<div class="printFooter">'+printFooter+'</div>');
		write('<div class="copyright">'+txtCopyright+'</div>');
		write('</body></html>');
		close();
	}
	popimpressao.print();
	popimpressao.close();
}
// Popups: <a href="arquivo.ext" onclick="popups(this.href,'nome','0','360','535','1'); return false;"></a>
function popups(pg,nome,fs,w,h,rolagem) {
	if(fs) { // fullscreen
		var w=screen.availWidth,h=screen.availHeight;
		var winObj = window.open(pg,nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left=0,top=0');
		with(winObj) { moveTo(0,0); resizeTo(w,h); focus(); }
	} else { // popup normal
		var winObj=window.open(pg,nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.width-w)/2)+-10)+',top='+(((screen.height-h)/2)+-30));
		winObj.focus();
	}
}
//esconde botoes de controle de conteudo
function hideCtrlBtns(btnContraste,btnTxt,btnImprimir,btnMeusRelatorios){
	if(btnContraste==true){
		$('#btnContrasteMais,#btnContrasteMenos, #lstBtnsCtrlTxt .sep:eq(2)').hide();
	}
	if(btnTxt==true){
		$('#btnTxtMais,#btnTxtMenos, #lstBtnsCtrlTxt .sep:eq(2)').hide();
	}
	if(btnImprimir==true){
		$('#btnImprimir, #lstBtnsCtrlTxt .sep:eq(1)').hide();
	}
	if(btnMeusRelatorios==true){
		$('#btnMeusRelatorios, #lstBtnsCtrlTxt .sep:eq(0)').hide();
	}
}
//jquery
$(function(){
//NAVBAR
//GERAL
	$('.scGeral #navSecao ul li:lt(3) a').attr('rel','ext');
//perfil
	$('#lstPerfil dd dl dd:first-child a,#lstAjuda ul li li:first-child a').css('border','0');
	$('#lstPerfil dd, #lstAjuda li').hover(function(){
			$(this).addClass('sfhover');
		},function(){
			$(this).removeClass('sfhover');
		}
	);	
//navsecao
	$('#navSecao ul li li.atv').parents('li').addClass('atv');
	$('#navSecao ul li li.atv > a').addClass('atv');
	$('#navSecao ul li.atv > a:lt(1)').addClass('firstAtv');	
	$('#navSecao ul li li li.atv').parents('li').addClass('atv');
	$('#navSecao ul li ul').hide();
	$('#navSecao ul li ul li ul li:last').addClass('last');
	$('#navSecao ul li:has(ul)').addClass('liRoot');
	$('#navSecao ul li.atv:lt(1) > a:lt(2)').addClass('firstAtv');
	$('#navSecao ul li:has(ul)').find('a:first').wrap('<div class="itnRoot"></div>');
	$('#navSecao ul li .itnRoot').prepend('<a href="javascript:;" class="lnkNavAbre">+</a>');
	$('#navSecao .lnkNavAbre').click(function(){
		var txtMaisMenos = $(this).text();
		if(txtMaisMenos=='+'){
			$(this).text('-');
			$(this).parents('div').siblings('ul').show('fast');
			$(this).next('a').addClass('mark');
			$(this).parents('li').addClass('mark');
		}else{
			$(this).text('+');
			$(this).parents('div').siblings('ul').hide('fast');
			$(this).next('a').removeClass('mark');
			$(this).parents('li').removeClass('mark');
		}
		return false;
	});
	$('#navSecao li.atv a.lnkNavAbre:lt(1)').click();
	$('#navSecao li li.atv a.lnkNavAbre:lt(1)').click();
//lnk Notas
	$('.popUpNota').click(function(){
		popups($(this).attr('href'),'popUpNota',false,'554','398',false);
		return false;
	});

//TABELAS
	$('.tabCont tbody').each(function(i){
		$(this).children('tr:odd').addClass('rowEsc');
	});
	$('.tabIn tbody tr').removeClass('rowEsc');
	$('.tabGlossario tbody').each(function(i){
		$(this).children('tr:even').addClass('rowEsc');
	});
	$('.tabCont tbody tr').each(function(i){
		$(this).children('td:eq(0):not(".txtCenter")').css('text-align','left');
	});
	$('a.jTip').each(function(i){
		var txtRel=$(this).text();
		$(this).attr('rel',txtRel);
		$(this).attr('id','lnkJTip'+i);
	});
//CONTROLES DE CONTEUDO
	//tamanho fontes
	$('#btnTxtMais a').click(function(){
		if($('#boxContent').is('.decFont')){
			$('#boxContent').removeClass('decFont');
			$('#btnTxtMenos a').fadeIn('normal');
		}else{
			$('#boxContent').addClass('incFont');
			$('#btnTxtMais a').fadeOut('normal',function(){
				$('#btnTxtMenos a').fadeIn('normal');
			});
		}
		return false;
	});
	$('#btnTxtMenos a').click(function(){
		if($('#boxContent').is('.incFont')){
			$('#boxContent').removeClass('incFont');
			$('#btnTxtMais a').fadeIn('normal');
		}else{
			$('#boxContent').addClass('decFont');
			$('#btnTxtMenos a').fadeOut('normal',function(){
				$('#btnTxtMais a').fadeIn('normal');
			});
		}
		return false;
	});
	//contraste fontes
	$('#btnContrasteMais a').click(function(){
		$('#boxContent').addClass('contrasteFont');
		$('#btnContrasteMais').hide();
		$('#btnContrasteMenos').show();
		return false;
	});
	$('#btnContrasteMenos a').click(function(){
		$('#boxContent').removeClass('contrasteFont');
		$('#btnContrasteMenos').hide();
		$('#btnContrasteMais').show();
		return false;
	});
	//print
	$('#btnImprimir').click(function(){
		var classLang=$("div:eq(0)").attr("class");
		imprimir(($('h1 .sIFR-alternate').text()),'boxContent',window.location.href,classLang);
	});
	$('#btnImprimirNota').click(function(){
	    var classLang=$("div:eq(0)").attr("class");
		imprimir('','popNotas',window.location.href,classLang);
	});
//Scroll to
	$('a[href*=#]').click(function(){
		if(location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname){
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if($target.length){
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset},1000);
				return false;
			}
		}
	});
//target _blank
	$('a[rel="ext"]').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
//Links inativos
	$('a.lnkOff').click(function(){return false;});
//Fale Conosco
	$('a.lnkFaleConosco').click(function(){
		$lnk=$(this).attr('href');
		window.open($lnk,'','width=480,height=400');
		return false;
	});
//form reset	
	$.fn.clearForm = function() {
		return this.each(function(){
			var type = this.type, tag = this.tagName.toLowerCase();
			if (tag == 'form')
			return $(':input',this).clearForm();
			if (type == 'text' || type == 'password' || tag == 'textarea')
				this.value = '';
			else if (type == 'checkbox' || type == 'radio')
				this.checked = false;
			else if (tag == 'select')
				this.selectedIndex = -1;
		});
	};
//********************
});


