(function()
{
    if ( 'undefined' == typeof(jQuery) ) {
        var script  = document.createElement('script');
        script.src  = 'http://www.sensya.com/js/jquery.js';

        if ( 0 <= navigator.userAgent.indexOf('MSIE') ) {
            script.onreadystatechange   = function()
            {
                if ( !('complete' == script.readyState || 'loaded' == script.readyState) ) return false;
                build();
            }
        } else {
            script.onload   = function()
            {
                build();
            }
        }
        document.getElementsByTagName('head')[0].appendChild(script);
    } else {
        build();
    }

    function build()
    {
        $(document).ready(function()
        {
            var html = ''
                + '<div id="keepre-dock-fixed" style="position: fixed; bottom: 0; width: 100%; color:#FFFFFF; font-size: 10px; letter-spacing: -0.03em; text-align: center; overflow:hidden;">'
                    + '<div id="keepre-dock-shade" style="position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: #2C224A; padding: 10px 0; filter:alpha(opacity=80); opacity: 0.8;"></div>'
                    + '<ul style="position: relative; z-index: 1; width: 712px; _width: 728px; /*width: 90%;*/ margin: 0 auto; _margin: 0; padding: 10px 0 0 0; text-align: left; list-style-type: none;">'
                        + '<li style="float: left; width: 168px; margin: 0 5px; padding: 0;"><a href="http://www.keepercoating.jp/"><img src="http://sensya.com/images/footerBanner/keepre.gif" width="168" height="40" alt="KeePer" style="margin: 0 0 5px 0; border: none;" /></a><br />キーパープロショップと店舗検索</li><li style="float: left; width: 168px; margin: 0 5px; padding: 0;"><a href="http://www.keeperlabo.jp/"><img src="http://sensya.com/images/footerBanner/kaisentai.gif" width="168" height="40" alt="KeePerLABO" style="margin: 0 0 5px 0; border: none;" /></a><br />洗車とコーティングのトータルショップ</li><li style="float: left; width: 168px; margin: 0 5px; padding: 0;"><a href="http://sensya.com/" style=""><img src="http://sensya.com/images/footerBanner/sensya.gif" width="168" height="40" alt="洗車.com" style="margin: 0 0 5px 0; border: none;" /></a><br />プロ達の3つのブログ</li><li style="float: left; width: 168px; margin: 0 5px; padding: 0;"><a href="http://keepercoating.jp/corp/"><img src="http://sensya.com/images/footerBanner/business.gif" width="168" height="40" alt="ビジネス" style="margin: 0 0 5px 0; border: none;" /></a><br />全国のSS・洗車に関わる人達へ</li>'
                    + '</ul>'
                    + '<hr style="clear: left;visibility: hidden;"/>'
                + '</div>'
            ;

            $('body').append(html);

            var minH = 60;
            var h   = $('#keepre-dock-fixed').height();
            $('#keepre-dock-fixed').height(minH);

            var overed      = false;
            var animated    = false;
            $('#keepre-dock-fixed').mouseover(function(e)
            {
                if ( animated ) return false;
                if ( overed ) return false;

                var obj = {height : h};
                if ( $.browser.msie && 7 > $.browser.version ) obj['top']  = $(this).offset().top - (h - minH);

                animated    = true;
                $('#keepre-dock-fixed').animate(obj, function(){animated = false;});
                overed  = true;
            });

            $('#keepre-dock-fixed').mouseout(function(e)
            {
                if ( animated ) return false;
                if ( !overed ) return false;

                if ( $(this).offset().top <= (e.pageY - 5) ) return false;
                var obj = {height:minH};
                if ( $.browser.msie && 7 > $.browser.version ) obj['top']  = $(this).offset().top + (h - minH);

                animated    = true;
                $('#keepre-dock-fixed').animate(obj, function(){animated = false});
                overed  = false;
            });

            if ( $.browser.msie && 7 > $.browser.version ) {
                $('#keepre-dock-shade').css('left', '0px').css('top', '0px');
                $('#keepre-dock-fixed').css('position', 'absolute').css('left', '0px').css('top', (document.documentElement.clientHeight || document.body.clientHeight) - $('#keepre-dock-fixed').height() + (document.documentElement.scrollTop || document.body.scrollTop) + 'px');
                $(window).scroll(function(){ $('#keepre-dock-fixed').css('position', 'absolute').css('left', '0px').css('top', (document.documentElement.clientHeight || document.body.clientHeight) - $('#keepre-dock-fixed').height() + (document.documentElement.scrollTop || document.body.scrollTop) + 'px') });
                $(window).resize(function(){ $('#keepre-dock-fixed').css('position', 'absolute').css('left', '0px').css('top', (document.documentElement.clientHeight || document.body.clientHeight) - $('#keepre-dock-fixed').height() + (document.documentElement.scrollTop || document.body.scrollTop) + 'px') });
            }
        });
    }
})();


