function ReplaceString(ABuf, AOldStr, ANewStr) {
	var tmp = "";
	if (ABuf == null) return tmp;
	var last_index = -1;
	var idx = ABuf.indexOf(AOldStr);
	while(idx >= 0) {
		var start = (last_index >= 0) ? last_index + AOldStr.length  : 0;
		tmp += ABuf.substring(start, idx) + ANewStr;
		last_index = idx;
		idx = ABuf.indexOf(AOldStr, idx + 1);
	}
	if (last_index >= 0) tmp += ABuf.substring(last_index + AOldStr.length);
	else tmp += ABuf;
	return tmp;
}

function GetTag(AName) {
	var temp = document.getElementsByName(AName);
	var tempID = document.getElementById(AName);
	if (tempID != null) return tempID;
	else if (temp != null && temp.length > 0) return temp[0];
	else return null;
}

function CheckNumber(e) {
	if (!e) e = window.event;
	if (e.charCode != null) return (e.charCode == 0 || /\d{1,1}/.test(String.fromCharCode(e.charCode)));
	else return /\d{1,1}/.test(String.fromCharCode(e.keyCode));
}

function CheckASCII(e) {
	if (!e) e = window.event;
	if (e.charCode != null) return (e.charCode == 0 || e.charCode == 43 || /\w|\-{1,1}/.test(String.fromCharCode(e.charCode)));
	else return /\w|\-{1,1}/.test(String.fromCharCode(e.keyCode));
}

function CheckPhone(e) {
	if (!e) e = window.event;
	if (e.charCode != null) return (e.charCode == 0 || e.charCode == 43 || /\d{1,1}/.test(String.fromCharCode(e.charCode)));
	else return /\d{1,1}/.test(String.fromCharCode(e.keyCode));
}

function ZobrazSkryjFiltr() {
	var obj = GetTag("filtr-dat");
	if (obj.style.display == "none") obj.style.display = "block";
	else obj.style.display = "none";
	return false;
}

function VyskakovaciOkno(adresa, sirka, vyska) {
	if (adresa != null && adresa != "") {
		sirka = sirka != null && !isNaN(parseInt(sirka)) ? sirka : 650;
		vyska = vyska != null && !isNaN(parseInt(vyska)) ? vyska : 500;
		window.open(adresa, 'fitness', "width=" + sirka + ",height=" + vyska + ",toolbar=no,menubar=no,scrollbars=yes,status=no,resizable=yes,left=" + parseInt((screen.width-sirka)/2) + ",top=" + parseInt((screen.height-vyska)/2) + "").focus();
	}
	return false;
}

