function ask() {
document.getElementById("ask").style.display="none";
if (navigator.appName=="Microsoft Internet Explorer") {document.getElementById("asktable").style.display = "inline"} else
			document.getElementById("asktable").style.display = "table";
}

function lookup(text, select_id, url, id) {
if (id=="name") {document.getElementById("table_text").value=text;}
        if(!this.http){
            this.http = get_http();
            this.working = false;
        }
        if (!this.working && this.http) {
            var http = this.http;
            if (text.length <1 ) return;
            url = url + "?id="+encodeURIComponent(id)+"&text="+encodeURIComponent(text);
            this.http.open("GET", url, true);
            this.http.onreadystatechange = function() {
                if (http.readyState == 4) {
                    fill(select_id, http.responseText);
                    this.working = false;
                    getcost();
                  var from_val =document.getElementById("from").value;
                   var name_val =document.getElementById("name").value;
                   var phone_val =document.getElementById("phone").value;
                   var mail_val =document.getElementById("mail").value;
                   var tr_number_val =document.getElementById("tr_number").value;
                   var vag_number_val =document.getElementById("vag_number").value;
                   var seats_val =document.getElementById("seats").value;
                   var table_text_val =document.getElementById("table_text").value;
                     redytogo (name_val, phone_val, mail_val, from_val, tr_number_val, vag_number_val, seats_val, table_text_val);
                   }else{
                  }
            }
            this.http.send(null);
        }
        if(!this.http){
              alert('Îøèáêà ïðè ñîçäàíèè XMLHTTP îáúåêòà!')
        }
    }
    
function cost(from, to, car_class, hour, min, seats) {
        if(!this.http_cost){
            this.http_cost = get_http();
            this.working = false;
        }
        if (!this.working && this.http_cost) {
            var http_cost = this.http_cost;
            //if (text.length <1 ) return;
            url = "cost.php?from="+encodeURIComponent(from)+"&to="+encodeURIComponent(to)+"&car_class="+encodeURIComponent(car_class)+"&hour="+encodeURIComponent(hour)+"&min="+encodeURIComponent(min)+"&seats="+encodeURIComponent(seats);
            this.http_cost.open("GET", url, true);
            this.http_cost.onreadystatechange = function() {
                if (http_cost.readyState == 4) {
                document.getElementById("price").innerHTML="";
                   document.getElementById("price").innerHTML="<font color='#44AA44'>"+http_cost.responseText+" гривен ($"+parseFloat(http_cost.responseText)/5+")</font>";
document.getElementById("hiddenprice").value=http_cost.responseText+" гривен ($"+parseFloat(http_cost.responseText)/5+")";                   
 this.working = false;
                  }else{
                  }
            }
            this.http_cost.send(null);
        }
        if(!this.http_cost){
              alert('Îøèáêà ïðè ñîçäàíèè XMLHTTP îáúåêòà!')
        }
    }
    
function getcost()
{
    				 var from_val =document.getElementById("from").value;
                   var to_val =document.getElementById("to").value;
                   var car_class_val =document.getElementById("car_class").value;
                   var hour_val =document.getElementById("hour").value;
                   var min_val =document.getElementById("min").value;
                   var seats_val = document.getElementById("seats").value;
                     cost (from_val, to_val, car_class_val, hour_val, min_val, seats_val);
}

function get_http(){
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new 
                ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
    @else
        xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

function fill (select_id, data){
    var select = document.getElementById(select_id);
    select.innerHTML="";
     select.innerHTML=data;
   /*  sendform();*/
       }
      
function from_change (from){
if (from=="2") {
			document.getElementById("whatisthis").innerHTML="№ поезда";
			if (navigator.appName=="Microsoft Internet Explorer") {document.getElementById("vagon").style.display = "inline"} else
			document.getElementById("vagon").style.display = "table-row";
			}
if (from=="1") {
document.getElementById("whatisthis").innerHTML="№ рейса";
document.getElementById("vagon").style.display = "none";
document.getElementById("vag_number").value="";
}
getcost();
}

function redytogo (name, phone, mail, from, tr_number, vag_number, seats, table_text)
{
if(!this.http_redytogo ){
            this.http_redytogo = get_http();
            this.working = false;
        }
        if (!this.working && this.http_redytogo ) {
            var http_redytogo = this.http_redytogo ;
            //if (text.length <1 ) return;
            url = "redy.php?name="+encodeURIComponent(name)+"&phone="+encodeURIComponent(phone)+"&mail="+encodeURIComponent(mail)+"&from="+encodeURIComponent(from)+"&tr_number="+encodeURIComponent(tr_number)+"&vag_number="+encodeURIComponent(vag_number)+"&seats="+encodeURIComponent(seats)+"&table_text="+encodeURIComponent(table_text);
            this.http_redytogo.open("GET", url, true);
            this.http_redytogo.onreadystatechange = function() {
                if (http_redytogo.readyState == 4) {
                /* alert("!");*/
                  /* document.getElementById("ura").innerHTML=http_redytogo.responseText;*/
                  if (http_redytogo.responseText==1) {document.forms[0].submit.disabled = false;}
                  else {document.forms[0].submit.disabled = true;}
                    this.working = false;
                  }else{
                  }
            }
            this.http_redytogo.send(null);
        }
        if(!this.http_redytogo){
              alert('Îøèáêà ïðè ñîçäàíèè XMLHTTP îáúåêòà!')
        }
    }
