Element.implement(
{
	confirmUnsaved : function()
	{
		if(this.get('tag') == 'form')
		{
			this.addEvents(
			{
				'submit' : function(){this.store('modified',false);},
				'reset' : function(){this.store('modified',false);}
			}).getElements('input,textarea,select').addEvent('change',function()
				{
					this.getParent('form').store('modified',true);
				});
			window.onbeforeunload = function()
			{
				if(this.retrieve('modified'))
				{
					window.alert("You did not submit the last modifications.");
				}
			}.bind(this);
		}
		return this;
	}
});