var _xmas_ad = null;

(function ( $ ) {

_xmas_ad = {
    ad_face:    null,
    ad_flash:   null,
    hovered:    false,

    init:       function (  ) {
        this.ad_face = $('#_xmas_ad_face')
            .click(function (  ) {
                    window.location = 'http://www.ipeen.com.tw/ad/adipeen.php?id=76a468697c4b19c32c0d1b0b005273d5';
                })
            .mouseover(function (  ) {
                    _xmas_ad.hovered = true;
                    _xmas_ad.stop().show();
                })
            .mouseout(function (  ) {
                    _xmas_ad.hovered = false;
                    _xmas_ad.async_hide();
                });
        this.ad_flash = $('#_xmas_ad_flash')
            .mouseover(function (  ) {
                    _xmas_ad.hovered = true;
                    _xmas_ad.stop().show();
                })
            .mouseout(function (  ) {
                    _xmas_ad.hovered = false;
                    _xmas_ad.async_hide();
                });
        return this;
    },
    async_hide: function (  ) {
        setTimeout('_xmas_ad.stop().hide();', 2000);
        return this;
    },
    stop:       function (  ) {
        this.ad_flash.stop(true);
        return this;
    },
    show:       function (  ) {
        if( this.hovered )
            this.ad_flash.slideDown('slow');
        // this.ad_flash.fadeIn('slow');
        return this;
    },
    hide:       function (  ) {
        if( !this.hovered )
            this.ad_flash.slideUp('fast', function (  ) { $('#_xmas_ad_flash').height(100); });
            // this.ad_flash.fadeOut('fast');
        return this;
    }
};

function onReady (  ) {
    _xmas_ad.init().show();
    setTimeout('_xmas_ad.hide();', 5000);
}

$(document).ready(onReady);

})(jQuery);
