function sendVote (rating, voteTotal, cid, spryid, url) {
	rating = (rating > 0) ? 1 : -1;
    var submitUrl  = url + "&vote=" + rating + "&cid=" + cid;
	new Request({
		url: submitUrl, 
		method: 'get',
		
		onSuccess: function(response){
			var scoreBoard = $$('.score');
			var thanks = $$('.vote-options');
			var parseReponse = response.split( '~' );
			var voteCount = (parseReponse[0] > 0) ? '+' + parseReponse[0] : parseReponse[0];
			
			//need to update this when voting more than once on a page
			scoreBoard[0].set('html',voteCount);
			thanks[0].set('html','thanks').addClass('thanks');
			//$('votetotal').set('html',voteTotal);
			Cookie.write('service', voteTotal + '~' + spryid, {duration: 30});
		}
	}).send(null);
}

var Voting = {
	vote: function(rating, voteHistory, cid, url){
		var rating = (rating > 0) ? 1 : -1;
	    var submitUrl  = url + "&vote=" + rating + "&cid=" + cid;
		this.send(submitUrl, voteHistory, cid);
	},
	
	send: function(submitUrl, voteHistory, cid){
		var subthis = this;  
		new Request({
			url: submitUrl, 
			method: 'get',

			onSuccess: function(response){
				var parseReponse = response.split( '~' );
				var voteScore = (parseReponse[0] > 0) ? '+' + parseReponse[0] : parseReponse[0];
				subthis.setHtml(voteScore, cid);
				subthis.setCookie(voteHistory, cid);
			}
		}).send(null);
	},
	
	setHtml: function(voteScore, cid){
		$('score-' + cid).set('html',voteScore);
		$('status-' + cid).set('html','thanks').addClass('thanks'); 
	}, 
	
	setCookie: function(voteHistory, cid){
		Cookie.write('service', voteHistory + '~' + cid, {duration: 30});	
	}
};

