// JavaScript Document
	$(document).ready(function() {
							   
		// get current rating
		// getRating();
	});
		 //get rating function
		function getRating(id,ip,t){
			$.ajax({
				type: "GET",
				url: path+"/update.php",
				data: "do=getrate&id=" + id +"&ip="+ip+"&type="+t,
				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,t){
		
			$.ajax({
				type: "GET",
				url: path+"/update.php",
				data: "rating="+vote+"&do=rate&id=" + id +"&ip="+ip+"&type="+t,
				cache: false,
				async: false,
				success: function(result) {
					// remove #ratelinks element to prevent another rate
					//alert(result);
					var ratelinks = "#ratelinks"+id+""+t;
					$(ratelinks).remove();
					// get rating after click
					getRating(id,ip,t);
				},
				error: function(result) {
					alert("some error occured, please try again later");
				}
			});
			
		};
