var searchEmptyText = "hledaný text";
var usernameEmptyText = "jméno";

function fieldsInit() {
	var target = null;

	target = document.getElementById("searchfield");
	if (target != null) {
		target.value = searchEmptyText;
	}
	target = document.getElementById("username");
	if (target != null) {
		target.value = usernameEmptyText;
	}
	target = document.getElementById("password");
	if (target != null) {
		target.value = "";
	}
}

function fieldClear(target) {
	if (target == document.getElementById("searchfield")) {
		if (target.value == searchEmptyText) {
			target.value = '';
			target.style.color = "#000000";
		}
	}
	if (target == document.getElementById("username")) {
		if (target.value == usernameEmptyText) {
			target.value = '';
			target.style.color = "#000000";
		}
	}
}

function fieldRestore(target) {
	if (target == document.getElementById("searchfield")) {
		if (target.value == '') {
			target.value = searchEmptyText;
			target.style.color = "#9f9f9f";
		}
	}
	if (target == document.getElementById("username")) {
		if (target.value == '') {
			target.value = usernameEmptyText;
			target.style.color = "#9f9f9f";
		}
	}
}

function areaCounter(target, limit) {
	str = target.value;
	len = str.length;
	if (len > limit) {
		aArea.value = str.substr(0, nLength);
		document.getElementById(target.name + "_cnt0").firstChild.data = limit;
		document.getElementById(target.name + "_cnt1").firstChild.data = 0;
	} else {
		document.getElementById(target.name + "_cnt0").firstChild.data = len;
		document.getElementById(target.name + "_cnt1").firstChild.data = limit - len;
	}
}
