/*
* Author: tenten Creative | ten2.tw
*/
$(document).ready(function() {

$('<div id="grayShade"></div>').hide().insertBefore('#wrapper');
$('<div id="grayShade2"></div>').hide().insertBefore('#wrapper');

// Sub Menu On Hover Over
function megaHoverOver(){
    $("#menubox-service").stop().fadeTo('fast', 1).show();
    $('#grayShade').show();
    $('#first-btn-1').addClass('onon');
}
//On Hover Out
function megaHoverOut(){
  $("#menubox-service").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
      $(this).hide();  //after fading, hide it
      $('#grayShade').hide();
      $('#first-btn-1').removeClass('onon');
  });
}
	var config = {    
		 sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 50, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 30, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};
function megaHoverOver2(){
    $("#menubox-else").stop().fadeTo('fast', 1).show();
    $('#grayShade2').show();
    $('#first-btn-2').addClass('onon');
}
//On Hover Out
function megaHoverOut2(){
  $("#menubox-else").stop().fadeTo('fast', 0, function() {
      $(this).hide(); 
      $('#grayShade2').hide();
      $('#first-btn-2').removeClass('onon');
  });
}
	var config2 = {    
		 sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 50, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver2, // function = onMouseOver callback (REQUIRED)    
		 timeout: 30, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut2 // function = onMouseOut callback (REQUIRED)    
	};

	//$(".menu2-box").css({'opacity':'0'});
	$("#menu-service").hoverIntent(config);
	$("#menu-else").hoverIntent(config2);
// End of Sub Menu

// Toggle Feature Button
	$('#menu-toggle').hover(function(){
		if ($(this).hasClass('expend')){return;}
		$(this).removeClass('on');
		$('#menu-sub').addClass('on');
		$('.menu-sub-btn').addClass('on');
		$('#menu-sub-text-box').stop().animate({
			left: -815,
		}, {
			queue:false,
			duration:500,
			easing: 'easeInOutQuint'
		});
	}, function(){
		if ($(this).hasClass('expend')){return;}
		$(this).addClass('on');
		$('#menu-sub').addClass('on');
		$('.menu-sub-btn').removeClass('on');
		$('#menu-sub-text-box').stop().animate({
			left: -863,
		}, {
			queue:false,
			duration:500,
			easing: 'easeInOutQuint'
		});
	}).click(function(){
		if ($(this).hasClass('expend')){
			$(this).removeClass('expend').addClass('on');
			$('#menu-sub').addClass('on');
			$('#menu-sub-text-box').stop().animate({
				left: -815,
			}, {
				queue:false,
				duration:1000,
				easing: 'easeInOutQuint'
			});
		}
		else{
			$('#menu-sub').removeClass('on');
			$(this).addClass('expend').removeClass('on');
			$('#menu-sub-text-box').stop().animate({
				left: 0,
			}, {
				queue:false,
				duration:1000,
				easing: 'easeInOutQuint'
			});
		}
	});


	$('.menu-sub-btn').click(function(){
		$('#menu-toggle').removeClass('expend').addClass('on');
		$('#menu-sub-text-box').stop().animate({
			left: -863,
		}, {
			queue:false,
			duration:1000,
			easing: 'easeInOutQuint'
		});
	});
// End of Toggle Feature Button

  $(".opacity").fadeTo(1, 0);
  $(".opacity").hover(
    function () {
      $(this).stop().fadeTo("normal", 0.6);
    },
    function () {
      $(this).stop().fadeTo("normal", 0);
    }
  );

//Start of Button Hover
			      $('.trail-text').hide().css("opacity", 0);				  
				  $('.btn-work').bind("mouseenter", (function()
				  {
						$(this).children('.trail-text').animate({height: "120px", opacity: 0.9},300);
				  }));
				  $('.btn-work').bind("mouseleave", (function()
				  {
						$(this).children('.trail-text').animate({height: "120px", opacity: 0},200);
				  }));
});
