App = {
	parseExternalLinks: function()
	{
		$$('a[rel=external]').each(function(link) {
			link.addClassName('external');
			/*link.observe('click', function(event) {
				event.stop();
				window.open(event.target.href, new Date().getTime()).focus();
			});*/						
		});
	},
	addPrintLink: function()
	{
		if (!window.print) {
			return;
		}		
		var span = new Element('span').update('Print Page');
		var li = new Element('li', {id: 'links_print'}).update(span);
		span.observe('click', function() {
			window.print();				  
		});
		if (pointer = $('links_tell')) {
			pointer.insert({after: li});
		} else if (pointer = $('links_comment')) {
			pointer.insert({after: li});			
		} else {
			$$('#links ul')[0].insert({top: li});
		}
	}
};

document.observe('dom:loaded', function() {
	App.parseExternalLinks();
	if (App.print) {
		//App.addPrintLink();
	}
});

Vote = {

  choice: -1,

  mark: function(obj)
  {
    this.choice = obj.value;
  },

  post: function(poll_id)
  {
    if (this.choice == -1) { alert('Make a selection first'); return; }
    document.body.style.cursor = 'wait';
    new Ajax.Request('/vote-do.html?vid='+poll_id+'&cid='+this.choice,
      {
        method: 'get',
        onSuccess: function(request)
        {
          var response = request.responseText || "Vote registering error.";
          document.getElementById('votearea').innerHTML = response;
          document.body.style.cursor = 'default';
        },
        onFailure: function()
        {
          document.getElementById('votearea').innerHTML = "Vote registering error.";
          document.body.style.cursor = 'default';
        }
      });
  }

};


