var ajaxUrlAdd = '/en/AjaxRequest/SBSPoints/point_add.html';
var ajaxUrlDel = '/en/AjaxRequest/SBSPoints/point_del.html';

function addPointToQuote(sbsId, Points) {
	new Ajax.Request(ajaxUrlAdd, {
    method:'post',
		parameters: {quote:sbsId},
		onSuccess: function(res){
      var data = res.responseText;
			makeReply(sbsId, Points, "add", data);
    }
  });
}

function deletePointFromQuote(sbsId, Points) {
	new Ajax.Request(ajaxUrlDel, {
    method:'post',
		parameters: {quote:sbsId},
		onSuccess: function(res){
      var data = res.responseText;
			makeReply(sbsId, Points, "del", data);
    }
  });
}

function makeReply(sbsId, Points, type, data) {
	data = data.split("|");
	if (data[0] == "1") {
		if (type == "add") { Points++; }
		else { Points--; }
		$('pointImage'+sbsId).src = "/images/score"+Points+".png";
	}
	builtSBSBox();
	showSBSBox(data[1]);
}

function builtSBSBox() {
	if ($("SBSBox") == null) {
		with (div = document.createElement('div')) {
			id = "SBSBox";
			style.zIndex = "99";
			style.position = "absolute";
			style.left = "460px";
			style.top = "400px";
			style.width = "300px";
			style.display = "none";
		}
		document.body.appendChild($(div));
	}
}

function showSBSBox(text) {
	$('SBSBox').innerHTML = text;
	$('SBSBox').style.left = (xPos-400)+"px";
	$('SBSBox').style.top = (yPos-100)+"px";
	$('SBSBox').show();
}

function hideSBSBox() {
	$('SBSBox').hide();
}

