﻿// For ColorBox

$(document).ready(function(){
		//Examples of how to assign the ColorBox event to elements
			$("a[rel='itemdetail']").colorbox({transition:"fade",width:"60%", height:"60%"});
			$(".ukraine").colorbox({innerWidth:"810px", innerHeight:"430px", iframe:true});
			$(".attention").colorbox({innerWidth:"810px", height:"400px", iframe:true});
			});


// For DwImageProtector

	$(window).bind('load', function() {
		$('img.protect').protectImage();
	});
	

// For hoverIntent

$(document).ready(function() {
	function megaHoverOver(){
		$(this).find(".hb-sub").stop().fadeTo('fast', 1).show();
		$(this).find(".lsb-sub").stop().fadeTo('fast', 1).show();
		$(this).find(".acs-sub").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".hb-sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".hb-sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".hb-sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
			$(this).find(".lsb-sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
			$(this).find(".acs-sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}


	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 500, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#gNavi li .hb-sub").css({'opacity':'0'});
	$("ul#gNavi li").hoverIntent(config);
	$("ul#gNavi li .lsb-sub").css({'opacity':'0'});
	$("ul#gNavi li").hoverIntent(config);
	$("ul#gNavi li .acs-sub").css({'opacity':'0'});
	$("ul#gNavi li").hoverIntent(config);

});


// For LocalScroll
// Easingの追加
jQuery.easing.quart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

/*-------------------------------------
 ページ読み込み中
-------------------------------------*/
jQuery(document).ready(function(){

	jQuery('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = jQuery(this.hash);
			$target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				jQuery('html,body').animate({ scrollTop: targetOffset }, 1200, 'quart');
				return false;
			}
		}
	});

});
