/*
	START sendToFriend
*/
var urlBlog = 'http://blog.cubovision.it?p=';
var urlPlayList = 'http://webtv.cubovision.it/playlist/video-';
var domainUrl='http://webtv.cubovision.it';

/*
	TYPE_CNT = 0;
	TYPE_BLOG = 1;
	TYPE_PLAYLIST = 2;
*/

//getContentName()

function sendToFriend() {
	
			if (!checkLogin()){
				return;
			}
			
			var id =  getCntId();
			id = id.toLowerCase();
			var title ='Mail da web.cubovision.it';
			try {
				title = _contentBean.contentName;
			} catch (e){}
			
			var _url='';
			var type=1;
			if(id.indexOf('dv-11111111')>=0){
				_url=domainUrl+"/canalitv/bonsai/";
				title =_contentBean.title;
				type = 3;
			} else
			if(id.indexOf('dv-22222222')>=0){
				_url=domainUrl+"/canalitv/classlife/";
				title =_contentBean.title;
				type = 3;
			} else
			if(id.indexOf('dv-33333333')>=0){
				_url=domainUrl+"/canalitv/classcnbc/";
				title =_contentBean.title;
				type = 3;
			} else
			if(id.indexOf('dv-44444444')>=0){
				_url=domainUrl+"/canalitv/classnews/";
				title =_contentBean.title;
				type = 3;
			} else
			if (id.indexOf('pl-')>=0){
				_url = urlPlayList + id.substring('pl-'.length);
				type = 2;
			} else 
			if (id.indexOf('blog-')>=0){
				_url = urlBlog + id.substring('blog-'.length);
				type = 1;
			} else
			if (id.indexOf('dv-')>=0){
				type = 0;
			}
			var mailTo = document.social_condividi_form.sendTo.value;
      var mailExp = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;     
      mailTo = mailTo.replace(/[\n\r]/g,"");
    	if (mailTo.length == 0) {
			  $.fn.colorbox({href:"/common/alert/template_alert.html",transition:'none',title:true,initialWidth:'480',initialHeight:'180'});
      	$(document).bind('cbox_complete', function(){
      		$('.note').html('Inserisci un indirizzo email valido');
      		$('.quest').html("Messaggio di avvertimento");
					$('#btOk').click(function(event){
						event.preventDefault();
						$.fn.colorbox.close();
					});
				});
			} else if (!mailExp.test(mailTo)) {
				 $.fn.colorbox({href:"/common/alert/template_alert.html",transition:'none',title:true,initialWidth:'480',initialHeight:'180'});
      	$(document).bind('cbox_complete', function(){
      		$('.note').html("'" + mailTo + "' non e' un'email valida!");
      		$('.quest').html("Messaggio di avvertimento");
					$('#btOk').click(function(event){
						event.preventDefault();
						$.fn.colorbox.close();
					});
				});
			} else {
				request = domainUrl+"/condividi/aa/inviaamico";         
	    	request = request + "?CONTENT_ID=" + getCntId(); 
	    	request = request + "&INTEREST_URL=" + encodeUrl(_url); 
  			request = request + "&TITLE=" + encodeUrl(title); 
  			request = request + "&TYPE="+type; 
	    	request = request + "&MAILTO=" + mailTo; 
	    	request = request + "&OUTPUT=json"; 
	    	request = request + "&CALLBACK=callback_sendToFriend";
				aObj = new JSONscriptRequest(request);
				aObj.buildScriptTag();
		 		aObj.addScriptTag();
			}
		
}

