$(document).ready(function () {
	
	var full_path = "http://www.time4news.ro/";
	var full_domain = "time4news.ro";
	
	// Start clicked
	$('.one-star').click(function(){
		var curent = $('#note').text()
		var id = $(this).text()
		if($.cookie(id)!=1){
			$.ajax({type:"GET", url:full_path+"bin/star_update.php?curent="+curent+"&vote=1&id="+id, success: function(text){
				$.cookie(id, '1', { expires: 1, path: '/', domain: full_domain });
				$("#note").html(text);
				var vh = parseFloat(text)*25;
				$(".current-rating").css('width', vh+'px');
			  },error: function(XMLHttpRequest, textStatus, errorThrown){
				alert('Eroare. Va rugam reincarcati pagina si votati din nou.');
			  }
			});
		}else{
			alert('Eroare. Ati votat deja pentru aceasta stire.');
		}
		return false;
	});
	$('.two-stars').click(function(){
		var curent = $('#note').text()
		var id = $(this).text()
		if($.cookie(id)!=1){
			$.ajax({type:"GET", url:full_path+"bin/star_update.php?curent="+curent+"&vote=2&id="+id, success: function(text){
				$.cookie(id, '1', { expires: 1, path: '/', domain: full_domain });
				$("#note").html(text);
				var vh = parseFloat(text)*25;
				$(".current-rating").css('width', vh+'px');
			  },error: function(XMLHttpRequest, textStatus, errorThrown){
				alert('Eroare. Va rugam reincarcati pagina si votati din nou.');
			  }
			});
		}else{
			alert('Eroare. Ati votat deja pentru aceasta stire.');
		}
		return false;
	});
	$('.three-stars').click(function(){
		var curent = $('#note').text()
		var id = $(this).text()
		if($.cookie(id)!=1){
			$.ajax({type:"GET", url:full_path+"bin/star_update.php?curent="+curent+"&vote=3&id="+id, success: function(text){
				$.cookie(id, '1', { expires: 1, path: '/', domain: full_domain });
				$("#note").html(text);
				var vh = parseFloat(text)*25;
				$(".current-rating").css('width', vh+'px');
			  },error: function(XMLHttpRequest, textStatus, errorThrown){
				alert('Eroare. Va rugam reincarcati pagina si votati din nou.');
			  }
			});
		}else{
			alert('Eroare. Ati votat deja pentru aceasta stire.');
		}
		return false;
	});
	$('.four-stars').click(function(){
		var curent = $('#note').text()
		var id = $(this).text()
		if($.cookie(id)!=1){
			$.ajax({type:"GET", url:full_path+"bin/star_update.php?curent="+curent+"&vote=4&id="+id, success: function(text){
			  $.cookie(id, '1', { expires: 1, path: '/', domain: full_domain });
			  $("#note").html(text);
			  var vh = parseFloat(text)*25;
			  $(".current-rating").css('width', vh+'px');
			  },error: function(XMLHttpRequest, textStatus, errorThrown){
				alert('Eroare. Va rugam reincarcati pagina si votati din nou.');
			  }
			});
		}else{
			alert('Eroare. Ati votat deja pentru aceasta stire.');
		}
		return false;
	});
	$('.five-stars').click(function(){
		var curent = $('#note').text()
		var id = $(this).text()
		if($.cookie(id)!=1){
			$.ajax({type:"GET", url:full_path+"bin/star_update.php?curent="+curent+"&vote=5&id="+id, success: function(text){
				$.cookie(id, '1', { expires: 1, path: '/', domain: full_domain });
				$("#note").html(text);
				var vh = parseFloat(text)*25;
				$(".current-rating").css('width', vh+'px');
			  },error: function(XMLHttpRequest, textStatus, errorThrown){
				alert('Eroare. Va rugam reincarcati pagina si votati din nou.');
			  }
			});
		}else{
			alert('Eroare. Ati votat deja pentru aceasta stire.');
		}
		return false;
	});
	
	
});