function zkontrolujVelikost(prvek, velikost){	
	if(prvek.value.length > velikost){
		prvek.value = prvek.value.substring(0,velikost);
	}
}

function getElement(psID) {
   if(document.all) {
      return document.all[psID];
   } else {
      return document.getElementById(psID);
   }
}

function switchVisible(divToSwitch, type){
	if(type == "off")
		getElement(divToSwitch).style.display = "none";
	else
		getElement(divToSwitch).style.display = "block";
}

function switchTRVisible(divToSwitch, type){
	if(type == "off")
		getElement(divToSwitch).style.display = "none";
	else
		getElement(divToSwitch).style.display = "";
}

function switchVisibleByCheckbox(divToSwitch, id){
	chck = getElement(id);
	if(chck.type == "checkbox"){
		if(chck.checked){
			switchVisible(divToSwitch,"on");
		}
		else {
			switchVisible(divToSwitch,"off");
		}
	}
}

function getCorrespondingRow(checkbox){
	idArr = checkbox.id.split("_");
	id = idArr[1];
	return getElement("tr_" + id);
}

function setOddSelectedRow(checkbox){
	radek = getCorrespondingRow(checkbox);
	if(checkbox.checked){
		radek.className = "selected";
	}
	else {
		radek.className = "";
	}	
}

function setEvenSelectedRow(checkbox){
	radek = getCorrespondingRow(checkbox);
	if(checkbox.checked){
		radek.className = "selected";
	}
	else {
		radek.className = "even";
	}
}


function lookup(path){
	myRef = window.open(''+path,'mywin','left=20,top=20,width=600,height=500,toolbar=0,resizable=1,menubar=0,scrollbars=1');
}

function showConfirm(redirectTo, text){
	if(confirm(text) == true){
		self.location.href = redirectTo;
	}
}



function setCookie(cookieName, cookieValue, expires, path, domain, secure) {
	document.cookie =
		escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; expires=' + expires.toGMTString() : '')
		+ (path ? '; path=' + path : '')
		+ (domain ? '; domain=' + domain : '')
		+ (secure ? '; secure' : '');
}



function getCookie(cookieName) {

	var cookieValue = '';
	var posName = document.cookie.indexOf(escape(cookieName) + '=');

	if (posName != -1) {
		var posValue = posName + (escape(cookieName) + '=').length;
		var endPos = document.cookie.indexOf(';', posValue);
		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
		else cookieValue = unescape(document.cookie.substring(posValue));

	}
	return (cookieValue);
}


