// JavaScript Document
	$(document).ready(function() {
							   
		// get current rating
		// getRating();
	});
		 //get rating function
		function getRating(type, id,ip){
			$.ajax({
				type: "GET",
				url: "http://www.desigujju.com/gujaratimusic/update.php",
				data: "do=getrate&type=" + type + "&id=" + id +"&ip="+ip,
				cache: false,
				async: false,
				success: function(result) {
					// apply star rating to element
					var barID = "#current-rating"+id+type;
					$(barID).css({ width: "" + result + "%" });
					
					//var barID = "current-rating" + id;
					//document.getElementById(barID).style.width = result + "%";
				},
				error: function(result) {
					//alert("some error occured, please try again later");
				}
			});
		}
		
		// link handler
		//$('#ratelinks li a').click(function(){
		function doRating(vote,type,id,ip){
		
			//alert(type+"   " + id);return false;
			$.ajax({
				type: "GET",
				url: "http://www.desigujju.com/gujaratimusic/update.php",
				data: "rating="+vote+"&do=rate&type=" + type + "&id=" + id +"&ip="+ip,
				cache: false,
				async: false,
				success: function(result) {
					// remove #ratelinks element to prevent another rate
					var rateLinks = "#ratelinks"+id+type;
					$(rateLinks).remove();
					// get rating after click
					getRating(type,id);
				},
				error: function(result) {
					//alert("some error occured, please try again later");
				}
			});
			
		};
