function openMap() {
    var m = window.open("http://www.qualivita.it/site/_page/elenco_europa.aspx", "ELENCO", "width=1300,height=750");
    m.focus();

}

function attachMe() {
    if (document.layers) { // Netscape
        document.captureEvents(Event.MOUSEMOVE);
        document.onmousemove = captureMousePosition;
    } else if (document.all) { // Internet Explorer
        document.onmousemove = captureMousePosition;
    } else if (document.getElementById) { // Netcsape 6
        document.onmousemove = captureMousePosition;
    }
}

// Global variables
var xMousePos = 0; // Horizontal position of the mouse on the screen
var yMousePos = 0; // Vertical position of the mouse on the screen
var xMousePosMax = 0; // Width of the page
var yMousePosMax = 0; // Height of the page
var isOpera = (navigator.userAgent.indexOf('Opera') != -1);
var isIE = (!isOpera && navigator.userAgent.indexOf('MSIE') != -1)

function captureMousePosition(e) {
    if (!e) var e = window.event;
    if (e.pageX || e.pageY) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        xMousePos = e.clientX;
        yMousePos = e.clientY;
        if (isIE) {
            xMousePos += document.body.scrollLeft;
            yMousePos += document.body.scrollTop;
        }

    }
}



// accende/spegne il pop-up e lo riempie con "cont"
function setVisible(o, cont) {
    ogg = document.getElementById(o);
    closeAnyPop(o);
    if (cont != null) ogg.innerHTML = cont;
    ogg.style.visibility = (ogg.style.visibility == 'visible') ? 'hidden' : 'visible';
    //ogg.style.display = (ogg.style.display == '') ? 'none' : '';
}

// posiziona (left - top)  un oggetto html di id = obj
function placeIt(obj, left, top) {
    obj = document.getElementById(obj);
    obj.style.left = left + 'px';
    obj.style.top = top + 'px';
    //alert(obj.style.left + "-" + obj.style.top);
    //alert(xMousePosMax + "-" + yMousePosMax);

}

// Apertura pop-up:
// prendo la posizione del mouse click: FF=pageX/Y IE=clientX/Y 
// e la correggo per visualizzare il pop-up del forum-post allo stesso modo in IE-FF
function setPopup(ev, cont, div) {
    var left = (ev.pageX != null) ? ev.pageX + 100 : ev.clientX + 100;
    var top = (ev.pageY != null) ? ev.pageY - 200 : ev.clientY + document.documentElement.scrollTop - 200;

    setVisible(div, cont);
    placeIt(div, left, top)
}

// Apertura pop-up "modificata":
// posizionamento fisso del pop-up 
function setPopupNoEvt(cont, div) {
    var left = 200;
    var top = 0;
    //alert('Left: '+left+'\nTop: '+top);
    setVisible(div, cont);
    placeIt(div, left, top);
}

function closeAnyPop(popName) {

    var popOgg = document.getElementById(popName);
    if (popOgg != null) {
        popOgg.style.visibility = 'hidden';
    }
}


function getHTTPObject() {
    var xhr = false;
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                xhr = false;
            }
        }
    }
    return xhr;
}

function grabFile(file) {
    var request = getHTTPObject();
    if (request) {
        request.onreadystatechange = function() {
            parseResponse(request);
        };
        request.open("GET", file, true);
        request.send(null);
    }
}

function parseResponse(request) {
    if (request.readyState == 4) {
        if (request.status == 200 || request.status == 304) {
            alert(request.responseText);
        }
    }
}



