/** POLL **/
Poll = {};
Poll.lightbox;
Poll.currentPoll = 1;
Poll.show = function(pollId)
{
	this.currentPoll = pollId;
		
	Ajax.HTML(
		'/poll/'+ this.currentPoll,
		{
			success: function(html)
			{
				Poll.lightbox = new WK.Lightbox(html);
				Poll.lightbox._absolute = true;
				Poll.lightbox._destroyOnHide = true;
				Poll.lightbox.show();
			}
		}
	);
}

Poll.login = function()
{
	window.scrollTo(0, 0);
	if (Poll.lightbox) {
		Poll.lightbox.hide();
	}
	Auth.refreshPage = BASE_URL + '/fortune/pollpop';
	Auth.display();
}

Poll.submit = function()
{
	if (Auth.loggedIn == false) {
		doubleTrack('GO_charity_logintovote');
		Auth.refreshPage = BASE_URL + '/fortune/pollpop';
		Auth.display();
	} else {

		if ($("input[name='poll_item_id']:checked").val() == null) {
			$('.errors').html('<li>Please select a charity.</li>');
		} else {
			$.post(BASE_URL+'/poll/'+ this.currentPoll +'/format/html', $('#pollForm').serialize(), function(data) {
				$('#pollContainer').html(data);
				doubleTrack('GO_charity_vote_submit');
				Poll.lightbox.center();
				window.scrollTo(0, 0);
			});
		}
	}
	
	return false;
}

/** CHARITY MORE **/
PollMore = {};
PollMore.lightbox;
PollMore.show = function()
{
	
	if (Poll.lightbox) {
		Poll.lightbox.hide();
	}
	
	Ajax.HTML(
		'/fortune/charitymore',
		{
			success: function(html)
			{
				doubleTrack('GO_charity_more_info');
				PollMore.lightbox = new WK.Lightbox(html);
				//PollMore.lightbox._customClass = 'topMargin';
				PollMore.lightbox.show();
				window.scrollTo(0, 0);
			}
		}
	);
}

