
var w=null;
var cnt=0;

function openWin(src,width,height,title) {
  leftStr='';
  topStr='';
  if (screen) {
    leftPos=(screen.width-width)/2;
    if (leftPos>0) leftStr=",left="+leftPos;
    topPos=(screen.height-height)/2;
    if (topPos>0) topStr=",top="+topPos;
  }
// Később propertyn keresztül lehessen állítani a következő sort
//  if ((w!=null) && (!w.closed)) w.close();
  cnt++; // Szelektor ablaknyitási bug miatt
  w=window.open("","image"+cnt,"toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,resizable=0,"+"width="+width+",height="+height+leftStr+topStr);
  d=w.document;
  d.open();
  if (title) {
    d.write("<head><title>"+title+"</title></head>");
  }
  d.write("<body style='margin:0px;padding:0px;text-align:center;vertical-align:middle;'>");
  d.write("<a href='#' onclick='window.close();return false;' title='Kép bezárása' style='margin:0px;'><img border='0' src='"+src+"' style='margin:0px;'></a>");
  d.write("</body>");
  d.close();
  return false;
}
// input check functions
var isError=false;	// van e hiba
var errObj;			// a hibás objektum
var style;			// az objektum hiba előtti stílusa

function submitForm(noMsg,deleterName,rDelMsg) {
  if (isError) {
    alert(noMsg);
	errObj.focus();
    return false;
  } else {
    if (document && document.forms && document.forms[0] && document.forms[0][deleterName] && (document.forms[0][deleterName].value=='yes')) {
	  return confirm(rDelMsg);
	} else {
      return true;
	}
  }
}

function errorMessage(object,message) {
  if (!isError) {
    style=object.style;
    object.style.backgroundColor='red';
    object.style.color='white';
    isError=true;
    object.title=message;
    object.focus();
    errObj=object;
    alert(message);
  }
}

function clearError(name) {
  if (isError && document && document.forms && document.forms[0] && (errObj==document.forms[0][name])) {
    isError=false;
    errObj.title='';
    errObj.style=style;
    errObj=null;
  }
}

function isEmpty(name,emptyErr) {
  if (document && document.forms && document.forms[0]) {
    if (!document.forms[0][name].value) {
      errorMessage(document.forms[0][name],emptyErr);
	}
  }
}

function pwdChk(name,name2,noEquErr) {
  if (document && document.forms && document.forms[0]) {
	if (document.forms[0][name].value!=(document.forms[0][name2].value)) {
	  if (document.forms[0][name2].value) {
        errorMessage(document.forms[0][name],noEquErr);
		document.forms[0][name].value='';
		document.forms[0][name2].value='';
	  } else {
	    document.forms[0][name2].focus();
	  }
	}
  }
}

function emailChk(name,invalidErr) {
  if (document && document.forms && document.forms[0] && document.forms[0][name]) {
	if (document.forms[0][name].value.search(/^[^@]+@[^@]+\.[a-z]+$/i)==-1) {
      errorMessage(document.forms[0][name],invalidErr);
	}
  }
}

function op(nev,width,height) {
  if (!width) width=520;
  if (!height) height=300;
  window.open("statics/"+nev+".html","","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width="+width+",height="+height);
  return false;
}

