(function($) {
  $.fn.fullBg = function(){
    var bgImg = $(this);
    
   /* bgImg.addClass('fullBg');*/
  bgImg.addClass('');  
    function resizeImg() {
      var imgwidth = bgImg.width();
      var imgheight = bgImg.height();
      
      var winwidth = $(window).width();
      var winheight = $(window).height();
      
      var widthratio = winwidth / imgwidth;
      var heightratio = winheight / imgheight;
      
      var widthdiff = heightratio * imgwidth;
      var heightdiff = widthratio * imgheight;
    
      if(heightdiff>winheight) {
        bgImg.css({
          width: winwidth+'px',
          height: heightdiff+'px'
        });
      } else {
        bgImg.css({
          width: widthdiff+'px',
          height: winheight+'px'
        });    
      }
    }
    resizeImg();
    $(window).resize(function() {
      resizeImg();
    });
  };
})(jQuery)

jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
  if ((t/=d) < (1/2.75)) {
    return c*(7.5625*t*t) + b;
  } else if (t < (2/2.75)) {
    return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  } else if (t < (2.5/2.75)) {
    return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  } else {
    return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  }
};


jQuery.noConflict();
jQuery(document).ready(function()
{
  jQuery("#background").fullBg();

  var i=1;
  jQuery(".top_navi ul li.level1").each(function(){
  		
  		jQuery(this).addClass("item_"+i);
		i++;
	});

jQuery('.top_navi ul>li').hover(function(){
		jQuery(this).children('ul').stop(true,true).fadeIn(10);
		jQuery(this).addClass('active');
	},function(){
		jQuery(this).children('ul').stop(true,true).fadeOut(10);
		jQuery(this).removeClass('active');
	});

jQuery('.seo_text h1').click(function() {
              jQuery('.seo_text .text').slideToggle('slow', function() {
                
                    if ( jQuery('.seo_text .text').is(':visible')){
                              var pos=jQuery("body").height();
                              jQuery('html,body').animate({scrollTop: pos}, 500);
                    }
                    
                    
              });
            });


});
