Fx.Morph = Fx.Styles.extend({

	start: function(className){
		
		var to = {};
		
		$each(document.styleSheets, function(style){
			var rules = style.rules || style.cssRules;
			$each(rules, function(rule){
				if (!rule.selectorText.test('\.' + className + '$')) return;
				Fx.CSS.Styles.each(function(style){
					if (!rule.style || !rule.style[style]) return;
					var ruleStyle = rule.style[style];
					to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
				});
			});
		});
		return this.parent(to);
	}
	
});

Fx.CSS.Styles = ["backgroundColor", "backgroundPosition", "color", "width", "height", "left", "top", "bottom", "right", "fontSize", "letterSpacing", "lineHeight", "textIndent", "opacity"];
Fx.CSS.Styles.extend(Element.Styles.padding);
Fx.CSS.Styles.extend(Element.Styles.margin);
Element.Styles.border.each(function(border){
	['Width', 'Color'].each(function(property){
		Fx.CSS.Styles.push(border + property);
	});
});


function setupMenu() {
		var navOPFX=$('navcontainer').effect('opacity', {duration: 500, transition: Fx.Transitions.Expo.easeIn, wait: false});
		var navHFX=$('navcontainer').effect('height', {duration: 600, transition: Fx.Transitions.Sine.easeIn, wait: false});
		var list = $$('#navcontainer ul ul');
		var headerImageHeight=($('headerImage').getSize().size.y);
		if (headerImageHeight==0) {
			headerImageHeight=220;
			}
		
		$('navcontainer').addEvents({
			'mouseenter': function() {
				navOPFX.start(0.8);
				if ($defined($E('#navcontainer ul ul'))) {
					navHFX.start(headerImageHeight);
				}
				$$('#navcontainer ul ul').each(function(list){
					list.effects({duration: 1500, transition: Fx.Transitions.Expo.easeIn}).start({'opacity':[0.9]});
					});
				},
			'mouseleave': function() {
				navOPFX.start(0.6);
				navHFX.start(25);
				$$('#navcontainer ul ul').each(function(list){
					list.effects({duration: 500, transition: Fx.Transitions.Expo.easeOut}).start({'opacity':[0]});
					});
				nav.setStyle('overflow','hidden');
				}
		});

			
$$('#navcontainer a').each(function(navitem){
	navitem.setProperty('class','morph1');
	var myMorph = new Fx.Morph(navitem, {wait: false, duration: 500});
	
	navitem.addEvent('mouseenter', function(e){
			//new Event(e).stop();
			myMorph.start('morph2');
			});

	navitem.addEvent('mouseleave', function(e){
			//new Event(e).stop();
			myMorph.start('morph1');
			});
			myMorph.start('morph1');
	});
	$$('#breadcrumbcontainer a').each(function(bread){
	bread.setProperty('class','morph1');
	var breadMorph = new Fx.Morph(bread, {wait: false, duration: 500});
	
	bread.addEvent('mouseenter', function(e){
			//new Event(e).stop();
			breadMorph.start('morph2');
			});

	bread.addEvent('mouseleave', function(e){
			//new Event(e).stop();
			breadMorph.start('morph1');
			});
			breadMorph.start('morph1');
	});
};
