function changeOrder(field,url,update){
    
     var req = new Request.HTML({ url:url,
                                onRequest:function(){showAjaxLoading($('ajax_results'))},
                                onSuccess:function(resp){
                                    $(update).empty();
                                    $(update).adopt(resp);
                                },
                                method: 'post',
                                evalScripts: true
                                });
    req.cancel();
    req.send('field='+field);
    
    return req;
}

function changePage(page,url,update){
    
     var req = new Request.HTML({ url:url,
                                onRequest:function(){showAjaxLoading($('ajax_results'))},
                                onSuccess:function(resp){
                                    $(update).empty();
                                    $(update).adopt(resp);
                                },
                                method: 'post',
                                evalScripts: true
                                });
    req.cancel();
    req.send('getpage='+page);
    
    var myFx = new Fx.Scroll(window).toTop();
    
    return req;
}



function initTooltip(classnamme,titletext,htmltext){
    if(classnamme){
        if(titletext){
            classnamme.store('tip:title', titletext);
        }
        if(htmltext){
            classnamme.store('tip:text', htmltext);
        }
    }    
}

var getplztimer = null;

function getPlzCheapest(sendfield){          
    if(getplztimer) window.clearTimeout(getplztimer);
    getplztimer = window.setTimeout("sendPlzCheapest()",1000);
      
    if(sendfield){        
        var plzval = $(sendfield).get('value');   
        if(plzval.length > 3){           
            $$('.usrPlz').each(function(usrPlzBox){
                usrPlzBox.set('value',plzval);
            });
        }
    }    
}

function sendPlzCheapest(){        
    $$('.plzbox').each(function(plzbox){
        var id = plzbox.id.replace(/plzresp_/g, "");
        var plz = $('plz_'+id);
        plzval = plz.get('value');
        if(plzval.length > 3){
            defaultAjaxAutoSend('/ajax.php/ajax/getCheapestDistance/id/'+id+'/plz/'+plz.get('value'),plzbox);
        }
    });    
}

function getPlz(sendfield){          
    if(getplztimer) window.clearTimeout(getplztimer);
    getplztimer = window.setTimeout("sendPlz()",1000);
      
    if(sendfield){        
        var plzval = $(sendfield).get('value');   
        if(plzval.length > 3){           
            $$('.usrPlz').each(function(usrPlzBox){
                usrPlzBox.set('value',plzval);
            });
        }
    }    
}

function sendPlz(){        
    $$('.plzbox').each(function(plzbox){
        var id = plzbox.id.replace(/plzresp_/g, "");
        var plz = $('plz_'+id);
        plzval = plz.get('value');
        if(plzval.length > 3){
            defaultAjaxAutoSend('/ajax.php/ajax/getDistance/id/'+id+'/plz/'+plz.get('value'),plzbox);
        }
    });    
}
