/*
function addLoadEvent(func) 
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{	window.onload = func;	} 
	else 
	{	window.onload = function() 
		{	oldonload();	func();	}
	}
}
*/

// Tabs
jQuery(document).ready(function() {
//// Inicia Tabs ////
// http://stilbuero.de/jquery/tabs/
// jQuery('#titularesPequenios').tabs({ fxAutoHeight: true, fxSlide: true, fxFade: true, fxSpeed: 'fast' });
jQuery('#titularesPequenios').tabs();

// ocultando titulares sin contenido
var cat=new Array('Locales', 'Nacionales', 'Internacionales', 'Eclesiales');
for(i=0; i<cat.length; i++){
// alert($('lstTitu'+cat[i]));
	if(!$('lstTitu'+cat[i]))
		jQuery('#titularesPequenios').disableTab(i+1);
//	if(!$('lstTitu'+cat[i])) $('titu'+cat[i]).setAttribute("src",$('titu'+cat[i]).className+' tabs-disabled');
}

//// Inicia Scroll de Banners ////
jQuery("#banners").jcarousel({
	auto: 5,
	scroll: 1,
	wrap: 'both',
	// easing: 'BounceEaseOut',
	easing: 'swing',
	animation: 1000, 
	initCallback: mycarousel_initCallback,
	// This tells jCarousel NOT to autobuild prev/next buttons
	buttonNextHTML: null,
	buttonPrevHTML: null
    });

//// Inicia Scrool de Titulares ////
	jQuery('#titularesGrandes').jcarousel({
	vertical: true,
	auto: 10,
	scroll: 1,
	wrap: 'both',
	// easing: 'BounceEaseOut',
	easing: 'swing',
	animation: 1000, 
	initCallback: carouselTitu_initCallback,
	// This tells jCarousel NOT to autobuild prev/next buttons
	buttonNextHTML: null,
	buttonPrevHTML: null
    });

//// Inicia Acrodeon de Categorias ////
	//jQuery('.widget').accordion({
	jQuery('#lstCategorias').accordion({
		autoheight: false,
		header: '.head',
		event: 'mouseover',
		navigation: true		
		});

//// Inica Otros ////
	actAhoraMismo();
	addLnkOnLine();

});

// Carousel
function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

};

jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};
/*
jQuery(document).ready(function() {
jQuery("#banners").jcarousel({
	auto: 5,
	scroll: 1,
	wrap: 'both',
	// easing: 'BounceEaseOut',
	easing: 'swing',
	animation: 1000, 
	initCallback: mycarousel_initCallback,
	// This tells jCarousel NOT to autobuild prev/next buttons
	buttonNextHTML: null,
	buttonPrevHTML: null
    });
});
*/
//

function carouselTitu_initCallback(carousel) {
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

};
/*
jQuery(document).ready(function() {
	jQuery('#titularesGrandes').jcarousel({
	vertical: true,
	auto: 10,
	scroll: 1,
	wrap: 'both',
	// easing: 'BounceEaseOut',
	easing: 'swing',
	animation: 1000, 
	initCallback: carouselTitu_initCallback,
	// This tells jCarousel NOT to autobuild prev/next buttons
	buttonNextHTML: null,
	buttonPrevHTML: null
    });
});
*/
// Ahora Mismo
jQuery(document).ready(function() {
	actAhoraMismo();
	addLnkOnLine();
});

// addLoadEvent(actAhoraMismo);

function actAhoraMismo()
{
	AhoraMismo();
	//alert($lnkprograma);
	if(am[4]!=undefined){am[0]="<a style='color:#fff' href='"+am[4]+"'>"+am[0]+"</a>";}
	$("AM_Programa").innerHTML=am[0];
	//$("AM_Imagen").src="/imagenes/programas/previo/"+am[1];
	$("AM_Imagen").setAttribute("src", "/imagenes/programas/previo/"+am[1]);
	
	if(am[2].length>0)	{	$("AM_lblConduce").innerHTML="Conduce";	$("AM_Conduce").innerHTML=am[2];	}
	else				{	$("AM_lblConduce").innerHTML="";	}

	if(am[3]!=undefined) $("AM_Sinopsis").innerHTML=am[3];
	if(am[4]!=undefined) $("AM_lnkPrograma").href=am[4];	// $("AM_lnkPrograma").setAttribute("href", am[4]); 

	setTimeout("actAhoraMismo()",300000); // se ejecuta cada 5 segundos (5*60000)
//	setTimeout("actAhoraMismo()",6000);
}

// OnLine

function addLnkOnLine()
{
	var obj=$("lnkOnLine");
	//alert(obj);
	obj.href="#";
	obj.onclick=function(){window.open("/OnLine/", "OnLine", "width=500,height=480,scrollbars=no,resizable=0,toolbar=0,border=0,hotkeys=0,Status=0");};
}