function callback_sendToFriend(sendResponse) {
	//alert(res.response.result_code);
  //alert(res.response.result_message);
      if (sendResponse.isError == 'false') {
      		 $.fn.colorbox({href:"/common/alert/template_alert.html",transition:'none',title:true,initialWidth:'480',initialHeight:'180'});
      	$(document).bind('cbox_complete', function(){
      		$('.quest').html("Messaggio di conferma");
      		$('.note').html(sendResponse.message);
					$('#btOk').click(function(event){
						event.preventDefault();
						$.fn.colorbox.close();
					});
				});    	 
      }
        else {
        	$.fn.colorbox({href:"/common/alert/template_alert.html",transition:'none',title:true,initialWidth:'480',initialHeight:'180'});
      	$(document).bind('cbox_complete', function(){
      		$('.quest').html("Messaggio di avvertimento");
      		$('.note').html(sendResponse.message);
					$('#btOk').click(function(event){
						event.preventDefault();
						$.fn.colorbox.close();
					});
				});
      }
    }

/*
	END sendToFriend
*/

/*
	BEGIN loadLikeIt
*/

//var response={"likeit":"VALUE"}; showTotalLikeit(response);
function loadLikeIt(id) { //aggiorna i messaggi e richiama showPrivateMessage
  var url = "http://comment.cubovision.it/json_likeit.php?id=" + id;
  callJSON(url);
}

function showTotalLikeit(jsonObject){
	$('#social_like').html(
			"<span><span class=\"ico\"></span>Mi piace (<b>" + response.likeit + "</b>)</span>"
	);
}

/*
	END loadLikeIt
*/

function addFacebook(title, description, pathImg, pathEmbed) {
		var urlFacebook="http://www.new.facebook.com/sharer.php?s=100&p[medium]=103";
		/*if (pathEmbed!=null && pathEmbed!=''){
			urlFacebook+="&p[title]="+encodeURIComponent(title)+"&p[summary]="+encodeURIComponent(description)+"&p[url]="+encodeURIComponent(pathImg)";
		} else {
			urlFacebook+="&p[title]="+encodeURIComponent(title)+"&p[summary]="+encodeURIComponent(description)+"&p[url]="+encodeURIComponent(pathImg)";
		}
		window.open(urlFacebook,'Condividi');
    */
    return true;
}

function addTwitter(title, description, pathVideo, pathImg) {
    return true;
}


function addFacebookPlayer() {
    //addFacebook("title", "description", "", "")
	getSocialBookUrl("facebook");
    return true;
}

function addTwitterPlayer() {
    location.href = "http://www.alice.it";
    return true;
}
/*
End Social network
*/

/*
Start Rating
*/
function addVote(contentId, vote, callBack) {
    addVoteSL(contentId, vote);
}

function addVoteSL(contentId, vote) {
    plugin = document.getElementById("pluginSL");
    alert(plugin.Content.slObject.GetVote());    
}

function viewVote(contentId, callBack) {
    viewVoteSL(contentId, 0.3);
}

function viewVoteSL(contentId, vote) {

    var plugin = document.getElementById("pluginSL");
	plugin.Content.slObject.SetVote("123456", 1);
}


function doCall_SendVote(id, vote) {        
        request = VotingClient.urlVoteService;
        request = request + "?MESSAGE=RECORD_VOTE";
       	request = request + "&CONTENT_ID=" + id; 
        request = request + "&VOTE=" + vote; 
        request = request + "&OUTPUT=json"; 
        request = request + "&CALLBACK=callback_sendvotes";
		aObj = new JSONscriptRequest(request);
		aObj.buildScriptTag();
	 	aObj.addScriptTag();
	}

function callback_sendvotes(jsonResp) {
    if(jsonResp.isError==false) {
    	//VotingClient.votingViewer.showThanksVoting(VotingClient.lastIdSendVote);
      // disable voting
      //VotingClient.votingViewer.disableVoting(VotingClient.lastIdSendVote);
      // read the cookie containing the ids already voted
      yv = getCookie(VotingClient.nameCookieVoted);
      // if the cookie doesn't exist create it 
      if(yv=='' | yv == undefined) {
        createCookie(VotingClient.nameCookieVoted, VotingClient.lastIdSendVote);
        // if the cookie exist add the new id 
      } else {
        if(!cookieContainId(yv, VotingClient.lastIdSendVote)) {
          newval = yv + ',' + VotingClient.lastIdSendVote;
          createCookie(VotingClient.nameCookieVoted, newval);
        }   
      } 
    }
	} 

