// zapisanie do cookie rozmairu okna

function getCookieData(labelName){
	var labelLen = labelName.length;
	var cookieData = document.cookie;
	var cLen = cookieData.length;
	var i = 0;
	var cEnd;
	while (i < cLen){
		var j = i + labelLen;
		if (cookieData.substring(i,j) == labelName){
			cEnd = cookieData.indexOf(";",j);
			if(cEnd == -1){
				cEnd = cookieData.length;
			}
			return unescape(cookieData.substring(j+1,cEnd))
		}
		i++;
	}
	return "";	
}
//wywolanie funkcji zapisu/odczytu cookie
if(getCookieData('width') !=''){
	//var wid = getCookieData('width');
}else{
	document.cookie = "width="+screen.width;
}
/*
 * Skrypt dla menu_dyn
 */

// czesc w oryginale JavaScript
var thresholdY = 15;		// in pixels; threshold for vertical repositioning of a layer
var ordinata_margin = 53;	// to start the layer a bit above the mouse vertical coordinate

DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
//alert('DOM: '+DOM+' NS4: '+NS4+' IE4: '+IE4);
var loaded = 0;	// to avoid stupid errors of Microsoft browsers
Opera5 = (navigator.userAgent.indexOf("Opera 5") > -1 || navigator.userAgent.indexOf("Opera/5") > -1) ? 1 : 0;

//alert ("DOM "+DOM +"\nNS4 "+NS4+"\nIE4 "+IE4+"\nOpera5 "+Opera5);

// czesc w oryginale JavaScript12

// it works with NS4, Mozilla, NS6, Opera 5, IE
currentY = -1;
currentX = -1;
function grabMouse(e) {
	if ((DOM && !IE4) || Opera5) {
		currentY = e.clientY;
		currentX = e.clientX;
	} else if (NS4) {
		currentY = e.pageY;
		currentX = e.pageX;
	} else {
		currentY = event.y;
		currentX = event.x;
	}
	if (DOM && !IE4 && !Opera5) {
		currentY += window.pageYOffset;
		currentX += window.pageXOffset;
	} else if (IE4 && DOM && !Opera5) {
		currentY += document.body.scrollTop;
		currentX += document.body.scrollLeft;
	}
currentX = 80;
}
if ((DOM || NS4) && !IE4) {
	document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
}
document.onmousemove = grabMouse;

function popUp(menuName,on) {
	if (loaded) {	// to avoid stupid errors of Microsoft browsers
		if (on) {
//			moveLayers();
			if (DOM) {
				document.getElementById(menuName).style.visibility = "visible";
			} else if (NS4) {
				document.layers[menuName].visibility = "show";
			} else {
				document.all[menuName].style.visibility = "visible";
			}
		} else {
			if (DOM) {
				document.getElementById(menuName).style.visibility = "hidden";
			} else if (NS4) {
				document.layers[menuName].visibility = "hide";
			} else {
				document.all[menuName].style.visibility = "hidden";
			}
		}
	}
}
/*
function popUp(menuName, on) { 
//alert(on+" popUp "+menuName);

  var v,obj;

  if(!(obj=document[menuName])&&document.all)
    obj=document.all[menuName]; 

  if(!obj && document.getElementById)
    obj=document.getElementById(menuName); 

//alert(obj);	
  if ((obj)!=null) { 
//alert("nie nul");	
    if (obj.style) { 
//alert("styl "+on);	
      obj=obj.style; 
      if(on) v='visible';
      else v='hidden';
    }
    obj.visibility=v; 
  }
}
*/

var id_interval2=false;

function shutdownOut2() {
    var shutdownTimeout = 300;
    id_interval2 = setInterval('shutdown2()', shutdownTimeout );
    return true;
}

 
function clearInt2() {
  if (id_interval2) {
     clearInterval(id_interval2);
 }
 return true;
}

function moveLayerY(menuName, x, ordinata, offsetX) {
	if (loaded) {	// to avoid stupid errors of Microsoft browsers
		if (ordinata != -1 && !isNaN(ordinata)) {	// The browser has detected the mouse position
			if (DOM) {
				document.getElementById(menuName).style.left = x + offsetX;
				appoggio = parseInt(document.getElementById(menuName).style.top);
				if (isNaN(appoggio)) appoggio = 0;
				if (Math.abs(appoggio + ordinata_margin - ordinata) > thresholdY)
					document.getElementById(menuName).style.top = ordinata - ordinata_margin;
			} else if (NS4) {
				document.layers[menuName].left = x + offsetX;
				if (Math.abs(document.layers[menuName].top + ordinata_margin - ordinata) > thresholdY)
					document.layers[menuName].top = ordinata - ordinata_margin;
			} else {
				document.all[menuName].style.pixelLeft = x + offsetX;
				if (Math.abs(document.all[menuName].style.pixelTop + ordinata_margin - ordinata) > thresholdY)
					document.all[menuName].style.pixelTop = ordinata - ordinata_margin;
			}
		}
	}
}

if (NS4) {
	document.onmousedown = function() { shutdown();shutdown2() }
} 
else {
	document.onclick = function() { shutdown();shutdown2() } 
}
