function getAbsolutePosition(obj) {
    var x = 0;
    var y = 0;
    var parent = obj;
    while (parent) {
        y += parent.offsetTop;
        x += parent.offsetLeft;
        parent = parent.offsetParent;
    }
    return [x, y];
}

function getInnerSize(theDocument) {
    if (theDocument == null) theDocument = document;
    var x, y;
    if (theDocument.innerWidth) {
        x = theDocument.innerWidth;
        y = theDocument.innerHeight;
    } else if (theDocument.documentElement && theDocument.documentElement.clientHeight) {
        x = theDocument.documentElement.clientWidth;
        y = theDocument.documentElement.clientHeight;
    } else if (theDocument.body) {
        x = theDocument.clientWidth;
        y = theDocument.clientHeight;
    }
    return [x, y];
}

function getEventPosition(e) {
    var x;
    var y;
    if (window.event) { /* ie */
        e = window.event;
        x = e.clientX + document.body.scrollLeft;
        y = e.clientY + document.body.scrollTop;
    } else { /* netscape */
        x = e.pageX;
        y = e.pageY;
    }
    return [x, y];
}


function getNodeContent(node) {
    var value = '';
    var child = node.firstChild;
    while (child != null) {
        value += child.nodeValue;
        child = child.nextSibling;
    }
    return value;
}

function createTableRow(contents) {
    var tr = document.createElement('tr');
    for (var i = 0; i < contents.length; i ++) {
        var td = document.createElement('td');
        if (typeof(contents[i]) == 'string') {
            td.appendChild(document.createTextNode(contents[i]));
        } else {
            td.appendChild(contents[i]);
        }
        tr.appendChild(td);
    }
    return tr;
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function clearNode(node) {
    while (node.firstChild != null) node.removeChild(node.firstChild);
}

function setOpacity(obj, value) {
    obj.style.opacity = value;
    obj.style.filter = 'alpha(opacity=' + value * 100 + ')';
}

function getZoomPoints() {
    return {
        'Karte zoomen': null,
        'Deutschland': [51.5, 10.5, 6],
        'Baden-Württemberg': [48.7, 9.0, 8],
        'Bayern': [49, 11.5, 7],
        'Berlin': [52.5, 13.4, 10],
        'Brandenburg': [52.5, 13.4, 8],
        'Bremen': [53.1, 8.8, 10],
        'Hamburg': [53.6, 10, 10],
        'Hessen': [50.5, 9, 7],
        'Mecklenburg-Vorpommern': [53.9, 12.8, 7],
        'Niedersachsen': [52.8, 9, 7],
        'Nordrhein-Westfalen': [51.5, 7.7, 7],
        'Rheinland-Pfalz': [50, 7.3, 8],
        'Saarland': [49.4, 6.9, 9],
        'Sachsen': [51.1, 13.2, 7],
        'Sachsen-Anhalt': [52.2, 11.9, 8],
        'Schleswig-Holstein': [54.2, 9.6, 8],
        'Thüringen': [50.9, 11.3, 8],
        
        '---': null,

        'Europa': [51.5, 10.5, 4],

        'Aserbaidschan': [40.143105, 47.576927, 7],
        'Australien': [-28.304381, 141.152344,3],
        'Belgien': [50.503887, 4.569936, 8],
        'Belize': [17.182779, -88.352051,8],
        'Bolivien': [-15.919074, -63.413086,5],
        'Brasilien': [-14.264, -51.9433, 4],
        'Bulgarien': [43, 25, 7],
        'Chile': [-37.020098, -71.894531,3],
        'Griechenland': [ 39.061849, 22.324219,6],
        'Estland': [58.7, 25.2, 7],
        'Finnland': [65.1, 26.78, 5],
        'Frankreich': [46.92, 1.692, 6],
        'Indien': [23.5, 78, 5],
        'Italien': [41.689322, 13.007813,5],
        'Kanada': [64.014496, -95.976562,2],
        'Kroatien': [44.5, 16.2, 7],
        'Liechtenstein': [47.15, 9.54, 10],
        'Luxemburg': [49.807859, 6.135864,9],
        'Namibia': [-22.95764, 18.49041, 6],
        'Niederlande': [52.3, 5.4, 7],
        'Österreich': [47.457809, 14.084473,6],
        'Polen': [52.025459, 19.138184,6],
        'Schweiz': [46.777493, 8.283691,7],
        'Seychellen': [-4.694142, 55.604553,9],
        'Saudi Arabien': [24.826, 45.417, 5],
        'Singapur': [1.352083, 103.819836, 11],
        'Südafrika': [-28.690588, 25.004883, 5],
        'Taiwan': [23.644524, 121.173706, 7],
        'Tschechische Republik': [49.8, 15.4, 7],
        'Türkei': [39.13006, 34.936523,5],
        'Ungarn': [47.294134, 19.35791,6],
        'Vietnam': [16.425548, 106.611328,5]
    };
}
