  
Ext.onReady(function()
{


	Ext.select('.rate_star').on('click', 
		function (e)
		{
			
			var obj = Ext.get(e.target);
			var information_id = obj.dom.name;
			var rateby = obj.dom.title;
			var tmp_id = 'rate_' + information_id;
			var url = base + '/common/rating/' + information_id + '/' + rateby;

			Ext.get(tmp_id ).dom.innerHTML = 'Loading...'; 

			Ext.Ajax.request({
					method: 'GET',
					url: url,
					scriptTag: true,
					success: function( response )
					{
						rating_star( response.responseText, information_id);

						Ext.get(tmp_id ).dom.innerHTML =  response.responseText + ' out of 5';


					},
				   failure: function()
					{
						alert( 'Server Error try after sometime.');
					}
			});
			


		});


		function rating_star( rating,information_id )
		{
			var r_id;
			for( var i =1; i<=5; i++ )
			{
				if( i <=rating )
				{
					Ext.get( 'recipe_' + information_id + i ).dom.src = base + 'common/get_image/aW1nL3N0YXJfb24uanBn/12/fix';
				}
				else
				{
					Ext.get( 'recipe_' + information_id + i ).dom.src = base + 'common/get_image/aW1nL3N0YXJfb2ZmLmpwZw==/12/fix';
				}
			}
		}
	

});


