	var dialogVars = Array();

	function popup(url, w, h) {
//		var w = 615;
//		var h = 490;
		if(!w) w = 640;
		if(!h) h = 480;
		var par = "width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,scrollbars=yes,left="+eval((screen.availWidth-w)/2)+",top="+eval((screen.availHeight-h)/2);
		window.open(url, '_blank', par);
//		return false;
	}

	function openScreen(screen) {
		var url = 'index.php?screen='+screen;
		var w = 615;
		var h = 490;
		var par = "width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,left="+eval((screen.availWidth-w)/2)+",top="+eval((screen.availHeight-h)/2);
		window.open(url, '_blank');
//		return false;
	}

	function preview(url) {
		var w = 615;
		var h = 515;
		var par = "width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,left="+eval((screen.availWidth-w)/2)+",top="+eval((screen.availHeight-h)/2);
		window.open(url, '_blank', par);
//		return false;
	}

	function nl2br(s) {
		return s.replace(/\n/gi, '<br>');
	}

	function show_wait() {
		var e = document.all['wait'];
		e.style.left = Math.round((document.body.clientWidth-200)/2);
		e.style.top = Math.round((document.body.clientHeight-40)/2);
		e.style.display = '';
		return false;
	}

	function submit_confirm(e) {
		var s;
		if(e.name == 'submit:delete') {
			s = 'Czy napewno usun±ć?';
		} else
		{
			s = 'Czy jeste¶ pewien?';
		}
		return window.confirm(s);
	}


function document_onload() {
	hidden2document();
}

function formSubmit(s) {
	var f = document.forms.form;
	if(s) {
		f.action = s;
	}
	f.submit();
}

function formInsert(n, v)
{
	var f, e;
	f = document.forms.form;
	e = f.document.createElement('<INPUT TYPE=hidden>');
	e.name = n;
	e.value = v;
	f.appendChild(e);
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
//		m_wn_on = newImage("images/.gif");
		preloadFlag = true;
	}
}

/////////

function calendar_setDate(d, n) {
	f = document.forms['schedule_form'];
	f[n].value = d;
}

function selectTab(tab) {
	var a = document.getElementsByTagName('DIV');
	var i, e, n, s;
	for(i=0; i<a.length; i++) {
		e = a[i];
		n = e.id;
		s = n.split(':');
		if(s[0] == 'tab') {
			if(s[1] == tab) {
				e.style.display = '';
			} else
			{
				e.style.display = 'none';
			}
		}
	}

}

function changeDiv(name, value) {
	var a = document.getElementsByTagName('DIV');
	var e, n;
	for(i=0; i<a.length; i++) {
		e = a[i];
		n = e.id;
		s = n.split('-');
		if(s[0] == name) {
			if(s[1] == value) {
				e.style.display = '';
			} else
			{
				e.style.display = 'none';
			}
		}
	}
//alert(name+' '+value)

}

function removeDiv(f) {
	var a = document.getElementsByTagName('DIV');
	var i, e, t = Array(), k=0;
	for(i=0; i<a.length; i++) {
		e = a[i];
		if(e.id && (e.style.display == 'none')) {
			t[k++] = e.id;
		}
	}
	for(i=0; i<t.length; i++) {
		e = document.getElementById(t[i]);
		if(e) {
			e.removeNode(true);
		}
	}

}

function enableInput(name, value) {
	var a = document.getElementsByTagName('DIV');
	var e, n;
	for(i=0; i<a.length; i++) {
		e = a[i];
		n = e.id;
		s = n.split('-');
		if(s[0] == name) {
			if(s[1] == value) {
				e.style.display = '';
			} else
			{
				e.style.display = 'none';
			}
		}
	}
}

function dialogIm(url) {
	if (typeof init == "undefined") {
		init = window;	// pass this window object by default
	}
	dialogVars = Array();

	if(ed) {
		dialogVars.ed = ed;
	}
	var v = showModelessDialog(url, init,
		"dialogWidth: "+610+"px; dialogHeight: "+610+"px; resizable: yes; help: no; status: yes; scroll: no");
	return false;
}

function dialogNode(url) {
	if (typeof init == "undefined") {
		init = window;	// pass this window object by default
	}
	dialogVars = Array();

	var v = showModalDialog(url, init,
//	var v = showModelessDialog(url, init,
		"dialogWidth: "+810+"px; dialogHeight: "+664+"px; resizable: yes; help: no; status: yes; scroll: no");
	if(dialogVars.func == 'node_save') {
		return true;
	} else
	if(dialogVars.func == 'node_tree') {
		ed.format('link', 'node:'+dialogVars.node_id);
		return false;
	} else
	if(dialogVars.func == 'node_navi_') {
		return true;
	} else
	if(dialogVars.func == 'node_navi') {
		return dialogVars.node_id;
	} else
	if(dialogVars.func == 'node_file') {
		return dialogVars.node_id;
	} else
	if(dialogVars.func == 'node_table') {
		return dialogVars.html;
	} else
	if(dialogVars.func == 'node_html') {
		return dialogVars.html;
	}

	if(dialogVars.refresh) {
	}
	return false;
}

function editNode(url) {
//alert(url)
	if (typeof init == "undefined") {
		init = window;	// pass this window object by default
	}
	dialogVars = Array();

//	e = form[name];
	var v = showModalDialog(url, init,
		"dialogWidth: "+118+"px; dialogHeight: "+610+"px; resizable: yes; help: no; status: yes; scroll: no");
//alert(dialogVars)
//alert(dialogVars.node_id);
	if(dialogVars.func == 'node_save') {
		return true;
	}
	if(dialogVars.func == 'node_tree') {
//		alert(dialogVars.node_id);
//		ed.format('link', 'http://zimek.si.pl/igg/node/'+dialogVars.node_id);
		ed.format('link', 'node:'+dialogVars.node_id);
		return false;
	}
	if(dialogVars.func == 'node_navi') {
		return true;
	}


	if(dialogVars.refresh) {
//		e.value = dialogVars.value;
	}

	return false;
}

function selectNode(url) {
//alert(url)
	if (typeof init == "undefined") {
		init = window;	// pass this window object by default
	}
	dialogVars = Array();

//	e = form[name];
	var v = showModalDialog(url, init,
		"dialogWidth: "+118+"px; dialogHeight: "+650+"px; resizable: yes; help: no; status: yes; scroll: no");
//alert(dialogVars)
//alert(dialogVars.node_id);
	if(dialogVars.func == 'node_navi') {
//		alert(dialogVars.node_id);
//		ed.format('link', 'http://zimek.si.pl/igg/node/'+dialogVars.node_id);
//		ed.format('link', 'node:'+dialogVars.node_id);
		return dialogVars.node_id;
	}
	if(dialogVars.func == 'node_file') {
		return dialogVars.node_id;
	}


	if(dialogVars.refresh) {
//		e.value = dialogVars.value;
	}

	return false;
}
