var lightbox1_width = 730, lightbox1_height= 100;

function showLightbox(){
	var arrayPageSize = getPageSize();
	document.getElementById('overlay').style.width = (arrayPageSize[0] + 'px');
	document.getElementById('overlay').style.height = (arrayPageSize[1] + 'px');
	if(document.getElementById('video')){document.getElementById('video').style.display="none";}
	if(document.getElementById('flash')){document.getElementById('flash').style.display = 'none';}
	document.getElementById('overlay').style.display = 'block';
	document.getElementById('lightbox1').style.left = ( ( ( arrayPageSize[0] / 2 ) - ( lightbox1_width / 2 ) ) + 'px');
	document.getElementById('lightbox1').style.top = ( ( getPageScroll() + ( lightbox1_height / 2 ) ) + 'px');
	document.getElementById('lightbox1').style.display = 'block';
	LoadURL("templates_globales/set_visit.php?p="+access_visit,"");
}

function hideLightbox(){
	document.getElementById('overlay').style.display = 'none'; // hide lightbox and overlay
    document.getElementById('lightbox1').style.display = 'none';
	if(document.getElementById('video')){document.getElementById('video').style.display="block";}
	if(document.getElementById('flash')){document.getElementById('flash').style.display = 'block';}
	document.onkeypress = ''; // disable keypress listener
}

function getPageScroll(){
	var theTop = 0;
	var old = 0;

	if (window.innerHeight) {
		pos = window.pageYOffset
	} else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop
	} else if (document.body) {
		pos = document.body.scrollTop
	}
	return pos;
}

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){ // 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 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)
	return arrayPageSize;
}

var theTop = 0;
var old = 0;
	function movelayer() {
		var pos;
		if (window.innerHeight) {
			  pos = window.pageYOffset
		} else if (document.documentElement && document.documentElement.scrollTop) {
			pos = document.documentElement.scrollTop
		} else if (document.body) {
			  pos = document.body.scrollTop
		}
		
		if (pos < theTop)
			pos = theTop
		else
			pos += 30
		if (pos == old)
			document.getElementById("lightbox1").style.top = pos + "px"

		old = pos
		setTimeout("movelayer()",20);
	}

function showDivLightbox(){
        var arrayPageSize = getPageSize();
        document.getElementById('overlay').style.width = (arrayPageSize[0] + 'px');
        document.getElementById('overlay').style.height = (arrayPageSize[1] + 'px');
        if(document.getElementById('video')){document.getElementById('video').style.display="none";}
        if(document.getElementById('flash')){document.getElementById('flash').style.display = 'none';}
        document.getElementById('overlay').style.display = 'block';
        document.getElementById('lightbox1').style.left = ( ( ( arrayPageSize[0] / 2 ) - ( lightbox1_width / 2 ) ) + 'px');
        document.getElementById('lightbox1').style.top = ( ( getPageScroll() + ( lightbox1_height / 2 ) ) + 'px');
        document.getElementById('lightbox1').style.display = 'block';
}

