var MooTip = {
	start: function(){
		var customTips = $$('#navi li.lion a');

		customTips.each(function(e) {  
			var content = e.getParent();
			content = content.getChildren('span');
			e.store('tip:text', content[0]);  
		});  

		var toolTips = new Tips(customTips, {
									className: 'mooTip', 
									fixed: 'true', 
									showDelay: 500, hideDelay: 500,
									offsets: { x: 200, y: -100 },

									onShow: function(toolTipElement){
											toolTipElement.fade(1);
									},

									onHide: function(toolTipElement){
											toolTipElement.fade(0);
									}
		});
	}
};

var SiteFLIR = {
	start: function(){
		FLIR.init( { path: webroot + '/js/common/libraries/facelift/' } );

		FLIR.replace( '*.flir-standard', new FLIRStyle({ cFont:'cocon_regular', mode:'fancyfonts', ff_Wrap:true }) );
		FLIR.replace( '*.flir-slim', new FLIRStyle({ cFont:'cocon_light', mode:'fancyfonts', ff_Wrap:true }) );
		FLIR.replace( '*.quote', new FLIRStyle({ cFont:'cocon_regular', mode:'fancyfonts', ff_Wrap:true }) );

		FLIR.replace( 'div.feature h2', new FLIRStyle({ cFont:'cocon_regular', mode:'fancyfonts', ff_Wrap:true }) );
		FLIR.replace( 'a.feature span', new FLIRStyle({ cFont:'cocon_regular', mode:'fancyfonts' }) );
		FLIR.replace( 'div#headline div p.headline', new FLIRStyle({ cFont:'cocon_regular', mode:'fancyfonts', ff_Wrap:true }) );

		var features = $$('a.feature');
		features.each(function(el){
			el.addEvent('mouseenter', function() {
				img = el.getChildren('span');
				img = img[0].getChildren('img');
				src = unescape(img.getProperty('src'));

				src = src.replace('rgb(8, 87, 158)','rgb(253, 180, 12)');
				src = src.replace(/08579E/i,'fdb40c');
				img.setProperty('src', src);

			}); 

			el.addEvent('mouseleave', function() {
				img = el.getChildren('span');
				img = img[0].getChildren('img');
				src = unescape(img.getProperty('src'));

				src = src.replace('rgb(253, 180, 12)','rgb(8, 87, 158)');
				src = src.replace(/fdb40C/i,'08579e');
				img.setProperty('src', src)				
			}); 
		});
	}
}

var Site = {
	start: function(){
		SiteFLIR.start();
		if(typeof(Tips) !== 'undefined'){ MooTip.start(); }
	}
}

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