// ============================================================================================		 
// @function	Box Luce
// @author		Daniele Florio
// @site		www.gizax.it
// @version		0.2 experimental

// (c) 2006 Daniele Florio <daniele@gizax.it>

// ============================================================================================= 

var boxLuce = {

	creaBoxLuce : function(url,altezzaBox){ 


		var larghezzaBox = '494';

		var oggBODY = document.getElementsByTagName("body").item(0);

		var divScuro = document.createElement("div");

		divScuro.setAttribute('id','divScuro');
		divScuro.onclick = function () { 
			boxLuce.rimuoviBoxLuce(); 
			boxLuce.lunghezzaPagina(); 
			return false; 
		}
		divScuro.style.zIndex = '90';
		divScuro.style.height = (boxLuce.lunghezzaPagina()) + 'px';
		oggBODY.insertBefore(divScuro, oggBODY.firstChild);

		var divChiaro = document.createElement("div");

		divChiaro.setAttribute('id','divChiaro');
		divChiaro.style.zIndex = '91';

		var margTOP = (altezzaBox / 2) + 120;
		margTOP = '-'+margTOP+'px';

		var margLEFT = (larghezzaBox / 2);
		margLEFT = '-'+margLEFT+'px';

		divChiaro.style.marginTop =  margTOP;
		divChiaro.style.marginLeft = margLEFT; 
		divChiaro.style.height = '550px';
		oggBODY.insertBefore(divChiaro, oggBODY.firstChild);

		var bod = document.getElementById('divScuro');

		var divChiaroCopertura = document.createElement('div');

		divChiaroCopertura.id = 'divChiaroCopertura';

		divChiaroCopertura.style.marginLeft = margLEFT ; 
		divChiaroCopertura.style.cursor = 'hand';

		divChiaroCopertura.innerHTML= '<a href=""><img src="http://www.branham.it/joomla/gallery/sudafrica/images/closelabel.gif" /></a>';

		divChiaroCopertura.onclick = function () { 
			boxLuce.rimuoviBoxLuce(); 
			boxLuce.lunghezzaPagina(); 
			return false; 
		}

		bod.appendChild(divChiaroCopertura);

		completeAHAH.ahah(url, 'divChiaro', '', 'GET', '');

	},

	rimuoviBoxLuce : function(){
		var divScuro = document.getElementById('divScuro');
		var divChiaro = document.getElementById('divChiaro');
		divScuro.style.display = 'none';
		divChiaro.style.display = 'none';
	},

	lunghezzaPagina : function(){
		
		var yScroll;
		
		if (window.innerHeight) {	
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){
			yScroll = document.body.scrollHeight;
		} else { 
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			windowHeight = document.body.clientHeight;
		}	
		
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		return totale = pageHeight;
	}
}
