window.onload = function () {init()};
$(document).ready(init2);

function init()
{
	var h = $('#main').height() - 100; // 100 es por el padding del menu 4em top y 6em bottom
	if (h > $('#submenu').height() )
		$('#submenu').height(h+'px');

	$('#buscador_videos').height($('#submenu').outerHeight() - 25); // restamos 25 que es el padding top del buscador de videos
	$('#buscador_blog').height($('#submenu').outerHeight() - 25); // restamos 25 que es el padding top del buscador de blog
	$('#panel_calendario').height($('#submenu').outerHeight() - 45); // restamos 45 que es el padding top + el bottom del panel de calendario
}

function init2()
{
    $('div.calendario div.maseventos ul li:even').addClass('par');

    $('#boton_buscador_videos').click(function () {
        var first = $(this).attr('first');
        var end = $(this).attr('end');
        var enlace = $(this).attr('enlace');
        var pag = $(this).prev().val();
        if (parseInt(pag) >= parseInt(first) && parseInt(pag) <= parseInt(end)) {
            document.location.href = enlace+$.trim(pag);
        }
    });

    $('#buscador_videos input.pag').keyup(function (e) {
        if (e.keyCode == 13) {
            $(this).next().trigger('click');
        }
    });

    $('#flash object').attr('width','460').attr('height','396');
    $('#flash embed').attr('width','460').attr('height','396');

    $('#blog .flash object').attr('width','460').attr('height','396');
    $('#blog .flash embed').attr('width','460').attr('height','396');

    $('a.escucha').click(function (e) { e.preventDefault();escucha($(this)) });
}

function escucha(elem)
{
	var img = elem.attr('img');
	var mp3 = elem.attr('mp3');

	window.open("/escucha.php?img="+img+" &mp3="+mp3,"mywindow");
}