var HEXA = Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
var R_MSG = { 	"emptytargy" 		: "K"+ch(233)+"rj"+ch(252)+"k, t"+ch(246)+"ltse ki a T"+ch(225)+"rgy mez"+ch(245)+"t!",
		"emptyleiras"  		: "K"+ch(233)+"rj"+ch(252)+"k, t"+ch(246)+"ltse ki a Le"+ch(237)+"r"+ch(225)+"s mez"+ch(245)+"t!",
		"nokereskinal"		: "K"+ch(233)+"rj"+ch(252)+"k, v"+ch(225)+"lasszon a K"+ch(237)+"n"+ch(225)+"l "+ch(233)+"s Keres rovat k"+ch(246)+"z"+ch(252)+"l!"
	    };

function hexencode(s)
 {
  var return_value = "";
  for (var i=0; i<s.length; i++)
   {
    var code = s.charCodeAt(i);
    if (code==337) code=245;
    else if (code==336) code=213;
    else if (code==369) code=251;
    else if (code==368) code=219;
    return_value += HEXA[parseInt(code/16)]+HEXA[code%16];
   }
  return return_value;
 }

function trim(s)
 {
  return String(s).replace(RE_START,"").replace(RE_END,"");
 }

function getKeresKinal(form)
 {
  var radio = form.kinalkeres;
  for (var i=0; i<radio.length; i++)
   if (radio[i].checked) return radio[i].value;
  return -1;
 }

function checkHangszerBorze(form)
 {
  var targy=trim(form.targy.value);
  var leiras=trim(form.leiras.value);
  var from=trim(form.aktualis_from.value);
  var to=trim(form.aktualis_to.value);

  if (targy=="")
  {
   alert(R_MSG.emptytargy);
   return false;
  }

  if (leiras=="")
     {
      alert(R_MSG.emptyleiras);
      return false;    
     }

  if (!/(^[0-9]{4}\.[0-9]{1,2}\.[0-9]{1,2}$)/i.exec(trim(from)))
   {
   alert("Helytelen"+ch(252)+"l adta meg az aktualit"+ch(225)+"s kezd"+ch(245)+"d"+ch(225)+"tum"+ch(225)+"t!");
   return false;
   }

  if (!/(^[0-9]{4}\.[0-9]{1,2}\.[0-9]{1,2}$)/i.exec(trim(from)))
   {
   alert("Helytelen"+ch(252)+"l adta meg az aktualit"+ch(225)+"s v"+ch(233)+"gd"+ch(225)+"tum"+ch(225)+"t!");
   return false;
   }

  else if (getKeresKinal(form)==-1)
   {
    alert(R_MSG.nokereskinal);
    return false;
   }

  return true;
 }
