window.addEvent('domready',function() {
									
	/* TIPS */
	
	var myTips = new Tips('p.hint span', {
		'className': 'toolTip',
		'offset': {
			'x': -180,
			'y':0
		},
		'fixed': true
	});
	
	/* SLIDER */
	
	var Slider = new Class({
		Implements: [Chain,Options,Events],
		initialize: function(slider) {
			if(!$(slider)) return;
			
			// Hide everything below the top slide
			$$('.hide').each(function(el) {
				el.set('opacity',0);						 
			});
			
			this.slider_items = $$('.slider_item');
			this.current_slide = 0;
			this.next_slide = this.slider_items.length > this.current_slide ? this.current_slide + 1 : 0;
			
			/* THIS WORKS:
			if(this.next_slide >= 1) this.goTo.bind(this).periodical(5000);
			*/
			
			if(this.next_slide >= 1) {
				this.timer = function() {
					this.goTo();
				}.bind(this).periodical(4000);
			}
			
			this.createPager();
		},
		createPager: function() {
			// Attach events to each slider number
			pager_anchors = $$('.pager a');
			
			pager_anchors.each(function(pager) {
				pager.addEvent('click',function() {
					var pager_request = parseInt(pager.get('text')) - 1;
					
					$clear(this.timer);
					
					if(pager_request != this.current_slide) {
						//alert(pager_request);
						this.goTo(pager_request);	
					}
				}.bind(this));
			}.bind(this));
		},
		goTo: function(slider_num) {	
		
			if($chk(slider_num)) {
				this.next_slide = slider_num;
			}
			
			this.slider_items[this.current_slide].fade('out');
			this.slider_items[this.next_slide].fade('in');
			this.current_slide = this.next_slide;
			this.next_slide = this.slider_items.length > this.current_slide + 1 ? this.current_slide + 1 : 0;
		}
	});
	
	var slider = new Slider('slider');
	
	/* END SLIDER */
	
	/* INLINE LIST BOX HIGHLIGHTS */
	
	var inlineListBoxes = $$('.inline-list-box ul.sequence');
	
	if(inlineListBoxes.length > 0) {
		inlineListBoxes.each(function(el) {
			var currentEl = el.getFirst();
			(function() {
				currentEl.highlight();  
				currentEl = currentEl.getNext() ? currentEl.getNext() : el.getFirst();
			}).periodical(750);
		});
	}
	
	/* ADD PLUS SIGN NEXT TO MENU ITEMS WITH SUB MENUS */
	
	var menuItems = $$('#menu-primary-menu li');
	
	menuItems.each(function(el) {
		if(el.getElement('ul.sub-menu')) {
			
			var anchorText = el.getElement('a').get('text');
			
			el.getElement('a').set('text', '');
			
			var wrapper = new Element('span', {
				'class':'submenu-icon',
				'text':anchorText
			}).inject(el.getElement('a'), 'top');
			
		}
	});
});
