var Acanthe = {

    init: function()
    {
        LabelToInput.init();
    }
}

var LabelToInput = {
	init: function() {
	
		$$('.labelvalue').each( function(elmt) {
		
			$(elmt).hide();
			var txt = $(elmt).innerHTML;
			var chpsTxt = $(elmt).next("input");
			
			if(chpsTxt.readAttribute('type') == "text")
			{
			
				chpsTxt.setValue(txt);
				$(chpsTxt).observe('focus', function(event) {
					if(chpsTxt.getValue() == txt)
					{
						chpsTxt.setValue('');
						
						if( chpsTxt.hasClassName('newsletter-email') )
							chpsTxt.removeClassName('grey-label');
					}
				});
				
				$(chpsTxt).observe('blur', function(event) {
					if(chpsTxt.getValue() == '')
					{
						chpsTxt.setValue(txt);
						
						if( chpsTxt.hasClassName('newsletter-email') )
							chpsTxt.addClassName('grey-label');
					}
				});
				
				if( chpsTxt.hasClassName('newsletter-email') )
					chpsTxt.addClassName('grey-label');
			}
		});
		
	}
}

AcantheRegister = Class.create();
AcantheRegister.prototype = {
	initialize: function() {
		Event.observe('submit_form', 'click', this.validatePhoneEntry);
	},
	validatePhoneEntry: function(event) {
		if( ($('telfixe').getValue() == "") && ($('telmobile').getValue() == ""))
		{
			$('telfixe').addClassName('validation-failed');
			$('telmobile').addClassName('validation-failed');
			$('advice-required-telephone-telephone-mobile').show();
			
			Event.stop(event);

			return false;
		}
		else
		{
			if($('telfixe').hasClassName('validation-failed'))
				$('telfixe').removeClassName('validation-failed');
			
			if($('telmobile').hasClassName('validation-failed'))
				$('telmobile').removeClassName('validation-failed');
			
			$('advice-required-telephone-telephone-mobile').hide();
		}
	}
}

Event.observe(window, "load", function() {
	Acanthe.init();
});
