/**
 *  @class      MightyGear, adapted for Grunge!sta V2
 *
 *  @author     Aldash Biybosunov
 *  @project    MightyTemplate
 *  @license    Commercial
 */

var MightyGear = new Class({
	version: '1.0',
	initialize: function(options) {
		this.options = options;
		url = this.options.url;
		if (this.options.enableLinkHov && $('component').getElement('a')) this.linkHover();
		if (this.options.menu) this.smoothMenu();
		this.markers();
		//this.toTop();
		//this.iewarning();
	},
	linkHover: function() {
		var hov = $('component').getElement('a').getStyle('color');
		$$('#container a').each(function(a) {
			a.setStyle('color', '#000000');
			a.addEvent('mouseover', function() {
				a.setStyle('color', hov);
			});
			var fx = new Fx.Style(a, 'color', {
				duration: 450,
				wait: false
			});
			a.addEvent('mouseout', function() {
				fx.start('#000000');
			});
			$$('a.readon').each(function(readon) {
				readon.removeEvents('mouseout');
				readon.removeEvents('mouseover');
			});
		});
	},
	smoothMenu: function () {
		var delay = this.options.menuDelay;
		this.parent = $('main-nav').getElements('.parent');
		this.parent.each(function(e) {
			var ul = e.getElement('ul');
			var fx = new Fx.Style(ul, 'opacity', {
				duration: delay,
				wait: false
			}).set(0);
			e.addEvent('mouseover', function() {
				fx.start(1);
			});
			e.addEvent('mouseout', function() {
				fx.start(0);
			});
		});
	},
	markers: function() {
		var blue = $$('.marker-blue');
		var yellow = $$('.marker-yellow');
		var pink = $$('.marker-pink');
		var green = $$('.marker-green');
		blue.each(function(e) {
			this.markerStart = new Element('img', {
				src: 'templates/grungesta_v2/images/typography/marker-blue.png',
				styles: {
					'vertical-align': 'top',
					'position': 'relative',
					'width': '12px',
					'height': '18px',
					'top': '1px'
				},
				'class': 'marker-bluehead'
			}).inject(e, 'before');
		});
		yellow.each(function(e) {
			this.markerStart = new Element('img', {
				src: 'templates/grungesta_v2/images/typography/marker-yellow.png',
				styles: {
					'vertical-align': 'top',
					'position': 'relative',
					'width': '12px',
					'height': '18px',
					'top': '1px'
				},
				'class': 'marker-yellowhead'
			}).inject(e, 'before');
		});
		pink.each(function(e) {
			this.markerStart = new Element('img', {
				src: 'templates/grungesta_v2/images/typography/marker-pink.png',
				styles: {
					'vertical-align': 'top',
					'position': 'relative',
					'width': '12px',
					'height': '18px',
					'top': '1px'
				},
				'class': 'marker-pinkhead'
			}).inject(e, 'before');
		});
		green.each(function(e) {
			this.markerStart = new Element('img', {
				src: 'templates/grungesta_v2/images/typography/marker-green.png',
				styles: {
					'vertical-align': 'top',
					'position': 'relative',
					'width': '12px',
					'height': '18px',
					'top': '1px'
				},
				'class': 'marker-greenhead'
			}).inject(e, 'before');
		});
	}
	/*iewarning: function() {
		this.popup = new Element('div', {
			styles: {
				'position': 'fixed',
				'top': 0,
				'width': '100%',
				'color': '#e00b0b',
				'background': '#fff',
				'padding': '30px 0',
				'text-indent': '50px',
				'text-align': 'left',
				'z-index': '1200',
				'opacity': 0.8
			},
			id: 'iewarning'
		}).inject($('layout'), 'top');
		this.popup.innerHTML = '<span style="font-size:30px; font-weight:bold;">IE6 Warning</span><br style="margin-bottom:20px;" /><div style="font-size:18px; font-weight:bold;">You are using unsafe and old browser. Website is not fully compatible with it. Please upgrade your browser to the newer version.</div>';
	}
	toTop: function() {
		var back = $('to-top');
		back.addEvent('click', function() {
			this.smooth = new Fx.Scroll(window, {
				duration: 650
			}).toTop();
		});
	}*/
});
MightyGear.implement({
	show: function(e) {
		e.setStyle('opacity', 1);
	}
});
