// Memory Alpha

(function() {
	jQuery.fn.guide = function(settings) {
		settings = jQuery.extend( {
			trigger : "#guideLink"
		}, settings);
		return this.each(function() {
			var containerObj = jQuery(this);
			var triggerObj = jQuery(settings.trigger);
			containerObj.hide();
			containerObj.position( {
				my : 'right top',
				at : 'right top',
				of : settings.trigger
			});
			triggerObj.click(function() {
				//containerObj.show('drop', {direction: 'right'}, 500);
				containerObj.show('scale', {origin: ['top','right']}, 500);
				return false;
			});
			var containerObjMouseleaveFunction = function() {
				//containerObj.hide('drop', {direction: 'right'}, 500);
				containerObj.unbind('mouseleave');
				containerObj.hide('scale', {origin: ['top','right']}, 500, function() {
					containerObj.mouseleave(containerObjMouseleaveFunction);
				});
			};
			containerObj.mouseleave(containerObjMouseleaveFunction);
		});
	};
})(jQuery);

function updateSelect(source, destination, url) {
	var destinationObj = jQuery(destination);
	var sourceObj = jQuery(source);
	jQuery.getJSON(url, { token : sourceObj.val() }, function(data) {
		destinationObj.children().remove();
		for ( var int = 0; int < data.length; int++) {
			var entry = data[int];
			var newOption = jQuery(document.createElement('option'));
			newOption.attr( {
				value : entry.value,
				label : entry.label
			});
			newOption.text(entry.label);
			destinationObj.append(newOption);
		}
	});
}

