 function string_to_url (target) {
 	target = target.value.replace("ő", "_C5_91").replace("Ő", "_C5_90");
    target = escape(target);
    target = target.replace('_C5_91', '%C5%91').replace('_C5_90', '%C5%90')
 	return target;
 }
 
 function loadcity () {
  AjaxUpdMode = "json";
  AjaxUpdTarget = "s_city";
  var target = document.getElementById("s_city");
  if (target!==null) {
   target.options.length=1;
   if (typeof IT_targeturl=='undefined') IT_targeturl = "";
   if (typeof IT_commfile=='undefined') IT_commfile = "";
   AjaxObj.Open(IT_targeturl+IT_commfile, '?field=city', AjaxUpd, citychanged, AjaxUpdTarget, AjaxUpdMode);
   target.disabled=true;
  }
  /*if (document.addEventListener) {
     document.removeEventlistener("DOMContentLoaded", loadcity, false);
  } else {
     window.onload = undefined;
  }*/
 }
 
 function citychanged () {
  AjaxUpdMode = "json";
  AjaxUpdTarget = "s_venue";
  var target = document.getElementById("s_venue");
  var source = document.getElementById("s_city");
  if (target!==null && source!==null) { 
   target.options.length=1;
   var cityGET = '&city='+string_to_url(source);
   if (source.value=="") cityGET = "";
   if (typeof IT_targeturl=='undefined') IT_targeturl = "";
   if (typeof IT_commfile=='undefined') IT_commfile = "";
   AjaxObj.Open(IT_targeturl+IT_commfile, '?field=venue'+cityGET, AjaxUpd, null, AjaxUpdTarget, AjaxUpdMode);
   target.disabled=true;
  }
 } 
 
 function yearchanged () {
  var target_y = document.getElementById("s_year");
  var target_m = document.getElementById("s_month");
  var target_d = document.getElementById("s_day");
  var d=new Date();
  var n=0;
  if (target_y.value==d.getYear()) {
   target_m.options.length = 0;
   for (i=d.getMonth()+1;i<=12;i++) {
    newopt = new Option(monthnames[i], i, false, false);
    target_m.options[n] = newopt;
    n++;
   }
   n=0;
   target_d.options.length = 0;
   for (i=d.getDate();i<=31;i++) {
    newopt = new Option(i, i, false, false);
    target_d.options[n] = newopt;
    n++;
   }
  } else {
   target_m.options.length = 0;
   for (i=1;i<=12;i++) {
    newopt = new Option(monthnames[i], i, false, false);
    target_m.options[n] = newopt;
    n++;
   }
   n=0;
   target_d.options.length = 0;
   for (i=1;i<=31;i++) {
    newopt = new Option(i, i, false, false);
    target_d.options[n] = newopt;
    n++;
   }
  }
 }
 
 function monthchanged () {
  var target_y = document.getElementById("s_year");
  var target_m = document.getElementById("s_month");
  var target_d = document.getElementById("s_day");
  var d=new Date();
  var n=0;
  if (target_y.value==d.getYear() && target_m.value==d.getMonth()+1 ) {
   target_d.options.length = 0;
   for (i=d.getDate();i<=31;i++) {
    newopt = new Option(i, i, false, false);
    target_d.options[n] = newopt;
    n++;
   }
  } else {
   for (i=1;i<=31;i++) {
    newopt = new Option(i, i, false, false);
    target_d.options[n] = newopt;
    n++;
   }
  }
 }
 
 function searchsubmit () {
  AjaxUpdMode = "";
  AjaxUpdTarget = "searchresults";
  var target = document.getElementById("searchresults");
  var sname = document.forms.searchform.s_name;
  var scity = document.getElementById("s_city");
  var svenue = document.getElementById("s_venue");
  var stime = document.getElementById("s_time");
  var syear = document.getElementById("s_year");
  var smonth = document.getElementById("s_month");
  var sday = document.getElementById("s_day");
  target.innerHTML="...";
  AjaxObj.Open("search.php", '?notemplate=1&s_name='+Url.encode(sname.value)+'&s_city='+Url.encode(scity.value)+'&s_time='+stime.value+'&s_venue='+Url.encode(svenue.value)+'&s_year='+syear.value+'&s_month='+smonth.value+'&s_day='+sday.value, AjaxUpd, null, AjaxUpdTarget, AjaxUpdMode);
 }
