
function openLayer(divLink, urlLoad, w, h, legenda, otherLinks){
	/*
	* abre novo layer sobre o site
	* otherLinks.prevLink
	* otherLinks.nextLink
	*/
	pageScrollBeforeZoom = getPageScroll();

	var pageSize = getPageSize();
	var pageScroll = getPageScroll();

	divShadow = document.createElement('div');
		divShadow.className = 'boxFade';
//		divShadow.style.height = pageSize.windowHeight+"px";
//		divShadow.style.width = pageSize.windowWidth+"px";

		divShadow.style.height = pageSize.pageHeight+"px";
		divShadow.style.width = pageSize.pageWidth+"px";

		divShadow.onclick=closeLayer;
	document.body.appendChild(divShadow);

	//divBoxZoom = document.createElement('div');
	var divBoxZoom = document.getElementById('boxZoom');
	var divBoxZoomImg = document.getElementById('boxZoomImg');
	var divBoxZoomLegenda = document.getElementById('boxZoomLegenda');
	if (otherLinks) {
		//constrói itens < >
		var divBoxZoomNav = document.getElementById('boxZoomNav');
		divBoxZoomNav.style.display = "block";
		var linksA = divBoxZoomNav.getElementsByTagName("a");
		linksA[0].onclick = function () {
			closeLayer();
			otherLinks.prevLink.click();
			return false;
		}
		linksA[1].onclick = function () {
			closeLayer();
			otherLinks.nextLink.click();
			return false;
		}
		linksA[0].style.display = (otherLinks.prevLink.length > 0 && otherLinks.prevLink.get(0).tagName == "A")? "block" : "none";
		linksA[1].style.display = (otherLinks.nextLink.length > 0 && otherLinks.nextLink.get(0).tagName == "A")? "block" : "none";
	}

		//divBoxZoom.className = 'boxZoom';
		divBoxZoom.style.display = "block";
		divBoxZoom.style.width = w+"px";
		divBoxZoom.style.height = h+"px";
		var pLeft = (pageSize.pageWidth - w)/2;
		var pTop = ((pageSize.windowHeight - h)/2) + pageScroll.yScroll;
		divBoxZoom.style.left = pLeft+"px";
		divBoxZoom.style.top = pTop+"px";
		//***divBoxZoom.onclick=closeLayer;
	imgZoom = document.createElement('img');
		imgZoom.src = urlLoad;
		divBoxZoomImg.appendChild(imgZoom);
	divBoxZoomLegenda.innerHTML = legenda;
	//document.body.appendChild(divBoxZoom);
}

function closeLayer(){
	divShadow.parentNode.removeChild(divShadow);
	//divBoxZoom.parentNode.removeChild(divBoxZoom);
	var divBoxZoomImg = document.getElementById('boxZoomImg');
	divBoxZoomImg.removeChild(divBoxZoomImg.firstChild);
	var divBoxZoom = document.getElementById('boxZoom');
	divBoxZoom.style.display = "none";
}

	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;
		objPageSize = {pageWidth:pageWidth,pageHeight:pageHeight,windowWidth:windowWidth,windowHeight:windowHeight}
		return objPageSize;
	}

	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;
	}
