window.addEvent('domready', function(e) {

	var iThanks= $$('.iThank');

		iThanks.each(function(el, i) {

		var iThank_bottom = el.getElement('.iThank_bottom');

		var iThankScore = el.getElement('.iThankScore');

		if(iThank_bottom){

			iThank_bottom.addEvent( 'click', function(evt){

			// send score

			new Ajax('ithank/ithank.php?action=update', {

				method: 'post',

				postBody:'coverid='+el.id,

				onRequest: function(){

				iThank_bottom.effect('opacity', {duration: 1000}).start(0);

				},

				onComplete: function(response){

				var newScore = eval(response);

                    if(!newScore){

                        alert('Ooops there was an error');

                        }else{

					         var fx = iThankScore.effect('opacity', {duration: 1000}).start(0);

								        fx.start().chain(

								        function(){

								        iThankScore.innerHTML=newScore;

								        iThankScore.effect('opacity', {duration: 1000}).start(1);}

								        );
				        }
                    }
			}).request();
		});
	}});
});