function isAlreadyVoted(id) {
    yv = getCookie(VotingClient.nameCookieVoted);
    // if the cookie doesn't exist create it 
    //if(yv=='') { return false; } 
	if(yv=='' | yv == undefined) { return false; } 
	else { return cookieContainId(yv, id); }
}

function cookieContainId(cookieval, id) {
    vals = cookieval.split(",");
	  for(ival=0; ival<vals.length; ival++)	  {
	    val = vals[ival];
	    if(val == id) {
        return true;
      }
	  }    
  	return false;
 }
  
function VotingClientFunct(){

	this.urlVoteService = "http://voting.cubovision.it/voting-cubo/VoteService";
	//this.urlGetVotesService = "http://search.yalp.alice.it/search-data-extractor/SearchService";
	this.idprefixUlVoting = "ulvote";	
	this.idprefixParagrMsgNearStars = "msgnearstars";	
  this.nameCookieVoted = "cubovision_voted";		
	this.timeMessages = "3000";		
	this.sendVote = function(id, voto) {
    if(isAlreadyVoted(id)) {
    	this.votingViewer.showAlreadyVoted(id);
    }	else {
    	doCall_SendVote(id, voto);
  	}
	}
	
	this.showAlreadyVoted = function(id) {
  	msgpar = document.getElementById(this.votingConfig.idprefixParagrMsgNearStars + id);
    msgpar.innerHTML = "<strong>Hai gi&agrave; votato</strong>";
    setTimeout('VotingClient.votingViewer.restoreVotesMsg("'+id+'")', this.votingConfig.timeMessages);  
   }
	
	
}

VotingClient = new VotingClientFunct();
/* Example
	
viewVote(1111,"setVotePlayer"");
 
 
function setVotePlayer(contentId,vote){
obj.setVote("5");
}
	
*/

/*
End Rating
*/

/*
Live stats
*/

	function callback_sv(jsonResp) {
      // do nothing
	} 
	
	function doCall_SendView(id, vote) {        
        request = LivestatsClient.urlService;
        request = request + "?MESSAGE=RECORD_VIEW";
       	request = request + "&CONTENT_ID=" + id; 
        request = request + "&OUTPUT=json"; 
        request = request + "&CALLBACK=callback_sv";
		aObj = new JSONscriptRequest(request);
		aObj.buildScriptTag();
	 	aObj.addScriptTag();
	}


    function LivestatsClientFunct(){
		
		this.urlService = "http://livestats.cubovision.it/livestats-cubo/ViewRecorderService";
		
		this.sendView = function(id) {
			doCall_SendView(id);
		}
			
	}
	
	
	// CREATE CLIENT
	LivestatsClient = new LivestatsClientFunct();
	
	
	// CHECK IF NECESSARY TO SEND AUTOMATICALLY THE VIEW
	sendviewautomatically = false;
	try {
    if(notSendAutomaticallyLiveStats!=null) {
      if(notSendAutomaticallyLiveStats==1) {
        sendviewautomatically = false;
      }
    }
  } catch (err) {
    // do nothing
  }
	
	
	// IF NECESSARY SEND AUTOMATICCALY THE VIEW
	if(sendviewautomatically) {
      try {
        ci = getContentId();
        //ci ="test";
    	  LivestatsClient.sendView(ci);
    	} catch (err) {
        // do nothing
      }
  }
  
/*
	END Live Stats
*/   

