window.onerror = HandleError

function HandleError(message, url, line) {
  var str = "An error has occurred in this dialog." + "\n\n"
  + "Error: " + line + "\n" + message;
  alert(str);
  //window.close();
  return true;
}
function status(text) {
	status=text;
}
function center_window(url,w,h){
	var top=screen.availHeight/2-h/2;
	var left=screen.availWidth/2-w/2;
	window.open(url,'','width='+w+',height='+h+',left='+left+',top='+top+'');	//,status=yes
}
function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}
function isEmpty(inputStr) {
	inputStr=removeTrailingChar(inputStr,' ');
	if (inputStr == null || inputStr == "") {
	return true
	}
	return false
}

function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}
function selectFiled(item) {
	item.className="warnedField";
	item.focus();	
}
function removeTrailingChar (inputString, removeChar)

{
	var returnString=inputString;
	if (removeChar.length)
	{
    while(''+returnString.charAt(returnString.length-1)==removeChar)
	  {
	    returnString=returnString.substring(0,returnString.length-1);
	  }
	}
	return returnString;
}
function submitSearch() {
	if(document.searchform.search.value=="szukaj...") {alert("Proszę podać poszukiwany wyraz."); return false}
	if(document.searchform.search.value.length<3) {alert("Proszę podać przynajmniej 3 litery."); return false}
	document.searchform.submit();
}
function wyslij_link(linka){
	center_window("../modules/wyslij_link.php?link="+linka,500,300);
}
function print_page(){
	var loc=location.href;
	var pindex = loc.indexOf("?",loc);
	if(pindex==-1) loc+="?";

	window.open(loc+'&m=print','','width=850,height=500,scrollbars=yes,resizable=yes');
}
