function slyOrganisationForm(parentNode, configuration) {
	
	this.parentNode = parentNode;
	if (!configuration) return;
	this.configuration = configuration;
	if (!this.configuration.entity) { alert('Configuration of slyForm failed. Please provide an entity!'); return; }

	this.id = 'slyOrg-' + this.configuration.entity + '-' + (new Date()).getTime();
	this.node = document.createElement('div');
	this.node.id = this.id;
	this.node.className = 'slyWidget slyTable';
	this.parentNode.appendChild(this.node);
	sly.widgets[this.id] = this;

	var html = '';
	html += '<div id="' + this.id + '-navDiv" class="slyForm-NavPanelContainer">';	
	html += '<div class="slyForm-NavPanel">';
	html += '<a id="' + this.id + '-navFirstObject" class="iconButton iconButtonFirstPage" href="" onclick="sly.widgets[\'' + this.id + '\'].firstObject(); return false" title="Erstes Element in der Liste">First object</a> ';
	html += '<a id="' + this.id + '-navPrevObject" class="iconButton iconButtonPrevPage" href="" onclick="sly.widgets[\'' + this.id + '\'].prevObject(); return false" title="Vorheriges Element in der Liste">Previous object</a> ';
	html += '<a id="' + this.id + '-navOverview" class="iconButton iconButtonOverview" href="" onclick="sly.widgets[\'' + this.id + '\'].backToOverview(); return false" title="Zurück zur Liste">Overview</a> ';
	html += '<a id="' + this.id + '-navNextObject" class="iconButton iconButtonNextPage" href="" onclick="sly.widgets[\'' + this.id + '\'].nextObject(); return false" title="Nächstes Element in der Liste">Next object</a> ';
	html += '<a id="' + this.id + '-navLastObject" class="iconButton iconButtonLastPage" href="" onclick="sly.widgets[\'' + this.id + '\'].lastObject(); return false" title="Letztes Element">Last object</a> ';
	html += '</div>';
	html += '<div id="slyForm-NavObjectInfo" class="slyForm-NavPanel">Objekt ' + (this.configuration.rowIndex + 1) + '/' + this.configuration.overviewTable.filteredData.length + '</div>';
	html += '</div>';
	html += '<div style="clear:both"></div>';
	html += '<div id="' + this.id + '-form">';
	html += '<table>';
	html += '<tr><td><span style="font-weight:bold">Name:</span></td><td><input id="slyNewsForm_name" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].name : '') + '" style="width:606px" /></td></tr>';
	html += '<tr><td><span style="font-weight:bold">Bereich:</span></td><td><select id="slyNewsForm_area"><option value="">Bereich wählen...</option><option value="Delegierte">Delegierte</option><option value="LFK">LFK</option><option value="Vorstand">Vorstand</option><option value="VTR Air">VTR Air</option></select></td></tr>';
	html += '<tr><td>Funktion:</td><td><input id="slyNewsForm_func" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].func : '') + '" style="width:606px" onblur="tinyMCE.execCommand(\'mceFocus\', true, \'slyNewsForm_funcSpec\');" /></td></tr>';
	html += '<tr><td valign="top"><span style="position:relative; top:35px">Funktionsbeschrieb:</span></span></td><td><textarea id="slyNewsForm_funcSpec" style="height:140px">' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].funcSpec : '') + '</textarea></td></tr>';
	html += '<tr><td valign="top">Bild:</td><td><img id="slyNewsForm_picture" src="res/scripts/slycms/images/empty.png" /></td></tr>';
	html += '<tr><td colspan="2">&nbsp;</td></tr>';
	html += '<tr><td>publiziert:</td><td><input type="checkbox" id="slyNewsForm_published" checked="checked" /></td></tr>';
	html += '<tr><td>Reihenfolge:</span></td><td><input id="slyNewsForm_publishOrder" type="text" style="width:30px" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].publishOrder : '') + '" /></td></tr>';
	html += '</table>';
	html += '</div>';
	html += '<div style="text-align:right"><input type="button" value="Zurück" onclick="sly.widgets[\'' + this.id + '\'].backToOverview()" /><input type="button" id="slyNewsForm_saveButton" value="Speichern" onclick="sly.widgets[\'' + this.id + '\'].saveObject()" /></div>';
	this.node.innerHTML = html;
	
	tinyMCE.execCommand("mceAddControl", true, "slyNewsForm_funcSpec")
	var ajaxUpload = document.createElement('div');
    ajaxUpload.id = 'ajaxUploadResult';
    ajaxUpload.innerHTML = '<form id="slyAjaxUpload" name="slyAjaxUpload" method="post" enctype="multipart/form-data"><input type="file" name="slyAjaxUploadFile" onchange="sly.ajaxUpload(document.getElementById(\'slyAjaxUpload\'), true);" /></form>';
    document.getElementById('slyNewsForm_picture').parentNode.appendChild(ajaxUpload);
	try { document.getElementById('slyNewsForm_name').focus(); } catch (err) {}
}

