var Frontend = {
	application: 'Jobbkezek'
}

Frontend.Controller = Class.create();

Frontend.Controller.prototype = {
	
	initialize: function( container, tagname, options )
	{
		this.container = container;
		this.tagname = tagname;
		this.options = options || {};
		
		Event.observe( window, 'load', this.addEvent.bindAsEventListener( this ) );
	},
	addEvent: function( obj )
	{
		var elements	= Form.getElements( this.container );
		var object 		= this;
		
		elements.each(function(item) {
			item.observe('change', object.callEvent.bindAsEventListener( object ) );
		});
	},
	callEvent: function( obj )
	{
		if ( this.options.event )
		{
			eval( 'this.' + this.options.event + '(obj)' );			
		}	
	},
	formSubmit: function( event )
	{
 		try
		{
			$( this.container ).onsubmit();
		}
		catch( err )
		{
			$( this.container ).submit();
		}
	}
}
