function init() {
	var objBody = document.getElementsByTagName("body").item(0);	
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.style.display = 'none';
	objBody.appendChild(objOverlay);
}

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;
}

function getPageScroll(){
		var x,y;
		if (self.pageYOffset) // all except Explorer
		{
			x = self.pageXOffset;
			y = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
			// Explorer 6 Strict
		{
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		}
		else if (document.body) // all other Explorers
		{
			x = document.body.scrollLeft;
			y = document.body.scrollTop;
		}
		arrayPageSize = new Array(x,y);
		return arrayPageSize;
}
	
function loadView(idlayer,layerwidth,layerheight) {
	var arrayPageSize = getPageSize();
	$('overlay').style.width = arrayPageSize[0] +"px";
	$('overlay').style.height = arrayPageSize[1] +"px";
	$('overlay').onclick = function() {closeView(idlayer);}

	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });
	$(idlayer).style.display="block";
	var arrayPageScroll = getPageScroll();

	if (arrayPageSize[3]>=layerheight) {
		var layerTop = arrayPageScroll[1] + ((arrayPageSize[3]-layerheight)/2);
	}
	else {
		var layerTop = arrayPageScroll[1] + 10;
	}
	
	if (arrayPageSize[2]>=layerwidth) {
		var layerLeft = arrayPageScroll[0] + ((arrayPageSize[2]-layerwidth)/2);
	}
	else {
		var layerLeft = arrayPageScroll[0] + 10;
	}
	$(idlayer).style.top = layerTop +"px";
	$(idlayer).style.left = layerLeft +"px";


	Element.show(idlayer);
}

function closeView(idlayer) {
		$(idlayer).style.display="none";
		$("overlay").style.display="none";
}