var et, tr;
var cba = "#FFCBB3";

function hide(obj) {obj.style.display='none';}
function null_item(obj) {
		document.getElementById(obj).value=0;
		document.order.submit();
}
function ShowFoto(IMI){var URL; URL=root+ '/common/bigimg.php?IMI='+IMI+'&root='+root; window.open(URL,'','scrollbars,width=1,height=1,left='+(screen.width/2)+',top='+(screen.height/2));}

function check_fill(obj,mail) {
	et=0;
	for (i=0;i<obj.length;i++) {
		o = obj[i];
		if (o.value.length == 0) {
			 et=1;
			 o.style.backgroundColor=cba;
		}
		else 
			 o.style.backgroundColor="";
	}
	if (mail!='' && mail!=undefined && mail.value.length > 0 && !et) {
		CheckEmail(mail.value)
		if (!tr) {
			mail.style.backgroundColor=cba; 
			return false;
		}
	}
	if (et) {
		if (document.getElementById('orderform')) document.getElementById('orderform').innerHTML = 'Označené položky musí být vyplněny.';
		return false;
	}
}

function CheckEmail(field){
	var str=field
	var filter=/^.+@.+\..{2,4}$/
	if (filter.test(str)) tr=true;
	else tr=false;
}
function chv(obj,nova,old) {if (obj.value==old) obj.value = nova; }

function highlightSearchTerms(searchText) {
	searchText = searchText.replace('>','');
	searchText = searchText.replace('<','');
	searchArray = searchText.split(" ");
	if (document.getElementById('content')) obj = document.getElementById('content')
	else obj = document.getElementById('contentall')
	var bodyText = obj.innerHTML;
	for (var i = 0; i < searchArray.length; i++) { bodyText = doHighlight(bodyText, searchArray[i]);  }
	obj.innerHTML = bodyText;
	return true;
}
function doHighlight(bodyText, searchTerm) {
	highlightStartTag = "<font style='background-color:"+cba+";'>";
	highlightEndTag = "</font>";
	var newText = "";
	var i = -1;
	var lcSearchTerm = searchTerm.toLowerCase();
	var lcBodyText = bodyText.toLowerCase();
	
	while (bodyText.length > 0) {
	i = lcBodyText.indexOf(lcSearchTerm, i+1);
		if (i < 0) {
		  newText += bodyText;
		  bodyText = "";
		} else {
		  if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
			if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
			  newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
			  bodyText = bodyText.substr(i + searchTerm.length);
			  lcBodyText = bodyText.toLowerCase();
			  i = -1;
			}
		  }
		}
	}
  
  return newText;
}