$(document).ready(function() {
	$('.note').each(function() {

		var noteLink = $('#' + this.id + '_link');
		
		if (noteLink != null) {

			$(this).addClass('positioned');
			$(this).hide();
			noteLink.note = this;
			
			noteLink.bind('mouseover', {note: this},  function(event) {
				var note = event.data.note;
				$(note).show();
				note.style.top  = ($(this).position().top - $(note).height()) + "px";
			});
			noteLink.bind('mouseout', {note: this}, function(event, options) {
				var note = event.data.note;
				$(note).hide();
			});
		}
	});
	
	$('input[rel=toggle], input[rel=inv_toggle]').each(function() {
		var eventFunction = function(event) {
			var toggle = options.toggle;
			var enable = $(toggle).attr('rel') == 'toggle' ? $(toggle).is(':checked') : !$(toggle).is(':checked');

			$('.' + $(toggle).attr('class')).each(function() {

				if (this != toggle) {
					if (enable) {
						$(this).removeClass('disabled');
						$(this).remove('div.mask');
						$('input', this).each(function() {
							$(this).removeAttr('disabled');
						});

					} else {
						$(this).addClass('disabled');

						var mask = document.createElement('div');
						$(mask).addClass('mask');
						this.appendChild(mask);

						$('input', this).each(function() {
							$(this).attr('disabled', 'disabled');
						});
					}
				}
			});
		};

		var options = {toggle: this};
		eventFunction({data: options});
		$(this).bind('change', options, eventFunction);
		$(this).bind('click', options, eventFunction);
	});
});
