var replace_display_active = new Object();
var login;

var details_cur;
var gallery_cur;

function switch_display(id) {

    var el = document.getElementById(id);
    if (el.style.display == 'none') {
        el.style.display = 'block';
    }
    else {
        el.style.display = 'none';
    }
}

function replace_display_id(group,id) {
    if (replace_display_active[group]) {
        replace_display_active[group].style.display = 'none';
    }
    var el = document.getElementById(id);
    if (el) {
        el.style.display = 'block';
        replace_display_active[group] = el;
    }
}

function replace_display_name(group,elname) {
    if (replace_display_active[group]) {
        for (var i=0; i < document.getElementsByName(replace_display_active[group]).length; i++) {
            var el = document.getElementsByName(replace_display_active[group])[i];
            if (el) {
                el.style.display = 'none';
            }
        }
    }
    for (var i=0; i < document.getElementsByName(elname).length; i++) {
        var el = document.getElementsByName(elname)[i];
        if (el) {
            el.style.display = 'block';
        }
    }
    replace_display_active[group] = elname;
}
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
//    window.attachEvent("onload", alphaBackgrounds);
}

function alphaBackgrounds(){
    var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
    var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
    var el = document.getElementById('teaser_overlay');
    if (el) {
        var bg = el.currentStyle.backgroundImage;
        if (itsAllGood && bg){
            if (bg.match(/\.png/i) != null){
                var mypng = bg.substring(5,bg.length-2);
                el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
                el.style.backgroundImage = "url('/img/blind.gif')";
            }
        }
    }
}

function showLogin(key) {
    if (key == 'a') {
        login = 'a';
        window.setTimeout("timeoutLogin()",3000);
    }
    else if (key == 'b' && login == 'a') {
        document.getElementById('showLogin').style.display = 'inline';
    }
    else if (key == 'b') {

    }
}

function timeoutLogin() {
    login = '';
}

function gallery_setcur(img_id) {
    if (!gallery_cur) {
        gallery_cur= img_id;
    }
}

function gallery_show(img_id) {
    if (gallery_cur) {
        var cur_img = document.getElementById('galerie_img_'+gallery_cur);
        if (cur_img) {
            cur_img.style.display = 'none';
        }
    }
    var next_img = document.getElementById('galerie_img_'+img_id);
    if (next_img) {
        next_img.style.display = 'inline';
    }
    gallery_cur = img_id;
}

function switch_details(details_show) {
    if ( details_cur ) {
        document.getElementById('details_'+details_cur).style.display = 'none';
        document.getElementById('menu_'+details_cur).className = 'inactive';
    }
    else {
        document.getElementById('details_content').style.display = 'none';
        document.getElementById('menu_content').className = 'inactive';
	var com = document.getElementById('details_comments');
	if (com) {
	    com.style.display = 'none';
    	    document.getElementById('menu_comments').className = 'inactive';
	}
    }
    document.getElementById('details_'+details_show).style.display = 'block';
    document.getElementById('menu_'+details_show).className = 'active';
    details_cur = details_show;
}