function getSocialBookUrl(book) {
  
    result = '';	
	url = document.location;
	title ="";
	contdescr = "";
 
	mustEncodeUri = true;
	if (contdescr == null)
	{ 
		contdescr = "";
	}
	
	switch(book) 
	{
		case 'oknotizie' :			
			result = 'http://oknotizie.alice.it/post?url='+url+'&title='+title;
		break;
		case 'facebook' :					
			imgvideo = '';
      		//imgvideocb = _contentBean.imageFilePath;
			imgvideocb="http://hannamontana.cubovision.it/img/thumbhp.png";
		    if( (imgvideocb!=null) && (imgvideocb!="") ) 
			{
				imgvideo = '&p[images][0]=' + encodeURIComponent('http://images.yalp.alice.it' + imgvideocb);
		    }
      
      		videostr = '';
      		if ($('txtEmb') != null && $('txtEmb').value!=null && $('txtEmb').value!="")
		    {	
				embstr = $('txtEmb').value;
	      		indstart = embstr.indexOf("embed src=");
	      		if(indstart!=-1) 
				{
		    		indstart = indstart + 11;
		    	}			
		    	indend = embstr.indexOf(" ", indstart);
		    	indend = indend - 1;
		    	videourl = embstr.substring(indstart, indend);								
		    	//videourl = videourl.replace(/&/, '');
				videourl = videourl.split("&").join("%26");
		    	indstart = embstr.indexOf("width=");
		    	wid = embstr.substring( (indstart+7) , (indstart+10));
	     		indstart = embstr.indexOf("height=");
	      		hei = embstr.substring( (indstart+8) , (indstart+11));
	      		videostr = '&p[video][type]=application%2Fx-shockwave-flash&p[video][height]='+hei+'&p[video][width]='+wid+'&p[video][src]='+encodeURIComponent(videourl)+'&p[video][v]=0&p[video][safe]=1';
                alertd("imgvideo: "+imgvideo);
				result = 'http://www.new.facebook.com/sharer.php?s=100&p[medium]=103&p[title]='+encodeURIComponent(title)+videostr+'&p[summary]='+encodeURIComponent(contdescr)+'&p[url]='+encodeURIComponent(url)+imgvideo;
            }   
	        else
            { 
      			result = 'http://www.new.facebook.com/sharer.php?s=100&p[medium]=103&p[title]='+encodeURIComponent(title)+'&p[summary]='+encodeURIComponent(contdescr)+'&p[url]='+encodeURIComponent(url);
		    }
		    mustEncodeUri = false;
			break;		
		case 'delicious' :
			result = 'http://del.icio.us/post?url='+url+'&title='+title+'&notes='+contdescr;
		break;		
		case 'myspace' :
			result = 'http://www.myspace.com/Modules/PostTo/Pages/?l=3&u='+url+'&t='+title+'&c='+contdescr;
		break;		
		case 'google' :	
			result = 'http://www.google.com/bookmarks/mark?op=edit&bkmk='+url+'&title='+title+'&annotation='+contdescr;
		break;
		case 'technorati' :		
			result = 'http://www.technorati.com/faves?add='+url;
		break;
		case 'bebo' :	
            u=location.href;
            t=document.title;
			//result = 'http://www.bebo.com/c/share?Url='+encodeURIComponent(u)+'&t='+encodeURIComponent(t);
			result = 'http://www.bebo.com/c/share?TUUID=af742319-c40b-4003-84d5-c0b3c1d01efb&MID=8395253461&Url='+encodeURIComponent(u)+'&t='+encodeURIComponent(t);
			mustEncodeUri = false;
		break;		
		case 'twitter' :
			result ='http://twitter.com/home?status=Controlla%20questo%20video%20--%20'+title+'%20'+url;
		break;	
		default : result = '';				
	}
		
	
	if ( null == result || "" == result ) 
	{
 
	  	alert("Servizio momentaneamente non disponibile. Riprova pi&ugrave; tardi."); 
	} 
	else 
	{		
		if (mustEncodeUri)
		{	
			result = encodeURI(result);
		}	
	    window.open(result,'Condividi');
	}
}


//=================== VARIABILI GLOBALI =================//
var communityBaseURL = "http://community.cubovision.it/community/";

