//Dynamic Menu - Simple on li click or keypress, pull in children var S2F = Class.create({ initialize: function() { this.sethandlers(); this.container = $('s2f'); this.inputs = []; this.frm = null; this.button = null; this.sethandlers(); }, sethandlers: function() { if(this.container) { this.frm = this.container.lastChild; this.frm.style.display = 'none'; this.button = this.container.firstChild; this.inputs = this.frm.getElementsByTagName('input'); this.closebutton = this.inputs[0]; Event.observe(this.button, 'click', this.toggle.bindAsEventListener(this)); Event.observe(this.closebutton, 'click', this.hide.bindAsEventListener(this)); //form submission Event.observe(this.frm, 'submit', this.check.bindAsEventListener(this)); } }, check: function(e) { var s2fName = this.inputs[1].value; var s2fEmail = this.inputs[0].value; if(s2fName == '' || s2fEmail == '') { e.stop(); return false; } return true; }, toggle: function(e) { if(this.frm.style.display == 'none') { this.show(); } else { this.hide(); } }, show: function() { this.frm.style.display = 'block'; }, hide: function() { this.frm.style.display = 'none'; } });