// wzorowany na layer_top.js uproszczony do włącznia i wyłączania okienka layer

/*
var aa = document.documentElement.clientWidth; alert ("document.documentElement.clientWidth: "+aa);
var bb = document.documentElement.offsetWidth; alert ("document.documentElement.offsetWidth: "+bb);
var cc = document.body.clientWidth; alert ("document.body.clientWidth: "+cc);
var dd = document.body.offsetWidth; alert ("document.body.offsetWidth: "+dd);
*/


var lay_jedn = document.layers? "" : "px";

function layer_on (_idname, _szer, _wys) {
	if (!document.getElementById && !document.all) return;

	obj_onoff = (document.getElementById)?document.getElementById (_idname).style : document.all? document.all[_idname] : document[_idname];

	// Określenie wymiaru okna przeglądarki
	if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		//var winWidth = document.documentElement.clientWidth; 
		var winHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		//var winWidth = document.body.clientWidth; 
		var winHeight = document.body.clientHeight;
	} else if (self.innerHeight) {    // all except Explorer
		//var winWidth = self.innerWidth; 
		var winHeight = self.innerHeight;
	}

	var winWidth = 1000;
	//var winHeight = 650;

	scroll_top = (document.all)? layer_dombody ().scrollTop : window.pageYOffset;

	obj_onoff.left = parseInt ((winWidth - _szer) / 2) + lay_jedn; // szerokość odczytane z index.css: #layer_top.width
	obj_onoff.top = parseInt ((winHeight - _wys) / 2 + scroll_top) + lay_jedn; // w pionie okienko przesówa się mimo skrolowania = zawsze na środku okna niezależnie od wyskości

	obj_onoff.visibility = "visible";
	obj_onoff.display = "block";
}

// Przy jednej obsługiwanej warstwie na stronie można nie podawać nazwy warstwy
function layer_off (_idname) {
	//obj_onoff.visibility = "hidden";
	if (_idname) {
		obj_onoff2 = (document.getElementById)?document.getElementById (_idname).style : document.all? document.all[_idname] : document[_idname];
		obj_onoff2.visibility = "hidden";
		obj_onoff2.display = "none";
	} else {
		obj_onoff.visibility = "hidden";
		obj_onoff.display = "none";
	}
}

function layer_dombody () {
	return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
}
