$(function() {
	function GM_wait() {
	  if($('.trivago_certificate_box').length > 0 ) { // check if trivagobox has loaded
	    $ = letsJQuery(); 
	  } else { 
	    window.setTimeout(GM_wait,100); 
	  }
	}
	GM_wait();

	function letsJQuery() {
	    //overwrite the width and bg image. trivago sets it via inline css
	    $('.trivago_partner_rating_graph').css({
			  'width' : '25px',
			  'background' : "url('fileadmin/designmaster/images/trivago-sprite.gif') 0px -40px no-repeat"
			});
			
	  	$('.trivago_partner_rating_value').each(function() {
				var width = parseInt($(this).text());
				var graph = $(this).next('div.trivago_partner_rating_graph');
				// remove first child / trivago sets the image / we dont need it
				$(graph).find(":nth-child(1)").remove();
				var newwidth = Math.floor(graph.width() / 100 * width);
				// set new div and style it via css stylesheet
				graph.append('<div class="trivago_partner_rating_graph_value" style="width:'+newwidth+'px"></div>');
			});

	}
});