﻿
var tooltips = {
	init : function(o) {
		this.root = $$('.addtips');
		if(this.root != null && this.root != undefined)
		{
			this.items = new Array();
			var _set = $$('*',this.root);
			for(var index = _set.length; index -- > 0;)
			{
				var i = _set[index];
				if(i.getAttribute('title') != null && i.getAttribute('title') != undefined)
				{
					i.addClass('hastip');
					i.onmouseover = function() {this.addClass('hastip-current');};
					i.onmouseout = function() {this.removeClass('hastip-current');};
					this.items.push(i);
				}
			}
			this.tips = new Tips(
				this.items, 
				{
					className: 'features-tip',
					showDelay:'100', hideDelay:'125',
					offsets:{x:16,y:-13}
				});		
	}}, tip : null, root : null, items : null
};

var list = {
	root : '/',
	init : function(element, listurl) {
		element = $(element);
		listurl = this.root + listurl;
		
		if(element == undefined || element == null) return;
		
		var req = new Request.HTML({url:listurl, 
			onSuccess: function(html) {
				//Clear the text currently inside the results div.
				element.set('text', '');
				//Inject the new DOM elements into the results div.
				element.adopt(html);
			},
			//Our request will most likely succeed, but just in case, we'll add an
			//onFailure method which will let the user know what happened.
			onFailure: function() {
				element.set('text', 'Could not load the list of items.');
			}
		});
		
		req.get();
	}
}

window.addEvent('domready', function() {
    //tooltips.init();
    list.init('newslistcurrent', '../../resources/newslistcurrent.html');
    list.init('newslistarchives', '../../resources/newslistarchives.html');
    list.init('eventlistcurrent', '../../resources/eventlistcurrent.html');
    list.init('eventlistarchives', '../../resources/eventlistarchives.html');

    $each($$('#nav li'), function(item, index) {
        item.addEvent('mouseover', function() { this.addClass('hover'); });
        item.addEvent('mouseout', function() { this.removeClass('hover'); });
    });
});


