function loading(){
    busy_hide();
    
    if (document.getElementById("error").innerHTML!=null){
        menu_hol_tart(0);
    } else
    {
        menu_hol_tart(2);
    }
    if (document.getElementById("reture").value=="0") 
    {
        if (document.getElementById("vagtat").value=="start"){
            document.getElementById("visszamezok").style.display="none";            
            document.getElementById("visszamezok_felirat").style.display="none";    
        }
        document.getElementById("visszajelzo").style.display="none";            
        document.getElementById("visszaut_adatok").style.display="none";            
        
    }
    if (document.getElementById("shaker").value!="") {   
        new Effect.Highlight(document.getElementById("shaker").value,{startcolor:'#FF8080', endcolor:'#FFFFFF', duration:3});
        document.getElementById(document.getElementById("shaker").value).focus();
    }

    if (document.getElementById("shaker1").value!="") {
        new Effect.Highlight(document.getElementById("shaker1").value,{startcolor:'#FF8080', endcolor:'#FFFFFF', duration:3});
    }
    
   if (document.getElementById("vagtat").value=="start"){  
      Calendar.setup({
        inputField     :    "startdate",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "start_pic",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });

      Calendar.setup({
        inputField     :    "returdate",     // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "retur_pic",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });
   }
    
}


function busy_hide(){
   Effect.Appear("busy",{duration:1, from:1.0, to:0.0});         
    
}
 
 function retur_del(){
      document.getElementById("reture").value="0";
      eltunik("visszamezok",2);
      document.getElementById("visszamezok").value="";
      eltunik("visszamezok_felirat",2);
      eltuntet_vissza();
 }
 
 function retur_set(){
      document.getElementById("reture").value="1";
      eloszed_vissza();
    elojon('visszamezok');
    elojon("visszamezok_felirat");
 }
 
 function eltuntet_vissza(){
    
    Effect.BlindUp("visszajelzo");
    Effect.BlindUp("visszaut_adatok");
 }
 
 function eloszed_vissza(){
    Effect.Appear("visszajelzo",{duration:2, from:0.0, to:0.3});
    Effect.BlindDown("visszaut_adatok");
    
 }
 
 function eltunik(elem,ido){
  Effect.Appear(elem,{duration:ido, from:1.0, to:0.0});
 }

  function elojon(elem){
  Effect.Appear(elem,{duration:2, from:0.0, to:1.0});
 }

 
 
 function menu_hol_tart(ido){
    if (document.getElementById('vagtat').value=="start"){
       Effect.Appear("m2",{duration:ido, from:1.0, to:0.3});  
       if (document.getElementById("reture").value=="1") Effect.Appear("visszajelzo",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m4",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m5",{duration:ido, from:1.0, to:0.3});  
    } else if (document.getElementById('vagtat').value=="jaratoda") {
       Effect.Appear("m1",{duration:ido, from:1.0, to:0.3});  
       if (document.getElementById("reture").value=="1")  Effect.Appear("visszajelzo",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m4",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m5",{duration:ido, from:1.0, to:0.3});  
    } else if (document.getElementById('vagtat').value=="jaratvissza") {
       Effect.Appear("m1",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m2",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m4",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m5",{duration:ido, from:1.0, to:0.3});  
    } else if (document.getElementById('vagtat').value=="helyfog") {
       Effect.Appear("m1",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m2",{duration:ido, from:1.0, to:0.3});  
       if (document.getElementById("reture").value=="1")  Effect.Appear("visszajelzo",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m5",{duration:ido, from:1.0, to:0.3});  
    } else if (document.getElementById('vagtat').value=="fizet") {
       Effect.Appear("m1",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m2",{duration:ido, from:1.0, to:0.3});  
       if (document.getElementById("reture").value=="1")  Effect.Appear("visszajelzo",{duration:ido, from:1.0, to:0.3});  
       Effect.Appear("m4",{duration:ido, from:1.0, to:0.3});  
    }
 }
 
  
  function dbplus(elem){
     var  db=null;
     db=document.getElementById(elem).value;
     if (db==null) db=0;
     db++;
     document.getElementById(elem).value=db;

  }
  
    function dbminus(elem){
     var  db="";
     db=document.getElementById(elem).value;
     db--;
     if (db<=0) db="";
     document.getElementById(elem).value=db;
  }
 
   function JaratInformacio(honnan,hova,datum,vonal,menrend,sorszam){
            var szel = 500;
            var mag = 500;
            feltwin=window.open('list_jaratind.php?honnan='+honnan+'&hova='+hova+'&datum='+datum+'&vonal='+vonal+'&menrend='+menrend+'&agazat=A&sorszam='+sorszam,'details','width='+szel+',height='+mag+',left='+((screen.width/2)-(szel/2))+',top='+((screen.height/2)-(mag/2))+',toolbar=no,location=no,status=no,scrollbars=yes,resizable=no,menubar=no,dependent=yes');
            feltwin.focus();
   }
   
   function helyjelol(session,ules)
   {
        if (document.getElementById("f"+ules).value=="1")
        {
            document.getElementById(ules).style.backgroundColor='#FF8080';
            postDataReturnXml("elofoglalastorol.php?"+session,"id="+ules, helyfoglal);
        } else
        {
            document.getElementById(ules).style.backgroundColor='#FF8080';
           postDataReturnXml("elofoglalas.php?"+session,"id="+ules, helyfoglal);
        }
   }

   function helyfoglal(xml)
   {
   var hely;
   var rhely;
   hely=xml.getElementsByTagName("hely")[0].firstChild.data; 
  
    if (xml.getElementsByTagName("ok")[0].firstChild.data=="1")
    {
        replaceinDOMstr ("error","");
     //   hely=xml.getElementsByTagName("hely")[0].firstChild.data;
        rhely="f"+hely;
        if (xml.getElementsByTagName("torles")[0].firstChild.data==0)
        {
            document.getElementById(rhely).value= "1";
            new Effect.Highlight(hely,{startcolor:'#FF8080', endcolor:'#FFFF00', duration:1,restorecolor:'#FFFF00'});
        } else 
        {
            document.getElementById(rhely).value= "0";
           new Effect.Highlight(hely,{startcolor:'#FF8080', endcolor:'#FFFFFF', duration:1,restorecolor:'#FFFFFF'});
        }
    } else if (xml.getElementsByTagName("ok")[0].firstChild.data=="0")
    {
        replaceinDOMstr ("error",xml.getElementsByTagName("hiba")[0].firstChild.data);
        replaceinDOMstr (xml.getElementsByTagName("hely")[0].firstChild.data,xml.getElementsByTagName("ertek")[0].firstChild.data);
    
        
    } else {
        replaceinDOMstr ("error",xml.getElementsByTagName("hiba")[0].firstChild.data);
        document.getElementById(hely).style.backgroundColor='#FFFFFF';   
   }  
   } 
   
   
   
   
   function replaceinDOMstr(hely,mit)
   {
        while (document.getElementById(hely).hasChildNodes())
            {
              document.getElementById(hely).removeChild(document.getElementById(hely).firstChild);
            }
        document.getElementById(hely).appendChild(document.createTextNode(mit));
   }
   
   
   
    function MailEll()
  {
   
    
    if (document.getElementById("vagtat").value!="fizet") return true;
    var text=document.getElementById("email").value;
    if (text==""){
      alert ('Nem adott meg e-mail címet!') ;
      return false;
    }
    if (text.indexOf('@') == -1)
    {
      alert('Nem szerepel az e-mail címben a @!');
      document.getElementById("email").focus();
      document.getElementById("email").select();
      return false;
    }
    if (text.indexOf('.') == -1)
    {
      alert('Hibás e-mail!');

      document.getElementById("email").focus();
      document.getElementById("email").select();
      return false;
    }  
    if ((text.length-text.lastIndexOf('.'))>4 || (text.length-text.lastIndexOf('.'))<2)
    {
      alert('Hibás e-mail!');
      document.getElementById("email").focus();
      document.getElementById("email").select();
      return false;
    }  
    if (text.indexOf('.')==text.indexOf('@')+1)
    {
      alert('{Hibás e-mail!}');
      document.getElementById("email").focus();
      document.getElementById("email").select();
      return false;
    }    
    if (!document.getElementById("feltetel").checked){
        alert ('Nem fogadta el az utazási feltételeket!'); 
        return false;
      }
    var tovabb=confirm("Kérem ellenőrizze adatait! Amennyiben megfelelnek, átirányításra kerül a banki fizető oldalra. A bevitt adatok megfelelnek?" );
    if (tovabb)
        return true;
    else
        return false;
  }     

 
 function Nyomtat(session)
 {
  NyomtatWin = window.open('nyomtat.php?'+session, 'nyomtatas', 'width=800,height=700,left='
                        + 100 + ',top=' + 20
                        + ',toolbar=no,location=no,status=no,scrollbars=yes,resizable=no,menubar=no,dependent=yes');
  NyomtatWin.focus();
 }
           
           
 function UtazasiFeltetel(){
        var szel = 500;
        var mag = 600;
        feltwin=window.open('http://www.volanbusz.hu/content.php?page=ufbelfold&menu=6&submenu=1','details','width='+szel+',height='+mag+',left='+100+',top='+20+',toolbar=no,location=no,status=no,scrollbars=yes,resizable=no,menubar=no,dependent=yes');
        feltwin.focus()
    }
     
function jegyFeltetel(fajta){
        var szel = 500;
        var mag = 600;
 
        feltwin=window.open('jegy'+fajta+'.html','details','width='+szel+',height='+mag+',left='+100+',top='+20+',toolbar=no,location=no,status=no,scrollbars=yes,resizable=no,menubar=no,dependent=yes');
        feltwin.focus()
       
    }   

 function UtazasiElfogad(){
        var szel = 500;
        var mag = 600;
        feltwin=window.open('utazasi_feltetel_hu.html','details','width='+szel+',height='+mag+',left='+100+',top='+20+',toolbar=no,location=no,status=no,scrollbars=yes,resizable=no,menubar=no,dependent=yes');
        feltwin.focus()
    }
       
 