//Karol Tyl
//kartyl@gmail.com

function rozwinMenu(id) {
    e = document.getElementById('pozycjaMenu' + id);
    if (e.style.display == 'block') {
        e.style.display = 'none';
        e = e.parentNode;
        e = e.getElementsByTagName('img').item(0);
        e.src = '_img/arrow_red.gif';
        return;
    }
    e = document.getElementById('lewy');
    e = e.getElementsByTagName('div');
    for (i=0; i < e.length; i++) {
        el = e.item(i);
        if (el.tagName != 'DIV') {
            continue;
        }
        div = el.getElementsByTagName('div');
        div = div.item(0);
        if (div == null || div.parentNode.parentNode.id != 'lewy') {
            continue;
        }
        img = el.getElementsByTagName('img');
        img = img.item(0);
        if (el.id == 'grupaMenu'+id) {
            div.style.display = 'block';
            if (img != null) {
                img.src = '_img/arrow_red_down.gif';
            }
        } 
        /*
         * Ponizszy kawalek kodu odpowiada za chowanie pozostalych pozycji menu
         * oprocz tej na ktora kliknal uzytkownik
    	 */
        /* else {
            div.style.display = 'none';
            if (img != null) {
                img.src = '_img/arrow_red.gif';
            }
        }*/
    }
}

var szukajFocusPierwszy = true;

function szukajFocus(id) {
    
    el = document.getElementById(id);
    if (el == null) {
        return;
    }
    if (szukajFocusPierwszy) {
        el.value='';
        szukajFocusPierwszy = false;
    }
    el.select();
}


//wst�pne za�adowanie obrazk�w
var preloadFlag = false;
var menuHidden = false;
var images = new Array (
        'arrow_red.gif',
        'arrow_red_down.gif'
    )

function newImage(arg) {
    if (document.images) {
	    res = new Image();
		res.src = arg;
		return res;
	}
}

function preloadImage(element, index, array) {
    img = newImage('_img/' + element);
}

function init() {
    if (!preloadFlag) {
        focus();
		if (document.images) {
		    for (i=0; i<images.length; i++) {
    		    preloadImage(images[i]);
    		}
		}
        preloadFlag = true;
    }
}

document.onload = init();

function dogoryin() {
    document.getElementById('dogory1').style.display="inline";
    document.getElementById('dogory2').style.display="inline";
}

function dogoryout() {
    document.getElementById('dogory1').style.display="none";
    document.getElementById('dogory2').style.display="none";
}

function changeKadencja(loc, id_menu) {
    k=document.getElementById('kadencja').value;
    window.location.href=loc + '?id=26&p0=szczegoly&p1='+id_menu+'&p2=' + k;
}

function changeKadencjaListaOsob(loc, id_menu) {
    k=document.getElementById('kadencja').value;
//    alert(id_menu);
//    alert(k);
    window.location.href=loc + '?id=' + id_menu + '&kadencja=' + k;
}

function popup(dest, title) {
    window.open(dest,title,"menubar=no,scrollbars=yes,width=430,height=450,toolbar=no");
}

function showHide(link) {
	var stan = document.getElementById('inne_stanowiska').style.display;
	
	if (stan=='none'){
		document.getElementById('inne_stanowiska').style.display = '';
		link.innerHTML='Ukryj inne stanowiska';
	}
	else{
		document.getElementById('inne_stanowiska').style.display = 'none';
		link.innerHTML='Pokaż inne stanowiska';
	}
	
}