function tlf() {
	var fo = document.forms['loginForm'];
	var st = (fo.style.display != 'none');
	fo.style.display = (st) ?  'none' : 'block';
	if (!st) {
		fo.elements['user'].focus();
	}
}

function gotoUrl(u) {
	self.location.href=u;
}

function deleteContentFromList(u) {
	if (confirm('Möchten Sie den Eintrag wirklich löschen?')) {
		gotoUrl(u);
	}
}

function saveContent(id, u, listid) {
	fid = (id == null) ? '_' + listid : id;
	id  = (id == null) ? '' : id;
	var fc = document.getElementById('fc' + fid);
	fc.action = u;
	var h = document.createElement('input');
	h.type = 'hidden';
	h.name = 'action';
	h.value = 'saveContent';
	fc.appendChild(h);
	var s = document.createElement('input');
	s.type = 'hidden';
	s.name = 'cid';
	s.value = id;
	fc.appendChild(s);
	if (listid) {
		var l = document.createElement('input');
		l.type = 'hidden';
		l.name = 'listid';
		l.value = listid;
		fc.appendChild(l);
	}
	fc.submit();
}

function getPlainText(o) {
	var rpl = o.innerHTML;
	rpl = rpl.replace(/\&amp;/g, '&');
	rpl = rpl.replace(/(\r?\n)+/g, ' ');
	rpl = rpl.replace(/<br\s*\/?>/gi, '\n');
	return rpl;
}

function editContent(id) {

	id = (id == null) ? '' : id;
	var cc = document.getElementById('cc' + id);

	if (cc) {

		var fc = document.getElementById('fc' + id);
		var hl = document.getElementById('chl' + id);
		var tx = document.getElementById('ctx' + id);
		var svlk = document.getElementById('svlk' + id);

		if (fc) {
			hl.style.display = (hl.style.display == 'none') ? 'block' : 'none';
			tx.style.display = (tx.style.display == 'none') ? 'block' : 'none';
			var f_hl = document.getElementById('fhl' + id);
			var f_tx = document.getElementById('ftx' + id);
			f_hl.style.display = (f_hl.style.display == 'none') ? 'block' : 'none';
			f_tx.style.display = (f_tx.style.display == 'none') ? 'block' : 'none';
			svlk.style.display = (svlk.style.display == 'none') ? 'block' : 'none';
			fc.style.display = (fc.style.display == 'none') ? 'block' : 'none';
			return;
		}

		var fc = document.createElement('form');
		fc.id = 'fc' + id;
		fc.method = 'post';
		fc.className = 'contentForm';
		cc.parentNode.insertBefore(fc, cc);
	
		var f_hl = document.createElement('input');
		f_hl.value = getPlainText(hl);
		// problem with ie: f_hl.className = hl.className;
		f_hl.style.width = (hl.offsetWidth > 200) ? hl.offsetWidth : '500';
		f_hl.id = 'fhl' + id;
		f_hl.name = 'headline';
		var contain = document.createElement('div');
		hl.style.display = 'none';
		fc.appendChild(contain);
		contain.appendChild(f_hl);
		
		var f_tx = document.createElement('textarea');
		f_tx.value = getPlainText(tx);
		f_tx.className = tx.className;
		f_tx.style.width = (tx.offsetWidth > 200) ? tx.offsetWidth : '500';
		f_tx.style.height = Math.max(tx.offsetHeight + 20, 200);
		f_tx.style.wrap = 'virtual';
		f_tx.id = 'ftx' + id;
		f_tx.name = 'text';
		var contain = document.createElement('div');
		tx.style.display = 'none';
		fc.appendChild(contain);
		contain.appendChild(f_tx);
		
		svlk.style.display = 'block';

	}
	
}

function iView(o, w, h) {
	
	w = ((typeof w == 'undefined') ? 820 : w);
	h = ((typeof h == 'undefined') ? 630 : h);
	
	var fu = o.src.replace(/\.t\./, '.');
	var h = window.open(fu, 'iView', 'width=' + w + ',height=' + h + ',scrollbars=no,resizable=yes');
	h.focus();
	
}

function ops(u, w, h) {
	
	w = (w == null) ? 800 : w;
	h = (h == null) ? 600 : h;
	
	var h = window.open(u, 'ops', 'width=' + w + ',height=' + h + ',scrollbars=yes,resizable=yes');
	h.focus();
	
}
