function SetCharCounter(sId,sIdCharLeft,iMax)
{		
		var oM = document.getElementById(sId);
		var oCharLeft = document.getElementById(sIdCharLeft);
		
		var iChar = oM.value.length;		
		var iLeft = iMax - iChar;
		
		if (iLeft < 0)
		{			
			oM.value = oM.value.substring(0,iMax);
			iLeft=0;
		}
		oCharLeft.innerHTML = iLeft; // (x-20);
		return true;
}


function voteUp(iId)
{
	var sUrl = gHTTPURL + 'dispatch/upvote.php?id=' + iId;
	var sId = 'voteHidden' + iId;
	//alert(sId);
	var sData;
	$("#"+sId).load(sUrl);
											
	getVote(iId);
	getVoteCount(iId);			    
}	

function voteDown(iId)
{
	
	sUrl = gHTTPURL + 'dispatch/downvote.php?id=' + iId;
	var sId = 'voteHidden' + iId;
	//alert(sId);
	var sData;
	$("#"+sId).load(sUrl);
	
	getVote(iId);
	getVoteCount(iId);
}

function getVote(iId)
{
	voteRank = document.getElementById("voteRank" + iId);
	sUrl = gHTTPURL + 'dispatch/getvote.php?id=' + iId;
	$.ajax({
	url: sUrl,
	type: 'GET',
	dataType: 'html',
	timeout: 0,
	error: function(){
    //alert('Error loading html document');
	},
		success: function(html){
		    voteRank.innerHTML = html + '%'; 
		}
	});
}

function getVoteCount(iId)
{
	voteCount = document.getElementById("voteCount" + iId);
	sUrl = gHTTPURL + 'dispatch/getvotecount.php?id=' + iId;
	
	$.ajax({
	url: sUrl,
	type: 'GET',
	dataType: 'html',
	timeout: 0,
	error: function(){
    /* alert('Error loading html document');*/
	},
		success: function(html){
		    voteCount.innerHTML = html; 
		}
	});
}
