var ajax = {
    ajaxFunction: function(file) {
        var xmlHttp;
        try {
            // Firefox, Opera 8.0+, Safari
            xmlHttp = new XMLHttpRequest();
        } catch (e) {
            // Internet Explorer
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                    alert("Your browser does not support AJAX!");
                    return false;
                }
            }
        }

        xmlHttp.open("GET", this.getCorrectUrl(file), false);
        xmlHttp.send(null);

        return xmlHttp.responseText;
    },
    getCorrectRelativePath: function() {
        var path = window.location.pathname;
        if (path.search(/\/charging/) != -1 || path.search(/\/contacts/) != -1 || path.search(/\/protocols/) != -1 || path.search(/\/personal_settings/) != -1 || path.search(/\/settings/) != -1 || path.search(/\/manual/) != -1 || path.search(/\/reports/) != -1)
            return "../";
        else
            return "./";
    },
    getCorrectUrl: function(file) {
        return this.getCorrectRelativePath() + file;
    },
    dictionary: function(word, lang) {
        return this.ajaxFunction('../_dictionary.php?word=' + word + '&lang=' + lang + '');
    }
}