// JavaScript Document
var Careguide = {

    InputFocus: new Class({
        text: null,
        input: null,
        initialize: function(elm) {
            this.input = $(elm);

            if (this.input == null || this.input == undefined) return false;

            this.text = this.input.value;
            this.input.addEvent('focus', this.handler_focus.bindWithEvent(this));
            this.input.addEvent('blur', this.handler_blur.bindWithEvent(this));
        },
        handler_focus: function(e) {
            if (this.input.value == this.text) this.input.value = "";
        },
        handler_blur: function(e) {
            if (this.input.value == "") this.input.value = this.text;
        }
    }),

    ExternalLinks: new Class({
        initialize: function() {
            $$('a').each(function(item) {
                if (item.getProperty('rel') == "external") item.setProperty('target', '_blank');
            });
        }
    }),

    Pages: new Class({
        initialize: function() {
            this.global();
            $$('body').getProperty('class').each(function(item) {
                if (this[item]) this[item]();
            } .bind(this));
        },

        global: function() {
            new Careguide.ExternalLinks();
        },

        popup: function() {
            if ($('contactform') == null) return false;

            var myCheck = new FormCheck('contactform', {
                display: {
                    scrollToFirst: false,
                    showErrors: 1
                }
            })
        }
    })
}

window.addEvent('domready', function() {
    new Careguide.Pages();
});