slyOrganisationForm.prototype.refresh = function() {
	document.getElementById('slyNewsForm_name').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].name;
	document.getElementById('slyNewsForm_area').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].area;
	document.getElementById('slyNewsForm_func').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].func;
	document.getElementById('slyNewsForm_publishOrder').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].publishOrder;
	//document.getElementById('slyNewsForm_funcSpec').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].funcSpec;
	if (this.configuration.overviewTable.filteredData[this.configuration.rowIndex].funcSpec) tinyMCE.activeEditor.setContent(this.configuration.overviewTable.filteredData[this.configuration.rowIndex].funcSpec);
	else tinyMCE.activeEditor.setContent('');
	if (this.configuration.overviewTable.filteredData[this.configuration.rowIndex].published == 1) document.getElementById('slyNewsForm_published').checked = true;
	else document.getElementById('slyNewsForm_published').checked = false;
	document.getElementById('slyNewsForm_picture').src = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].picture;
	document.getElementById('slyForm-NavObjectInfo').innerHTML = 'Objekt ' + (this.configuration.rowIndex + 1) + '/' + this.configuration.overviewTable.filteredData.length;
	if (this.configuration.rowIndex == 0) {
		document.getElementById(this.id + '-navFirstObject').className = 'iconButton iconButtonFirstPage iconButtonFirstPageDisabled';
		document.getElementById(this.id + '-navPrevObject').className = 'iconButton iconButtonPrevPage iconButtonPrevPageDisabled';
	} else {
		document.getElementById(this.id + '-navFirstObject').className = 'iconButton iconButtonFirstPage';
		document.getElementById(this.id + '-navPrevObject').className = 'iconButton iconButtonPrevPage';
	}
	if (this.configuration.rowIndex < this.configuration.overviewTable.filteredData.length - 1) {
		document.getElementById(this.id + '-navNextObject').className = 'iconButton iconButtonNextPage';
		document.getElementById(this.id + '-navLastObject').className = 'iconButton iconButtonLastPage';
	} else {
		document.getElementById(this.id + '-navNextObject').className = 'iconButton iconButtonNextPage iconButtonNextPageDisabled';
		document.getElementById(this.id + '-navLastObject').className = 'iconButton iconButtonLastPage iconButtonLastPageDisabled';
	}
	try { document.getElementById('slyNewsForm_name').focus(); } catch (err) {}
};

slyOrganisationForm.prototype.backToOverview = function() {
	if (document.getElementById('tooltip')) {
		document.body.removeChild(document.getElementById('tooltip'));
		clearTimeout(tooltipTimeout);
	}
	document.getElementById(this.configuration.overviewTable.id).style.display = 'block';
	this.configuration.overviewTable.formNode.style.display = 'none';
	try { document.getElementById(this.configuration.overviewTable.id + '-NavFilter').focus(); } catch (err) {}
};

slyOrganisationForm.prototype.firstObject = function() {
	this.configuration.rowIndex = 0;
	this.refresh();
};

slyOrganisationForm.prototype.prevObject = function() {
	if (this.configuration.rowIndex > 0) this.configuration.rowIndex--;
	this.refresh();
};

slyOrganisationForm.prototype.nextObject = function() {
	if (this.configuration.rowIndex < this.configuration.overviewTable.filteredData.length - 1) this.configuration.rowIndex++;
	this.refresh();
};

slyOrganisationForm.prototype.lastObject = function() {
	this.configuration.rowIndex = this.configuration.overviewTable.filteredData.length - 1;
	this.refresh();
};

slyOrganisationForm.prototype.saveObject = function() {
	var _this = this;
	var name = document.getElementById('slyNewsForm_name');
	var area = document.getElementById('slyNewsForm_area');
	var func = document.getElementById('slyNewsForm_func');
	var funcSpec = tinyMCE.activeEditor.getContent();
	//var funcSpec = document.getElementById('slyNewsForm_funcSpec');
	var published = document.getElementById('slyNewsForm_published');
	var picture = document.getElementById('slyNewsForm_picture');
	var publishOrder = document.getElementById('slyNewsForm_publishOrder');
	
	//------------------------- VALIDATIONS --------------------------
	if (name.value == '') {
		new slyTooltip('Bitte geben Sie einen Namen ein!', name);
		name.focus();
		return;
	}
	if (area.value == '') {
		new slyTooltip('Bitte wählen Sie den Tätigkeitsbereich!', area);
		area.focus();
		return;
	}
	//TODO: Add some regex validators
	
	document.getElementById('slyNewsForm_saveButton').disabled = true;
	
	var obj = {};
	obj.entity = 'organisation';
	if (this.configuration.action == 'update') obj.id = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].id;
	obj.name = document.getElementById('slyNewsForm_name').value;
	obj.area = document.getElementById('slyNewsForm_area').value;
	obj.publishOrder = document.getElementById('slyNewsForm_publishOrder').value;
	obj.func = document.getElementById('slyNewsForm_func').value;
	obj.funcSpec = funcSpec;
	if (picture.src != '' && !picture.src.match(/index\.php$/i)) obj.picture = picture.src;
	obj.published = document.getElementById('slyNewsForm_published').checked ? 1 : 0;
	sly.call('save', obj, function(res) {
		if (res.statusCode != 200) alert(res.statusMessage);
		else {
			_this.configuration.overviewTable.updateNewsList();
			_this.configuration.overviewTable.loadData();
			_this.backToOverview();
		}
		document.getElementById('slyNewsForm_saveButton').disabled = false;
	});
};
