﻿// JavaScript Document
/*******************************************************
 * PORTAL INTERNET DA EMPRESA FLUXO E TECNOLOGIA LTDA.
 * ANO: 2009
 * ARQUIVO DE SCRIPT
 *******************************************************/
 
var br = new Object();
    br.com = new Object();
    br.com.fluxotech = new Object();
    br.com.fluxotech.util = new Object();

br.com.fluxotech.util.ToolsContent = {
	printContent: function(id) {
		var obj = document.getElementById(id);
		if (obj != null) {
			_width = 800;
			_height = 600;
			
			_top  = (screen.height/2) - (_height/2);
			_left = (screen.width/2)  - (_width/2);
			
			_props = 'channelmode=0,directories=0,fullscreen=0,height=' + _height + ',left=' + _left + ',location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,top=' + _top + ',width=' + _width;
			
			var win = window.open('', '_blank', _props);
			win.document.open();
			win.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + 
							   "<html><head><title>Impressão de Conteúdo</title></head><body onload='window.print();'><div style=\"width: 800px; margin: 0 auto;\">" +  
								obj.innerHTML + 
							   "</div></body></html><scr"+"ipt>try{document.getElementById('divToolsContent').style.display = 'none'}catch(e){}</scr"+"ipt>");
			//win.onload = function() { win.print(); };
			win.document.close();
		}
	},
	
	
	_arrEleHide: new Array('divDepoimento', 'divNoticia', 'divSolucao', 'divServico', 'divConteudo', 'divFique'),
	showHideWcm: function() {
		var objWcm = document.getElementById('WCMWindowFocusAnchor_1');
		
		if (objWcm != null) {
			for (i = 0; i < this._arrEleHide.length; i++) {
				var obj = document.getElementById( this._arrEleHide[i] );
				if (obj != null) {
					obj.style.display = 'none';
				}
			}
		}
	},
	
	
	/**
	 * Aumentar ou diminuir a fonte do texto do conteúdo exibido.
	 * 	Execução: br.com.fluxotech.util.ToolsContent.aumentarFonte(container) | br.com.fluxotech.util.ToolsContent.diminuirFonte(container)
	 *  or var xx = br.com.fluxotech.util.ToolsContent; 	xx.aumentarFonte(container);
	 *  Para incluir mais tags para serem afetados pelo ação, incluí-la no Array
	 * 		_elAfetados
	 */
	_elAfetados: new Array("DIV","P","A","LI","STRONG","H1","H2","H3","H4","H5","H6","LABEL","FONT", "SPAN"),

	_value: 1,
	_valueAdd: 0.085,
	_limitMais: 100000,
	_limitMenos: 1,
	  
	aumentarFonte: function(container) {
	  this._value = Math.min(this._limitMais, this._value + this._valueAdd);
	  this.updateFonte(container);
	},
  
	diminuirFonte: function(container) {
	  this._value = Math.max(this._limitMenos, this._value - this._valueAdd);
	  this.updateFonte(container);
	},
	  
	updateFonte: function(container) {		
	  var objCont = document.getElementById(container);
  
	  if (objCont != null) {
		for (i=0; i < this._elAfetados.length; i++) {
			var elObjs = objCont.getElementsByTagName(this._elAfetados[i]);
  
			for (j=0; j < elObjs.length; j++) {
			  elObjs[j].style.fontSize = this._value + 'em';
			}
		}
	  }
	}
};

var teste = br.com.fluxotech.util.ToolsContent;
		
/**
 * Configura para que as combinações Alt + Seta para cima e Alt + Seta para baixo
 * funcionem como aumentar e diminuir fonte respectivamente.
 *
 */
function configFonte(e) {
	e = e ? e : window.event;
	
	if (e.altKey && e.keyCode == 38) {
		teste.aumentarFonte('divConteudo');
	} else if (e.altKey && e.keyCode == 40) {
		teste.diminuirFonte('divConteudo');
	}
}

document.onkeydown = configFonte;



/**
 * Deixa as camadas com a mesma altura.
 */
var AjustaCamadas = {
	_maxHeight : 0,
	_arContainers : new Array(),
	
	addContainer : function( /*String*/ id ) {
		this._arContainers.push( id );
	},
	
	setMaxHeight : function() {
		for (i = 0; i < this._arContainers.length; i++) {
			var _height = 0;
			try {
				_height = parseInt( document.getElementById( this._arContainers[i] ).offsetHeight );
			} catch(e) {}	
			
			this._maxHeight = this._maxHeight < _height ? _height : this._maxHeight;
		}	
	},
	executeAjuste : function() {
		this.setMaxHeight();
		for (i = 0; i < this._arContainers.length; i++) {
			try {
				document.getElementById( this._arContainers[i] ).style.height = this._maxHeight + "px";
			} catch(e) {alert()}
		}
	}
}

var ajusteCamadas = AjustaCamadas;

