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 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 zoom(func,ls) {
	var pageSize = getPageSize();
	var pageScroll = getPageScroll();
	var boxLeft = ((pageSize.pageWidth - 200) / 2);
	var boxTop = pageScroll.yScroll + ((pageSize.windowHeight) / 2);
	document.getElementById('sombra').style.height = pageSize.pageHeight+"px";
	document.getElementById('sombra').style.visibility = 'visible';
	document.getElementById('zoom_abc').style.top = (boxTop < 0) ? "0px" : boxTop + "px";
	document.getElementById('zoom_abc').style.left = (boxLeft < 0) ? "0px" : boxLeft + "px";
	document.getElementById('zoom_abc').style.visibility = 'visible';
	document.getElementById('zoom_abc').style.fontSize = '12px';
	document.getElementById('zoom_abc').style.lineHeight = '18px';
	
	
	document.getElementById('desc_abc').innerHTML = '<div><img src="imgs/gerais/aguarde.gif"></div>';
	if (func == 'foto'){
		fotos(ls);
	} else {
		videos();
	}
}

function fecharzoom() {
	document.getElementById('sombra').style.visibility = 'hidden';
	document.getElementById('zoom_abc').style.visibility = 'hidden';
	document.getElementById('sombra').style.height = "0px";
	document.getElementById('frame').style.visibility = 'hidden';
	document.getElementById('frame').style.width = '0px';
	document.getElementById('frame').style.height = '0px';
	document.getElementById('desc_abc').innerHTML = "";
}


function fotos(ls)
{ 
	var url="fotos.asp?ls="+ls;
	xmlHttp=GetXmlHttpObject(stateChangedfotos)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
} 

function stateChangedfotos() 
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var pageSize = getPageSize();
		var pageScroll = getPageScroll();
		var boxLeft = ((pageSize.pageWidth - 520) / 2);
		var boxTop = pageScroll.yScroll + ((pageSize.windowHeight - 453) / 2);
		document.getElementById('sombra').style.height = pageSize.pageHeight+"px";
		document.getElementById('sombra').style.visibility = 'visible';
		document.getElementById('zoom_abc').style.top = (boxTop < 0) ? "0px" : boxTop + "px";
		document.getElementById('zoom_abc').style.left = (boxLeft < 0) ? "0px" : boxLeft + "px";

		document.getElementById('frame').style.top = "0px";
		document.getElementById('frame').style.left = (boxLeft < 0) ? "0px" : boxLeft + "px";
		document.getElementById('frame').style.visibility = 'visible';
		
		document.getElementById('frame').style.width = '470px';
		document.getElementById('frame').style.height = pageSize.windowHeight+'px';
	
		
		
		document.getElementById('desc_abc').innerHTML = xmlHttp.responseText;
	}
}

function videos(ls)
{ 
	var url="videos.asp?ls="+ls;
	xmlHttp=GetXmlHttpObject(stateChangedvideos)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
} 

function stateChangedvideos() 
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var pageSize = getPageSize();
		var pageScroll = getPageScroll();
		
		var boxLeft = ((pageSize.pageWidth - 520) / 2);
		var boxTop = pageScroll.yScroll + ((pageSize.windowHeight - 500) / 2);
		
		document.getElementById('sombra').style.height = pageSize.pageHeight+"px";
		document.getElementById('sombra').style.visibility = 'visible';
		document.getElementById('zoom_abc').style.top = (boxTop < 0) ? "0px" : boxTop + "px";
		document.getElementById('zoom_abc').style.left = (boxLeft < 0) ? "0px" : boxLeft + "px";

		document.getElementById('frame').style.top = "0px";
		document.getElementById('frame').style.left = (boxLeft < 0) ? "0px" : boxLeft + "px";
		document.getElementById('frame').style.visibility = 'visible';
		
		document.getElementById('frame').style.width = '470px';
		document.getElementById('frame').style.height = '3px';
	
		
		
		document.getElementById('desc_abc').innerHTML = xmlHttp.responseText;
	}
}

var inoout=false;
var chamarola;
var cond;
function para()
{
	inoout=true;
}

function chama(valor)
{
	clearTimeout(chamarola);
	cond = valor;
	inoout=false;
	rola();
}
function rola()
{
	if(inoout==false){		
		if (cond == 'dire') {
			var valor = document.getElementById('fotos_2').scrollLeft;
			document.getElementById('fotos_2').scrollLeft = valor+9;
		} else {
			var valor = document.getElementById('fotos_2').scrollLeft;
			document.getElementById('fotos_2').scrollLeft = valor-9;
		}

		chamarola = setTimeout('rola()',100);
	}else{
		clearTimeout(chamarola);
	}
}

function selimg(ls,img){
	document.getElementById('foto_img').innerHTML = '<img Width="470px" height="353px" src="imgs/'+ls+'/Fotos/'+img+'">'
}
