function pid5vis(VIS) {
  if (pid==5) if (document.getElementById('pid5s1')) if (document.getElementById('pid5s1').style.visibility!=VIS) document.getElementById('pid5s1').style.visibility=VIS;
  if (pid==5) if (document.getElementById('pid5s2')) if (document.getElementById('pid5s2').style.visibility!=VIS) document.getElementById('pid5s2').style.visibility=VIS;
}

function almenu(ID, VIS) {
  if (document.getElementById(ID)) document.getElementById(ID).style.visibility=VIS;
}

function changeSrc (ID, SRC) {
  if (document.getElementById(ID)) document.getElementById(ID).src=SRC;
}

function setActMenu (ID, _almenu) {
   if (typeof(T_O)!='undefined') window.clearTimeout(T_O);
   if (parent[ID] == 0) {
      for (i in swapped) if ((swapped[i]==1) && (i!=ID)) {changeSrc('m_'+i,'images/menu/lang'+lang+'/'+i+'_n.gif'); swapped[i]=0;};
      if (swapped[ID]==0) {changeSrc('m_'+ID,'images/menu/lang'+lang+'/'+ID+'_s.gif'); swapped[ID]=1;};
      for (i in swapped) if ((parent[i]==0)) almenu('almenu_'+i, 'hidden');
      if (_almenu) almenu('almenu_'+ID, 'visible');
   }
   if (parent[ID] != 0) {
      for (i in swapped) if ((parent[i]==0) && (parent[i]!=parent[ID])) almenu('almenu_'+i, 'hidden');
      if (_almenu) almenu('almenu_'+parent[ID], 'visible');
      for (i in swapped) if ((i != parent[ID]) && (i != ID) && (swapped[i] == 1)) {changeSrc('m_'+i,'images/menu/lang'+lang+'/'+i+'_n.gif'); swapped[i]=0;};
      if (swapped[ID]==0) {changeSrc('m_'+ID,'images/menu/lang'+lang+'/'+ID+'_s.gif'); swapped[ID]=1;};
      var p=parent[ID];
      if (swapped[p]==0) {changeSrc('m_'+p,'images/menu/lang'+lang+'/'+p+'_s.gif'); swapped[p]=1;};
   }
}

function setActUjsag (ID) {
   if(ID==0) {
     for (i in uswapped) if (uswapped[i]==1) {changeSrc('u_'+i,'images/menu/lang'+lang+'/u'+i+'_n.gif'); uswapped[i]=0;};
   } else {
     if (typeof(uT_O)!='undefined') window.clearTimeout(uT_O);
     for (i in uswapped) if ((uswapped[i]==1) && (i!=ID)) {changeSrc('u_'+i,'images/menu/lang'+lang+'/u'+i+'_n.gif'); uswapped[i]=0;};
     if (uswapped[ID]==0) {changeSrc('u_'+ID,'images/menu/lang'+lang+'/u'+ID+'_s.gif'); uswapped[ID]=1;};
  }
}

function setActLang (ID) {
   if(ID==0) {
     if (lswapped==1) {changeSrc('l_1','images/menu/lang'+lang+'/l1_n.gif'); lswapped=0;};
   } else if (ID==1) {
     if (typeof(lT_O)!='undefined') window.clearTimeout(lT_O);
     if (lswapped==0) {changeSrc('l_1','images/menu/lang'+lang+'/l1_s.gif'); lswapped=1;};
  }
}

function setActKiadvany (ID) {
     if (typeof(kT_O)!='undefined') window.clearTimeout(kT_O);
     for (i=1;i<=5;i++) if ((kswapped[i]==1) && (i!=ID)) {changeSrc('k_'+i,'images/menu/lang'+lang+'/k'+i+'_n.gif'); kswapped[i]=0;};
     if (kswapped[ID]==0) {changeSrc('k_'+ID,'images/menu/lang'+lang+'/k'+ID+'_s.gif'); kswapped[ID]=1;};
}

function setActHirdetes (ID) {
     for (i=1;i<=6;i++) if ((hswapped[i]==1) && (i!=ID)) {changeSrc('h_'+i,'images/menu/lang'+lang+'/h'+i+'_n.gif'); hswapped[i]=0;};
     if (hswapped[ID]==0) {changeSrc('h_'+ID,'images/menu/lang'+lang+'/h'+ID+'_s.gif'); hswapped[ID]=1;};
}

