var tam = 13;

function mudaFonte(tipo,elemento){
	if (tipo=="mais") {
		if(tam<16) tam+=1;
		createCookie('fonte',tam,365);
	} else {
		if(tam>10) tam-=1;
		createCookie('fonte',tam,365);
	}
	document.getElementById('mudaFonte').style.fontSize = tam+'px';
	// document.getElementById('mudaFoto').style.fontSize = tam+'px';
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

var undefined;
function isUndefined(property) {
	return (typeof property == 'undefined');
}


// float do box de publicidadec 
		function resizePublicidade(){
				var d=document;
				if (!d.getElementById('publicidadeMateria')) d.getElementById('boxesMateria').style.width='99.5%';
				if (d.getElementById('pub')!= null) {
					if (!d.getElementById('publicidadeMateria')) d.getElementById('pub').style.width='460px';
				}
			}			
			
// Popup 
function popup(lnk,pop,w,h,s) { 
	window.open(lnk,pop,'width='+w+',height='+h+',top=100,left=100,resizable=0,status=0,menubar=0,scrollbars='+s); 
}


// Largura do box descri??o do Zoom

function larguraBoxZoom(){
	if (document.getElementById('imgZoom') != null) {
		var largura = document.getElementById('imgZoom').width;	
	}	
	if (document.getElementById('fotoZoom')) document.getElementById('descricao').style.width=largura;
}


/* ----- zoom ---- */

	function getPageSize() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY){
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else {
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {
			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 = windowWidth;
		else pageWidth = xScroll;
		arrayPageSize = {pageWidth:pageWidth,pageHeight:pageHeight,windowWidth:windowWidth,windowHeight:windowHeight}
		return arrayPageSize;
	}
	
	function getPageScroll(){
		var yScroll;
		if (self.pageYOffset) yScroll = self.pageYOffset;
		else if (document.documentElement && document.documentElement.scrollTop) yScroll = document.documentElement.scrollTop;
		else if (document.body) yScroll = document.body.scrollTop;
		arrayPageScroll = {yScroll:yScroll};
		return arrayPageScroll;
	}

 	function initZoom(div) {
		var container = document.getElementById(div);	
		var lnks = container.getElementsByTagName('a');
		for(var i=0,len=lnks.length;i<len;i++) {
			if(lnks[i].className.indexOf('linkZoom') > -1) {
				lnks[i].onclick = function() {
					openZoom(this);
					return false;
				}
			}
		}
	}
	
	function closeZoom() {
		document.body.removeChild(document.getElementById('zoom'));
		document.body.removeChild(document.getElementById('sombra'));
		//obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
	}
	
	function resizeZoom(obj) {
		var largura = obj.width;
		var altura = obj.height;
		var box = obj.parentNode.parentNode;
		var pageSize = getPageSize();
		var pageScroll = getPageScroll();
		var boxTop = pageScroll.yScroll + ((pageSize.windowHeight - altura - 26) / 2);
		var boxLeft = ((pageSize.pageWidth - largura - 40) / 2);
		box.style.top = (boxTop < 0) ? "0px" : boxTop + "px";
		box.style.left = (boxLeft < 0) ? "0px" : boxLeft + "px";
		box.style.visibility = 'visible';
		try {
			var divZoom = document.getElementById('zoom_'+obj.className);
			var divDescricao = document.getElementById('desc_'+obj.className);
			if(divZoom) divZoom.style.width = largura;
			if(divDescricao) divDescricao.style.width = largura;
		} catch(erro) {}
	}
	
	function openZoom(obj) {
		var pageSize = getPageSize();
		var divContainer = document.createElement('div');
		divContainer.id = 'zoom';
		divContainer.className = 'zoom';
		divContainer.style.height = (pageSize.pageHeight + 'px');
		
		var divCreditos = document.createElement('div');
		divCreditos.id = 'creditos';
		divCreditos.style.height = (pageSize.pageHeight + 'px');
		
		var imgCreditos = document.createElement('img');
		imgCreditos.src = "images/layout/creditosLightBox.jpg";
		imgCreditos.alt = "";
		imgCreditos.useMap = "#mapCreditos"
	
		
		var divSombra = document.createElement('div');
		divSombra.id = 'sombra';
		divSombra.className = 'sombra';
		divSombra.style.height = (pageSize.pageHeight + 'px');
		
		document.body.appendChild(divSombra);
		
		divCreditos.appendChild(imgCreditos);
		divContainer.appendChild(divCreditos);
		document.body.appendChild(divContainer);
		
	
		
	}
						
/* --------- */