/**
 * Opens external links in a new window.
 *
 * @requires	jQuery
 */
$('a').each(function(){
	var $this	= $(this);
	var loc		= $this.attr('href');
	
	if (loc.search(/https?:\/\/[^(www.humbird.co.jp)]/i) == 0)
	{
		$this.click(function(e){
			e.preventDefault();
			
			window.open(loc);
		});
	}
});

/**
 * Plays YouTube video in a light box
 *
 * @requires	jQuery
 * @requires	Colorbox
 */
$('#before-after').colorbox({
	iframe:			true,
	innerWidth:		640,
	innerHeight:	490,
});

/**
 * Drop down menu
 *
 * @requires	jQuery
 * @param		jQuery object
 */
(function($element){
	
	var timeoutId		= 0,
		$thisElement	= null,
		slideSpd		= 100,
		showIt			= function(){
			$thisElement.children('ul').stop(true, true).slideDown(slideSpd);
		};
	
	$element.hover(function(){
		$thisElement	= $(this);
		timeoutId		= setTimeout(showIt, 400);
	}, function(){
		clearTimeout(timeoutId);
		$(this).children('ul').stop(true, true).slideUp(slideSpd);
	});
	
})($('.method'));

$('#menu-main-menu > li').has('ul').children('a').removeAttr('href').css('cursor', 'default');
