var req;

function loadXMLDocOfertas(url,valor,valor2)
{
    req = null;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChangeOfertas;
        req.open("GET", url+'?id='+valor+'&foto='+valor2, true);
        req.send(null);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChangeOfertas;
            req.open("GET", url+'?id='+valor+'&foto='+valor2, true);
            req.send();
        }
    }
}

function processReqChangeOfertas()
{
    if (req.readyState == 4) {
        if (req.status == 200) {
            document.getElementById('fotolarg').innerHTML = req.responseText;
        } else {
            alert("Houve um problema ao obter os dados:\n" + req.statusText);
        }
    }
}

function fechagaleria()
{
	document.getElementById('fotolarg').innerHTML = "";
    document.getElementById('fotolarg').style.visibility='hidden';
}

function jsGaleria(valor,valor2)
{
    document.getElementById('fotolarg').style.visibility='visible';
	
	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){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}


	var UA = navigator.userAgent;if (UA.indexOf('MSIE') > -1) {
        meuscroll = document.documentElement.scrollTop;
	} else {
    	meuscroll = document.body.scrollTop;
	}
		
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	document.getElementById('fotolarg').style.width = pageWidth+'px';
	document.getElementById('fotolarg').style.height = pageHeight+'px';
	meuscroll += 20;
	document.getElementById('fotolarg').style.paddingTop = meuscroll+'px';
	loadXMLDocOfertas("./galeria/galeria.php", valor, valor2);
}
