var doc = document.all ? document.all : document;

var detect = navigator.userAgent.toLowerCase();

isNN = isNN4 = false;
isIE = isIE4 = isIE5 = isIE6 = false; 

if (checkIt('msie')) {
	isIE = true;
	version = detect.charAt(place + thestring.length);
	if (version >= 4 && version < 5) { isIE4 = (document.all)?true:false; }
	if (version >= 5 && version < 6) { isIE5 = (document.all)?true:false; }
	if (version >= 6 && version < 7) { isIE6 = (document.all)?true:false; }
}
else if (!checkIt('compatible')) {
	isNN = true;
	version = detect.charAt(8);
	if (version >= 3 && version < 4) { isNN3 = (document.layers)?true:false; }
	if (version >= 4 && version < 5) { isNN4 = (document.layers)?true:false; }
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

// menu (c) root.pl
function img_off(imgName) {
	if ( isNN || isIE ) {
		imgOff = eval(imgName+'off.src'); document[imgName].src = imgOff;
		return true;
	}
}
function img_on(imgName) {
	if ( isNN || isIE ) {
		imgOn = eval(imgName+'on.src'); document[imgName].src = imgOn;
		return true;
	}
}
function img_swap(imgName,src) {
	if ( isNN || isIE ) {
		document[imgName].src = src;
		return true;
	}
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2]?argv[2]:null : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

// functions
// lang change
function setlang(lang) {
	if (lang == 'pl' || lang == 'en') {
		SetCookie('LANG',lang,'','/');
	}
	window.location = window.location;
}

function confDelete() {
	str = 'Czy jeste¶ pewien, że chcesz usun±ć ten rekord?';
	return confirm(str);
}
