﻿if (Object.isUndefined(FormUtils)) { var FormUtils = {} }

// Web 2.0-style form labels
// Example HTML Mark-up
// <div class="input"><label for="[id]">Label here</label><input id="[id]" /></div>
FormUtils.SelfLabeledInput = Class.create({
    initialize: function(selector) {
        if (!selector) selector = "div.input label";
        document.observe("dom:loaded", function() {
            $$(selector).each(function(label) {
                var forAttr = label.getAttribute('for') || label.readAttribute('for');
                var formElement = $(forAttr);
                if (formElement) {
                    if (formElement.value) label.hide();
                    formElement.observe('focus', function() { label.hide(); });
                    formElement.observe('blur', function() { if (!formElement.getValue()) label.show(); });
                    label.observe('click', function() { label.hide(); });
                }
            });
        });
    }
});

document.observe("dom:loaded", function() {
    var alertHeaderList = ['Site Improvements coming soon!', 'We’ve updated Voices of Challenge!'];
    var alertTextList = [
        'Timberland is in the process of updating the Voices of Challenge dialogue so all users have an improved experience. Going forward, the dialogue will be structured more like a Forum, where we can discuss multiple topics within each pillar area at one time. We’ll also be asking you to log in when making comments, which will allow us to create improved communication within this community. As always, the dialogue will remain open to all users. We value your comments and participation. If you have questions about the planned changes, please email <a href="mailto:csrinfo@timberland.com">csrinfo@timberland.com</a>.',
        'If you’re an active participate in Timberland’s Voices of Challenge dialogue, you may notice our new site design upon visiting this page. We have upgraded our dialogue so it is structured as a Forum. Now, participants can discuss multiple topics within each pillar area at one time, and we’re also asking you to log in when making comments. We believe these changes will improve everyone’s experience and communication. As always, the dialogue is open to all users. We value your comments and participation.'
    ];
    var alertHeader = alertHeaderList[0];
    var alertText = alertTextList[0];
    var alertContent =
        new Element('div')
            .setStyle({ background: '#fee', padding: '10px', margin: '10px 0 0', color: '#c00' })
            .insert(new Element('h3').setStyle({ fontWeight: 'bold', margin: '0 0 8px' }).insert(alertHeader))
            .insert(new Element('div').insert(alertText));

    $$('img[src=/Resource_/Page/Content2603/Voices-of-Challenge.gif]').each(function(el) {
        $(el).next('br').insert({ after: alertContent });
    });
    $$('img[src=/Resource_/Voices/1/Energy-Pillar.gif]').each(function(el) {
        $(el).next('#comments').insert({ before: alertContent }).insert({ before: '<br />' });
    });
});