var DEVOUR = { menu: { addEffects: function () { $$('#main_menu li p a').each( function (a) { var p = a.getParent(); var menuFX = new Fx.Styles(p, {wait: false, duration: 250, transition: Fx.Transitions.backOut}); p.setStyle('cursor', 'pointer'); p.addEvents({ 'mouseenter': function () { menuFX.start({ 'border-top-width': 25, 'padding-top': 55, 'padding-bottom': 53 }); }, 'mouseleave': function () { menuFX.start({ 'border-top-width': 3, 'padding-top': 70, 'padding-bottom': 60 }); }, 'click': function () { location.href = a.getProperty('href'); } }); } ); } }, content: { replaceTitles: function () { var headers = []; var titleGraphics = []; $$('h1').each( function (h) { if ($defined(h.getProperty('title'))) { var imgSource = 'images/text_' + h.getProperty('title').toLowerCase().split(' ').join('') + '.gif'; headers.push(h); titleGraphics.push(imgSource); } } ); new Asset.images(titleGraphics, { onComplete: function () { headers.each( function (h) { if ($defined(h.getProperty('title'))) { var imgSource = 'images/text_' + h.getProperty('title').toLowerCase().split(' ').join('') + '.gif'; var image = new Element('img', { 'src': imgSource, 'alt': h.getProperty('title') }); h.empty(); image.injectInside(h); } } ); } }); }, modifyLinks: function () { var links = $$('a').each( function (a) { if ($defined(a.getProperty('title'))) { a.addEvents({ 'mouseover': function () { //console.log(a.getProperty('title')); window.status = a.getProperty('title'); return true; }, 'mouseout': function () { window.status = ''; return true; } }); } } ); }, addQuotes: function () { if ($defined($$('.testimonials blockquote'))) { var blocks = $$('.testimonials blockquote'); var beginQuote = new Element('img', { 'class': 'beginquote', 'width': '19px', 'height': '13px', 'alt': '&ldquot;', 'src': '../images/quote_begin.gif' }); var endQuote = new Element('img', { 'class': 'endquote', 'width': '19px', 'height': '14px', 'alt': '&rdquot;', 'src': '../images/quote_end.gif' }); if (blocks.length) { blocks.each( function (block) { var paras = block.getElements('p'); beginQuote.clone().injectBefore(paras[0]); endQuote.clone().injectInside(block); } ); } } }, blockquote: function () { if ($defined($('blocklist'))) { var container = new Element('div'); var block = new Element('blockquote'); var elements = $('blocklist').getChildren(); var previousElementTag = ''; block.clone().injectInside(container); elements.each(function (element) { var elementTag = element.getTag(); if (elementTag == 'hr') { block.clone().injectInside(container); element.remove(); } else { if ('br,a'.indexOf(elementTag) == -1) { element.injectInside(container.getLast()); } else { element.injectInside(container); } } }); container.getChildren().injectInside($('blocklist')); DEVOUR.content.addQuotes(); } } }, form: { createOtherLocationInput: function () { DEVOUR.form.otherLabel = new Element('label', { 'for': 'CustomFields5', 'id': 'CustomFields_5_1_Label' }).setText(' Location:'); var span = new Element('span', { 'class': 'required' }).setText('*').injectTop(DEVOUR.form.otherLabel); DEVOUR.form.otherInput = new Element('input', { 'type': 'text', 'class': 'text', 'name': 'CustomFields[5]', 'id': 'CustomFields_5_1', 'value': '', 'size': '30' }); DEVOUR.form.otherLabel.setOpacity(0); DEVOUR.form.otherInput.setOpacity(0); }, addOtherEvents: function () { if ($defined($('CustomFields_4_1'))) { var stateSelect = $('CustomFields_4_1'); var internationalOption = stateSelect.getLast(); stateSelect.addEvent('change', function () { if (stateSelect.selectedIndex == 7) { DEVOUR.form.showOtherInput(); } else { DEVOUR.form.hideOtherInput(); } }); stateSelect.addEvent('keyup', function () { if (stateSelect.selectedIndex == 7) { DEVOUR.form.showOtherInput(); } else { DEVOUR.form.hideOtherInput(); } }); } }, showOtherInput: function () { var stateSelect = $('CustomFields_4_1'); DEVOUR.form.otherLabel.injectAfter(stateSelect); DEVOUR.form.otherInput.injectAfter(DEVOUR.form.otherLabel); var labelFX = new Fx.Styles('CustomFields_5_1_Label', {wait: false, duration: 1000, transition: Fx.Transitions.sineOut}); var inputFX = new Fx.Styles('CustomFields_5_1', {wait: false, duration: 1000, transition: Fx.Transitions.sineOut}); labelFX.start({'opacity': 0.9999}); inputFX.start({'opacity': 0.9999}); DEVOUR.form.otherInput.focus(); }, hideOtherInput: function () { if (DEVOUR.form.otherLabel.getStyle('opacity') > 0) { DEVOUR.form.otherLabel.setOpacity(0); DEVOUR.form.otherInput.setOpacity(0); DEVOUR.form.otherLabel.remove(); DEVOUR.form.otherInput.remove(); } } } } window.addEvent('domready', function () { DEVOUR.menu.addEffects(); DEVOUR.content.replaceTitles(); DEVOUR.content.blockquote(); DEVOUR.form.createOtherLocationInput(); DEVOUR.form.addOtherEvents(); }); window.addEvent('load', function () { });