		if(typeof jQuery == "function") {
		jQuery(document).ready(function($) {
			this_week = 03;
			wprs_rating_unitwidth = 30;
			$('body').on( 'click', ".wprs_rated", function(event){
				event.preventDefault();
				var song_id = $(this).attr("id").split("-")[1];
				var chart_id = $(this).attr("id").split("-")[2];
				$(".wprs_rating_err").html('');
				$('#wprs_rating_err-'+song_id+"-"+chart_id).html('<br/>You have voted for this song');
				return false;
			});

			$('body').on( 'click', ".wprs_rate", function(event){
				event.preventDefault();

				var song_id = $(this).attr("id").split("-")[1];
				var chart_id = $(this).attr("id").split("-")[2];
				var vote_star = $(this).attr("id").split("-")[3];

				var data = {
					action		: 'wprs_rating',
					wprs_songid		: song_id,
					wprs_chartid	: chart_id,
					wprs_votestar	: vote_star,
					_ajax_nonce	: wprs_rating_object.ajax_nonce
				};

				$("#wprs_done-"+song_id+"-"+chart_id).hide();
				$("#wprs_ajax-"+song_id+"-"+chart_id).show();
				$(".wprs_rating_err").html('');
				$('#wprs_rating_err-'+song_id+"-"+chart_id).html('' );

				var myajax = jQuery.post(wprs_rating_object.ajaxurl, data, function(response) {
					$("#wprs_ajax-"+song_id+"-"+chart_id).hide();
					if( response != '-1' && ! response.err )
					{
						$("#wprs_done-"+song_id+"-"+chart_id).show();
						$("#wprs_ratingtxt-"+song_id+"-"+chart_id+" >.wprs_ajaxtxt").html(response.msg);
						$("#unit_ul-"+song_id+"-"+chart_id+" >.current-rating").css('width',response.rating_width+'px');
						setCookie('wprs-'+song_id+'-'+chart_id+'-'+this_week, vote_star, 7 );
					}
					else
					{
						$('#wprs_rating_err-'+song_id+"-"+chart_id).html('<!-- code: '+response.err+' -->'+ response.msg );
					}
					if( response.ristrict_rating )
						$("#unit_ul-"+song_id+"-"+chart_id+" a.wprs_rate").removeClass('wprs_rate').addClass('wprs_rated');
				}, "json");
				$(window).unload( function() { myajax.abort(); } );
			});

			$(".ratingblock ul.unit-rating").each( function( i, v ) {
				if( $(this).data('cookie') && $(this).data('songrow') ){
					songrow = $(this).data('songrow');

					star_rating = getCookie( 'wprs-'+$(this).data('cookie') );
					if( star_rating ) {
						$("#unit_ul-"+songrow+" >.current-rating").css('width',( star_rating * wprs_rating_unitwidth )+'px');
					}
				}
			});
		});
		}

		window.setCookie = function(cname, cvalue, exdays) {
			var d = new Date();
			d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
			var expires = "expires="+d.toUTCString();
			document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
		}
		window.getCookie = function(cname) {
			var name = cname + "=";
			var ca = document.cookie.split(';');
			for(var i = 0; i < ca.length; i++) {
				var c = ca[i];
				while (c.charAt(0) == ' ') {
					c = c.substring(1);
				}
				if (c.indexOf(name) == 0) {
					return c.substring(name.length, c.length);
				}
			}
			return "";
		}
		