/**
 * current_page.js
 *
 * @author    Masuda <h-masuda@ttib.jp>
 * @pachage   Wedding
 * @see       jquery-1.3.2.js
 * @copyright JOYJOY Inc. & Gourmet Navigator Inc.
 * @version   $Id: current_page.js 436 2009-11-04 08:16:45Z u-iwasaki@ttib.jp $
 */

/**
 * 左サイドメニューの該当ページの項目の背景を反転させる
 *
 */
jQuery(function($){

    $(document).ready(function(){

        var path_name = window.location.pathname;

        var file_name = path_name.substring(path_name.lastIndexOf("/") + 1, path_name.length)

        var page_3 = file_name.substr(0,3);

        var page_type = '';
        switch (page_3) {
            case 'ind':
                var name2 = file_name.substr(0,9);
                if (name2 == 'index.htm') {
                    page_type = 'top';
                } else {
                    page_type = 'map';
                }
                break;
            case 'fai':
                page_type = 'fair';
                break;
            case 'pla':
                page_type = 'plan';
                break;
            case 'cus':
                var num = file_name.substr(6,1);
                page_type = 'custom' + num;
                break;
        }

        var li_id = 'l_m_' + page_type;
        var a_id  = 'l_m_a_' + page_type;

        // 該当ページは背景反転させる
        $('li[id="' + li_id + '"]').attr('class','here');
        var txt = $('a[id="' + a_id + '"]').text();

        // htmlエスケープ
        txt = txt.replace(/&/g, "&amp;");
        txt = txt.replace(/"/g, "&quot;");
        txt = txt.replace(/'/g, "&quot;");
        txt = txt.replace(/</g, "&lt;");
        txt = txt.replace(/>/g, "&gt;");


        var txt = '<span><strong>' + txt + '</strong></span>';

        $('li[id="' + li_id + '"]').html(txt);

    });

  $("#toSearch").click(function(){ $(this).searchSubmit("search_form");return false; });


});

/**
 *  関数
 *
 */
jQuery.fn.extend({
  searchSubmit: function(form_id) {
    var form = $("#"+form_id);
    form.submit();
    return this;
  }

});