var isPreferito = false;
var isPreferitoPlaylist = false;
var isPlayListOpen = false;

var isPlayListLoaded = false; //indica se la lista delle playlist e' stata caricata

//=======================================================//
jQuery(document).ready(function (){
	//PREFERITI
	jQuery('#az_prf').click(function(){
	 //alert("ADD PREFERITI");
		if(!isPreferito){
			addPreferiti(getCntId(),getCntType());
		}
		return false;
	});
	
	//PLAYLIST
	jQuery('#az_pls').click(function () {
		if(isPlayListOpen){//la playlist era aperta la sto chiudendo
			isPlayListOpen = false;
			jQuery('.mnu_playlist').slideToggle("slow");
		}else{//la playlist era chiusa la apro
			if(!isPlayListLoaded){
				loadPlayList();
			}else{
				isPlayListOpen = true;
				jQuery('.mnu_playlist').slideToggle("slow");
			}
			
		}
		return false;
	});
});

//======================= ADD PREFERITI ========================//
function addPreferiti(contentId,contentType){
  if (!checkLogin()){
		  return;
	}else{  
    	var urlRequest = communityBaseURL+"mycubo/";
    	urlRequest += "AddPreferiti?contentid="+contentId+"&idtype="+contentType;
    
    	//alert(urlRequest);
      callJson(urlRequest,"aggiuntoAPreferiti");  
  }
}

function aggiuntoAPreferiti(jsonObject){
	var statusCode = jsonObject.status.code;
//alert("AGGIUNTO");
	if(statusCode !== 0){
		errorResponse(jsonObject);
		return;
	}else{   
	    if(jsonObject.response == -1){
	        //gia è presente tra i preferiti
	        //showFeedback("Contenuto gia presente nei preferiti");                
          $('#az_prf').html('<span class="v_pref"></span>Contenuto gia presente nei preferiti');             
      }else{
  		    $('#az_prf').html('<span class="v_pref"></span>Aggiunto ai preferiti');
  		}
  		isPreferito = true;	  
	}
}

function addPlaylistToPreferiti(){
    if (!checkLogin()){
  		  return;
  	}else{
  	    if(!isPreferitoPlaylist){
  	       var playlistId = $("#id_attr").val();
        	 var urlRequest = communityBaseURL+"mycubo/";
        	 urlRequest += "AddPreferiti?contentid=cpl-"+playlistId+"&idtype=PLAYLIST";
        
        	 //alert(urlRequest);
           callJson(urlRequest,"cbAddPlaylistToPreferiti");
        }  
    }
}

function cbAddPlaylistToPreferiti(jsonObject){
	var statusCode = jsonObject.status.code;
	
	if(statusCode !== 0){
		errorResponse(jsonObject);
		return;
	}else{
	     if(jsonObject.response == -1){
	        //gia è presente tra i preferiti
	        //showFeedback("Playlist gia presente nei preferiti");
          $('#az_prf_play').html('<span class="v_pref"></span>Playlist gia presente nei preferiti');                             
       }else{
		      $('#az_prf_play').html('<span class="v_pref"></span>Aggiunta playlist ai preferiti');
		   }
		   isPreferitoPlaylist = true;
	}   
}
//==============================================================//

//======================= SHOW PLAY LIST =======================//
function loadPlayList(){
  if (!checkLogin()){
		  return;
	}else{
    	var urlRequest = communityBaseURL+"mycubo/";
    	urlRequest += "LoadPlayList";
    	//alert(urlRequest);
    	
    	callJson(urlRequest,"showPlayList");
  } 
}

