if (document.all) {
	LayerPre = "document.all[";
	LayerStyle = "].style";
}
else {
	if (document.getElementById) {
		LayerPre = "document.getElementById(";
		LayerStyle = ").style";
	}
}



// Funkcja wyświetla warstwę
function ShowLayer(LayerName) {
	if (LayerPre!="") eval(LayerPre+'"'+LayerName+'"'+LayerStyle+'.display=""');
}



// Funkcja ukrywa warstwę
function HideLayer(LayerName) {
	if (LayerPre!="") eval(LayerPre+'"'+LayerName+'"'+LayerStyle+'.display="none"');
}



// Funkcja przełącza wyświetlanie warstwy
function ToggleLayer(LayerName) {
	if (LayerPre!="") {
		// ukrycie warstwy
		if (eval(LayerPre+'"'+LayerName+'"'+LayerStyle+'.display!="none"')) eval(LayerPre+'"'+LayerName+'"'+LayerStyle+'.display="none"');
		// wyświetlenie warstwy
		else eval(LayerPre+'"'+LayerName+'"'+LayerStyle+'.display=""');
	}
}



/*
Disable right mouse click Script
By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
For full source code, visit http://www.dynamicdrive.com
*/
/*
function clickIE4() {
	if (event.button==2) {
		return false;
	}
}

function clickNS4(e) {
	if (document.layers||document.getElementById&&!document.all) {
		if (e.which==2||e.which==3) {
			return false;
		}
	}
}

if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
}
else {
	if (document.all&&!document.getElementById) {
		document.onmousedown=clickIE4;
	}
}

document.oncontextmenu=new Function("return false")
*/


/*
Funkcje daty / czasu
*/

// funkcja dokonuje walidacji daty
function checkDate(pole) {
	if (chkdate(pole)) {
		return true;
	} else {
		alert("Data wpisana błędnie. Spróbuj jeszcze raz.\nWpisz datę w jednym z poniższych formatów:\n\nRRRR-MM-DD (np. 1985-08-15 lub 85-08-15)\n\nDD.MM.RRRR (np. 15.08.1985 lub 15.08.85)\n\nMM/DD/RRRR (np. 08/15/1985 lub 08/15/85)\n\nMożesz ewentualnie pominąć rok, wówczas zostanie wprowadzony rok bieżący.");
		pole.focus();
		pole.select();
		return false;
	}
}



function chkdate(objName) {

	var strDate;
	var strDateArray;
	var strDay;
	var strMonth;
	var strYear;
	var intDay;
	var intMonth;
	var intYear;
	var datefield = objName;
	strSeparator1 = "-";
	strSeparator2 = ".";
	strSeparator3 = "/";  
	strDate = datefield.value;
	dateData = new Date();
	akt_rok = dateData.getYear();

	if (strDate=="") return true;
	if (strDate.indexOf(strSeparator1) != -1) {
		strDateArray = strDate.split(strSeparator1);
		if (strDateArray.length != 3 && strDateArray.length != 2) {
			return false;
		} else {
			if (strDateArray.length == 3) {
				strDay = strDateArray[2];
				strMonth = strDateArray[1];
				strYear = strDateArray[0];
			} else {
				strDay = strDateArray[1];
				strMonth = strDateArray[0];
				strYear = akt_rok;
			}
		}
	} else {
		if (strDate.indexOf(strSeparator2) != -1) {
			strDateArray = strDate.split(strSeparator2);
			if (strDateArray.length != 3 && strDateArray.length != 2) {
				return false;
			} else {
				strDay = strDateArray[0];
				strMonth = strDateArray[1];
				if (strDateArray.length == 3) strYear = strDateArray[2];
				else strYear = akt_rok;
			}
		} else {
			if (strDate.indexOf(strSeparator3) != -1) {
				strDateArray = strDate.split(strSeparator3);
				if (strDateArray.length != 3 && strDateArray.length != 2) {
					return false;
				} else {
					strDay = strDateArray[1];
					strMonth = strDateArray[0];
					if (strDateArray.length == 3) strYear = strDateArray[2];
					else strYear = akt_rok;
				}
			} else {
				return false;
			}
		}
	}

	if (strYear.length > 4 || strYear.length == 0 || strYear.length == 1 || strYear.length == 3 ) {
		return false;
	}

	intYear = parseInt(strYear, 10);

	if (isNaN(intYear)) return false;

	//if (intYear > akt_rok) return false;

	if (intYear < 100) {
		if (intYear > (akt_rok + 50) % 100) intYear += 1900;
		else intYear += 2000;
	}

	intDay = parseInt(strDay, 10);
	if (isNaN(intDay)) return false;

	intMonth = parseInt(strMonth, 10);
	if (isNaN(intMonth)) return false;

	if (intMonth>12 || intMonth<1) return false;

	if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intDay > 31 || intDay < 1)) return false;
	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intDay > 30 || intDay < 1)) return false;
	if (intMonth == 2) {
		if (intDay < 1) return false;
		if (LeapYear(intYear) == true) {
			if (intDay > 29) return false;
		} else {
			if (intDay > 28) return false;
		}
	}

	if (intMonth < 10) intMonth = "0" + intMonth;
	if (intDay < 10) intDay = "0" + intDay;

	datefield.value = intYear + "-" + intMonth + "-" + intDay ;
	return true;
}



function LeapYear(intYear) {

	if (intYear % 100 == 0) {
		if (intYear % 400 == 0) { return true; }
	} else {
		if ((intYear % 4) == 0) { return true; }
	}
	return false;
}

