/* *** VIDEO CONTROL *** */

function replaceAll(stringValue, replaceValue, newValue)
{
	var functionReturn = new String(stringValue);
	while ( true )
	{
		var currentValue = functionReturn;
		functionReturn = functionReturn.replace(replaceValue, newValue);
		if ( functionReturn == currentValue )
			break;
		}
	return functionReturn;
}



function controlTogglePlay(){
	var thePlayer = 'player1';
	player = document.getElementById(thePlayer);
	player.sendEvent("PLAY");
}


//comparte con facebook
 function encodeface(index){
                  var currentVideoIndex = index;
                  var s = encodeURI(laurlface); 
                  abreface = window.open(s)
                  return abreface;

 
}	
	     
 
// fin comparte con facebook	     
 
 
// comparte con twitter


        		function twit(index){
              		var videoPlayingIndex = index;
              		
          			BitlyCB.shortenResponse = function(data) {//alert("Viendo");
                          var s = '';
                          var first_result;
                          // Results are keyed by longUrl, so we need to grab the first one.
                          for     (var r in data.results) {
                                  first_result = data.results[r]; break;
                                 
                          }
                          
                          for (var key in first_result) {
                          
                                  s += key + ":" + first_result[key].toString() + "\n";
                          
                          }
          
                          var twite= "http://twitter.com/home?status=Viendo en CruzRoja.tv: " + first_result['shortUrl'];
                          twitee = window.open(twite)
          
                          
                          return twitee;
                          
                  	}

             BitlyClient.shorten(laurl, 'BitlyCB.shortenResponse');
      
      		}	
          
          
//// fin comparte con twiter 

function playVideo(index, showing){


  currentVideoIndex = index;
  currentlyShowing = showing;
 
	highlightPlaylistItem(index);
	displayPlayingItem(index, showing);
	
	initPlayer(currentVideoIndex);
	c.scroll(currentVideoIndex);
	

				
}