/*
function LoadVideoBar() {

    var videoBar;
    var options = {
        largeResultSet : !true,
        horizontal : true,
		
        autoExecuteList : {
          cycleTime : GSvideoBar.CYCLE_TIME_MEDIUM,
          cycleMode : GSvideoBar.CYCLE_MODE_LINEAR,
          executeList : ["asturforesta"]
        }
      }

    videoBar = new GSvideoBar(document.getElementById("videoBar-bar"),
                              GSvideoBar.PLAYER_ROOT_FLOATING,
                              options);
    }
    // arrange for this function to be called during body.onload
    // event processing
    GSearch.setOnLoadCallback(LoadVideoBar);
*/
function loadVideo(playerUrl, autoplay) {
  swfobject.embedSWF(
      playerUrl + '&rel=1&border=0&fs=1&autoplay=' + 
      (autoplay?1:0), 'player', '290', '250', '9.0.0', false, 
      false, {allowfullscreen: 'true'});
}
/*
function showMyVideos2(data) {
  var feed = data.feed;
  var entries = feed.entry || [];
  var html = ['<ul class="videos">'];
  for (var i = 0; i < entries.length; i++) {
    var entry = entries[i];
    var title = entry.title.$t.substr(0, 20);
    var thumbnailUrl = entries[i].media$group.media$thumbnail[0].url;
    var playerUrl = entries[i].media$group.media$content[0].url;
    html.push('<li onclick="loadVideo(\'', playerUrl, '\', true)">',
              '<span class="titlec">', title, '...</span><br /><img src="', 
              thumbnailUrl, '" width="130" height="97"/>', '</span></li>');
  }
  html.push('</ul><br style="clear: left;"/>');
  document.getElementById('videos2').innerHTML = html.join('');
  if (entries.length > 0) {
    loadVideo(entries[0].media$group.media$content[0].url, false);
  }
}
*/

hs.wrapperClassName= 'borderless floating-caption no-footer draggable-header';
hs.align= 'center';
hs.dimmingOpacity= .75;
hs.captionText= this.title;
hs.outlineType = 'rounded-white';

// Apply the Highslide settings
/*
hs.graphicsDir = 'javascript/highslide/graphics/';
hs.outlineType = 'drop-shadow';
hs.outlineWhileAnimating = true;
hs.allowSizeReduction = false;
// always use this with flash, else the movie will be stopped on close:
hs.preserveContent = false;
hs.wrapperClassName = 'draggable-header no-footer';
hs.showCredits = false;*/





// create a shorthand function so we don't need to put all this in the opener's onclick
function openYouTube(opener) {
	var returnValue;
	
	// Safari Mobile doesn't have Flash, so we just let the device use the built-in 
	// YouTube viewer.		
	if (/(iPhone|iPod|iPad)/.test(navigator.userAgent)) {
		opener.href = opener.href.replace('/v/', '/watch?v=');
		returnValue = true;		
	}
	else returnValue =hs.htmlExpand(opener, { 
		objectType: 'swf', 
		objectWidth: 480, 
		objectHeight: 385, 
		width: 480, 
		swfOptions: { 
			params: { 
				allowfullscreen: 'true' 
			}
		}, 
		maincontentText: 'You need to upgrade your Flash player' 
	});
	return returnValue;
} 
/*
function loadVideo(playerUrl, autoplay) {
  swfobject.embedSWF(
      playerUrl + '&rel=1&border=0&fs=1&autoplay=' + 
      (autoplay?1:0), 'player', '290', '250', '9.0.0', false, 
      false, {allowfullscreen: 'true'});
}
*/
function showMyVideos2(data) {

  var feed = data.feed;
  var entries = feed.entry || [];
  var html = ['<ul class="videos">'];
  var img1="";
  for (var i = 0; i < entries.length; i++) {
    var entry = entries[i];
    var title = entry.title.$t.substr(0, 20);
	var duration=Math.floor( entry[ "media$group" ][ "yt$duration" ].seconds / 60 ) + 'm ' + ( entry[ "media$group" ][ "yt$duration" ].seconds % 60 )+'s';
    var thumbnailUrl = entries[i].media$group.media$thumbnail[0].url;
    var playerUrl = entries[i].media$group.media$content[0].url;
/*
	if (i==1){
		img1=' class="video1"';
	}else {
		img1="";
	}*/
    html.push('<li',img1,'>', '<a href="',playerUrl,' &fs=1&" onclick="return openYouTube(this)" class="highslide"><img src="', 
              thumbnailUrl, '" width="140" height="80"/><br/><span class="titlec">', title, '</span><br/><span class="tiempo">',duration,'</span>', '</a></li>');
		  
  }
  html.push('</ul><br style="clear: left;"/>');
  document.getElementById('videoswrapper').innerHTML = html.join('');
  if (entries.length > 0) {
    loadVideo(entries[0].media$group.media$content[0].url, false);
  }
} 

function showMyVideos(data) {

  var feed = data.feed;
  var entries = feed.entry || [];
  var html = ['<ul class="videos">'];
  var img1="";
  for (var i = 0; i < entries.length; i++) {
    var entry = entries[i];
    var title = entry.title.$t.substr(0, 20);
	var duration=Math.floor( entry[ "media$group" ][ "yt$duration" ].seconds / 60 ) + 'm ' + ( entry[ "media$group" ][ "yt$duration" ].seconds % 60 )+'s';
    var thumbnailUrl = entries[i].media$group.media$thumbnail[0].url;
    var playerUrl = entries[i].media$group.media$content[0].url;

    html.push('<li',img1,'>', '<a href="',playerUrl,' &fs=1&" onclick="return openYouTube(this)" class="highslide"><img src="', 
              thumbnailUrl, '" width="120" height="80"/><br/><span class="titlec">', title, '</span><br/><span class="tiempo">',duration,'</span>', '</a></li>');
		  
  }
  html.push('</ul><br style="clear: left;"/>');
  document.getElementById('videoswrapper').innerHTML = html.join('');
  if (entries.length > 0) {
    loadVideo(entries[0].media$group.media$content[0].url, false);
  }
} 