//callback
function showPlayList(jsonObject){
     
	var statusCode = jsonObject.status.code;

	if(statusCode !== 0){
		errorResponse(jsonObject);
		return;
	}else{
		if(jsonObject.response !== null){
			for(var i=0; i<jsonObject.response.length; i++){
				//$("#video_azioni .mnu_playlist").append('<li><a href="javascript:addContenutoPlayList(getCntId(), getCntType(), '+jsonObject.response[i].idAttributo+');">'+jsonObject.response[i].nome+'</a></li>');
				$(".mnu_playlist").append('<li><a href="javascript:addContenutoPlayList(getCntId(), getCntType(), '+jsonObject.response[i].idAttributo+');">'+jsonObject.response[i].nome+'</a></li>');
			}
		}
		$('.mnu_playlist').slideToggle("slow");//mostra la playlist
		isPlayListOpen = true;
		isPlayListLoaded = true; //indica che la play list e' stata caricata
	}
}
//========================================================//

function addContenutoPlayList(contentId, contentType, idPlayList){
	    if (!checkLogin()){
				  return;
			}else{
          var urlRequest = communityBaseURL+"mycubo/";
        	urlRequest += "AddContenutoAttributo" +
        	"?contentid="+contentId+
        	"&idtype="+contentType+
          "&attributoid="+idPlayList;
        
        	callJson(urlRequest,"aggiuntoContenutoPlayList"); 
	    }
}

//callback
function aggiuntoContenutoPlayList(jsonObject){
	var statusCode = jsonObject.status.code;

	if(statusCode !== 0){
		errorResponse(jsonObject);
		return;
	}else{
		$('.mnu_playlist').slideUp(200,function (){
			$('#az_pls').html('<span class="v_playl"></span>Aggiunto alla playlist');
		});
	}
}

/**
 * funzione che viene chiamata anche con chiamate JSON 
 * per gestire i messaggi di errore lato server
 * 
 * @param jsonObject: risposta lato server
 */
function errorResponse(jsonObject){//TODO
	//alert("code: "+jsonObject.status.code+"\n message: "+jsonObject.status.message);
	if(jsonObject.status.code == -1){ //codice -1 errore utente non autenticato
		//alert("POPUP - autentica");
		viewLogin();
		//$.fn.colorbox({href:""+urlAlertLogin});
	}else{ //errore generico
		//alert("POPUP - errore generico (code="+jsonObject.status.code+"&mess="+jsonObject.status.message+")");
		//TODO messaggio d'errore
    //$.fn.colorbox({href:""+urlAlertGenericError+"?code="+jsonObject.status.code+"&mess="+jsonObject.status.message});
	}
}

/*
function getSocialBookUrl(book) {
  result = '';	
	url = document.location;
	title = _contentBean.title;
	contdescr = _contentBean.longDescription;
	mustEncodeUri = true;
	if (contdescr == null)
	{ 
		contdescr = "";
	}
	
	switch(book) 
	{
		case 'facebook' :					
			imgvideo = '';
      		imgvideocb = _contentBean.imageFilePath;
			if( (imgvideocb!=null) && (imgvideocb!="") ) 
			{
				imgvideo = '&p[images][0]=' + encodeURIComponent('http://images.yalp.alice.it' + imgvideocb);
		    }
      		videostr = '';
				if ($('txtEmb') != null && $('txtEmb').value!=null && $('txtEmb').value!="")
				
		    {	
				embstr = $('txtEmb').value;
	      		indstart = embstr.indexOf("embed src=");
	      		if(indstart!=-1) 
				{
		    		indstart = indstart + 11;
		    	}			
		    	indend = embstr.indexOf(" ", indstart);
		    	indend = indend - 1;
		    	videourl = embstr.substring(indstart, indend);								
		    	videourl = videourl.split("&").join("%26");
		    	indstart = embstr.indexOf("width=");
		    	wid = embstr.substring( (indstart+7) , (indstart+10));
	     		indstart = embstr.indexOf("height=");
	      		hei = embstr.substring( (indstart+8) , (indstart+11));
	      		videostr = '&p[video][type]=application%2Fx-shockwave-flash&p[video][height]='+hei+'&p[video][width]='+wid+'&p[video][src]='+encodeURIComponent(videourl)+'&p[video][v]=0&p[video][safe]=1';
				alert(videostr);
                alert("imgvideo: "+imgvideo);
				result = 'http://www.new.facebook.com/sharer.php?s=100&p[medium]=103&p[title]='+encodeURIComponent(title)+videostr+'&p[summary]='+encodeURIComponent(contdescr)+'&p[url]='+encodeURIComponent(url)+imgvideo;
            }   
	        else
            { 
				result = 'http://www.new.facebook.com/sharer.php?s=100&p[medium]=103&p[title]='+encodeURIComponent(title)+'&p[summary]='+encodeURIComponent(contdescr)+'&p[url]='+encodeURIComponent(url);
		    }
		    mustEncodeUri = false;
		break;		
		case 'twitter' :
			result ='http:\/\/twitter.com\/home?status=Controlla%20questo%20video%20--%20'+title+'%20'+url;
		break;	
		default : result = '';				
	}
		
	if ( null == result || "" == result ) 
	{

	  	alert("Servizio momentaneamente non disponibile. Riprova pi&ugrave; tardi."); 
	} 
	else 
	{		
		if (mustEncodeUri)
		{	
			result = encodeURI(result);
		}	
	    window.open(result,'Condividi');
	}
} */

