//funo para pegar o tamanho da rea til do IE
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 lerLivro(parametro)
{
	//mostrando elementos
	var pageSize = getPageSize();
	document.getElementById('mascara').style.height = (pageSize.pageHeight + 'px');
	document.getElementById('mascara').style.display = '';
	document.getElementById('livro').style.display = '';
	document.getElementById('fechar').style.display = '';
	document.getElementById('livro').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" name="flash" width="100%" height="100%" id="flash"><param name="movie" value="livros/livro.swf?caminho=livros/'+parametro+'/paginas.xml" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="livros/livro.swf?caminho=livros/'+parametro+'/paginas.xml" width="100%" height="100%" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="flash" wmode="transparent"></embed>';
	
}

function fecharLivro()
{
	document.getElementById('mascara').style.display = 'none';
	document.getElementById('livro').style.display = 'none';
	document.getElementById('fechar').style.display = 'none';
	document.getElementById('livro').innerHTML = '';
}

function mostrarImagem(param,altura,largura,legenda)
{	
	var pageSize = getPageSize();
	document.getElementById('mascara').style.height = (pageSize.pageHeight + 'px');
	
	document.getElementById('caixa').innerHTML 		= '<img src="'+param+'" height="'+altura+'" width="'+largura+'" alt="Clique na imagem para fechar"><div id="caixa_legenda">Clique na imagem para fechar</div>';
	document.getElementById('caixa').style.width 	= largura+'px';
	n_altura = parseInt(altura) + 20;
	document.getElementById('caixa').style.height 	= n_altura +'px';
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var alturaScroll = document.documentElement.scrollTop;
		diferencaIE = alturaScroll - altura/2;
		document.getElementById('caixa').style.marginLeft = -largura/2 + "px";
		document.getElementById('caixa').style.marginTop = diferencaIE + "px";
	}
	else
	{
		document.getElementById('caixa').style.margin = "-"+ altura/2 + "px 0 0 -" + largura/2 + "px";	
	}
	document.getElementById('mascara').style.display 	= '';
	document.getElementById('caixa').style.display 	= '';
}

function fecharImagem()
{
	document.getElementById('caixa').innerHTML 		= '';
	document.getElementById('mascara').style.display 	= 'none';
	document.getElementById('caixa').style.display 	= 'none';
}