Voter = {
  vote: function(what_in) {

    what = what_in.substring(0,what_in.indexOf("."));
    up_down = what_in.substring(what_in.indexOf(".")+1,what_in.length);

	if (up_down == 'down') {
		document.getElementById("thumber_message").innerHTML = "Please tell us why didn't you like this software.";
		var feedback = Popup.popup_submit();
		if (feedback == null || feedback == undefined || feedback == '') {
			Popup.popup_show('thumber_popup', 'element-bottom', 0, 30, what_in);
			return false;
		}
		else {
			document.getElementById(what_in).style.background = 'url(/freeware/thumber/loading.gif) left center no-repeat';
			document.getElementById(what_in).style.cursor = 'default';
		}
	}
	else {
		document.getElementById("thumber_message").innerHTML = "Please tell us why you like this software.";
		var feedback = Popup.popup_submit();
		if (feedback == null || feedback == undefined || feedback == '') {
			Popup.popup_show('thumber_popup', 'element-bottom', 0, 30, what_in);
			return false;
		}
		else {
			document.getElementById(what_in).style.background = 'url(/freeware/thumber/loading.gif) left center no-repeat';
			document.getElementById(what_in).style.cursor = 'default';
		}
	}

    if (Cookies.check()) cookie_set = "true"; else cookie_set = "false";

    var voted = Cookies.read(what);

    if (voted == null) {
		var score = parseInt($(what_in).innerHTML)+1;
		this.voted = true;
		pars = "thumber_score=" + score + "&thumber_vote=" + up_down + "&thumber_what=" + what + "&cookie_set=" + cookie_set + "&thumber_feedback=" + feedback;
		Cookies.create(what,"voted",1);
		var myAjax = new Ajax.Request('/freeware/thumber/output.php', {method: 'get', parameters: pars, onComplete: this.showResponse})
    }
   	else {
   		$(what+'.result').innerHTML="You already voted &nbsp;"+$(what+'.result').innerHTML;
		document.getElementById(what+'.down').style.background = 'url(/freeware/thumber/down.gif)  left center no-repeat';
		document.getElementById(what+'.down').style.cursor = 'default';
		document.getElementById(what+'.up').style.background = 'url(/freeware/thumber/up.gif) left center no-repeat';
		document.getElementById(what+'.up').style.cursor = 'default';
   	}
  },
  showResponse: function(originalRequest) {
	$(what+'.result').innerHTML = originalRequest.responseText;
  }
}
