timerId = 0;
timerIdInd = 0;
function popitup(url) {
    //newwindow = window.open(url,'name','resizable=1,scrollbars=1,status=1,menubar=1,toolbar=1,titlebar=1,height=700,width=1024');
    newwindow = window.open(url,'name');
    if (window.focus) {
        newwindow.focus()
    }
}
function popitupNormal(url) {
    //newwindow = window.open(url,'name', 'resizable=1,scrollbars=1,status=1,menubar=1,toolbar=1,titlebar=1,height=700,width=1024');
    newwindow = window.open(url,'name');
    if (window.focus) {
        newwindow.focus()
    }
}                
function popitupSmall(url) {
    newwindow = window.open(url,'name','resizable=0,scrollbars=0,status=0,menubar=0,toolbar=0,titlebar=0,height=100,width=100');
    if (window.focus) {
        newwindow.focus()
    }
}
function mappa(comune, indirizzo) {
    document.getElementById('ricerca:comune').value = comune;
    document.getElementById('ricerca:indirizzo').value = indirizzo;
    document.getElementById('ricerca:glat').value = "";
    document.getElementById('ricerca:glon').value = "";
}
function init() {
    syncFromHidden();
    syncFromHiddenInd();
}
//per comune
function syncToHidden() {
    var field = document.getElementById("ricerca:comune");
    var hidden = document.getElementById("ricerca:comuneHidden");
    hidden.value = field.value;
    return true;
}
function syncFromHidden() {
    var field = document.getElementById("ricerca:comune");
    var hidden = document.getElementById("ricerca:comuneHidden");
    field.value = hidden.value;
}                
function onblurComune() {
    var field = document.getElementById("ricerca:comune");
    var hidden = document.getElementById("ricerca:comuneHidden");
    if (field != hidden) {
        syncToHidden();
        clearTimeout(timerId);
        timerId=setTimeout('ajaxAnywhere.submitAJAX()', 150);
    }
}
function clickComune(comune) {
    document.getElementById('ricerca:comune').value = comune; 
    document.getElementById('ricerca:glat').value = "";
    document.getElementById('ricerca:glon').value = "";
    syncToHidden();
    clearTimeout(timerId);
    timerId = setTimeout('ajaxAnywhere.submitAJAX()', 150);

}
function chiudiSuggestComune() {
    document.getElementById('suggestComuni').style.visibility = 'hidden';
}
//per indirizzo
function syncToHiddenInd() {
    var field = document.getElementById("ricerca:indirizzo");
    var hidden = document.getElementById("ricerca:indirizzoHidden");
    hidden.value = field.value;
    return true;
}
function syncFromHiddenInd() {
    var field = document.getElementById("ricerca:indirizzo");
    var hidden = document.getElementById("ricerca:indirizzoHidden");
    field.value = hidden.value;
}                
function onblurInd() {
    var field = document.getElementById("ricerca:indirizzo");
    var hidden = document.getElementById("ricerca:indirizzoHidden");
    if (field != hidden) {
        syncToHiddenInd();
        clearTimeout(timerIdInd);
        timerIdInd = setTimeout('ajaxAnywhere.submitAJAX()', 150);
    }
}
function clickInd(indirizzo) {
    document.getElementById('ricerca:indirizzo').value = indirizzo; 
    syncToHidden();
    clearTimeout(timerIdInd);
    timerIdInd = setTimeout('ajaxAnywhere.submitAJAX()', 150);
    chiudiSuggestInd();
}
function chiudiSuggestInd() {
    document.getElementById('suggestInd').style.visibility = 'hidden';
}