function checkSecondStep() {


    document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = "";
    var _nome = document.getElementById("ctl00_ContentPlaceHolder1_txt_NAME");
    var _mail = document.getElementById("ctl00_ContentPlaceHolder1_txt_MAIL");

    var _ente = document.getElementById("ctl00_ContentPlaceHolder1_txt_SURNAME");
    var _indirizzo = document.getElementById("ctl00_ContentPlaceHolder1_txt_indirizzo");
    var _cap = document.getElementById("ctl00_ContentPlaceHolder1_txt_cap");
    var _citta = document.getElementById("ctl00_ContentPlaceHolder1_txt_citta");
    var _provincia = document.getElementById("ctl00_ContentPlaceHolder1_txt_provincia");
    var _file = document.getElementById("ctl00_ContentPlaceHolder1_FILE1");

    var _nazione = document.getElementById("ctl00_ContentPlaceHolder1_LIST_NATION");
    var _lingua = document.getElementById("ctl00_ContentPlaceHolder1_LIST_LANGUAGE");
    var _tipoEnte = document.getElementById("ctl00_ContentPlaceHolder1_list_ente");



    _nome.style.backgroundColor = '#FFFFFF';
    _nome.style.borderColor = "#777d11";

    _mail.style.backgroundColor = '#FFFFFF';
    _mail.style.borderColor = "#777d11";

    _ente.style.backgroundColor = '#FFFFFF';
    _ente.style.borderColor = "#777d11";

    _indirizzo.style.backgroundColor = '#FFFFFF';
    _indirizzo.style.borderColor = "#777d11";

    _cap.style.backgroundColor = '#FFFFFF';
    _cap.style.borderColor = "#777d11";

    _citta.style.backgroundColor = '#FFFFFF';
    _citta.style.borderColor = "#777d11";

    _provincia.style.backgroundColor = '#FFFFFF';
    _provincia.style.borderColor = "#777d11";

    _file.style.backgroundColor = '#FFFFFF';
    _file.style.borderColor = "#777d11";

    _nazione.style.backgroundColor = '#FFFFFF';
    _tipoEnte.style.backgroundColor = '#FFFFFF';
    _lingua.style.backgroundColor = '#FFFFFF';


    if (_nome.value == "" || _nome.value == null) {
        _nome.style.backgroundColor = '#DDDDDD';
        _nome.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getNameError().value;

        return;
    }

    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(_mail.value)) {
        _mail.style.backgroundColor = '#DDDDDD';
        _mail.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getMailError().value;
        return;
    }

    var _checkAjax = AjaxQualigeo.VerifyMail(_mail.value).value;

    if (_checkAjax != 'OK') {
        _mail.style.backgroundColor = '#DDDDDD';
        _mail.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = _checkAjax;
        return;
    }


    if (_file.value != "" && _file.value != null) {
        var _estensione = _file.value.substr(_file.value.lastIndexOf("."));
        if (_estensione.toLowerCase() != ".jpg" && _estensione.toLowerCase() != ".jpeg" && _estensione.toLowerCase() != ".png") {
            _file.style.backgroundColor = '#DDDDDD';
            _file.style.borderColor = 'red';
            document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getImageError().value;
            return;

        }



    }

    if (_tipoEnte.options[_tipoEnte.selectedIndex].value != "99") {
        if (_ente.value == "" || _ente.value == null) {
            _ente.style.backgroundColor = '#DDDDDD';
            _ente.style.borderColor = 'red';
            document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getEnteError().value;
            return;
        }
    }


    if (_indirizzo.value == "" || _indirizzo.value == null) {
        _indirizzo.style.backgroundColor = '#DDDDDD';
        _indirizzo.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getIndirizzoError().value;
        return;
    }

    if (_cap.value == "" || _cap.value == null) {
        _cap.style.backgroundColor = '#DDDDDD';
        _cap.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getCapError().value;
        return;
    }

    if (_citta.value == "" || _citta.value == null) {
        _citta.style.backgroundColor = '#DDDDDD';
        _citta.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getCittaError().value;
        return;
    }

    if (_provincia.value == "" || _provincia.value == null) {
        _provincia.style.backgroundColor = '#DDDDDD';
        _provincia.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getProvinciaError().value;
        return;
    }

    if (_nazione.options[_nazione.selectedIndex].value == "" || _nazione.options[_nazione.selectedIndex].value == null) {
        _nazione.style.backgroundColor = '#DDDDDD';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getNazError().value;
        return;
    }

    if (_lingua.options[_lingua.selectedIndex].value == "" || _lingua.options[_lingua.selectedIndex].value == null) {
        _lingua.style.backgroundColor = '#DDDDDD';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getLinguaError().value;
        return;
    }

    document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = "";
    _nome.style.backgroundColor = '#FFFFFF';
    _nome.style.borderColor = "#777d11";

    _mail.style.backgroundColor = '#FFFFFF';
    _mail.style.borderColor = "#777d11";


    if (_file.value != null && _file.value != "") {
        var _action = document.getElementById("ctl00_ContentPlaceHolder1_ACTION");
        _action.value = "CHECKREG2";
        document.forms[0].submit();
    } else {
        MM_showHideLayers('regmain_3', '', 'show');
    }

}



