function cambiar_color_over(celda){
		celda.style.background='#EF2F72';
                celda.style.cursor='arrow';
	}
function cambiar_color_out(celda){
		celda.style.backgroundImage='url(img/pagina/bg_menu.gif)';
                celda.style.cursor='hand';
	}

function MostrarFecha()
   {
   var nombres_dias = new Array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado")
   var nombres_meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")

   var fecha_actual = new Date()

   dia_mes = fecha_actual.getDate()		
   dia_semana = fecha_actual.getDay()		
   mes = fecha_actual.getMonth() + 1
   anio = fecha_actual.getFullYear()
   
   document.write(nombres_dias[dia_semana] + ", " + dia_mes + " de " + nombres_meses[mes - 1] + " de " + anio)
   }
   

var TVS = null;

function getVideos(query) { 
	document.getElementById("TitleBarDiv").innerHTML = 'Cargando...';
	TVS.getVideos(query);
}


function playVideo(videoUrl, id) {
	window.open(videoUrl, '', 'width=800,height=800,location=no,menubar=no,resizable=yes,scrollbars=yes');
}


function handleUpdate(methodName) {
	refreshResults(TVS);
}



TruveoVideoSearch object is complete.
function handleLoad(reloadStateFlag) {
	getVideos('veniparchate');
}


function handleError(errorCode, errorMessage) {
	alert("ERROR: Code " + errorCode + "; " + errorMessage);
}


function refreshResults(TVS) {
	var theHTML = '';
	if (TVS.VideoSet && TVS.VideoSet.Video) {
		var VideoSet = TVS.VideoSet;
		var cellsPerRow = 5;
		var rows = 5;
		theHTML += '<table style="width: 100%; margin: 0 0 0 0; border: 0px; border-style: none; 

border-collapse: collapse; vertical-align: top;">';
		for (var j=0; j < rows; j++) {
			theHTML += '<tr>';
			for (var k=0; k < cellsPerRow; k++) {
				var i = (j * cellsPerRow) + k; 
				theHTML += '<td align="center" valign="top" style="padding: 12px 4px 12px 

4px;">';
				if (i >= VideoSet.Video.length) { theHTML += '&nbsp;'; }
				else {
					var theVideo = VideoSet.Video[i];
					if (theVideo) {
						theHTML += '<div style="width: 130px;">';
						theHTML += '<a 

href="javascript:playVideo(\''+theVideo.videoUrl+'\','+theVideo.id+'); void(0);"><img 

src="'+theVideo.thumbnailUrl+'" class="thumbnail" alt="click to play video"/></a>';
						theHTML += '<div><a 

href="javascript:playVideo(\''+theVideo.videoUrl+'\','+theVideo.id+'); 

void(0);">'+theVideo.title+'</a></div>';
						theHTML += '</div>';
					}
				}
				theHTML += '</td>';
			}
			theHTML += '</tr>';
		}
		theHTML += '</table>';
		document.getElementById("ResultsDiv").innerHTML = theHTML;
		document.getElementById("TitleBarDiv").innerHTML = TVS.VideoSet.title;
	}
	else {
		document.getElementById("ResultsDiv").innerHTML = '&nbsp;';
		document.getElementById("TitleBarDiv").innerHTML = 'There are no videos available.';
	}
	document.getElementById('searchBox').value = TVS.query;
}


function VSLoad() {
	TVS = new TruveoVideoSearch('b7baf0adb57811d6e');
	TVS.results = 25;
	TVS.attachEvent('onerror', 'handleError(errorCode, errorMessage);');
	TVS.attachEvent('onupdate', 'handleUpdate(methodName);');
	TVS.attachEvent('onload', 'handleLoad(reloadStateFlag);');
	TVS.initialize();
}


