var lock = false
var slen = 250;
var maxLen = 250;

function countit() {
  if (!lock) {
	lock=true;
	str= document.forms[0].anotace.value;
	strlength= str.length;
	if (strlength > slen) {
	  document.forms[0].cntr1.value="!!!";
	  alert("Dlouhý text!");
	  document.forms[0].anotace.value=str.substring(0,slen);
	} else
	  document.forms[0].cntr1.value = slen - strlength;
	lock=false;
  }
}

function cleantext() {
  document.forms[0].anotace.value="";
  countit();
}

function externalLinks() {
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
		}
	} 
} 

function f(id) {
	var el=document.getElementById(id)
	if (el.style.display=="none") {
		el.style.display="";
	}
	else {
		el.style.display="none";
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  w = window.open('',winName,features);
  w.document.open();
  w.document.writeln('<html><head><title>Detail</title><style type=\"text/css\">body{margin:0;padding:0}</style></head>');
  w.document.writeln('<body><img src=\"' + theURL + '\" onclick=\"window.close();\" alt=\"\" title=\"Click to close window\" /></body></html>');
  w.document.close();
}
function AddFavorite(linkObj,addUrl,addTitle) {
	if (document.all && !window.opera) {
		window.external.AddFavorite(addUrl,addTitle);
		return false;
	}
	else if (window.opera && window.print) {
		linkObj.title = addTitle;
		return true;
	}
	else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) {
		if (window.confirm('Přidat oblíbenou stránku jako nový panel?')) {
			window.sidebar.addPanel(addTitle,addUrl,'');
			return false;
		}
	}
	window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.');
	return false;
}

function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}