
// Function to turn red stars while mouse overs

function OverStars(VideoId, HowManyStarsOvered, Over, HowManyStarsFilled, RandomId){
	//HowManyStarsOvered++;
	HowManyStarsFilled--;
	if (Over){
		for(i = 0; i <= HowManyStarsOvered; i++){
			MM_swapImage('Video' + VideoId + '-Star' + i + '-'+ RandomId, '','/images/elmnt/star_full_red.gif',1);
		}
	} else {
		for(i = 0; i <= HowManyStarsOvered; i++){
			if(i <= HowManyStarsFilled){
				MM_swapImage('Video' + VideoId + '-Star' + i + '-'+ RandomId, '','/images/elmnt/star_full_grey.gif',1);
			} else {
				MM_swapImage('Video' + VideoId + '-Star' + i + '-'+ RandomId, '','/images/elmnt/star_empty_grey.gif',1);
			}
		}
	}
}


// Ban user, called from /admin/users

function banUser(UserId){
	var elemId = 'BtnBanUser-'+UserId;
	var Blocked = ($(elemId).src.indexOf('unlock') == -1 ? 0: 1);
	new Ajax.Request('/users/banUser/userId:' + UserId + '/canComment:' + Blocked + '/',{onSuccess: function(response){eval(response.responseText)}});
}

// Inserts or replaces vote
function VoteVideo(VideoId, Rating, RandomId){
	var Resp = new Ajax.Request('/videos/vote/'+VideoId+'/'+Rating+'/'+RandomId+'/',{onSuccess: function(response){eval(response.responseText)}});
}

// Reports comment abuse
function ReportCommentAbuse(CommentId){
	var Resp = new Ajax.Request('/comments/reportAbuse/'+CommentId+'/',{onSuccess: function(response){eval(response.responseText)}});
}


function htmlEntities(texto){
    //by Micox - elmicoxcodes.blogspot.com - www.ievolutionweb.com
    var i,carac,letra,novo='';
    for(i=0;i<texto.length;i++){
        carac = texto[i].charCodeAt(0);
        if( (carac > 47 && carac < 58) || (carac > 62 && carac < 127) ){
            //se for numero ou letra normal
            novo += texto[i];
        }else{
            novo += "&#" + carac + ";";
        }
    }
    return novo;
}


function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else
		cntfield.value = maxlimit - field.value.length;
}


function closeQuickBanner(){
	$('DivQuickBanner').innerHTML = '';
	$('DivQuickBanner').hide();
	$('Container').show();

}

