
var http = createRequestObject();
var id1;
function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
        
        
    }
    return ro;
}

//function used internally
function f1() {
    handleResponse(http, id1);
}

function f1_2() {
    handleResponse2(http, id1);
}

function sndReq(script,action,id) {
    argv=script+'?'+action;
    http.open('GET', argv);
    //http.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
    id1=id;
    http.onreadystatechange = f1;
    http.send(null);
    return (true);
}

function sndReq2(script,action,id) {
    argv=script+'?'+action;
    http.open('GET', argv);
    id1=id;
    http.onreadystatechange = f1_2;
    http.send(null);
//    return (true);
}


function handleResponse(http_obj, id) {
    if(http_obj.readyState == 4){
        var response = http_obj.responseText;    
        
        document.getElementById(id).innerHTML =  response;        
        
    }
}

function handleResponse2(http_obj, id) {
    if(http_obj.readyState == 4){
        var response = http_obj.responseText;    
        
        document.getElementById(id).innerHTML =  response;        
//    alert('ee');    
    }
}
 







 
 
 function get_look(v,cont){
    $.get('http://www.infoo.ro/strSuggestion.php',{q:v},
        function(obj){
          var res = [];
          for(var i=0;i<obj.length;i++){
            res.push({ id:i , value:obj[i]});
          }
          cont(res);
        },
        'json')
}

function print_sugg(v){ 
  //$('#info').html('ID: '+v.id+'<br>VALUE: '+v.value+'<br>INFO: '+v.info+' <i>'+v.extra+'</i>'); 
}


  function getCityField(start_country) {              
        document.getElementById('textd').innerHTML='';
        sndReq('strSuggestion.php', "start_country="+start_country,'start_city',f1);                    
    }    
  function getStreetField(start_city) {              
        //document.getElementById('rez_final').innerHTML='';
        sndReq('strSuggestion.php', "start_city="+start_city,'start_street',f1);                    
    }   
  
  function getECountryList() {              
        //document.getElementById('rez_final').innerHTML='';
        sndReq('strSuggestion.php', "getECountryList=true",'end_country',f1);                    
    }
            
  function getECityField(end_country) {              
        //document.getElementById('rez_final').innerHTML='';
        sndReq('strSuggestion.php', "end_country="+end_country,'end_city',f1);                    
    }        
  function getEStreetField(end_city) {              
        //document.getElementById('rez_final').innerHTML='';
        sndReq('strSuggestion.php', "end_city="+end_city,'end_street',f1);                    
    }    

