
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, rutaCert, adZone, autostart){
	srcVideo = 'http://www.youtube.com/embed/' + idVideo + '?wmode=opaque';
	if (tipo=='bc') srcVideo = 'http://play.tuteve.tv/brightcovevideo/' + idVideo + '/default/618/354/' + rutaCert + '/' + 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;
	}
}

function setVideoFrame2(idVideo, indice, tipo, rutaCert, adZone, autostart, preroll){
	srcVideo = 'http://www.youtube.com/embed/' + idVideo + '?wmode=opaque';
	if (tipo=='bc') srcVideo = 'http://play.tuteve.tv/brightcovevideo/' + idVideo + '/default/618/354/' + rutaCert + '/' + autostart + '/' + preroll;
	if (indice >0) focusVideo(indice);
	document.getElementById('videoFrame').setAttribute('src',srcVideo);
	//alert(33);
	//if (adZone != ""){
//		html = document.getElementById(adZone).innerHTML;
//		
//		document.getElementById(adZone).innerHTML = '';
//		//alert(html);
//		document.getElementById(adZone).innerHTML = html;
//	}
	
	m=setTimeout("detectVideoStatus()",5000);
}

var t=0;
function detectVideoStatus(){
	
	//var fra = document.getElementById('videoFrame');
// following will work on same domain (or subdomain with document.domain set) only
	//var fraContent = fra.contentDocument || fra.contentWindow.document;
	
	status=document.getElementById('videoStatus').innerHTML;
	//status=fraContent.getElementById('videoStatus').innerHTML;
	//alert(status);
	//document.getElementById('xstatus').innerHTML = status;
	if (status == 1) {
	//	alert('fin');
		clearTimeout(t);
		finalizaPreRoll();
	}else{
		t=setTimeout("detectVideoStatus()",2000);
	}
}

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(){
	if(top!=self){
		top.location.replace(document.location);
		//alert("For security reasons, framing is not allowed; click OK to remove the frames.")
	}
	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 inicializaPortada_play2(){
	if(top!=self){
		top.location.replace(document.location);
		//alert("For security reasons, framing is not allowed; click OK to remove the frames.")
	}
	var ocaruselVideos = new classCarrusel('caruselThumbs', 'botPrevNav', 'botNextNav', 3, 300);
    ocaruselVideos.init();
	
	$(".itmVideo:nth-child(odd)").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(){
	if(top!=self){
		top.location.replace(document.location);
		//alert("For security reasons, framing is not allowed; click OK to remove the frames.")
	}
	$(".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';
	
	if (senal == "Live") {
		document.getElementById('publicidad').style.display = 'none';		
	} else {
		document.getElementById('publicidad').style.display = 'block';		
	}
	
	senalOn = senal;
	cert_registerHit(235347, '/videoview/play/senal' + senalOn, 'cert_Pivot')
}

//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('play.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;
	
}


//Fin de Scripts para google search
