// JavaScript Document
var HoosierLottery = {

    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 = "";
            this.input.addClass('focus');
        },
        handler_blur: function (e) {
            if (this.input.value == "") this.input.value = this.text;
            if (this.input.value == this.text) this.input.removeClass('focus');
        }
    }),

    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 HoosierLottery.InputFocus('searchfield');
            new HoosierLottery.InputFocus('q'); /* this was added to properly display in the GoogeCustomSearch form - JL 20101207 */
            
            var globalnav = new MenuMatic({
                id: 'globalnavlist',
                hideDelay: '350',
                opacity: '95',
                onPositionSubMenu_begin: function (classRef) {
                    $liclass = classRef.btn.getParent("li").get('class');
                    if ($liclass == "about") {
                        classRef.childMenu.setStyle('margin-left', '-80px');
                    }
                }
            });
            new HoosierLottery.ExternalLinks();
            $$('.box .footer', '.box.b2 .header', '.box.b3 .header').each(function (el) {
                var wideframe = new Element('div', {});
                el.grab(wideframe);
            });
            $$('input.datepicker').DatePicker();
        },

        home: function () {
            var params = {
                menu: "false",
                wmode: "transparent"
            };
            swfobject.embedSWF("flash/homeflash.swf", "homeflash", "580", "295", "8.0.0", "flash/expressInstall.html", null, params, null);
        }
    })
}

window.addEvent('domready', function(){
        new HoosierLottery.Pages();
});

