function ukryj() {
	var Nodes = document.getElementsByTagName('ul')
	var max = Nodes.length
	for(var i=0;i<max;i++) {
		var nodeObj = Nodes.item(i);                                
		if(nodeObj.id.indexOf('f17')!=-1) {
		nodeObj.style.display = 'none';                                
		}
	}
	var Nodes = document.getElementsByTagName('h1')
	var max = Nodes.length
	for(var i=0;i<max;i++) {
		var nodeObj = Nodes.item(i);  
		nodeObj.style.display = 'none';                                
	}
}     

ukryj();

function otworz( url, tytul, szer, wys ) {
    if (parseInt(szer) > 800 || parseInt(wys) > 800){
        NoweOkienko=window.open(url, tytul);
    } else{
        config='left=100,top=100,width='+szer+',height='+wys+',innerheight='+wys+',innerwidth='+szer+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
        NoweOkienko=window.open('', tytul, config);
        NoweOkienko.document.open();
        NoweOkienko.document.write('<HTML>');
        NoweOkienko.document.write('<HEAD>');
        NoweOkienko.document.write('<TITLE>'+tytul+'</TITLE>');
        NoweOkienko.document.write('</HEAD>');
        NoweOkienko.document.write('<BODY BGCOLOR=white LEFTMARGIN=0 TOPMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0>');
        NoweOkienko.document.write('<A HREF=# onclick="javascript:self.close();"><IMG SRC="'+url+'" BORDER=0 ALT="Zamknij"></A>');
        NoweOkienko.document.write('</BODY>');
        NoweOkienko.document.write('</HTML>');
        NoweOkienko.document.close();
        NoweOkienko.focus();
    }
}

function pokaz( url, tytul, szer, wys ) {
        config='left=100,top=100,width='+szer+',height='+wys+',innerheight='+wys+',innerwidth='+szer+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no';
        NoweOkienko=window.open(url, tytul, config);
        NoweOkienko.focus();
}

function start() {
	document.getElementById('edytor').contentWindow.document.designMode = 'on';
}

function wykonaj(command) {

	var edytor = document.getElementById('edytor');
	var doc = edytor.contentWindow.document;
	var param = null;

	if (command == 'wstawlink') {
		param = prompt('Link', 'http://');
		doc.execCommand('createlink', false, param);
	}
	
	if (command == 'wstawmail') {
		param = prompt('e-mail', 'mailto:');
		doc.execCommand('createlink', false, param);
	}

	if ((command != 'wstawlink') && (command != 'wstawmail'))
	{
	doc.execCommand(command, false, param);
	}

}

function nazwa_czcionki(param) {	
	var edytor = document.getElementById('edytor');
	var doc = edytor.contentWindow.document;
	doc.execCommand('fontname', false, param);	
}

function rozmiar_czcionki(param) {	
	var edytor = document.getElementById('edytor');
	var doc = edytor.contentWindow.document;
	doc.execCommand('fontsize', false, param);	
}

function kolor_czcionki(param) {	
	var edytor = document.getElementById('edytor');
	var doc = edytor.contentWindow.document;
	doc.execCommand('forecolor', false, param);
    var picker = getObj('colorpicker');     	
	picker.style.display = 'none';
	return;	
}

function stworz_tabelke() {
        var nt = window.showModalDialog('tabelka.php', 'window', 'scrollbars=no;resizable=no;status:false;dialogHeight:190px;dialogWidth:420px');
        if (nt) {
            var newtable = document.createElement('TABLE');
            newtable.width = (nt.width) ? nt.width : '';
            newtable.height = (nt.height) ? nt.height : '';
            newtable.border = (nt.border) ? nt.border : '';

            if (nt.cellPadding) newtable.cellPadding = nt.cellPadding;

            if (nt.cellSpacing) newtable.cellSpacing = nt.cellSpacing;

            // create rows
            for (i = 0; i < parseInt(nt.rows); i++) {
                var newrow = document.createElement('TR');

                for (j = 0; j < parseInt(nt.cols); j++) {
                    var newcell = document.createElement('TD');
                    newrow.appendChild(newcell);
                }

                newtable.appendChild(newrow);
            }
			var edytor = document.getElementById('edytor');
			var doc = edytor.contentWindow.document;
            var selection = doc.selection.createRange();
            selection.pasteHTML(newtable.outerHTML);
		}
}

function detekcja() {
	var doc = document.getElementById('edytor').contentWindow.document;
	var body = doc.body;
	var textarea = document.getElementById('textarea');
	textarea.value = body.innerHTML;
}

function sprawdz() {
	detekcja();
	return true;
}
