function SwitchMenu(obj)
{
	var el = document.getElementById(obj);
	var ar = document.getElementById("button").getElementsByTagName("div"); 
	for (var i=0; i<ar.length; i++)
	{
		if (ar[i].className=="sub") 
		{
			ar[i].style.display = "none";
		}
	}
	if (el) { el.style.display = "block"; }
}
function pokaz_obrazek(sciezka,x,y)
{
ext_pic=open('', '', 'width='+x+', height='+y+'');
ext_pic.document.write('<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\"><title>Eko-Systemy</title></head><body marginwidth=0 merinheight=0 leftmargin=0 topmargin=0 onLoad=\"focus(self);\"><img src=\"'+sciezka+'\" onClick=\"javascript:window.close()\" alt=\"Kliknij, aby zamknąć!\"></body></html>');
}

function pokaz_foto(id_strona,x,y)
{
	szer=x*1+10;
	wys=y*1+30;
	okienko('obrazek.php?galeria=strona&id='+id_strona,szer,wys,'auto');
}
function pokaz_foto_oferta(id_strona,x,y)
{
	szer=x*1+10;
	wys=y*1+30;
	okienko('obrazek.php?galeria=oferta&id='+id_strona,szer,wys,'auto');
}
function pokaz_foto_galeria(id_strona,x,y)
{
	szer=x*1+10;
	wys=y*1+30;
	okienko('obrazek.php?galeria=galeria&id='+id_strona,szer,wys,'auto');
}


function okienko(url, w, h, s)
{   
    var winl = (screen.width-w)/2;
    var wint = (screen.height-h)/2;
    var t='location=no,toolbar=no,directories=no,menubar=no,resizable=yes,scrollbars='+s+',status=no,width='+w+',height='+h+',left='+winl+',top='+wint;

    now = new Date();
    sec = now.getSeconds(); 
    sec = sec+""+now.getMinutes();
    namex="okno"+sec;
    
    nowe_okienko=window.open(url,namex,t);
    nowe_okienko.focus();
}

function skok(elmnt,content)
{
    if (content.length==elmnt.maxLength)
    {
	if (elmnt.name=='dzien_od') {  document.forms[0].miesiac_od.focus() }
	else if (elmnt.name=='miesiac_od') { document.forms[0].rok_od.focus() }
	else if (elmnt.name=='rok_od') { document.forms[0].tytul.focus() }
    }
}
function edytujbaner()
{
	okienko("cmsbaner.php", 400, 400, 1);
}
function dodaj_logo(id_banera)
{
	okienko("cmsb.php?funkcja=upload&id_banera="+id_banera, 400, 220, 1);
}
function efo(foto_id)
{
	okienko("cmsg.php?funkcja=upload&photo_id="+foto_id, 400, 220, 1);
}
function efi(file_id)
{
	okienko("cmspliki.php?funkcja=upload&file_id="+file_id, 400, 220, 1);
}
function usun_fotog()
{
	if (window.confirm('Czy na pewno chcesz usunąć fotografię?'))
	{
		document.forms[0].funkcja.value='usun';
		document.forms[0].submit();
	}
}
function usun_plik()
{
	if (window.confirm('Czy na pewno chcesz usunąć plik?'))
	{
		document.forms[0].funkcja.value='usun';
		document.forms[0].submit();
	}
}

function usug(content_id,d)
{
	okienko("cmsusg.php?content_id="+content_id+"&d="+d, 400, 110, 0);
}
function galeria_dodaj(cid)
{
	okienko("cmsg.php?funkcja=upload&content_id="+cid, 400, 220, 1);
}
function pliki_dodaj(cid)
{
	okienko("cmspliki.php?funkcja=upload&content_id="+cid, 400, 220, 1);
}
function up_galeria()
{
	document.forms[0].funkcja.value='zapisz';
	document.forms[0].submit();
}
function edytuj(cid)
{
    okienko("cmse.php?funkcja=edytuj&cid="+cid, 740, 630, 1);
}

function dodaj(d)
{
    okienko("cmse.php?funkcja=dodaj&d="+d, 740, 520, 1);
}

function usun_akapit()
{
	if (window.confirm('Czy na pewno chcesz usunąć akapit?'))
	{
		document.forms[0].funkcja.value='usun';
		document.forms[0].submit();
	}
}
function dodaj_podstrone(frame_over_id,frame_id)
{
    okienko('cmsp.php?frame_over_id='+frame_over_id+'&frame_id='+frame_id, 440, 150, 0);
}

function usun(rekord)
{
    if (window.confirm('Czy na pewno chcesz skasować dane?'))
    {
        document.forms[0].funkcja.value='usun';
        document.forms[0].rekord.value=rekord;
        document.forms[0].submit();
    }
}

function usun_strone(doc)
{
    if (window.confirm('Czy na pewno chcesz skasować stronę?'))
    {
		document.forms[0].funkcja.value='usun_strone';
        document.forms[0].rekord.value=doc;
        document.forms[0].submit();
    }
}




function fotoedit(plik,plik_d,id,tablica,pole,doc)
{
    okienko("image.php?plik="+plik+"&plik_d="+plik_d+"&id="+id+"&tablica="+tablica+"&pole="+pole+"&doc="+doc, 360, 460, 0);
}

function edycja_p(d,p)
{
	okienko("e_p.php?d="+d+"&p="+p,"430","160","0");
}

function zapisz_p()
{
	if (document.forms[0].frame_name.value=='') { alert('Podaj nazwę podstrony.') }
	else { document.forms[0].submit(); }
}

function usun_p()
{
	if (window.confirm('Czy na pewno chcesz stronę razem z całą zawartością oraz podstronami?'))
	{
		document.forms[0].funkcja.value='usun';
		document.forms[0].submit();
	}
}

function usun_foto(rodzaj_foto)
{
	document.getElementById(rodzaj_foto).src='inc/noimage.gif';
	eval('document.forms[0].'+rodzaj_foto+'_name.value=""');
	eval('document.forms[0].'+rodzaj_foto+'_url.value=""');
}

function setActiveMenu() {
	if (!document.all) return;
	
	tags = document.all.tags("TR");
	for (var i=0; i<tags.length; i++) {
		if (tags[i].className == "trm") {
			tags[i].onmouseover = tagover;
			tags[i].onmouseout = tagout;
			//tags[i].onclick = tagclick;
		}
	}
	
	storeBColor = null;
	storeLColor = null;
	function tagover() {
		if (this.className == "trm") {
			storeBColor = this.style.backgroundColor;
			this.style.backgroundColor = "#FFCE42";
		}
		this.style.cursor = "hand";
	}
	
	
	function tagout() {
		if (this.className == "trm")
			this.style.backgroundColor = storeBColor;
	}
	
	
	function tagclick() {
		this.all.tags("A")[0].click();
	}
		
}

