');
});
$('#content .news').addClass('in');
// NEWS NAV
if($('#content .news').length){
var month_table = {
'enero': '01',
'febrero': '02',
'marzo': '03',
'abril': '04',
'mayo': '05',
'junio': '06',
'julio': '07',
'agosto': '08',
'septiembre': '09',
'octubre': '10',
'noviembre': '11',
'diciembre': '12'
};
$('#content .lateral-nav li>ul').collapse();
$('#content .lateral-nav a').attr('rel', function(){
var year = $(this).parent().parent().siblings('a').text() ||
$(this).text();
var month = month_table[$(this).text().toLowerCase()] ||
month_table[$(this).siblings('ul').find('a').eq(0).text().toLowerCase()] ||
'12';
return '#year-month-'+year+month;
});
$('#content .lateral-nav a').on('click.ntg-nav-news', function(e){
e.preventDefault();
var top = $(this.rel).offset().top;
$('html, body').animate({'scrollTop': top}, 500);
});
}
// TR ARTICLES LAZYLOAD
var articles_lazyload = lazy_load('#content .chpn-articles .figure', function(img){
return img.src.replace('img_70x50','img_700x500').split('?')[0];
});
// PA NEWS LAZYLOAD
var news_lazyload = lazy_load('#content .news .figure', function(img){
return img.src.replace('img_70x50','img_700x500').split('?')[0];
});
// PA NEWS NAV SCROLLSPY
var news_scrollspy = (function(){
var nav_anchors = $('#content .lateral-nav a');
var nav_lis = $('#content .lateral-nav li');
var fn = function(scroll){
nav_anchors.each(function(){
var target = $(this.rel);
if(target.length){
var top = target.offset().top;
var height = target.outerHeight(true);
if(top - 10 < scroll && top + height + 10 > scroll){
nav_lis.removeClass('current');
$(this)
.parent().addClass('current')
.parent().collapse('show')
.parent().siblings()
.children('ul').collapse('hide');
}
}
});
};
fn($(window).scrollTop());
return fn;
})();
// AR NEW DATE & TITLE
$('.article .noticia .fecha').html(function(){
var txt = $(this).text().split(' de ');
return ''+txt[0]+''+txt[1]+''+txt[2]+'';
});
$('.article .noticia')
.children('.fecha,.title').wrapAll('
');
// AR BODY CLASS
var ar_type = $('body.article').ntg().getClass('.toclass')[0];
$('body.article').addClass(ar_type);
// AR LINK TEMA
//link_tema($('#modal'));
// AR REDRAW
redraw_article($('body.article #modal').contents());
var close_modal_ficha = $('×');
$('#modal_ficha')
.children()
.wrapAll('
');
$('#modal_ficha .modal-content').prepend(close_modal_ficha);
close_modal_ficha.click(function(e){
e.preventDefault();
$('#modal_ficha').modal('hide');
})
// AR GALLERY
// TR SCROLL
$(window).scroll(function(e){
var scroll = $(this).scrollTop();
throttle(function(){
articles_lazyload(scroll);
news_lazyload(scroll);
}, 33);
if($('#content .news').length) news_scrollspy(scroll);
});
// FOOTER APPEAR
$('#main').css('margin-bottom', function(){
return $('#footer').height();
});
// REMOVE ALL EMPTYS
remove_all_emptys.call($('.no-empty'));
function remove_all_emptys(){
if ($(this).is(':empty')) $(this).remove();
else $(this).children().not('img, input, br').each(remove_all_emptys);
if ($(this).is(':empty')) $(this).remove();
}
// COLUMNS
$('[class*="recuadros-col"]')
.each(function(){
var that = $(this);
var row = null;
var col = that.attr('class')
.match(/recuadros-col-(\w*)-(\d*)/)
.slice(1);
that
.children('.recuadro')
.addClass('col-'+col[0]+'-'+col[1])
.wrapAll('
');
});
});
function draw_share(content, href){
content
.find('.share')
.append(function(){
return $(this).find('a');
})
.children('a')
.click(popup);
}
function redraw_article(content, href, type){
content.find('.resources').zen('div.border>$(>*)');
content.find('.link-media').each(function(i){ active_link_media.call(this, i); });
draw_share(content, href);
var filelink = content.find('.figure > a');
if(filelink.length){
filelink.attr('href', function(){
return $(this).attr('href').split('?')[0];
}).remove();
var filename = filelink.attr('href').split('/').pop();
var fileinfo = content.find('.figure').children('.sizekb, .formato').html(function(){
var label = $(this).hasClass('sizekb') ? 'Tamaño: ' : 'Formato: ';
return '