function submitAjaxForm(form) {
	if (form.elements['divId']) {
		var divId = form.elements['divId'].value;
		var a = new Ajax.Updater(divId, form.action, {
			method: form.method || 'get',
			parameters: Form.serialize(form),
			onComplete: function(response, json) {
				if (json.download) {
					document.location.href = json.download;
				}
			}
		});
	}
	return false;
}

function openMediaPopup(url, width, height, top, left) {
	if (!top) top  = (screen.height  / 2) - 250;
	if (!left) left = (screen.width / 2) - 230;
	if (!width) width = 500; //459;
	if (!height) height = 540; //494;

	var F2=window.open(url, 'mediapopup', 'resizable=no,menubar=no,scrollbars=no,status=no,directories=no,width=' + width + ',height=' + height + ',top=' + top + ',left='+ left);
	F2.focus();
}


/*
 * Bewertungsklasse für Projekte
 */
var ProjectFeedback = Class.create();
ProjectFeedback.prototype = {
	mainElement: null,
	projectId: null,
	initialize: function(ul) {
		this.mainElement = ul;
		this.projectId = parseInt(ul.id.replace(/^\D*/, ''));
		this.bindEvents();
	},
	bindEvents: function() {
		var _self = this;
		this.mainElement.getElementsBySelector('li a').each(function(e) {
			e.onclick = _self.saveFeedback.bindAsEventListener(_self, e);
		});
	},
	saveFeedback: function(evt, link) {
		var _self = this;
		var a = new Ajax.Updater(this.mainElement, link.href, {
			onComplete: function() {
				_self.bindEvents();
			}
		});
		return false;
	}
};

Event.observe(window, 'load', function() {
	$$('ul.star-rating').each(function(e) {
		var feedback = new ProjectFeedback(e);
	});

	$$('.pdf-download-teaser a.open').each(function($e) {
		$e.onclick = function() {
			$e.up('div.section').removeClassName('closed');
			return false;
		};
	});
});




