function toggle_elem(id, txt) {
    if (id.style.display != 'none') {
        id.style.display = 'none';
        txt.nodeValue = 'отобразить';
    }
    else {
        id.style.display = '';
        txt.nodeValue = 'скрыть';
    }
}

function toggle_grp(sender, grp, parent_id) {
    var a = sender.childNodes[0];
    var el = document.getElementById(parent_id);
    for (var i = 0; i < el.rows.length; i++) {
        if (el.rows[i].getAttribute('vendor') == grp) {
            toggle_elem(el.rows[i], a);
        }
    }
}

function show_elem(id) {
    id.style.display = '';
}

function show_grp(sender_id, grp, parent_id) {
    var b = document.getElementById(sender_id);
    var a = b.childNodes[0];
    var el = document.getElementById(parent_id);
    a.nodeValue = 'скрыть';
    for (var i = 0; i < el.rows.length; i++) {
        if (el.rows[i].getAttribute('vendor') == grp) {
            show_elem(el.rows[i]);
        }
    }
}

var map=null;
var lngAst = null;
var lngAlm = null;
var lngAlmCl = null;

function mapinitialize() {
    if (GBrowserIsCompatible()) {
        function createMarker(point, options, message) {
            var marker = new GMarker(point, options);
            GEvent.addListener(marker, "click", function () {
                var myHtml = message;
                map.openInfoWindowHtml(point, myHtml);
            });
            return marker;
        }

        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(43.244124, 76.954679), 16);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());

        markerOptionsAlmCl = { title: 'Учебный Центр ELTC, учебный класс в г. Алматы' };
        markerOptionsAst = { title: 'Учебный Центр ELTC, г. Астана' };
        markerOptionsAlm = { title: 'Учебный Центр ELTC, офис в г. Алматы' };

        lngAst = new GLatLng(51.1492686, 71.47838);
        lngAlm = new GLatLng(43.247227, 76.955911);
        lngAlmCl = new GLatLng(43.244124, 76.954679);
        map.addOverlay(createMarker(lngAst, markerOptionsAst, '<div class="div_map_baloon"><p><img src="images/eltc.gif" width="110px" height="65px" alt="ELTC" /><b>Учебный центр ELTC</b></p><p style="margin-bottom: 1px; margin-top: 1px">Филиал в г. Астана</p></div><div><p style="margin-bottom: 1px; margin-top: 1px">Астана, ул. Куйши Дина, 25/2</p></div>'));
        map.addOverlay(createMarker(lngAlmCl, markerOptionsAlmCl, '<div class="div_map_baloon"><p><img src="images/eltc.gif" width="110px" height="65px" alt="ELTC" /><b>Учебный центр ELTC</b></p><p style="margin-bottom: 1px; margin-top: 1px">Учебный класс</p></div><div><p style="margin-bottom: 1px; margin-top: 1px">Алматы, ул. Пушкина, 129, офис 44</p></div>'));
        map.addOverlay(createMarker(lngAlm, markerOptionsAlm, '<div class="div_map_baloon"><p><img src="images/eltc.gif" width="110px" height="65px" alt="ELTC" /><b>Учебный центр ELTC</b></p><p style="margin-bottom: 1px; margin-top: 1px">Офис</p></div><div><p style="margin-bottom: 1px; margin-top: 1px">Алматы, ул. Шевченко, 13</p></div>'));
    }
}

function pantoalmaty() {
    map.panTo(lngAlmCl);
}

function pantoastana() {
    map.panTo(lngAst);
}

function pantoalmaty2() {
    map.panTo(lngAlm);
}

function toggle(sender, contentId, expandedImage, collapsedImage, expandedStyle, collapsedStyle) {

    var contentContainer = document.getElementById(contentId);
    // debugger
    if (contentContainer == null) {
        throw Error("Argument null exception. Parameter contentContainer can't be null.")
    }

    if (contentContainer.className == expandedStyle) {
        sender.src = collapsedImage;
        //sender.className = collapsedStyle;
        replaceStyle(contentContainer, expandedStyle, collapsedStyle);

    }
    else {
        sender.src = expandedImage;
        //sender.className = expandedStyle;
        replaceStyle(contentContainer, collapsedStyle, expandedStyle);
    }

}

function replaceStyle(element, removedStyle, newStyle) {
    if (element.className == null || element.className == "") {
        element.className = newStyle;
        return;
    }

    var index = element.className.indexOf(removedStyle);

    if (index == -1) {
        element.className = element.className + " " + newStyle;
        return;
    }

    element.className = element.className.replace(removedStyle, newStyle);

}


