/* rx-library.js */

// add classes to "first" and "last" children of node (fast routine)
// 17/09/09
jQuery.fn.RX_markSides = function(Q) {
	return this.each(function() {
		$(this).children(':first').addClass(Q.c_first);
		$(this).children(':last').addClass(Q.c_last);
	});
}
//

// menu drop down : toggling + callbacks
// 24/08/09
jQuery.fn.RX_menu = function(Q) {
	return this.each(function() {
		$(this).hover(
			function() {
				var t = $(this),
						i = t.children('ul');

				if(i.size()) {
					t.addClass('rx-selected');
					i.css( {visibility:'visible', display:'none'}).slideDown('fast');
					//Q.onHover();
				}
			},
			function() {
				var t = $(this),
						i = t.children('ul');

				if(i.size()) {
					t.removeClass('rx-selected');
					i.css( {visibility:'hidden' } );
					//Q.onOut();
				}
			}
		);
	});
}
//

// smooth hover effect based on animated opacity
// 19/09/09
jQuery.fn.RX_smoothHover = function(Q) {
	this.each(function() {
		$(this).hover(
			function() {
				if (!$(this).hasClass(Q.c_dis)) {
					$(this).children('a').animate({opacity:1}, 'fast');
				}
			},
			function() {
				if (!$(this).hasClass(Q.c_dis)) {
					$(this).children('a').animate({opacity:Q.hide}, 'fast');
				}
			}
		);
	});
}
//

// open links in another window
// 01/09/09
jQuery.fn.RX_externalLink = function() {
	return this.each(function() {
		$(this).click(function() {
			window.open($(this).attr('href'));
			return false;
		})
		return;
	});
}
//

jQuery(window).load(function() {
	$('a.rx-el, .rx-el a').RX_externalLink();

	$('.x-archives ul').RX_markSides({
		c_first : 'rx-first',
		c_last : 'rx-last'
	});


	$('.menu-navy li').RX_menu();

});
