/* 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.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 */

}

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

	
  myregexp = /already%20voted/;


  if (myregexp.test(response) == true) {
	  jQuery('#'+id).html("<font color='red'>Your already seem to have voted.</font>");	
  } else {
	  jQuery('#'+id).html("<font color='green'>'Your rating has been accepted.</font>");
  }
} //finishAjax




/* 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.post("/cgi-bin/rate.cgi", {
	        rate: Rating,
			ID:  LID
	      }, function(response){

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

	      });	
	 }


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

}

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

  myregexp = /already%20voted/;

  if (myregexp.test(response) == true) {
	  jQuery('#'+id).html("<font color='red'>Your already seem to have voted.</font>");	
  } else {
	  jQuery('#'+id).html("<font color='green'>'Your rating has been accepted.</font>");
  }
} //finishAjax



/* 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.post("/cgi-bin/rate.cgi", {
	        rate: Rating,
			ID:  LID
	      }, function(response){

	        jQuery('#ajax_rate_indicator' + the_id).show();
	        setTimeout("finishAjaxAdvancedCategory(" + 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 finishAjaxAdvancedCategory(linkid, id, response) {
  jQuery('#ajax_rate_indicator' + linkid).hide();

  myregexp = /already%20voted/;

  if (myregexp.test(response) == true) {
	  jQuery('#'+id).html("<font color='red'>Your already seem to have voted.</font>");	
  } else {
	  jQuery('#'+id).html("<font color='green'>'Your rating has been accepted.</font>");
  }
} //finishAjax