function getRatingVoto(idRating,iTotal,iCounter) {
	try {
		var ulbg=document.getElementById(idRating);
		var iVote;
		
		if(iTotal == 0 ||  iCounter == 0){
			iVote = 0;
		}else{
			iVote = parseInt(iTotal/iCounter);
		}
			
		if (iVote==0) {
			ulbg.style.backgroundPosition="-166px -114px";
		} 
		if (iVote==1) {
			ulbg.style.backgroundPosition="-166px -125px";
		} 
		if (iVote==2) {
			ulbg.style.backgroundPosition="-166px -136px";
		}
		if (iVote==3) {
			ulbg.style.backgroundPosition="-166px -147px";
		}
		if (iVote==4) {
			ulbg.style.backgroundPosition="-166px -158px";
		}
		if (iVote==5) {
			ulbg.style.backgroundPosition="-166px -169px";
		}
	} catch(ex){}
}

//Questa si comporta come getRatingVoto, ma accettando in entrata direttamente la media,
//non fa la divisione tra numero voti e totale voti.
function getVoto(idRating,iVote) {
	var ulbg=document.getElementById(idRating);
		
	if (iVote==0) {
		ulbg.style.backgroundPosition="-166px -114px";
	} 
	if (iVote==1) {
		ulbg.style.backgroundPosition="-166px -125px";
	} 
	if (iVote==2) {
		ulbg.style.backgroundPosition="-166px -136px";
	}
	if (iVote==3) {
		ulbg.style.backgroundPosition="-166px -147px";
	}
	if (iVote==4) {
		ulbg.style.backgroundPosition="-166px -158px";
	}
	if (iVote==5) {
		ulbg.style.backgroundPosition="-166px -169px";
	}
}


/* START SOCIAL LIKE */
function doCall_SendLike(id) {        
      request = LikeClient.urlVoteService;
      request = request + "?MESSAGE=RECORD_LIKE";
     	request = request + "&CONTENT_ID=" + id; 
      request = request + "&OUTPUT=json"; 
      request = request + "&CALLBACK=callback_sv";
	aObj = new JSONscriptRequest(request);
	aObj.buildScriptTag();
 	aObj.addScriptTag();
}

function LikeClientFunct(){  
	this.urlVoteService = "http://like.cubovision.it/like-cubo/LikeService";
	this.nameCookieLike = "cubovision_like";		
	this.timeMessages = "3000";		
	this.sendLike = function(id) {
		doCall_SendLike(id);
   }
	
}

LikeClient = new LikeClientFunct(); 

function socialLike(){
	LikeClient.sendLike(getCntId());
	document.getElementById("social_like").innerHTML ="<strong>Grazie!</strong>";
	return false;
}

/* END SOCIAL LIKE */