$(function () {
	P.module('ideas', function () {
		var $el = $('#idea_popup'),
			$toggle = $('#go_ideas');

		function show (e) {
			$(this).addClass('selected').find('.toggle').text('-');
			$el.css({
				opacity: 0,
				left: $(this).offset().left + 'px',
				top: $(this).offset().top + $(this).height() + 'px'
			}).animate({
				opacity: 1
			}, 400);
			return this;
		}

		function hide () {
			$toggle.removeClass('selected').find('.toggle').text('+');
			$el.animate({
				opacity: 0
			}, 400, function () {
				$(this).css('left', '-9999px');
			});
			return this;
		}

		function toggle (e) {
			return ($toggle.hasClass('selected')? hide: show).call(this, e);
		}

		return {
			show: show,
			hide: hide,
			toggle: toggle,
			init: function () {
				$el.css('opacity', 0).appendTo('body').click(function () {

				});
				$toggle.click(function (e) {
					toggle.call(this, e);
					return false;
				});
				$el.find('.close').click(hide);
				//$('body').click(hide);
				return true;
			}()
		};
	});	
});