function InsertRoutes(selectRouteCtrl, fromCtrl, toCtrl)
{    
    if(selectRouteCtrl.value == '-1') return;//route = 'lalala';
    else 
    {
    idx = selectRouteCtrl. selectedIndex;
    //alert(idx);
    route = selectRouteCtrl.options[idx].text;
    }
    //alert(route);
    from = route.split(" - ")[0];
    //alert(from);
    fromCtrl.value = from; 
    to = route.split(" - ")[1];
    //alert(to);
    toCtrl.value = to;
    selectRouteCtrl.selectedIndex = 0;
}   

function InsertPsgrs(selectPsgrCtrl, doctypeCtrl, surnameCtrl, nameCtrl, patronimicCtrl, docnumCtrl)
{    
    if(selectPsgrCtrl.value == '-1') return;
    else 
    {
        idx = selectPsgrCtrl. selectedIndex;
        //alert(idx);
        psgr = selectPsgrCtrl.options[idx].text; 
        //alert(psgr);
        
        fio = psgr.split(' / ')[0];
        //alert(fio);
        doc = psgr.split(' / ')[1];
        //alert(doc);
        
        surnameCtrl.value = fio.split(' ')[0];
        nameCtrl.value = fio.split(' ')[1];
        patronimicCtrl.value = fio.split(' ')[2];
        
        doctypeCtrl.value = doc.split('-')[0];
        docnumCtrl.value = doc.split('-')[1];
                
        selectPsgrCtrl.selectedIndex = 0;       
    }    
}

function Reverse(fromCtrl, toCtrl)
{
    var from = fromCtrl.value;
    fromCtrl.value = toCtrl.value;
    toCtrl.value = from;
}

function FindName(selectCtrl, prefix)
{
    id = selectCtrl.name.split('_')[1];
    return prefix + '_' + id;
}