function rendeles() {
     var szam = /^[0-9]{1,6}$/;
     var irszam  = /^[0-9]{4}$/;
     var adoszam = /^[0-9]{8}-[0-9]{1}-[0-9]{2}$/;
     Error = '';
     if (!document.kitolt.nev.value) Error += 'Nem töltötte ki a Név mezőt!\n';
     if (!document.kitolt.ir_szam.value.match(irszam)) Error + 'Nem helyes az Irányítószám mező!\n';
     if (!document.kitolt.varos.value) Error +=  'Nem töltötte ki a Város mezőt!\n';
     if (!document.kitolt.utca.value) Error += 'Nem töltötte ki az Utca mezőt!\n';
     if (document.kitolt.azonosito.value) if (!document.kitolt.azonosito.value.match(szam)) Error += 'Nem helyes az azonosító (1-6 jegyű szám)!\n';
     if (document.kitolt.a_szam.value) if (!document.kitolt.a_szam.value.match(adoszam)) Error += 'Nem helyes az adószám! (8-1-2 számjegy pl.: 12345678-1-12)\n';
     if (Error) alert(Error); else document.kitolt.submit();
}

function szemelyes() {
     document.kitolt.s_nev.value = document.kitolt.nev.value;
     document.kitolt.s_varos.value = document.kitolt.varos.value;
     document.kitolt.s_ir_szam.value = document.kitolt.ir_szam.value;
     document.kitolt.s_utca.value = document.kitolt.utca.value;
}

function munkahelyi() {
     document.kitolt.s_nev.value = document.kitolt.m_nev.value;
     document.kitolt.s_varos.value = document.kitolt.m_varos.value;
     document.kitolt.s_ir_szam.value = document.kitolt.m_ir_szam.value;
     document.kitolt.s_utca.value = document.kitolt.m_utca.value;
}

function copySzemelyes() {
     if ((document.mainform.apro_titulus.value) && (document.mainform.apro_titulus.value!=0)) document.mainform.apro_sz_nev.value = document.mainform.apro_titulus.value+' '; else document.mainform.apro_sz_nev.value = '';
     document.mainform.apro_sz_nev.value += document.mainform.apro_vez_nev.value+' '+document.mainform.apro_ker_nev.value;
     document.mainform.apro_sz_iranyito.value = document.mainform.apro_iranyito.value;
     document.mainform.apro_sz_varos.value = document.mainform.apro_varos.value;
     document.mainform.apro_sz_utca.value = document.mainform.apro_utca.value;
}

function copyMunkahelyi() {
     document.mainform.apro_sz_nev.value = document.mainform.apro_m_nev.value;
     document.mainform.apro_sz_iranyito.value = document.mainform.apro_m_iranyito.value;
     document.mainform.apro_sz_varos.value = document.mainform.apro_m_varos.value;
     document.mainform.apro_sz_utca.value = document.mainform.apro_m_utca.value;
}

