browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

isNN = false;
isIE = false;
isOO = false;
isNN4 = false;
isNN5 = false;
isIE4 = false;
isOO8 = false;

var doc = document.all ? document.all : document;

function open_window( url, width, height ) {
//	if( popup ){
//		popup.window.close();
//	}
        popup = window.open(
                        url,
                        "WINDOW",
                        "directories=no,width="+width+",height="+height+",left=10,top=5,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
	popup.focus();
}


if (browserName == "Netscape") {
	isNN = true;
	if (browserVer >= 3) {
		isNN4 = true;
	}
	if (browserVer >= 5) {
		isNN5 = true;
	}
}

if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) {
	isIE = true;
	isIE4 = (document.all)?true:false;
}

if (browserName == "Opera") {
	isOO = true;
	if (browserVer >= 7.5 ) {
		isOO8 = true;
	}
}

// menu (c) root.pl
function img_off(imgName) {
	if ( isNN || isIE || isOO ) {
		imgOff = eval(imgName+'off.src'); document[imgName].src = imgOff;
		return true;
	}
}
function img_on(imgName) {
	if ( isNN || isIE || isOO ) {
		imgOn = eval(imgName+'on.src'); document[imgName].src = imgOn;
		return true;
	}
}
function img_swap(imgName,src) {
	if ( isNN || isIE || isOO ) {
		document[imgName].src = src;
		return true;
	}
}

function find(item) {
	if (document.all) {
		ai = document.all[item];
		return(ai);
	}
	if (document.getElementById) {
		gebi = document.getElementById(item);
		return(gebi);
	}
	return(false);
}

function moveXbySlicePos (x, img) { 

	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45   = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
		if (!document.all) {
			x += 400;
		}
	}
	else if (img.x) {
		x += img.x;
	}
	return x;
}

function moveYbySlicePos (y, img) {

	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
		if (!document.all) {
			y += +50;
		}
	}
	else if (img.y >= 0) {
		y += img.y;
	}
	return y;
}

function slownik(id, x, y) {
	var posx = xMousePos2 ? xMousePos2 : 10;
	var posy = yMousePos2 ? yMousePos2 : 10;
	var glossary = window.open(
			"/pl/winslownik/?id="+id,
			"słownik",
			"directories=no,width=350,height=300,left="+posx+",top="+posy+",menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
	glossary.focus();
}

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

if (document.layers) { // Netscape
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
	document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
	document.onmousemove = captureMousePosition;
}

function captureMousePosition(e) {

	if (document.layers) {
		// When the page scrolls in Netscape, the event's mouse position
		// reflects the absolute position on the screen. innerHight/Width
		// is the position from the top/left of the screen that the user is
		// looking at. pageX/YOffset is the amount that the user has 
		// scrolled into the page. So the values will be in relation to
		// each other as the total offsets into the page, no matter if
		// the user has scrolled or not.
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
		xMousePos2 = xMousePos - (xMousePosMax - window.innerWidth);
		yMousePos2 = yMousePos - (yMousePosMax - window.innerHeight);
	} else if (document.all) {
		// When the page scrolls in IE, the event's mouse position 
		// reflects the position from the top/left of the screen the 
		// user is looking at. scrollLeft/Top is the amount the user
		// has scrolled into the page. clientWidth/Height is the height/
		// width of the current page the user is looking at. So, to be
		// consistent with Netscape (above), add the scroll offsets to
		// both so we end up with an absolute value on the page, no 
		// matter if the user has scrolled or not.
		xMousePos    = window.event.x + document.body.scrollLeft;
		yMousePos    = window.event.y + document.body.scrollTop;
		xMousePosMax = document.body.clientWidth  + document.body.scrollLeft;
		yMousePosMax = document.body.clientHeight + document.body.scrollTop;
		xMousePos2   = xMousePos - (xMousePosMax - document.body.clientWidth);
		yMousePos2   = yMousePos - (yMousePosMax - document.body.clientHeight);
	} else if (document.getElementById) {
		// Netscape 6 behaves the same as Netscape 4 in this regard 
		xMousePos    = e.pageX;
		yMousePos    = e.pageY;
		xMousePosMax = window.innerWidth  + window.pageXOffset;
		yMousePosMax = window.innerHeight + window.pageYOffset;
		xMousePos2   = xMousePos - (xMousePosMax - window.innerWidth);
		yMousePos2   = yMousePos - (yMousePosMax - window.innerHeight);
	}
}