function focusReg() {
    var _regon = document.getElementById("regon");
    var _regoff = document.getElementById("regoff");
    if (_regoff.style.display == 'none') {
        _regoff.style.display = '';
        //_regon.style.display = 'none';
    } else {
        _regoff.style.display = 'none';
        //_regon.style.display = '';
    }
}

function checkPeriodiche(obj) {
    var _per = document.getElementById("ctl00_ContentPlaceHolder1_PERIODICHE");
    if (obj.checked)
        _per.value = "1";
    else
        _per.value = "0";

}

function checkGiorn(obj) {
    var _gior = document.getElementById("ctl00_ContentPlaceHolder1_GIORNALIERE");
    if (obj.checked)
        _gior.value = "1";
    else
        _gior.value = "0";


}

function regUser() {
    var _action = document.getElementById("ctl00_ContentPlaceHolder1_ACTION");
    _action.value = "REG";
    document.forms[0].submit();
}

function showEnd() {

    var _action = document.getElementById("ctl00_ContentPlaceHolder1_ACTION");
    if (_action.value == "END")
        MM_showHideLayers('regmain_5', '', 'show')
    if (_action.value == "REG2")
        MM_showHideLayers('regmain_3', '', 'show');
    if (_action.value == "REG2NO")
        MM_showHideLayers('regmain_2', '', 'show');

}


function checkServices() {
    var _gior = document.getElementById("ctl00_ContentPlaceHolder1_GIORNALIERE");
    if (_gior.value == "1") {
        try {
            document.getElementById("GIORN_ITA").checked = true;
        } catch (e) { }
        try {
            document.getElementById("GIORN_ENG").checked = true;
        } catch (e) { }
        try { document.getElementById("GIORN_SPA").checked = true; } catch (e) { }
        try { document.getElementById("GIORN_FRA").checked = true; } catch (e) { }

    }

    var _per = document.getElementById("ctl00_ContentPlaceHolder1_PERIODICHE");
    if (_per.value == "1") {
        try {
            document.getElementById("PER_ITA").checked = true;
        } catch (e) { }
        try { document.getElementById("PER_ENG").checked = true; } catch (e) { }
        try { document.getElementById("PER_SPA").checked = true; } catch (e) { }
        try { document.getElementById("PER_FRA").checked = true; } catch (e) { }
    }
}


function backfromReg() {

    if (document.referrer != '')
        location.href = document.referrer;
    else
        location.href = "/homesearch.aspx";


}


