/*Copyright @2010 TOSHIBA TEC CORPORATION
*
*   Licensed under the Apache License, Version 2.0 (the "License");
*   you may not use this file except in compliance with the License.
*   You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*
*  jQuery MegaMenu Plugin
*  Author: GeekTantra
*  Author URI: http://www.geektantra.com
*  Written by TEC INFORMATION SYSTEMS CORPORATION
*/
var isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;

jQuery.fn.megamenu = function(options) {
  options = jQuery.extend({
                              activate_action: "mouseover",
                              deactivate_action: "mouseleave",
                              show_method: "slideDown",
                              hide_method: "simple",
                              justify: "left",
                              enable_js_shadow: true,
                              shadow_size: 1,
                              mm_timeout: 250
                          }, options);
  var $megamenu_object = this;
  if( options.activate_action == "click" ) options.mm_timeout = 0;
	$("li.topMenu").each(function(i){
		i=i+1;
		//グローバルナビにマウスがかかった時の動作
		$("li.topMenu").bind(options.activate_action,function(){
			var item_content_obj = jQuery(this).find("div.submenu"+i);
				//表示
        switch(options.show_method) {
          case "simple":
                item_content_obj.show();
                break;
          case "slideDown":
								item_content_obj.height("auto");
								item_content_obj.slideDown('fast');
                break;
          case "fadeIn":
                item_content_obj.fadeTo('fast', 1);
                break;
          default:
                item_content_obj.each( options.show_method );
                break;
        }
		});
		//グローバルナビからマウスが離れたときの動作
		$("li.topMenu").bind(options.deactivate_action,function(){
			var item_content_obj = jQuery(this).find("div.submenu"+i);
				//非表示
      switch(options.hide_method) {
        case "simple":
              item_content_obj.hide();
              break;
        case "slideUp":
              item_content_obj.slideUp('fast');
              break;
        case "fadeOut":
							item_content_obj.fadeOut('fast');
              break;
        default:
              item_content_obj.each( options.hide_method );
              break;
      }
		});
	});
};

