/*
	Page Effects for the RoCS Website – 2009, Christian Thiemann
	Based on AN7effects v1.4 by John Einselen (http://Iaian7.com)
	MooTools v1.2 required
*/

function mouseOverTween(selector, property, normval, overval, resetval) {
	$$(selector).each(function (elem) {
		var fx = new Fx.Tween(elem, {duration: 250, wait: false});
		if ($defined(resetval))
			fx.addEvent('complete', function () {
				if (elem.getStyle(property) == normval)
					elem.setStyle(property, resetval); });
		elem.addEvents({
			'mouseover': function () { fx.start(property, overval); },
			'mouseout': function () { fx.start(property, normval); }
		});
	});
}

function mouseOverMorph(selector, normstyles, overstyles) {
	$$(selector).each(function (elem) {
		var fx = new Fx.Morph(elem, {duration: 250, wait: false});
		elem.addEvents({
			'mouseover': function () { fx.start(overstyles); },
			'mouseout': function () { fx.start(normstyles); }
		});
	});
}

function contentFade(cfFade, cfHide) {
	$$(cfFade).each(function(div){
		var hide = div.getElement(cfHide);
		var mouseFx = new Fx.Tween(hide, {duration: 200, wait: false});
		hide.set('opacity', 0);
//		hide.set('display', 'block');
		div.addEvents({
			'mouseenter': function(){
				mouseFx.start('opacity', [0, 0.9]);
			},
			'mouseleave': function(){
				mouseFx.start('opacity', [0.9, 0]);
			}
		});
	});
}


window.addEvent('domready', function(){
	var smscr = new SmoothScroll();

	killCSSRule('a:hover img');
	mouseOverTween('a img', 'opacity', 1, 0.75);
	
	killCSSRule('#content a:hover');
	killCSSRule('#sidebar a:hover');
	killCSSRule('#content a:hover, #sidebar a:hover');
	mouseOverTween('#content a', 'color', '#3875d7', '#f77538');
	mouseOverTween('#sidebar a', 'color', '#3875d7', '#f77538');
	
	killCSSRule('#navigation .content a:hover');
	mouseOverTween('#navigation .content > ul > li > a', 'background-color', '#6d6d6d', '#999999', 'transparent');
	mouseOverTween('#navigation .content ul ul a', 'background-color', '#c7c7c7', '#999999', 'transparent');
	
	killCSSRule('.tooltipAnchor:hover .tooltip');
	getCSSRule('.tooltip').style.display = 'block';
	contentFade('.tooltipAnchor', '.tooltip');
});