//##########################################################################################################

//Abrir div 

// JavaScript Document

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 abrir(x, obj){
	

		var layer   	 = document.getElementById("layer"+x);
		var div_content	 = document.getElementById("content"+x);
		var div_sombra   = document.getElementById("sombra"+x);
		var xScroll 	 = document.body.scrollWidth;
		
		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;
		}
		
		layer.style.display       = "block";
		div_content.style.display = "block";
		div_sombra.style.display  = "block";
		
		var largura = div_content.style.width;
		var altura  = div_content.style.height;
	
		var pageSize = getPageSize();
		var pageScroll = getPageScroll();
		
			
			
			var boxTop = pageScroll.yScroll + ((pageSize.windowHeight - altura.replace(/px/,"") - (-90)) / 2);
			var boxLeft = ((pageSize.windowWidth - largura.replace(/px/,"") ) / 2);
			
			if (boxTop > 15){
				layer.style.top = boxTop + "px";
			} else {
				layer.style.top = "15px";
			}
			layer.style.left = boxLeft + "px";
		
		
		div_sombra.style.height = (pageSize.pageHeight + 'px');
		div_sombra.style.width = (xScroll + 'px');
		
	}

function fechar(x){
		document.getElementById("layer"+x).style.display = "none";
		document.getElementById("content"+x).style.display = "none";
		document.getElementById("sombra"+x).style.display = "none";
	}


function muda(obj){
	
	obj.style.color = '#990066'	;
}