function langMenu() {

	$('.sub-menu').hover(function() {
		$(this).stop().animate({paddingRight: '80px'}, 200);
		}, function () { 
		$(this).stop().animate({paddingRight: '0'}, 200);
	});
	
} 

// Slider on front page
sliderProperties = { 
	fx: 'scrollLeft', 
	prev: '#prev-slide', 
	next: '#next-slide',
	pager: '#slider-nav ul',
	timeout: 10000,
	speed: 2000,
	manualTrump: true,
	pagerAnchorBuilder: function(idx, slide) {
		return '<li><a href="#'+ idx +'"><span>' + $(slide).attr('data-metainfo') +  '</span></a></li>';
	}
};

// Contact modal view
fancyFrameProperties = {
	'autoScale': false,
	'type': 'iframe',
	'width': 370,
	'height': 540
};

youtubeProperties = {
	'autoScale': false,
	'type': 'iframe',
	'width': 852,
	'height': 480
};

// Client Bubble
function bubble() {
    $('.client-logo').each(function () {
        var distance = 10;
        var time = 250;
        var hideDelay = 0;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;

        var trigger = $('.trigger', this);
        var popup = $('.client-quote', this).css('opacity', 0);

        $([trigger.get(0), popup.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);

            if (beingShown || shown) {
                return;
            } else {
                beingShown = true;

                popup.css({
                    bottom: 116,
                    left: 12,
                    display: 'block'
                })

                .animate({
                    bottom: '+=' + distance + 'px',
                    opacity: 1
                }, time, 'swing', function () {

                    beingShown = false;
                    shown = true;

                });
            }
        }).mouseout(function () {

            if (hideDelayTimer) clearTimeout(hideDelayTimer);

            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                popup.animate({
                    bottom: '+=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    popup.css('display', 'none');
                });
            }, hideDelay);

        });

    });
}

//Tabs
(function ($) {
    $.organicTabs = function (el, options) {

        var base = this;
        base.$el = $(el);
        base.$nav = base.$el.find(".nav");

        base.init = function () {

            base.options = $.extend({}, $.organicTabs.defaultOptions, options);

            // Accessible hiding fix
            $(".hide").css({
                "position": "relative",
                "top": 0,
                "left": 0,
                "display": "none"
            });

            base.$nav.delegate("li > a", "click", function () {

                // Figure out current list via CSS class
                var curList = base.$el.find("a.current").attr("href").substring(1),

                    // List moving to
                    $newList = $(this),

                    // Figure out ID of new list
                    listID = $newList.attr("href").substring(1),

                    // Set outer wrapper height to (static) height of current inner list
                    $allListWrap = base.$el.find(".list-wrap"),
                    curListHeight = $allListWrap.height();
                $allListWrap.height(curListHeight);

                if ((listID != curList) && (base.$el.find(":animated").length == 0)) {

                    // Fade out current list
                    base.$el.find("#" + curList).fadeOut(base.options.speed, function () {

                        // Fade in new list on callback
                        base.$el.find("#" + listID).fadeIn(base.options.speed);

                        // Adjust outer wrapper to fit new list snuggly
                        var newHeight = base.$el.find("#" + listID).height();
                        $allListWrap.animate({
                            height: newHeight
                        });

                        // Remove highlighting - Add to just-clicked tab
                        base.$el.find(".nav li a").removeClass("current");
                        $newList.addClass("current");

                    });

                }

                // Don't behave like a regular link
                // Stop propegation and bubbling
                return false;
            });

        };
        base.init();
    };

    $.organicTabs.defaultOptions = {
        "speed": 300
    };

    $.fn.organicTabs = function (options) {
        return this.each(function () {
            (new $.organicTabs(this, options));
        });
    };

})(jQuery);

$(document).ready(function() {
	langMenu();
});