/**** EDIT USER*/
function editUser() {


    document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = "";
    var _nome = document.getElementById("ctl00_ContentPlaceHolder1_txt_NAME");
    var _mail = document.getElementById("ctl00_ContentPlaceHolder1_txt_MAIL");

    var _ente = document.getElementById("ctl00_ContentPlaceHolder1_txt_SURNAME");
    var _indirizzo = document.getElementById("ctl00_ContentPlaceHolder1_txt_indirizzo");
    var _cap = document.getElementById("ctl00_ContentPlaceHolder1_txt_cap");
    var _citta = document.getElementById("ctl00_ContentPlaceHolder1_txt_citta");
    var _provincia = document.getElementById("ctl00_ContentPlaceHolder1_txt_provincia");
    var _file = document.getElementById("ctl00_ContentPlaceHolder1_FILE1");

    var _nazione = document.getElementById("ctl00_ContentPlaceHolder1_LIST_NATION");
    var _lingua = document.getElementById("ctl00_ContentPlaceHolder1_LIST_LANGUAGE");
    var _tipoEnte = document.getElementById("ctl00_ContentPlaceHolder1_list_ente");


    var _pass1 = document.getElementById("ctl00_ContentPlaceHolder1_NewPW");
    var _pass2 = document.getElementById("ctl00_ContentPlaceHolder1_ConfirmNewPW");

    _nome.style.backgroundColor = '#FFFFFF';
    _nome.style.borderColor = "#777d11";

    _pass1.style.backgroundColor = '#FFFFFF';
    _pass1.style.borderColor = "#777d11";

    _pass2.style.backgroundColor = '#FFFFFF';
    _pass2.style.borderColor = "#777d11";

    _mail.style.backgroundColor = '#FFFFFF';
    _mail.style.borderColor = "#777d11";

    _ente.style.backgroundColor = '#FFFFFF';
    _ente.style.borderColor = "#777d11";

    _indirizzo.style.backgroundColor = '#FFFFFF';
    _indirizzo.style.borderColor = "#777d11";

    _cap.style.backgroundColor = '#FFFFFF';
    _cap.style.borderColor = "#777d11";

    _citta.style.backgroundColor = '#FFFFFF';
    _citta.style.borderColor = "#777d11";

    _provincia.style.backgroundColor = '#FFFFFF';
    _provincia.style.borderColor = "#777d11";

    _file.style.backgroundColor = '#FFFFFF';
    _file.style.borderColor = "#777d11";

    _nazione.style.backgroundColor = '#FFFFFF';
    _tipoEnte.style.backgroundColor = '#FFFFFF';
    _lingua.style.backgroundColor = '#FFFFFF';


    if (_nome.value == "" || _nome.value == null) {
        _nome.style.backgroundColor = '#DDDDDD';
        _nome.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getNameError().value;
        return;
    }

    if (_pass1.value != "" && _pass1.value != null) {

        if (_pass1.value != _pass2.value) {
            _pass1.style.backgroundColor = '#DDDDDD';
            _pass1.style.borderColor = 'red';
            document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getPasswordError().value;
            return;
        }
    }

    if (_pass2.value != "" && _pass2.value != null) {


        if (_pass1.value != _pass2.value) {
            _pass2.style.backgroundColor = '#DDDDDD';
            _pass2.style.borderColor = 'red';
            document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getPasswordError().value;
            return;
        }
    }
    

    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(_mail.value)) {
        _mail.style.backgroundColor = '#DDDDDD';
        _mail.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getMailError().value;
        return;
    }
    
    if (_file.value != "" && _file.value != null) {
        var _estensione = _file.value.substr(_file.value.lastIndexOf("."));
        if (_estensione.toLowerCase() != ".jpg" && _estensione.toLowerCase() != ".jpeg" && _estensione.toLowerCase() != ".png") {
            _file.style.backgroundColor = '#DDDDDD';
            _file.style.borderColor = 'red';
            document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getImageError().value;
            return;
        }
    }

    if (_tipoEnte.options[_tipoEnte.selectedIndex].value != "99" && _tipoEnte.options[_tipoEnte.selectedIndex].value != "98") {
        if (_ente.value == "" || _ente.value == null) {
            _ente.style.backgroundColor = '#DDDDDD';
            _ente.style.borderColor = 'red';
            document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getEnteError().value;
            return;
        }
    }

    if (_indirizzo.value == "" || _indirizzo.value == null) {
        _indirizzo.style.backgroundColor = '#DDDDDD';
        _indirizzo.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getIndirizzoError().value;
        return;
    }

    if (_cap.value == "" || _cap.value == null) {
        _cap.style.backgroundColor = '#DDDDDD';
        _cap.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getCapError().value;
        return;
    }

    if (_citta.value == "" || _citta.value == null) {
        _citta.style.backgroundColor = '#DDDDDD';
        _citta.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getCittaError().value;
        return;
    }

    if (_provincia.value == "" || _provincia.value == null) {
        _provincia.style.backgroundColor = '#DDDDDD';
        _provincia.style.borderColor = 'red';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getProvinciaError().value;
        return;
    }

    if (_nazione.options[_nazione.selectedIndex].value == "" || _nazione.options[_nazione.selectedIndex].value == null) {
        _nazione.style.backgroundColor = '#DDDDDD';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getNazError().value;
        return;
    }

    if (_lingua.options[_lingua.selectedIndex].value == "" || _lingua.options[_lingua.selectedIndex].value == null) {
        _lingua.style.backgroundColor = '#DDDDDD';
        document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = AjaxQualigeo.getLinguaError().value;
        return;
    }

    document.getElementById("ctl00_ContentPlaceHolder1_html_error").innerHTML = "";
    _nome.style.backgroundColor = '#FFFFFF';
    _nome.style.borderColor = "#777d11";

    _mail.style.backgroundColor = '#FFFFFF';
    _mail.style.borderColor = "#777d11";

    var _action = document.getElementById("ctl00_ContentPlaceHolder1_ACTION");
    _action.value = "SAVE";
    document.forms[0].submit();


}
/****/
