  /* For doing ratings on the rate.html template */
function do_confirm(Rating,Star,LID) {
	if (confirm('Are you sure you want to rate this link a ' + Star + ' star rating?')) { 

		  jQuery('#ajax_rate_indicator' + LID).show();
	      jQuery.post("/cgi-bin/rate.cgi", {
	        rate: Rating,
		ID:  LID
	      }, function(response){

	        jQuery('#ajax_rate_indicator').fadeOut();
	        setTimeout("finishAjax('the_rating_box', '"+escape(response)+"')", 400);
	      });	
	 }


	return false; /* we dont wanna submit the form - as its done via AJAX */

}


/* For doing ratings on the category/search results/ bookmark templates  */
function do_confirm_category(Rating,Star,LID) {
    var the_id = LID;
	if (confirm('Are you sure you want to rate this link a ' + Star + ' star rating?')) { 

		  jQuery('#ajax_rate_indicator' + the_id).show();
	      jQuery.post("/cgi-bin/rate.cgi", {
	        rate: Rating,
		ID:  LID
	      }, function(response){

	        jQuery('#ajax_rate_indicator' + the_id).show();
	        setTimeout("finishAjax(" + the_id + ",'the_rating_box" + the_id + "', '"+escape(response)+"')", 400);

	      });	
	 }


	return false; /* we dont wanna submit the form - as its done via AJAX */

}


/* For doing ratings on the category/search results/ bookmark templates  */
function do_confirm_advanced_category(Rating,Star,LID) {
    var the_id = LID;
	if (confirm('Are you sure you want to rate this link a ' + Star + ' star rating?')) { 

		  jQuery('#ajax_rate_indicator' + the_id).show();
	      jQuery.post("/cgi-bin/rate.cgi", {
	        rate: Rating,
		ID:  LID
	      }, function(response){

	        jQuery('#ajax_rate_indicator' + the_id).show();
	        setTimeout("finishAjax(" + the_id + ",'the_rating_box" + the_id + "_confirmation', '"+escape(response)+"')", 400);

	      });
	 }


	return false; /* we dont wanna submit the form - as its done via AJAX */

}

function finishAjax(linkid, id, response) {
  jQuery('#ajax_rate_indicator' + linkid).hide();

  response = unescape(response);

 /* an erorr test, in case we get an error in the <div id="error"> div, which didn't get caught before for some reason */
  var error = jQuery(response).find('div.error').html();
  var message = jQuery(response).find('div.message').html();

var regextest1 = /You must first login before you can access that./;

  if (error) {
	  jQuery('#'+id).html("<font color='red'>" + error + "</font>");
  } else if (regextest1.test(response) == true) {
	  jQuery('#'+id).html("<font color='red'>Please login before you can rate!</font>");
  } else {
	  jQuery('#'+id).html("<font color='green'>Your rating has been accepted</font>");
  }
} //finishAjax

