var Jack = {
	start: function ()
	{
		var hoverColor;
		var Settings = {
			color: 'default'
		};
		switch (Settings.color) {
		case 'whitegrey':
			hoverColorMenu = '#82B400';
			leaveColorMenu = '#535251';
			hoverColorSubmenu = hoverColorMenu;
			leaveColorSubmenu1 = '#C0C0C0';
			hoverColorSubmenu2 = '#F0F0F0';
			hoverColorModule = '#D7D7D7';
			break;
		default:
			hoverColorMenu = '#3F5C8C';
			leaveColorMenu = '#404858';
			hoverColorSubmenu = hoverColorMenu;
			leaveColorSubmenu1 = '#989AA4';
			hoverColorSubmenu2 = '#F0EDF0';
			hoverColorModule = '#F8F6F6'
		}

		var submenuEnter = {
			'background-color': hoverColorSubmenu
		};

		var submenuLeave = {
			'background-color': leaveColorSubmenu1
		};

		new Morph('div.mod-menu-blank ul.menu a.level1, div.mod-menu-blank ul.menu span.level1', submenuEnter, submenuLeave, {
			transition: Fx.Transitions.expoOut,
			duration: 0,
			ignore: 'div.mod-menu-blank ul.menu li.active a.level1, div.mod-menu-blank ul.menu li.active span.level1'
		},
		{
			transition: Fx.Transitions.sineIn,
			duration: 200
		});
		new SmoothScroll({
			duration: 500,
			transition: Fx.Transitions.Expo.easeOut
		})

		/* Tool Tip */
		var Tips2 = new Tips($$('.tooltip'),
		{
			initialize:function()
			{
				this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
			},
			onShow: function(toolTip)
			{
				this.fx.start(1);
			},
			onHide: function(toolTip)
			{
				this.fx.start(0);
			}
		});
	}
};
var Morph = new Class({
	initialize: function (element, enter, leave, enterFx, leaveFx, elementFx) {
		this.setOptions({
			duration: 500,
			transition: Fx.Transitions.expoOut,
			wait: false,
			ignore: ''
		},
		enterFx);
		var options = this.options;
		var ignore = null;
		if ($chk(options.ignore)) {
			ignore = $$(options.ignore)
		}
		$$(element).each(function (el, i) {
			if (ignore && ignore.contains(el)) return;
			var fxs = [];
			var elfx = [el];
			if (elementFx) {
				elfx = el.getElementsBySelector(elementFx)
			}
			elfx.each(function (elm, i) {
				fxs[i] = new Fx.Styles(elm, options)
			});
			el.addEvent('mouseenter', function (e) {
				fxs.each(function (fx) {
					fx.setOptions(options, enterFx).start(enter)
				})
			});
			el.addEvent('mouseleave', function (e) {
				fxs.each(function (fx) {
					fx.setOptions(options, leaveFx).start(leave)
				})
			})
		})
	}
});

Morph.implement(new Options);
var BackgroundFx = new Class({
	initialize: function (options)
	{
		this.setOptions({
			transition: Fx.Transitions.linear,
			duration: 9000,
			wait: false,
			colors: ['#FFFFFF', '#999999']
		},
		options);
		var body = new Element(document.body);
		var fx = body.effects(this.options);
		var index = 0;
		var colors = this.options.colors;
		var timer = animate.periodical(this.options.duration * 2);
		animate();

		function animate() {
			fx.start({
				'background-color': colors[index]
			});
			if (index + 1 >= colors.length) {
				index = 0
			} else {
				index++
			}
		}
	}
});
BackgroundFx.implement(new Options);



function $E(a, b) {
	return ($(b) || document).getElement(a)
}
function $ES(a, b) {
	return ($(b) || document).getElementsBySelector(a)
}

/* hover fo IE 6 */
sfHover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

window.addEvent('domready', Jack.start);