navDOM = window.innerHeight;
DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0; 
IE = (document.all) ? 1 : 0;
IE4 = IE && !DOM; 

function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' musí obsahovat e-mailovou adresu.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' musí obsahovat číslo.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' musí obsahovat číslo mezi '+min+' a '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' je nutno uvést.\n'; }
  } if (errors) alert('Ve formuláři byly nalezeny následující chyby:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_openBrWindow(URL,windows,features) { 
window.open(URL, windows, features);
};

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MyPopUP(what,on) {

	if (on) {
	if (DOM) {
		document.getElementById(what).style.visibility = "visible";
	} else if (NS4) {
		document.layers[what].visibility = "show";
	} else {
		document.all[what].style.visibility = "visible";
	}
} else {
	if (DOM) {
		document.getElementById(what).style.visibility = "hidden";
	} else if (NS4) {
		document.layers[what].visibility = "hide";
	} else {
		document.all[what].style.visibility = "hidden";
	}
}
};

function mDT(width,title) { //makeDivTop
	res = '<table border="0" cellpadding="1" cellspacing="0" class="ndCatFrame"><tr><td nowrap>';
	res = res + '<div class="ndCatFrameTitle">'+title+'</div>';
	res = res + '<table border="0" cellpadding="3" cellspacing="0" class="ndCatFrameInner" width="100%">';
	res = res + '<tr><td>';
	res = res + '<table border="0" cellpadding="0" cellspacing="0" width="100%" class="ndCatFrameInner"><tr><td nowrap>';
	document.write(res);
};

function mDB() { //makeDivBottom
	res = '</td></tr></table></td></tr></table></td></tr></table></div>';
	document.write(res);
};

function mDH(layer_label) { //makeDivHeader
	res = '<div id="' + layer_label + '" style="position: absolute; left: 0; top: 0; visibility: hidden;">';
	document.write(res);
};

function mDF() { //makeDivFooter
	res = '</table></td></tr></table></td></tr></table>';
	document.write(res);
};

function mDC(kategorie,refid,onmouseovr,text,arrow,title) { //makeDivCell
	if (kategorie.substr(0,1) == '*') {
		link = kategorie.substr(1,255);
		res = '<div class="ndCatSubLevel"><a href="' + link + '" id="ref' + refid + '" onMouseOver="'+onmouseovr+'" >'+text+'</a>'+arrow+'</div>\n';
	} else {
		link = 'index.php?kategorie='+kategorie+'&type=list&page=1';
		res = '<div class="ndCatSubLevel"><a href="' + link + '" id="ref' + refid + '" onMouseOver="'+onmouseovr+'" >'+text+' - '+title+'</a>'+arrow+'</div>\n';
	}
	document.write(res);
};

function mAL(type,text) { //makeAnchorLine (with break?)
	res = '<br><img src="images/dot.gif"><a href="index.php?type=' + type +'">' + text + '</a>';
	document.write(res);
};

function cCP(ID,text,select) {
	document.write('<option value="' + ID + '"');
	if (ID == select) {
		document.write(' selected');
	};
	document.write(' title="' + text + '">' + text + '</option>');
};

function changeVerifyImage() {
	var vi = document.getElementById('verifyImage');
	vi.src = 'slices/verify.php?rel=' + Math.random();
}

function checklength(baseName,maxLength) {
	var item = document.getElementById('frm_' + baseName);
	var echo = document.getElementById('lenghtfrm_' + baseName);
	theLength = item.value.length;
	if (theLength > maxLength) {
		item.value = item.value.substr(0,maxLength);
		length = maxLength;
	}
	echo.innerHTML = maxLength - theLength;
}

function checksharp(vName,vLength) {
	document.getElementById('frm_submit').disabled = document.getElementById(vName).value.length != vLength;
}

function trim(str) {
	if (str) {
  	return str.replace(/^\s*|\s*$/g,"");
  } else {
  	return '';
  }
} 


