var NFU = {};
NFU = {
init: function () {
this.TOPMENU.init();
this.SIDEMENU.init();
this.UTIL.init();
this.BREADCRUMB.init();
this.MEDIALIB.init();
this.LIGHTBOXVIDEO.init();
this.CUSTOMFORM.init();
$('#events-api').each(function () {
NFU.TIMELINE.init();
});
$('#mediacontent').each(function () {
NFU.MEDIAPLAYER.init();
});
function supports_input_placeholder () {
var i = document.createElement('input');
return 'placeholder' in i;
}
if (!supports_input_placeholder()) {
$('[placeholder]').focus(function () {
if ($(this).val() === $(this).attr('placeholder')) {
$(this).addClass('placehold-it-active').val('');
}
}).blur(function () {
if ($(this).val() === '') {
$(this).removeClass('placehold-it-active').val($(this).attr('placeholder'));
}
}).blur();
$('form').submit(function () {
$(this).find('input.placehold-it').each(function () {
if ($(this).val() === $(this).attr('placeholder')) {
$(this).val('');
}
});
});
}
}
};
NFU.TOPMENU = (function () {
var $wrap,
maxX,
calcMaxX = function () {
$wrap = $('header .wrap');
maxX = $wrap.offset().left + $wrap.width();
};
return {
init: function () {
$('header .wrap > ul > li').on('mouseover', function (event) {
var $li = $(event.currentTarget),
$dropdown = $li.children('.dropdown'),
dropdownOverflow;
if ($dropdown.size() === 0) {
return;
}
setTimeout(function () {
dropdownOverflow = -(maxX - ($dropdown.offset().left + $dropdown.width()));
if (dropdownOverflow > 0) {
$dropdown.css('left', $dropdown.position().left - dropdownOverflow);
}
}, $dropdown.is(':visible') ? 0 : 50);
});
$(window).resize(function () {
calcMaxX();
});
calcMaxX();
$('header .wrap > ul > li > a').click(function (event) {
event.stopPropagation();
event.preventDefault();
});
}
};
}());
NFU.SIDEMENU = {
options: {
noMenuToggle: true
},
$menu: $('#page').find('.sidemenu'),
init: function () {
this.initBindings();
},
initBindings: function () {
if (!this.options.noMenuToggle) {
this.$menu.find('> ul > li').not('simple').each(function () {
$(this).find('> ul').each(function () {
$(this).on('click', function (e) {
e.stopPropagation();
});
});
$(this).on('click', function (e) {
e.preventDefault();
e.stopPropagation();
$(this).toggleClass('opened');
});
});
}
$('footer span.sitetop').each(function () {
$(this).on('click', function () {
window.scrollTo(0, 0);
});
});
},
showLoginBox: function () {
var $loginBox = $('.login-box'),
$inner = $loginBox.children('.wrapper');
$loginBox.data('originalHeight', $inner.height());
$loginBox.height(0);
$inner.css('opacity', 0);
$loginBox.stop().animate({
'height': $inner.outerHeight(true)
}, {
'duration': 300,
'complete': function () {
$inner.animate({
'opacity': 1
}, {
'duration': 300
});
}
});
$loginBox.addClass('open');
$loginBox.next('.info-wrapper').animate({
'height': 0
}, {
'duration': 300
});
},
hideLoginBox: function () {
var $loginBox = $('.login-box'),
$inner = $loginBox.children('.wrapper'),
$infoWrapper;
$inner.stop().animate({
'opacity': 0
}, {
'duration': 300,
'complete': function () {
$loginBox.animate({
'height': 0
}, {
'duration': 300
});
$infoWrapper = $loginBox.next('.info-wrapper');
$infoWrapper.animate({
'height': $infoWrapper.children('.description').outerHeight(true)
}, {
'duration': 300
});
}
});
$loginBox.removeClass('open');
}
};
NFU.TIMELINE = {
actYear: 2012,
actMonth: 1,
inited: false,
loadedMonths: [],
ajaxUrl: '/esemenyek_json',
datCont: 'div#events-api div.dates-handler > ul',
item_length: 0,
item_per_page: 8,
item_width: 78,
actual_item: 0,
handler: 'div.dates-handler > ul',
speed: 400,
templates: {
'date_row_evtd': '
{%num}{%date}',
'date_row_null': '{%date}'
},
contents: {
'month': [
'január',
'február',
'március',
'április',
'május',
'június',
'július',
'augusztus',
'szeptember',
'október',
'november',
'december'
],
'month_s': [
'Jan', 'Feb', 'Márc',
'Ápr', 'Máj', 'Jún',
'Júl', 'Aug', 'Szept',
'Okt', 'Nov', 'Dec'
],
'month_l': [
31, 29, 31, 30,
31, 30, 31, 31,
30, 31, 30, 31
],
'days': [
'vasárnap', 'hétfő', 'kedd',
'szerda', 'csütörtök', 'péntek',
'szombat'
]
},
ready: function () {
if (!NFU.TIMELINE.inited) {
var d = new Date(),
t = d.getDate() - parseInt(d.getDay(), 10);
NFU.TIMELINE.actual_item = t;
NFU.TIMELINE.goto(t);
NFU.TIMELINE.inited = true;
}
},
init: function () {
NFU.TIMELINE.setActualDates();
NFU.TIMELINE.attachRollers();
},
getWeekDay: function (year, month, day) {
var d = new Date(year + '/' + month + '/' + day).getDay();
return NFU.TIMELINE.contents.days[d];
},
getContent: function (array, year, month) {
NFU.TIMELINE.loadedMonths[NFU.TIMELINE.loadedMonths.length] = year + '' + month;
var contents = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
ret = '',
i, cnt, actDay, date,
retu = [];
for (i in array) {
if (array.hasOwnProperty(i)) {
if (array[i].date_start.substr(0, 7) === year + '-' + month) {
contents[array[i].date_start.substr(8, 2) - 1]++;
}
}
}
for (i = 0; i < NFU.TIMELINE.contents.month_l[month - 1]; i++) {
cnt = '';
actDay = (i < 9 ? '0' + (i + 1) : i + 1);
date = (i + 1) + '. ' + NFU.TIMELINE.getWeekDay(year, month, (i + 1));
if (contents[i] > 0) {
cnt = NFU.TIMELINE.templates.date_row_evtd;
cnt = cnt.replace('{%num}', contents[i]);
cnt = cnt.replace('{%date}', date);
cnt = cnt.replace('{%year}', year);
cnt = cnt.replace('{%day}', actDay);
cnt = cnt.replace('{%month}', month);
cnt = cnt.replace('{%href}', '/events/0/search?Date_Year=' + year + '&Date_Month=' + month + '&Date_Day=' + actDay);
ret += cnt;
} else {
cnt = NFU.TIMELINE.templates.date_row_null;
cnt = cnt.replace('{%date}', date);
cnt = cnt.replace('{%year}', year);
cnt = cnt.replace('{%month}', month);
cnt = cnt.replace('{%day}', actDay);
ret += cnt;
}
}
retu.data = ret;
retu.datnum = NFU.TIMELINE.contents.month_l[month - 1];
return retu;
},
goto: function (i) {
var year, month, al, act, next;
if (i < 14) {
NFU.TIMELINE.loadedMonths.sort();
year = (NFU.TIMELINE.loadedMonths[0].toString().substr(0, 4));
month = (NFU.TIMELINE.loadedMonths[0].toString().substr(4, 2));
if (month === 1) {
year--;
month = 12;
} else {
month--;
}
month = month > 9 ? month : '0' + month;
NFU.TIMELINE.loadDatas(year, month);
}
if (i > NFU.TIMELINE.item_length - 14) {
NFU.TIMELINE.loadedMonths.sort();
year = (NFU.TIMELINE.loadedMonths[NFU.TIMELINE.loadedMonths.length - 1].toString().substr(0, 4));
month = (NFU.TIMELINE.loadedMonths[NFU.TIMELINE.loadedMonths.length - 1].toString().substr(4, 2));
if (month === 12) {
year++;
month = 1;
} else {
month++;
}
month = month > 9 ? month : '0' + month;
NFU.TIMELINE.loadDatas(year, month);
}
al = $(NFU.TIMELINE.handler).children('li').eq(i);
if ($(NFU.TIMELINE.handler).children('li').eq(i + 6).attr('data-month') === al.attr('data-month')) {
$('div.month-roller > span').html(NFU.TIMELINE.contents.month[(al.attr('data-month')) - 1]);
} else {
act = NFU.TIMELINE.contents.month[(al.attr('data-month')) - 1];
next = NFU.TIMELINE.contents.month[al.attr('data-month')];
$('div.month-roller > span').html(
(act === undefined ? NFU.TIMELINE.contents.month[11] : act) + ' - ' + (next === undefined ? NFU.TIMELINE.contents.month[0] : next)
);
}
$('div.events-api-wrapper > span.date').html(al.attr('data-year') + '. ' + NFU.TIMELINE.contents.month[al.attr('data-month') - 1]);
$(NFU.TIMELINE.handler).stop(true, true).animate({
'left': -1 * NFU.TIMELINE.item_width * i
}, NFU.TIMELINE.speed);
},
goto_next: function () {
NFU.TIMELINE.actual_item += 7;
NFU.TIMELINE.goto(NFU.TIMELINE.actual_item);
},
goto_back: function () {
NFU.TIMELINE.actual_item -= 7;
NFU.TIMELINE.goto(NFU.TIMELINE.actual_item);
},
prependLoad: function (data, year, month) {
var c = NFU.TIMELINE.getContent(data, year, month), new_left;
NFU.TIMELINE.item_length += c.datnum;
new_left = parseInt($(NFU.TIMELINE.handler).css('left'), 10) - (c.datnum * NFU.TIMELINE.item_width);
NFU.TIMELINE.actual_item += c.datnum;
$(NFU.TIMELINE.datCont).prepend(c.data);
$(NFU.TIMELINE.handler).stop(true, true).animate({'left': new_left}, 0);
NFU.TIMELINE.goto(NFU.TIMELINE.actual_item);
},
appendLoad: function (data, year, month) {
var c = NFU.TIMELINE.getContent(data, year, month);
NFU.TIMELINE.item_length += c.datnum;
$(NFU.TIMELINE.datCont).append(c.data);
},
loadDatas: function (year, month) {
$.ajax({
url: NFU.TIMELINE.ajaxUrl,
dataType: 'json',
data: {'year': year, 'month': month},
success: function (data) {
var now = new Date(),
m,
d;
NFU.TIMELINE.loadedMonths.sort();
if (NFU.TIMELINE.loadedMonths[0] && NFU.TIMELINE.loadedMonths[0] > (year + '' + month)) {
NFU.TIMELINE.prependLoad(data, year, month);
} else {
NFU.TIMELINE.appendLoad(data, year, month);
}
NFU.TIMELINE.ready();
m = (now.getMonth() + 1) < 10 ? '0' + (now.getMonth() + 1) : (now.getMonth() + 1);
d = now.getDate() < 10 ? '0' + now.getDate() : now.getDate();
$('#events-api')
.find('li[data-day="' + d + '"][data-month="' + m + '"][data-year="' + now.getFullYear() + '"]')
.addClass('today');
},
error: function (a, b, c) {}
});
},
setActualDates: function () {
var d = new Date(), m;
NFU.TIMELINE.actYear = d.getFullYear();
m = d.getMonth() + 1;
m = m > 9 ? m : '0' + m;
NFU.TIMELINE.actMonth = m;
NFU.TIMELINE.loadedMonths[0] = NFU.TIMELINE.actYear.toString() + NFU.TIMELINE.actMonth.toString();
NFU.TIMELINE.loadDatas(NFU.TIMELINE.actYear, NFU.TIMELINE.actMonth);
},
attachRollers: function () {
$('a#roll_back').click(function () {
NFU.TIMELINE.goto_back();
});
$('a#roll_next').click(function () {
NFU.TIMELINE.goto_next();
});
var w = NFU.TIMELINE.item_length * NFU.TIMELINE.item_width;
$(NFU.TIMELINE.handler).css({ 'width': w});
$(NFU.TIMELINE.handler).draggable({
axis: 'x',
stop: function () {
NFU.TIMELINE.actual_item = (Math.round((-1 * $(this).css('left').replace('px', '')) / NFU.TIMELINE.item_width));
NFU.TIMELINE.goto(NFU.TIMELINE.actual_item);
}
});
}
};
NFU.MEDIAPLAYER = {
url: '',
$xml: null,
items: [],
itemCount: 0,
type: 2, // 1 -> gallery, 2 -> video, 3 -> doc
currentIndex: 0,
currentThumbIndex: 0,
init: function () {
var $mediaContent = $('#mediacontent');
this.url = $mediaContent.data('url');
this.type = $mediaContent.data('type');
this.loadXML();
},
loadXML: function () {
var ajaxObj = {
type: 'GET',
url: NFU.MEDIAPLAYER.url,
dataType: 'xml',
beforeSend: function (xhr) {
xhr.withCredentials = true;
},
success: NFU.MEDIAPLAYER.parseXML,
error: function (xhr, text, error) {}
},
host = NFU.UTIL.parseURL(NFU.MEDIAPLAYER.url).host,
a;
if (basicAuth[host]) {
for (a in basicAuth[host]) {
if (basicAuth[host].hasOwnProperty(a)) {
ajaxObj[a] = basicAuth[host][a];
}
}
}
$.ajax(ajaxObj);
},
parseXML: function (data) {
NFU.MEDIAPLAYER.$xml = $(data);
NFU.MEDIAPLAYER.$xml.find('item').each(function () {
var entry = {};
entry.title = $(this).find('title').first().text();
entry.link = $(this).find('link').text();
if ($.trim($(this).find('description').first().text()) !== '') {
entry.description = $.trim($(this).find('description').first().text());
} else {
entry.description = $.trim($(this).find('description').not(':first').text());
}
entry.content = $(this).contents().filter('media\\:content').attr('url');
entry.thumbnail = $(this).contents().filter('media\\:thumbnail').attr('url');
entry.download = $(this).contents().filter('enclosure').attr('url');
entry.filesize = $(this).contents().filter('media\\:content').attr('fileSize');
NFU.MEDIAPLAYER.items.push(entry);
NFU.MEDIAPLAYER.itemCount++;
});
if (NFU.MEDIAPLAYER.type !== 3) {
NFU.MEDIAPLAYER.generateThumbnails();
NFU.MEDIAPLAYER.initShow();
NFU.MEDIAPLAYER.initBindings();
$('#mediacontent').show();
$('#doccontent').hide();
} else {
$('#doccontent').show();
$('#mediacontent').hide();
NFU.MEDIAPLAYER.generateDocs();
}
},
initShow: function () {
var $mediaContent = $('#mediacontent'),
$wrapper = $mediaContent.find('.show .show-wrapper'),
$download = $mediaContent.find('.show .download'),
$title = $mediaContent.find('.show h4'),
$img = null,
$video;
$wrapper.empty();
if (NFU.MEDIAPLAYER.type === 1) {
$img = $('');
$img.attr('src', this.items[0].content);
$img.attr('title', this.items[0].title);
$download.attr('href', this.items[0].download);
$title.text(this.items[0].title);
$wrapper.append($img);
} else if (NFU.MEDIAPLAYER.type === 2) {
$video = $('');
$wrapper.append($video);
$download.attr('href', this.items[0].download);
$title.hide();
jwplayer("video-player").setup({
flashplayer: 'redesign/swf/player.swf',
file: this.items[0].content,
height: 480,
width: 530,
image: this.items[0].thumbnail,
skin: 'redesign/swf/skins/nfu/nfu.zip'
});
}
},
generateThumbnails: function () {
var $wrapper = $('#mediacontent').find('.thumbnails-wrapper ul'), i, $li, item;
$wrapper.empty();
for (i = 0; i < this.itemCount; i++) {
$li = $('');
item = this.items[i];
$li.find('a').attr('href', item.link);
$li.find('img').attr('src', item.thumbnail);
$li.find('img').attr('title', item.title);
if (i === 0) {
$li.addClass('active');
}
$wrapper.append($li);
}
},
initBindings: function () {
var $mediacontent = $('#mediacontent'),
$show = $mediacontent.find('.show'),
$thumbs = $mediacontent.find('.thumbnails');
if (this.currentIndex === 0) {
$show.find('a.prev').addClass('disabled');
$thumbs.find('a.prev').css({opacity: 0.2});
}
if (this.itemCount < 5) { $thumbs.find('a.next').css({opacity: 0.2}); }
$show.find('a.prev').each(function () {
$(this).on('click', function (e) {
e.preventDefault();
if (NFU.MEDIAPLAYER.currentIndex > 0) {
NFU.MEDIAPLAYER.currentIndex--;
}
if (NFU.MEDIAPLAYER.type === 1) {
NFU.MEDIAPLAYER.slideGallery(NFU.MEDIAPLAYER.currentIndex);
} else if (NFU.MEDIAPLAYER.type === 2) {
NFU.MEDIAPLAYER.playVideo(NFU.MEDIAPLAYER.currentIndex);
}
NFU.MEDIAPLAYER.checkNavigation();
});
});
$show.find('a.next').each(function () {
$(this).on('click', function (e) {
e.preventDefault();
if (NFU.MEDIAPLAYER.currentIndex < NFU.MEDIAPLAYER.itemCount - 1) {
NFU.MEDIAPLAYER.currentIndex++;
}
if (NFU.MEDIAPLAYER.type === 1) {
NFU.MEDIAPLAYER.slideGallery(NFU.MEDIAPLAYER.currentIndex);
} else if (NFU.MEDIAPLAYER.type === 2) {
NFU.MEDIAPLAYER.playVideo(NFU.MEDIAPLAYER.currentIndex);
}
NFU.MEDIAPLAYER.checkNavigation();
});
});
$thumbs.find('li').each(function (i) {
$(this).on('click', function (e) {
e.preventDefault();
$(this).addClass('active').siblings().removeClass('active');
NFU.MEDIAPLAYER.currentIndex = i;
if (NFU.MEDIAPLAYER.type === 1) {
NFU.MEDIAPLAYER.slideGallery(i);
} else if (NFU.MEDIAPLAYER.type === 2) {
NFU.MEDIAPLAYER.playVideo(NFU.MEDIAPLAYER.currentIndex);
}
NFU.MEDIAPLAYER.checkNavigation();
});
});
$thumbs.find('a.prev').each(function () {
$(this).on('click', function (e) {
e.preventDefault();
if (NFU.MEDIAPLAYER.currentThumbIndex > 0) {
NFU.MEDIAPLAYER.currentThumbIndex--;
}
NFU.MEDIAPLAYER.checkNavigation();
NFU.MEDIAPLAYER.slideThumbnails();
});
});
$thumbs.find('a.next').each(function () {
$(this).on('click', function (e) {
e.preventDefault();
if (NFU.MEDIAPLAYER.currentThumbIndex < NFU.MEDIAPLAYER.itemCount - 4) {
NFU.MEDIAPLAYER.currentThumbIndex++;
}
NFU.MEDIAPLAYER.checkNavigation();
NFU.MEDIAPLAYER.slideThumbnails();
});
});
},
checkNavigation: function () {
var $mediacontent = $('#mediacontent'),
$show = $mediacontent.find('.show'),
$thumbs = $mediacontent.find('.thumbnails');
if (NFU.MEDIAPLAYER.currentThumbIndex > 0) {
$thumbs.find('a.prev').css({opacity: 1});
} else {
$thumbs.find('a.prev').css({opacity: 0.2});
}
if (NFU.MEDIAPLAYER.currentThumbIndex < NFU.MEDIAPLAYER.itemCount - 4) {
$thumbs.find('a.next').css({opacity: 1});
} else {
$thumbs.find('a.next').css({opacity: 0.2});
}
if (NFU.MEDIAPLAYER.currentIndex > 0) {
$show.find('a.prev').removeClass('disabled');
} else {
$show.find('a.prev').addClass('disabled');
}
if (NFU.MEDIAPLAYER.currentIndex < NFU.MEDIAPLAYER.itemCount - 1) {
$show.find('a.next').removeClass('disabled');
} else {
$show.find('a.next').addClass('disabled');
}
},
slideThumbnails: function () {
var $wrapper = $('#mediacontent').find('.thumbnails .thumbnails-wrapper ul'),
pos = -124 * NFU.MEDIAPLAYER.currentThumbIndex;
$wrapper.stop().animate({
left: pos
}, 300, function () {});
},
slideGallery: function (index) {
var $mediacontent = $('#mediacontent'),
$showimg = $mediacontent.find('.show .show-wrapper img'),
$title = $mediacontent.find('.show h4'),
$download = $mediacontent.find('.show a.download');
$showimg.attr('title', NFU.MEDIAPLAYER.items[index].title);
$download.attr('href', NFU.MEDIAPLAYER.items[index].download);
$title.text(this.items[index].title);
$mediacontent.find('.thumbnails .thumbnails-wrapper ul li').eq(index).addClass('active').siblings().removeClass('active');
$showimg.fadeOut(300, function () {
$showimg.load(function () {
$showimg.fadeIn(300);
});
$showimg.attr('src', NFU.MEDIAPLAYER.items[index].content);
});
},
playVideo: function (index) {
var $mediacontent = $('#mediacontent'),
$download = $mediacontent.find('.show a.download');
$download.attr('href', NFU.MEDIAPLAYER.items[index].download);
jwplayer().stop();
jwplayer().load({
file: NFU.MEDIAPLAYER.items[index].content,
image: NFU.MEDIAPLAYER.items[index].thumbnail
});
jwplayer().play();
$mediacontent.find('.thumbnails .thumbnails-wrapper ul li').eq(index).addClass('active').siblings().removeClass('active');
},
generateDocs: function () {
var $list = $('#doccontent').find('.related-list ul.docfiles'),
i, $li, $a, $fileinfo, $desc, $icon, item;
for (i = 0; i < this.itemCount; i++) {
$li = $('');
$a = $('');
$fileinfo = $('');
$desc = $('');
$icon = $('');
item = this.items[i];
$a.attr('href', item.download).attr('title', item.title);
$a.text(item.title);
$desc.text(item.description);
$fileinfo.text('(' + item.content.substr(item.content.length - 3, 3) + ', ' + Math.round(item.filesize * 1000) / 100000 + ' kB)');
$li.append($a).append($fileinfo).append($icon).append($desc);
$li.addClass(item.content.substr(item.content.length - 3, 3));
$list.append($li);
}
}
};
NFU.UTIL = {
init: function () {
this.selectorHelper();
this.clearEmptyTags();
$(window).on('load', $.proxy(function () {
this.distributeElements($('header nav.main .wrap > ul'), {gapType: 'padding', selector: '> a'});
this.distributeElements($('.footer-sitemap .cols'), {gapType: 'margin'});
}, this));
},
selectorHelper: function () {
if ($.browser.msie) {
$('*:last-child').addClass('last-child');
}
if ($.browser.opera) {
$('html').addClass('opera');
}
},
clearEmptyTags: function () {
$('#page').find('.content .block p').each(function (idx, element) {
if ($(element).children().length === 0 && $.trim($(this).text()) === '') {
$(this).remove();
}
});
},
embedSWF: function (file, id, w, h, flashvars, params, attributes) {
swfobject.embedSWF(file, id, w, h, '9.0.0', 'expressInstall.swf', flashvars, params, attributes);
},
parseURL: function (url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':', ''),
host: a.hostname,
port: a.port,
query: a.search,
params: (function () {
var ret = {},
seg = a.search.replace(/^\?/, '').split('&'),
len = seg.length, i, s;
for (i = 0; i < len; i++) {
if (!seg[i]) {
continue;
}
s = seg[i].split('=');
ret[s[0]] = s[1];
}
return ret;
}()),
file: (a.pathname.match(/\/([^\/?#]+)$/i) || [, ''])[1],
hash: a.hash.replace('#', ''),
path: a.pathname.replace(/^([^\/])/, '/$1'),
relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [, ''])[1],
segments: a.pathname.replace(/^\//, '').split('/')
};
},
//egyenlo tavolsagra szetosztja az elemeket egy konteneren belul
//flexbox helyett
distributeElements: function ($container, args) {
var $children = $container.children(),
numChildren = $children.size(),
childrenW = 0,
containerW = 0,
gap,
options = $.fn.extend({
gapType: 'margin'
}, args);
containerW = $container.width();
$children.each(function () {
childrenW += $(this).outerWidth(true);
});
if (childrenW > containerW) {
return;
}
gap = Math.floor((containerW - childrenW) / (numChildren * 2));
$children.each(function (index, element) {
var $element;
if (options.selector) {
$element = $(this).find(options.selector);
} else {
$element = $(this);
}
$element.css(options.gapType + '-left', gap);
$element.css(options.gapType + '-right', gap);
$element.css('width', $element.width());
});
}
};
NFU.BREADCRUMB = {
init: function () {
setTimeout(this.setPosition, 1000);
},
setPosition: function () {
/*if ($('#counter').length>0)
{
var marginTop = ($('#counter').offset().top - $('nav.breadcrumb.head-box').offset().top);
if($('nav.breadcrumb.head-box').height()+marginTop < $('div.head-box').height()) {
$('nav.breadcrumb.head-box').css('margin-top', ($('#counter').offset().top - $('nav.breadcrumb.head-box').offset().top));
}
}*/
var menu = $('nav.breadcrumb.head-box');
var cont = $('div.head-box');
var firstLiMarginTop = parseInt($('nav.breadcrumb.head-box li:first').css('marginTop'), 10, 0);
menu.css({marginTop: (cont.height() - menu.height() - firstLiMarginTop) / 2});
}
};
NFU.MEDIALIB = (function () {
var $container,
activeItemTimer;
var onTabClick = function (event) {
$this = $(event.currentTarget);
$container.find('.pane.active').removeClass('active');
$container.find('.pane').eq($this.parent().index() - 1).addClass('active');
$container.find('.tabs li.active').removeClass('active');
$this.parents('li').addClass('active');
event.stopPropagation();
event.preventDefault();
};
var onItemMouseOver = function (event) {
activeItemTimer = setTimeout(function () {
$(event.currentTarget).find('.lnk-goto-map').addClass('active');
}, 200);
};
var onItemMouseOut = function (event) {
clearTimeout(activeItemTimer);
$(event.currentTarget).find('.lnk-goto-map').removeClass('active');
};
/* mediatar rotator a fejlecben */
var initHeaderRotator = function () {
$container = $('.media-library-rotator');
$container.on('click', '.tabs a', onTabClick);
$container.on('mouseenter', '.item', onItemMouseOver);
$container.on('mouseleave', '.item', onItemMouseOut);
$container.find('.rotator').each(function (index, element) {
var $rotator = $(this);
$rotator.cycle({
activePagerClass: 'active-slide',
pager: $rotator.next('.pager').find('.inner'),
fx: 'scrollHorz',
width: 648,
cleartypeNoBg: true,
timeout: 0
});
});
};
/* mediatar rotator a jobb oldali bannerhelyen */
var initBannerRotator = function () {
$('.media-library-banner .rotator').each(function () {
var $container = $(this);
$container.find('.pages').cycle({
fx: 'scrollHorz',
cleartypeNoBg: true,
prev: $container.find('.pager-prev'),
next: $container.find('.pager-next'),
speed: 400,
timeout: 0
});
});
};
return {
init: function () {
initHeaderRotator();
initBannerRotator();
}
}
}());
NFU.LIGHTBOXVIDEO = {
player: null,
init: function () {
var self = NFU.LIGHTBOXVIDEO;
if ($('body.index-page').length > 0 && $('#lightbox-video-overlay').length > 0) {
/*
if ($.cookie('hide-home-video-overlay')) {
$('html').removeClass('index-video');
this.destroy();
return false;
}
*/
$('html').addClass('index-video');
self.createPlayer();
self.alignCenter();
self.initEventListeners();
}
},
createPlayer: function () {
var $videoHolder = $('#lightbox-video-holder'),
self = NFU.LIGHTBOXVIDEO,
isTablet = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/);
var $streamHolder = $('#lightbox-video').find('span#stream');
if(isTablet) {
$('#lightbox-video-holder .lightbox-video-ext-link').addClass('hide');
$('#lightbox-video-holder .button-box').removeClass('hide');
}
if ($streamHolder.attr('source') !== undefined && $streamHolder.attr('source') != '')
{
self.player = jwplayer("lightbox-video").setup({
primary: 'flash',
autostart: !isTablet,
width: 700,
height: 366,
'image': 'redesign/i/video-cover.png',
modes: [
{ type:'flash', src:'redesign/swf/player.swf', config: { provider:'redesign/swf/HLSProvider5.swf', file:$streamHolder.attr('source') } },
{ type:'html5', config: { file:$streamHolder.attr('source') } }
]
});
}
else
{
self.player = jwplayer("lightbox-video").setup({
primary: 'flash',
autostart: false,
flashplayer: "redesign/swf/player.swf",
file: $('#lightbox-video').find('a').attr('href'),
height: $videoHolder.height(),
width: $videoHolder.width()
});
}
if(!isTablet) {
self.player.play();
}
},
alignCenter: function () {
var $h = $('#lightbox-video-holder');
$h.css({
'margin-top': -$h.height() / 1.7,
'margin-left': -$h.width() / 2
});
},
destroy: function () {
var self = NFU.LIGHTBOXVIDEO;
$('html').removeClass('index-video');
if (self.player) {
self.player.stop().remove();
}
$('#lightbox-video-holder, #lightbox-video-overlay').remove();
},
initEventListeners: function () {
var self = NFU.LIGHTBOXVIDEO;
self.player.onComplete(function () {
self.destroy();
});
$('#lightbox-video-overlay, #lightbox-video-holder .close').click(function (e) {
e.preventDefault();
self.destroy();
/*$.cookie('hide-home-video-overlay', 1, { expires: 1 });*/
});
}
};
NFU.CUSTOMFORM = {
init: function () {
var self = NFU.CUSTOMFORM;
if ($('select[data-customselect]').length > 0) {
$('select[data-customselect=true]').selectBoxIt({
dynamicPositioning: false
});
$(".selectboxit").each(function(){
var $sb = $(this);
$sb.parent().css('max-width', $sb.closest('form').width())
$sb.css("width", "100%")
$sb.parent().find(".selectboxit-text").css({
'max-width': $sb.closest('form').width() - 40,
'margin-right': 30
})
$sb.parent().find(".selectboxit-options a").css({
'white-space': 'nowrap'
})
//ha többsoros, akkor a dropdown szélessége a form szélessége, és wrap engedélyezve
if($sb.parent().find(".selectboxit-options").width() > $sb.closest('form').width()){
$sb.parent().find(".selectboxit-options a").css({
'white-space': 'normal'
})
$sb.parent().find(".selectboxit-options").css({
'width': $sb.closest('form').width()
})
}
})
}
}
};
var ProjektGallery = function () {
var obj,
itemnums = 0,
actualItem = 1,
itemWidth = 128,
attach, goto;
this.init = function ($obj) {
obj = $obj;
itemnums = $obj.find('.slide-holder > ul > li').length;
if (itemnums > 5) {
attach();
}
obj.find('a.next, a.prev').hide();
goto(0);
};
attach = function () {
var space = itemWidth / 2;
obj.find('.slide-holder > ul').draggable({
containment: [obj.offset().left - (itemWidth * (itemnums - 5)) - space, obj.offset().top + 8, obj.offset().left + 8 + space, obj.offset().top + 8],
stop: function () {
actualItem = (Math.round((-1 * $(this).css('left').replace('px', '')) / itemWidth));
goto(actualItem);
},
start: function () {
obj.find('a.next, a.prev').hide();
}
});
obj.find('a.next, a.prev').click(function () {
goto(actualItem + ($(this).hasClass('next') ? 1 : -1));
});
};
goto = function (i) {
obj.find('a.next, a.prev').hide();
i = i <= 0 ? 0 : (i > itemnums - 5 ? itemnums - 5 : i);
actualItem = i;
obj.find('a.next, a.prev').removeClass('hide');
if (i <= 0) {
obj.find('a.prev').addClass('hide');
}
if (i >= (itemnums - 5)) {
obj.find('a.next').addClass('hide');
}
obj.find('.slide-holder > ul').stop(true, true).animate({
'left': -1 * itemWidth * i + 8
}, 300, 'easeOutExpo', function () {
if (itemnums > 5) {
obj.find('a.next:not(.hide), a.prev:not(.hide)').fadeIn(300);
}
});
};
};
$(document).ready(function () {
NFU.init();
$('.galery-wrapper').each(function (i, e) {
var pg = new ProjektGallery();
pg.init($(e));
});
$('#page').find('table').each(function () {
if ($(this).parents('.table-wrapper').length === 0) {
$(this).wrap('');
}
});
});