var ROOT = '/';

$(document).ready(function() {
    $('#lmenu > li').each(function() {
        if ($(this).find('ul').is('.second_cate')) {
            $(this).hover(function() {
                $(this).find('.second_cate').show();
            }, function() {
                $(this).find('.second_cate').hide();
            });
        }
    });

    if (eflg != 0) {
        alert(eflg);
    }
    $('#ulogin').click(function() {
        var loginForm = '<div id="login">\n' +
                                 '<h2>メンバーログイン</h2>\n' +
                                 '<div class="close"><img src="' + ROOT + 'common/img/icon_close.gif" /></div>\n' +
                                 '<p>お客様のメールアドレスとパスワードを入力して[ログイン]ボタンをクリックしてください。</p>\n' +
                                 '<form method="post" action="' + ROOT + 'login/">\n' +
                                 '<table>\n' +
                                 '<tr>\n' +
                                 '<th>メールアドレス</th>\n' +
                                 '<td><input type="text" name="login_id" size="30" class="email" /><span class="ml10">※半角英数字のみ</span>\n' +
                                 '<p class="mt5 ml10">例：info@whogot.jp</p></td>\n' +
                                 '</tr>\n' +
                                 '<tr>\n' +
                                 '<th>パスワード</th>\n' +
                                 '<td><input type="password" name="passwd" size="30" class="email" /><span class="ml10">※半角英数字のみ</span></td>\n' +
                                 '</tr>\n' +
                                 '</table>\n' +
                                 '<p class="btn">\n' +
                                 '<input type="image" src="' + ROOT + 'common/img/btn_login.gif" alt="ログイン" />\n' +
                                 '</p>\n' +
                                 '</form>\n' +
                                 '</div>\n';

//        var loginForm = '<div id="login">\n' +
//                                '<h1><img src="' + ROOT + 'login/img/title_logins.gif" alt="メンバーログイン" /></h1>\n' +
//                                '<div class="box">\n' +
//                                '<p>お客様のメールアドレスとパスワードを入力して[ログイン]ボタンをクリックしてください。<br />\n' +
//                                '必須入力項目は<span class="blue">＊</span>をつけていますので、必ず入力してください。</p>' +
//                                '<form method="post" action="' + ROOT + 'login/">\n' +
//                                '<table summary="メンバーログイン">\n' +
//                                '<tr>\n' +
//                                '<th><span class="blue">＊</span> メールアドレス</th>\n' +
//                                '<td><input type="text" name="login_id" size="30" class="email" /><span class="ml10">※半角英数字のみ</span>\n' +
//                                '<p class="mt5 ml10">例：info@whogot.jp</p></td>\n' +
//                                '</tr>\n' +
//                                '<tr>\n' +
//                                '<th><span class="blue">＊</span> パスワード</th>\n' +
//                                '<td><input type="text" name="passwd" size="30" class="email" /><span class="ml10">※半角英数字のみ</span></td>\n' +
//                                '</tr>\n' +
//                                '</table>\n' +
//                                '<p class="btn">\n' +
//                                '<input type="image" src="' + ROOT + 'login/img/btn_login.gif" alt="ログイン" />\n' +
//                                '</p>\n' +
//                                '</form>\n' +
//                                '</div>\n' +
//                                '</div>\n';

        $.blockUI({
            message: loginForm,
            css: {
                width: '480px',
                top: '100px'
            }
        });
        $('div.blockOverlay').click($.unblockUI);
        $('div.close').click($.unblockUI);
        return false;
    });

    $('#ulogout').click(function() {
        location.href = ROOT + 'login/logout.php';
    });

    $('#search input:text').focus(function() {
        if ($(this).val() === '商品検索') {
            $(this).val('');
        }
    });

    $('#search input:text').blur(function() {
        if ($(this).val() === '') {
            $(this).val('商品検索');
        }
    });

    $('#search input:image').click(function() {
        if ($('#search input:text').val() === '' || $('#search input:text').val() === '商品検索') {
            alert('検索語句を入力してください');
            return false;
        }
    });
});
