﻿function getPageSize() {
	// PageWidth 
	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}
	
	// Page Scroll
	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};
	//alert(pageWidth +"-"+ pageHeight + "|"+ windowWidth + "-"+ windowHeight +"|"+ yScroll);
	
	var d = document.getElementById("diContainer");
	
	switch(d.style.display) {
		case "none":
			d.style.width = "100%";
			d.style.height = pageHeight + "px";
			d.style.display = '';
	        document.getElementById("tBody").style.overflow = 'hidden';
	        document.forms[0].ucBusca1$ddlFiltro.style.display = 'none';
			ShowAmpliada(1);
			break;
		default:
			d.style.display = 'none';
	        document.getElementById("tBody").style.overflow = 'auto';
	        document.forms[0].ucBusca1$ddlFiltro.style.display = '';
			ShowAmpliada(2);
			break;
	}
	
	
	return;
}

function ShowAmpliada() {
	var div1 = document.getElementById('ampliada_faixa');
	var div2 = document.getElementById('ampliada');
	switch(arguments[0]) {
		case 1:
			div1.style.display = "";
			div2.style.display = "";
			
			div2.style.width = document.getElementById('fotoAmpliada').width + "px";
            div2.style.height = document.getElementById('fotoAmpliada').height + "px";
            div2.style.margin = "100px 0 0 -" + (document.getElementById('fotoAmpliada').width / 2) + "px";
    
			break;
		case 2:
			div1.style.display = "none";
			div2.style.display = "none";
			break;
	}
}

function imageLoad(img) {
    var d = document.getElementById('ampliada');
    
    d.style.width = img.width + "px";
    d.style.height = img.height + "px";
    d.style.margin = "100px 0 0 -" + (img.width / 2) + "px";
    
    document.getElementById("carregando").style.display = 'none';
    document.getElementById("fotoAmpliada").style.display = '';
}
