$(document).ready(function() {
    $('a.Menu_Level2_First_Selected, a.Menu_Level2_Selected, a.Menu_Level2_Last_Selected, a.Menu_Level2_First_Last_Selected').each(function() {
        $('.Menu_bottom:first a').css('color', '#808080');
    });
});

$(document).ready(function() {
    $('.Faq .Top').click(function() {
        var next = $(this).next();
        var intro = $(this).find('.Intro');
        if (next.is(':hidden')) {
            intro.hide();
            next.slideDown(300);
        } else {
            next.slideUp(300, function() { intro.show(); });
        }
    });

    $('.Faq .Close').click(function() {
        var main = $(this).parent();
        main.slideUp(300, function() { main.prev().find('.Intro').show(); });
    });
});







(function ($) {
	$.extend(true, window, {
        ssnSlideShow: slideShow
    });
	
	function slideShow(items, options)
	{
		var defaults = {
			autoRun: 10000
        };
        options = $.extend({}, defaults, options);
		var self = this;
		var pos = 0;
		var max = items.size();
		var timer;
		
		function init() {
			if (options.autoRun != 0)
			{
				timer = setInterval(next, options.autoRun);
			}
		};
		
		function next()
		{
			var oldPos = pos;
			var oldItem = items.eq(pos);
			if (++pos == max) pos = 0;
			var newItem = items.eq(pos);
			self.onChange.notify({item: newItem, pos: pos}, {item: oldItem, pos: oldPos});
		}
		
		function goto(p)
		{
			var oldPos = pos;
			var oldItem = items.eq(pos);
			pos = p;
			var newItem = items.eq(pos)
			self.onChange.notify({item: newItem, pos: pos}, {item: oldItem, pos: oldPos});
		}
		
		function stop()
		{
			clearInterval(timer);
		}
		
        $.extend(this, {
			onChange: new Event(),
			next: next,
			stop: stop,
			goto: goto
        });
		init();
	};
	
	function Event() {
        var handlers = [];
        this.subscribe = function (fn) { handlers.push(fn); };
        this.unsubscribe = function (fn) {
            for (var i = handlers.length - 1; i >= 0; i--) {
                if (handlers[i] === fn) { handlers.splice(i, 1); }
            }
        };
        this.notify = function (scope, args) {
            for (var i = 0; i < handlers.length; i++) {
                handlers[i].call(scope, args);
            }
        };
    };
})(jQuery);



$(document).ready(function() {
    $('div.slideShow').each(function() {
        var items = $(this).children('div');
        var pager = $(this).children('ul');
        var pagerItems = pager.children();

        var slideShow = new ssnSlideShow(items);
        items.filter('.item').hide();
        items.eq(0).show().find('.bgBox').width(272).end().find('.box').show();
        if (items.size() == 1) return;

        slideShow.onChange.subscribe(function(oldItem) {
            var newItem = this;
            oldItem.item.find('.bgBox').width(0);
            oldItem.item.find('.box').hide();
            oldItem.item.fadeOut(200);
            newItem.item.fadeIn(200, function() {
                newItem.item.find('.bgBox').animate({ width: '272px' }, 300, function() {
                    newItem.item.find('.box').show();
                });
            });
            pagerItems.eq(oldItem.pos).removeClass('current');
            pagerItems.eq(newItem.pos).addClass('current');
        });

        pager.click(function(e) { e.preventDefault(); });

        pagerItems.eq(0).addClass('current');

        pagerItems.each(function(i) {
            $(this).click(function() {
                slideShow.stop();
                slideShow.goto(i);
            });
        });
    });
});
