var VoteItUpURL = "http://www.pitilin.com/3rdParty/voteitup/";

jQuery().ready(function() {
	 setupEvents();
});

function setupEvents() {
	jQuery('div.voteitupDiv').find('img').click(
		function(){
		
			myParent    = jQuery(this).parent('div.voteitupDiv');
			buttonState = myParent.attr('name');
			id          = myParent.find('span[name=myId]').html();
			theMessage  = myParent.find('span[name=myMessage]').html();
			
			switch (buttonState) {
				case'normalState':
					url = VoteItUpURL+'vote.php'+ '?' + Math.round(new Date().getTime());

					jQuery.getJSON(url, 
						{
							elementId: id,
							message: theMessage,
							mode: jQuery(this).attr('name')
						},							
					function(data) {
						myParent.html(data.message);
					});
					
					break;
			}
				
		});
}

