/**
 * 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 1417 2011-10-06 11:42:22Z okuji-na $
 */

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

    $(document).ready(function(){

      var path_name = window.location.pathname;

      var page_type = '';
      if (path_name.match(/site[_k]*\/[1-5]\/[^/]+\/?$/g)) {
        page_type = 'top';
      } else if (path_name.match(/^.*\/(index|plan|fair|mw|custom[1-6])\.htm$/g)) {
        page_type = (RegExp.$1 == 'index') ? 'top' : RegExp.$1;
      } else if (path_name.match(/^.*\/(plan)\/[\d]+\/?$/g)) {
        page_type = RegExp.$1;
      } else if (path_name.match(/^\/user[1-5]\/map\//g)) {
        page_type = 'map';
      } else if (path_name.match(/^\/user[1-5]\/fair\//g)) {
        page_type = 'fair';
      } else if (path_name.match(/^\/user[1-5]\/mw\//g)) {
        page_type = 'maruwakari';
      }

        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();
        
        if(page_type == 'maruwakari'){
          txt = $('a[id="' + a_id + '"]').html();
        }else{
	        // 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;
  }

});

