var ds_Module_Web_Callmeback = ds_Base.extend({
	
	options: {},
	
	initialize: function(options) {
		this.setOptions(options);
		var onValidFunction = this.showMsg.bind(this);
		this.callBackForm = new ds_Plugin_Form({form:$('callBackForm'), onValid: onValidFunction, scroll: false});
		this.bindSaveEvents($('submitCallmeback'));
		$('naam').addEvent('focus', function (el) {
			if ($('naam').getProperty('value') == 'Uw naam') {
				$('naam').setProperty('value', '');
			}
		}, this);
		$('telefoonnummer').addEvent('focus', function (el) {
			if ($('telefoonnummer').getProperty('value') == 'Uw telefoonnummer') {
				$('telefoonnummer').setProperty('value', '');
			}
		}, this);
		
	},
	
	bindSaveEvents: function(button) {
		$(button).addEvent('click', this.processCallbackForm.bind(this));
	},
	
	processCallbackForm: function () {
		if ($('telefoonnummer').getProperty('value') == 'Uw telefoonnummer') {
			$('telefoonnummer').setProperty('value', '');
		}
		if ($('naam').getProperty('value') == 'Uw naam') {
			$('naam').setProperty('value', '');
		}
		this.callBackForm.processForm();
	},
	
	showMsg: function () {
		var oMessage = new Element('p').addClass('completeMsg').setHTML('<strong>Bedankt voor het achterlaten van uw telefoonnummer. U wordt zo spoedig mogelijk terug gebeld door een medewerker.</strong>');
		$('submitCallmeback').remove();
		$('callBackForm').replaceWith(oMessage);
	}
});

ds_Module_Web_Callmeback.implement(new Options);