function felad(target, from) {
     feladError = '';
     if ((from==1)) {
        checked = 0;
        for (cbox in apro_szam) {
            if (document.getElementById('apro_szam_'+cbox).checked) checked = 1;
        }
        if (!checked) {
           feladError += 'Nem válaszotta ki, hogy melyik számban jelenjen meg a hirdetés!\n';
        }
     }
     if ((from==2)) {
        checked = 0;
        for (var i=0;i<document.mainform.apro_sablon.length;i++) {
            if (document.mainform.apro_sablon[i].checked) checked = 1;
        }
        if (!checked) {
           feladError += 'Nem válaszott ki hirdetési sablont!\n';
        }
     }
     if ((from==3)) {
        if (!document.mainform.apro_cim.value) feladError += 'Nem töltötte ki a címsor mezőt!\n';
        if (!document.mainform.apro_hirdetes.value) feladError += 'Nem töltötte ki a hirdetés mezőt!\n';
        if (document.mainform.apro_cim.value.length > 40) feladError += 'A cím sor hossza maximum 40 karakter lehet!\n';
     }
     if ((from==5)) {
        var szam = /^[0-9]{1,6}$/;
        var irszam  = /^[0-9]{4}$/;
        var mail = /^[a-zA-Z0-9-]+(\.?[a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.?[a-zA-Z0-9-]+)+$/;
        if ((document.mainform.apro_elof_azonosito.value) && (!document.mainform.apro_elof_azonosito.value.match(szam))) feladError += 'Nem helyes az azonosító!\n';
        if (!document.mainform.apro_vez_nev.value) feladError += 'Nem töltötte ki a vezeték név mezőt!\n';
        if (!document.mainform.apro_ker_nev.value) feladError += 'Nem töltötte ki a kereszt név mezőt!\n';
        if (!document.mainform.apro_mail.value) feladError += 'Nem töltötte ki az E-mail mezőt!\n';
        else if (!document.mainform.apro_mail.value.match(mail)) feladError += 'Nem helyes az E-mail mező!\n';
        if (!document.mainform.apro_iranyito.value) feladError += 'Nem töltötte ki az irányítószám mezőt!\n';
        else if (!document.mainform.apro_iranyito.value.match(irszam)) feladError += 'Nem helyes az irányítószám mező!\n';
        if (!document.mainform.apro_varos.value) feladError += 'Nem töltötte ki a város mezőt!\n';
        if (!document.mainform.apro_utca.value) feladError += 'Nem töltötte ki az utca mezőt!\n';
        checked = 0;
        for (var i=0;i<document.mainform.apro_szamla.length;i++) {
            if (document.mainform.apro_szamla[i].checked) checked = 1;
        }
        if (!checked) {
           feladError += 'Nem választotta ki, hogy melyik címre küldjük a számlát!\n';
        }
        checked = 0;
        for (var i=0;i<document.mainform.apro_posta.length;i++) {
            if (document.mainform.apro_posta[i].checked) checked = 1;
        }
        if (!checked) {
           feladError += 'Nem választotta ki, hogy melyik címre küldjük az újságot!\n';
        }
     }
     if (!feladError || (target<from)) {
        document.mainform.apro.value = target;
        document.mainform.submit();
     } else {
        alert(feladError);
     }
}

function HirdetesLength(){
     document.getElementById('aproCimSzamlalo').innerHTML = document.getElementById('apro_cim').value.length;
     document.getElementById('aproSzovegSzamlalo').innerHTML = document.getElementById('apro_hirdetes').value.length;
     document.getElementById('aproHirdetesSzamlalo').innerHTML = document.getElementById('apro_cim').value.length + document.getElementById('apro_hirdetes').value.length;
     elof = (document.getElementById('apro_cim').value.length + document.getElementById('apro_hirdetes').value.length - document.getElementById('elof_ingyen').value) * document.getElementById('elof_ar').value;
/*
     if (elof<=0) document.getElementById('aproElofSzamlalo').innerHTML = 'Ingyen';
     else if (document.getElementById('szamok').value>1) {
          if ((document.getElementById('szamok').value*elof)<1000) document.getElementById('aproElofSzamlalo').innerHTML = '1000 Ft + ÁFA';
          else document.getElementById('aproElofSzamlalo').innerHTML = document.getElementById('szamok').value+' x '+elof+ 'Ft = '+(document.getElementById('szamok').value*elof)+' Ft + ÁFA';
     } else {
          if (elof<1000) document.getElementById('aproElofSzamlalo').innerHTML = '1000 Ft + ÁFA';
          else document.getElementById('aproElofSzamlalo').innerHTML = elof+' Ft + ÁFA';
     }
*/
     nemelof = (document.getElementById('apro_cim').value.length + document.getElementById('apro_hirdetes').value.length - document.getElementById('nem_elof_ingyen').value) * document.getElementById('nem_elof_ar').value;
     if (nemelof<=0) document.getElementById('aproNemElofSzamlalo').innerHTML = 'Ingyen';
     else if (document.getElementById('szamok').value>1) {
          if ((document.getElementById('szamok').value*nemelof)<1000) document.getElementById('aproNemElofSzamlalo').innerHTML = '1000 Ft + ÁFA';
          else document.getElementById('aproNemElofSzamlalo').innerHTML = document.getElementById('szamok').value+' x '+nemelof+ 'Ft = '+(document.getElementById('szamok').value*nemelof)+' Ft + ÁFA';
     } else {
          if (nemelof<1000) document.getElementById('aproNemElofSzamlalo').innerHTML = '1000 Ft + ÁFA';
          else document.getElementById('aproNemElofSzamlalo').innerHTML = nemelof+' Ft + ÁFA';
     }
     if (document.getElementById('apro_cim').value.length>40) {
        document.getElementById('szamlalo2').className = 'apro-text-p-pad';
     } else {
        document.getElementById('szamlalo2').className = 'apro-text-f-pad';
     }
}

function HirdetesKesz(){
     feladError = '';
     var szam = /^OT-[0-9]{1,6}$/;
     var irszam  = /^[0-9]{4}$/;
     var mail = /^[a-zA-Z0-9-]+(\.?[a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.?[a-zA-Z0-9-]+)+$/;
     if ((document.mainform.h_apro_elof_azonosito.value != 'OT-') && (!document.mainform.h_apro_elof_azonosito.value.match(szam))) feladError += 'Nem helyes az azonosító!\n';
     if (document.mainform.h_apro_szam.value == '-') feladError+= 'Nem válaszotta ki, hogy melyik számban jelenjen meg a hirdetés!\n';
     if (document.mainform.h_apro_cim.value == '-') feladError += 'Nem töltötte ki a címsor mezőt!\n';
     if (document.mainform.h_apro_hirdetes.value == '-') feladError += 'Nem töltötte ki a hirdetés mezőt!\n';
     if (document.mainform.h_apro_cim.value.length > 40) feladError += 'A cím sor hossza maximum 40 karakter lehet!\n';
     if (document.mainform.h_apro_vez_nev.value == '-') feladError += 'Nem töltötte ki a vezeték név mezőt!\n';
     if (document.mainform.h_apro_ker_nev.value == '-') feladError += 'Nem töltötte ki a kereszt név mezőt!\n';
     if (!document.mainform.h_apro_mail.value) feladError += 'Nem töltötte ki az E-mail mezőt!\n';
     else if (!document.mainform.h_apro_mail.value.match(mail)) feladError += 'Nem helyes az E-mail mező!\n';
     if (document.mainform.h_apro_iranyito.value == '-') feladError += 'Nem töltötte ki az irányítószám mezőt!\n';
     else if (!document.mainform.h_apro_iranyito.value.match(irszam)) feladError += 'Nem helyes az irányítószám mező!\n';
     if (document.mainform.h_apro_varos.value == '-') feladError += 'Nem töltötte ki a város mezőt!\n';
     if (document.mainform.h_apro_utca.value == '-') feladError += 'Nem töltötte ki az utca mezőt!\n';
     if (document.mainform.h_apro_szamla.value == '-') feladError += 'Nem válaszotta ki, hogy melyik címre küldjük a számlát!\n';
     if (document.mainform.h_apro_posta.value == '-') feladError += 'Nem válaszotta ki, hogy melyik címre küldjük az újságot!\n';
     if (!feladError) {
        document.mainform.apro_felad.value = 1;
        document.mainform.apro.value = 10;
        document.mainform.submit();
     } else alert(feladError);

}

function kitoltback(){
     document.kitolt.kitolt.value=1;
     document.kitolt.submit();
}

function regisztracio() {
     var szam = /^[0-9]{1,6}$/;
     var mail = /^[a-zA-Z0-9-]+(\.?[a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.?[a-zA-Z0-9-]+)+$/;
     Error = '';
     if (!document.regform.u_pecset.value) Error += 'Nem töltötte ki a Pecsétszám mezőt!\n';
     if (!document.regform.u_vez_nev.value) Error +=  'Nem töltötte ki a Vezetéknév mezőt!\n';
     if (!document.regform.u_ker_nev.value) Error +=  'Nem töltötte ki a Keresztnév mezőt!\n';
     if (!document.regform.u_mail.value) Error += 'Nem töltötte ki az E-mail cím mezőt!\n';
     if (!document.regform.u_mail.value.match(mail)) Error += 'Nem helyes az E-mail mező!\n';
     if ( document.regform.u_as) if ( document.regform.u_as.value) if (!document.regform.u_as.value.match(szam)) Error += 'Nem helyes az azonosító (1-6 jegyű szám)!\n';
     if (Error) alert(Error); else document.regform.submit();
}

function kviz_felad() {
     Error = 0;
     for (k in kerdes) {
         ii = 0;
         for (v in valasz[k]) {
             if (document.getElementById('valasz['+k+']['+v+']').checked) ii = 1;
         }
         if (!ii) Error = 1;
     }
     if (Error) alert('Nem válaszolt minden kérdésre!'); else document.kvizform.submit();
}

function init_stopper () {
     if (starttime) {
        stopper_handler = setTimeout("update_stopper()",10);
     }
}

function update_stopper () {
     var stopper_act = new Date();
     //generate time
     var time_int = starttime.getTime() - (stopper_act.getTime() - stopper_start.getTime());
     var time = new Date(time_int);
     //destroy handler
     if (stopper_handler) {
        clearTimeout(stopper_handler);
     };
     //call update_stopper after a second
     var _time = ((Math.floor(time_int/3600000)).toString()).replace(/^([0-9]{1})$/,"0$1")+':'+((time.getMinutes()).toString()).replace(/^([0-9]{1})$/,"0$1")+':'+((time.getSeconds()).toString()).replace(/^([0-9]{1})$/,"0$1");
     if (!_time.match(/\-/)) {
        document.getElementById('stopper').innerHTML = _time;
        stopper_handler = setTimeout("update_stopper()",1000);
     } else {
        document.getElementById('stopper').innerHTML = "00:00:00";
     }
}
