function slyMembersForm(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 = 'slyMembers-' + 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">Firma:</span></td><td><input id="slyNewsForm_company" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].company : '') + '" style="width:606px" /></td></tr>';
	html += '<tr><td>Firmenzusatz:</td><td><input id="slyNewsForm_companyAddon" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].companyAddon : '') + '" style="width:606px" /></td></tr>';
	html += '<tr><td>Strasse:</span></td><td><input id="slyNewsForm_street" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].street : '') + '" style="width:606px" /></td></tr>';
	html += '<tr><td>Adresszusatz:</span></td><td><input id="slyNewsForm_addressAddon" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].addressAddon : '') + '" style="width:606px" /></td></tr>';
	html += '<tr><td><span style="font-weight:bold">PLZ:</span></td><td><input id="slyNewsForm_zip" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].zip : '') + '" style="width:100px" /></td></tr>';
	html += '<tr><td><span style="font-weight:bold">Ort:</span></td><td><input id="slyNewsForm_city" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].city : '') + '" style="width:606px" /></td></tr>';
	html += '<tr><td><span style="font-weight:bold">Region:</span></td><td><select id="slyNewsForm_region"><option value="">Region wählen...</option><option value="Aargau">Aargau</option><option value="Affoltern">Affoltern</option><option value="Andelfingen">Andelfingen</option><option value="Bülach">Bülach</option><option value="Dielsdorf">Dielsdorf</option><option value="Dietikon">Dietikon</option><option value="Hinwil">Hinwil</option><option value="Horgen">Horgen</option><option value="Meilen">Meilen</option><option value="Pfäffikon">Pfäffikon</option><option value="Schwyz">Schwyz</option><option value="Uster">Uster</option><option value="Winterthur">Winterthur</option><option value="Zug">Zug</option><option value="Zürich">Zürich</option></select></td></tr>';
	html += '<tr><td>Telefon:</td><td><input id="slyNewsForm_phone" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].phone : '') + '" style="width:606px" /></td></tr>';
	html += '<tr><td>Fax:</td><td><input id="slyNewsForm_fax" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].fax : '') + '" style="width:606px" /></td></tr>';
	html += '<tr><td>Webseite:</td><td><input id="slyNewsForm_website" type="text" value="' + (this.configuration.overviewTable.filteredData.length > 0 ? this.configuration.overviewTable.filteredData[this.configuration.rowIndex].website : '') + '" style="width:606px" /></td></tr>';
	html += '<tr><td valign="top">Bild:</td><td><img id="slyNewsForm_picture" /></td></tr>';
	html += '<tr><td>publiziert:</td><td><input type="checkbox" id="slyNewsForm_published" checked="checked" /></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;
	
	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_company').focus(); } catch (err) {}
}

slyMembersForm.prototype.refresh = function() {
	document.getElementById('slyNewsForm_company').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].company;
	document.getElementById('slyNewsForm_companyAddon').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].companyAddon;
	document.getElementById('slyNewsForm_street').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].street;
	document.getElementById('slyNewsForm_addressAddon').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].addressAddon;
	document.getElementById('slyNewsForm_zip').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].zip;
	document.getElementById('slyNewsForm_city').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].city;
	document.getElementById('slyNewsForm_region').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].region;
	document.getElementById('slyNewsForm_phone').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].phone;
	document.getElementById('slyNewsForm_fax').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].fax;
	document.getElementById('slyNewsForm_website').value = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].website;
	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_company').focus(); } catch (err) {}
};

slyMembersForm.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) {}
};

slyMembersForm.prototype.firstObject = function() {
	this.configuration.rowIndex = 0;
	this.refresh();
};

slyMembersForm.prototype.prevObject = function() {
	if (this.configuration.rowIndex > 0) this.configuration.rowIndex--;
	this.refresh();
};

slyMembersForm.prototype.nextObject = function() {
	if (this.configuration.rowIndex < this.configuration.overviewTable.filteredData.length - 1) this.configuration.rowIndex++;
	this.refresh();
};

slyMembersForm.prototype.lastObject = function() {
	this.configuration.rowIndex = this.configuration.overviewTable.filteredData.length - 1;
	this.refresh();
};

slyMembersForm.prototype.saveObject = function() {
	var _this = this;
	var company = document.getElementById('slyNewsForm_company');
	var companyAddon = document.getElementById('slyNewsForm_companyAddon');
	var street = document.getElementById('slyNewsForm_street');
	var addressAddon = document.getElementById('slyNewsForm_addressAddon');
	var zip = document.getElementById('slyNewsForm_zip');
	var city = document.getElementById('slyNewsForm_city');
	var region = document.getElementById('slyNewsForm_region');
	var phone = document.getElementById('slyNewsForm_phone');
	var fax = document.getElementById('slyNewsForm_fax');
	var website = document.getElementById('slyNewsForm_website');
	var published = document.getElementById('slyNewsForm_published');
	var picture = document.getElementById('slyNewsForm_picture');
	
	//------------------------- VALIDATIONS --------------------------
	if (company.value == '') {
		new slyTooltip('Geben Sie den Namen der Firma ein!', company);
		company.focus();
		return;
	}
	if (zip.value == '') {
		new slyTooltip('Bitte geben Sie eine Postleitzahl ein!', zip);
		zip.focus();
		return;
	}
	if (city.value == '') {
		new slyTooltip('Bitte geben Sie eine Stadt ein!', city);
		city.focus();
		return;
	}
	if (region.value == '') {
		new slyTooltip('Bitte wählen Sie die Region!', region);
		region.focus();
		return;
	}
	if (website.value != '' && !website.value.match(/^[^:]+:\/\//i)) {
		website.value = 'http://' + website.value;
	}
	
	//TODO: Add some regex validators
	
	document.getElementById('slyNewsForm_saveButton').disabled = true;
	
	var obj = {};
	obj.entity = 'members';
	if (this.configuration.action == 'update') obj.id = this.configuration.overviewTable.filteredData[this.configuration.rowIndex].id;
	obj.company = document.getElementById('slyNewsForm_company').value;
	obj.companyAddon = document.getElementById('slyNewsForm_companyAddon').value;
	obj.street = document.getElementById('slyNewsForm_street').value;
	obj.addressAddon = document.getElementById('slyNewsForm_addressAddon').value;
	obj.zip = document.getElementById('slyNewsForm_zip').value;
	obj.city = document.getElementById('slyNewsForm_city').value;
	obj.region = document.getElementById('slyNewsForm_region').value;
	obj.phone = document.getElementById('slyNewsForm_phone').value;
	obj.fax = document.getElementById('slyNewsForm_fax').value;
	obj.website = document.getElementById('slyNewsForm_website').value;
	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;
	});
};
