﻿/**
 * @require jQuery
 * @require jQuery easing
 */

$(function() {
	Kaas.preloadStyle.destroy();
	
	/**
	 * Mega Dropdown Menu
	 */
	var target = $('#dropdown');
	var menu   = $('#megaNav').fadeOut(0).addClass('hide');
	target.mouseenter(function() {
		menu.removeClass('hide').stop().fadeTo(500, 1);
	});
	target.mouseleave(function() {
		menu.fadeOut(500, function() {
			menu.stop().addClass('hide');
		});
	});
	
	/**
	 * Smooth Scroll
	 */
	$('a[href*=#]').click(function () {
		var wH = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
		if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
			var target = $(this.hash);
			target = target.length && target;
			if (target.length) {
				// var targetOffset = (this.hash != '#informations') ? target.offset().top : $('body').height() - wH;
				$('html,body').animate({
					scrollTop: target.offset().top
				}, 1000, 'easeOutExpo');
				return false;
			}
		}
	});
	
	/**
	 * lightbox
	 */
	if ($.fn.lightBox) {
		var lightboxPath = Kaas.root() + 'lib/jquery/lightbox/images/';
		$('.lightbox').lightBox({
			imageLoading:  lightboxPath + 'lightbox-ico-loading.gif',
			imageBtnClose: lightboxPath + 'lightbox-btn-close.gif',
			imageBtnPrev:  lightboxPath + 'lightbox-btn-prev.gif',
			imageBtnNext:  lightboxPath + 'lightbox-btn-next.gif',
			imageBlank:    lightboxPath + 'lightbox-blank.gif'
		});
	}
});
