// JavaScript Document
	$(document).ready(function() {
							   
		// get current rating
		// getRating();
	});
		 //get rating function
		function getRating(id,ip){
			$.ajax({
				type: "GET",
				url: "http://www.desigujju.com/wallpapers/update.php",
				data: "do=getrate&id=" + id +"&ip="+ip,
				cache: false,
				async: false,
				success: function(result) {
					// apply star rating to element
					var barID = "#current-rating"+id;
					$(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,id,ip){
		
			//alert(id);return false;
			$.ajax({
				type: "GET",
				url: "http://www.desigujju.com/wallpapers/update.php",
				data: "rating="+vote+"&do=rate&id=" + id +"&ip="+ip,
				cache: false,
				async: false,
				success: function(result) {
					// remove #ratelinks element to prevent another rate
					var rateLinks = "#ratelinks"+id;
					$(rateLinks).remove();
					// get rating after click
					getRating(id,ip);
				},
				error: function(result) {
					//alert(result);
				}
			});
			
		};
