
function fixCabecera(){
	// Get a reference to the message whose position
	// we want to "fix" on window-scroll.
	var message = $( "#panelSuperior" );
	 
	// Get the origional position of the message; we will
	// need this to compare to the view scroll for
	// reverting back to the original display position.
	var originalMessageTop = message.offset().top;
	 
	// Get a reference to the window object; we will use
	// this several time, so cache the jQuery wrapper.
	var view = $( window );
	 
	 
	// Bind to the window scroll and resize events.
	// Remember, resizing can also change the scroll
	// of the page.
	view.bind(
	"scroll resize",
	function(){
	 
	// Get the current scroll of the window.
	var viewTop = view.scrollTop();
	 
	// Check to see if the view had scroll down
	// past the top of the original message top
	// AND that the message is not yet fixed.
	if (
	(viewTop > originalMessageTop) &&
	!message.is( ".cabecera-fixed" )
	){
	 
	// Toggle the message classes.
	message
	.removeClass( "cabecera-absolute" )
	.addClass( "cabecera-fixed" )
	;
	 
	// Check to see if the view has scroll back up
	// above the message AND that the message is
	// currently fixed.
	} else if (
	(viewTop <= originalMessageTop) &&
	message.is( ".cabecera-fixed" )
	){
	 
	// Toggle the message classes.
	message
	.removeClass( "cabecera-fixed" )
	.addClass( "cabecera-absolute" )
	;
	 
	}
	}
	);
}

 function moverLista(lista, izq, altura, listaOn){
	document.getElementById('itmvistos').className = 'item';
	document.getElementById('itmcompartidos').className = 'item';
	document.getElementById('itm' + listaOn).className = 'item On';
	$("#" + lista).animate({ 
            marginLeft: izq + "px", 
        }, 700);
	$("#loMas").animate({ 
            height: altura + "px", 
        }, 700);
}

function setVideoFrame(idVideo, indice, tipo, adZone, autostart){
	srcVideo = 'http://www.youtube.com/embed/' + idVideo + '?wmode=opaque';
	if (tipo=='bc') srcVideo = 'http://play.tuteve.tv/brightcovevideo/' + idVideo + '/default/453/293/' + autostart;
	if (indice >0) focusVideo(indice);
	document.getElementById('videoFrame').setAttribute('src',srcVideo);
	if (adZone != ""){
		html = document.getElementById(adZone).innerHTML;
		
		document.getElementById(adZone).innerHTML = '';
		//alert(html);
		document.getElementById(adZone).innerHTML = html;
	}
}

indiceGaleria = 1;
function focusVideo(indice){
	document.getElementById('layer_' + indiceGaleria).className = 'layer';
	document.getElementById('titulo_' + indiceGaleria).className= 'titulo';
	document.getElementById('num_' + indiceGaleria).className =  'numero';
	indiceGaleria = indice;
	document.getElementById('layer_' + indice).className = 'layer layerOn';
	document.getElementById('titulo_' + indice).className = 'titulo tituloOn'
	document.getElementById('num_' + indice).className =  'numero numeroOn';
}

function  verMenu(layer, flag){
	if (flag == 1){
		$("#" + layer).show();
	}else{
		$("#" + layer).hide();
	}
}

function inicializaPortada(){
	var ocaruselVideos = new classCarrusel('caruselThumbs', 'botPrevNav', 'botNextNav', 3, 300);
    ocaruselVideos.init();
	
	$(".itmVideo:nth-child(even)").css("margin-right","0px");
	$('#cajaBuscador').focus(function() {
		if ($('#cajaBuscador').val() == 'Ingresa tu búsqueda...') $('#cajaBuscador').val('');
	});
	$('#cajaBuscador').blur(function() {
  		if ($('#cajaBuscador').val() == '') $('#cajaBuscador').val('Ingresa tu búsqueda...');
	});
}

function inicializaInterior(){
	$(".itmVideo:nth-child(even)").css("margin-right","0px");
	$('#cajaBuscador').focus(function() {
		if ($('#cajaBuscador').val() == 'Ingresa tu búsqueda...') $('#cajaBuscador').val('');
	});
	$('#cajaBuscador').blur(function() {
  		if ($('#cajaBuscador').val() == '') $('#cajaBuscador').val('Ingresa tu búsqueda...');
	});
}
function cambiarSenal(senal){
	document.getElementById('senal' + senalOn).style.display = 'none';
	document.getElementById('fbstream_' + senalOn).style.display = 'none';
	document.getElementById('btn' + senalOn).className = 'boton';
	
	document.getElementById('senal' + senal).style.display = 'block';
	document.getElementById('fbstream_' + senal).style.display = 'block';
	document.getElementById('btn' + senal).className = 'boton On';
	
	senalOn = senal;
}

//Scripts para google search

function inicializaSearch(paramBuscador) {
	//Inicializo el control de busqueda de google
	searchControl = new google.search.SearchControl();
	searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
	SearchOptions = new google.search.SearcherOptions();
        SearchOptions.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);

	var webSearch = new google.search.WebSearch();
	webSearch.setSiteRestriction('magaly.tuteve.tv');
	webSearch.setUserDefinedClassSuffix("buscador");
	// Limito la busqueda a tuteve.tv
	searchControl.addSearcher(webSearch,SearchOptions);
	searchControl.setNoResultsString('No se encontro ningún resultado');
	// agrego el contenedor para el formulario
	searchControl.draw(document.getElementById("searchcontrol"));
        //-- Adiciono la cadena de busqueda
        var textobusqueda = paramBuscador;
	if (textobusqueda != ''){
            var spanresult = $('.textresultsearch');
            spanresult.html(textobusqueda);
            searchControl.execute(textobusqueda);
	}
}


function buscar(){
	var textobusqueda = $('#cajaBuscador').val();
	document.location='http://play.tuteve.tv/buscador/'+textobusqueda;
	
}

function buscador(){
	var textobusqueda = $('#cajaBuscador').val();
	document.location='http://magaly.tuteve.tv/busqueda/'+textobusqueda;

}


//Fin de Scripts para google search

