
jQuery(document).ready(function() {

		// Catching clicks on any additional link image 
		jQuery("#msRestorationAdditionalImages a").click(function() {

			// Updating attributes of mainImageTag with the href attributes
			$("#restorationMainImage").attr("src",$(this).attr("href"));

			// Finding description with the selecter
			var description = ($(this).find("span.hidden_description").text());
			
			// updating text from the description
			$("#restorationDescription").text(description);
			
			
			return false;
		});
		
		
		jQuery("#set-rating-a a").click(function() {
		
			var route = ($(this).attr("href"));
			
			 $.get(route, function(data){
				  
				 var score = data * 1;
				 var newWidth = 200 / 5 * score;

			/*switch(data){
				
			case "0.5":
			case "1":
			var newWidth = 40;	
			break;
			
			
			case "1.5":
			case "2":
			var newWidth = 80;	
			break;
				
			
			case "2.5":
			case "3":
			var newWidth = 120;	
			break;
			

			case "3.5":
			case "4":
			var newWidth = 160;	
			break;
				

			case "4.5":
			case "5":
			var newWidth = 200;	
			break;
				
			default:
			var newWidth = 0;	
			break;
			
			}
			
	*/
	
	
				 // When voted, empty the rating box and replacing by message + new result
				 $("#rating-box").html("");
				 var dataToInsert = '<div class="already_rated">Thank you for voting!</div><div class="content-current-rating"><div class="current-rating" id="current-rating-id" style="width:'+newWidth+'px">'+data+'</div></div>';
				 $("#rating-box").html(dataToInsert);
			
		 });
			return false;
		});

});


