function mainFunctionalities() {
// png fix
jQuery('body').pngFix();
if (window.location.href.indexOf('/ch/') == -1) {
Cufon.replace('h1.page_title');
Cufon.replace('h1.subsection');
Cufon.replace('h2.claim');
}
$('#tab_structure').tabs();
$('.sottomenu').hide();
initTopMenu('.jd_menu');
$('.accordion_menu .active').next().show();
$('.ui-accordion .contenuto').hide();
$('.ui-accordion .nome_contenuto.selected').next().show();
$('.ui-accordion .nome_contenuto').click(function() {
$(".ui-accordion .nome_contenuto").removeClass('selected');
$(".ui-accordion .contenuto").slideUp(300);
if($(this).next().is(':hidden')) {
$(this).next().slideToggle(300);
$(this).addClass('selected');
}
return false;
});
$('#normal_menu li a').click(function() {
var classe = $(this).attr('href').replace('#tab-','.n_');
$('div.storia p.active').removeClass('active');
$(classe).addClass('active');
});
$('.tabs-nav li a').click(function() {
var classe = $(this).attr('href').replace('#tab-','.n_');
$('div.storia p.active').removeClass('active');
$(classe).addClass('active');
});
if($('#newsletter, #jobs, #contatti, #privacy, #credits').fancybox) {
$('#newsletter, #jobs, #contatti, #privacy, #credits').fancybox({
frameWidth:518,
frameHeight:546
});
}
linkAlbiniStatus();
if($('.elenco_rassegna').hasClass('authenticated')) {
if($('.elenco_rassegna').accordion) {
$('.elenco_rassegna').accordion({
autoheight:false,
collapsible:true,
active:false,
header:'.nome_cartella',
alwaysOpen: false,
autoheight: false
});
}
}
else {
if($('.elenco_rassegna p a').fancybox) {
$('.elenco_rassegna p a').each(function() {
$(this).fancybox({
frameWidth:518,
frameHeight:590
});
});
}
}
}
/* top menu */
function initTopMenu(element) {
var menu = $(element);
menu.children('li').children('ul').hide();
menu.children('li').mouseenter(function() {
$(this).children('ul').fadeIn();
menu.addClass('menu_active');
});
menu.children('li').mouseleave(function() {
var el = this;
menu.removeClass('menu_active');
window.setTimeout(function() {
if(!menu.hasClass('menu_active')) {
$(el).children('ul').fadeOut();
}
},500);
});
}
function openTopMenu() {
$('.jd_menu li ul').show();
$('.jd_menu li').unbind();
}
/* fine top menu*/
/*menu*/
function onAnimate(show) {
if (show) {
$(this)
.css('visibility', 'hidden').show()
.css('width', $(this).innerWidth())
.hide().css('visibility', 'visible')
.fadeIn('fast');
}
else {
$(this).fadeOut('fast');
}
}
var MENU_COUNTER = 1;
function loadMenu() {
if (this.id == 'dynamicMenu') {
$('> ul > li', this).remove();
var ul = $('
');
var t = MENU_COUNTER + 10;
for (; MENU_COUNTER < t; MENU_COUNTER++) {
$('> ul', this).append('Item ' + MENU_COUNTER + '');
}
}
}
function unloadMenu() {
if (MENU_COUNTER >= 30) {
MENU_COUNTER = 1;
}
}
// We're passed a UL
function onHideCheckMenu() {
return !$(this).parent().is('.LOCKED');
}
// We're passed a LI
function onClickMenu() {
$(this).toggleClass('LOCKED');
return true;
}
/*Brands*/
/*Status link albini menu */
function linkAlbiniStatus() {
$('.wrap-menu-brand').click(function() {
$('#link_brand').addClass('open');
$('.menu_albini').slideDown(500);
});
$('.wrap-menu-brand').mouseleave(function() {
window.setTimeout(closeMenu, '500')
});
}
function closeMenu() {
$('#link_brand').removeClass('open');
$('.menu_albini').slideUp(500);
}
/*scroll menu*/
function makeScrollable(wrapper, scrollable) {
var wrapper = $(wrapper), scrollable = $(scrollable);
// Hide images until they are not loaded
scrollable.hide();
var loading = $('Loading...
').appendTo(wrapper);
// Set function that will check if all images are loaded
var interval = setInterval(function() {
var images = scrollable.find('img');
var completed = 0;
// Counts number of images that are succesfully loaded
images.each(function() {
if (this.complete) completed++;
});
if (completed == images.length) {
clearInterval(interval);
// Timeout added to fix problem with Chrome
setTimeout(function() {
loading.hide();
// Remove scrollbars
wrapper.css({overflow: 'hidden'});
scrollable.show('slow', function() {
enable();
});
}, 1000);
}
}, 100);
function enable() {
// height of area at the top at bottom, that don't respond to mousemove
var inactiveMargin = 0;
// Cache for performance
var wrapperWidth = wrapper.width();
var wrapperHeight = wrapper.height();
// Using outer height to include padding too
var scrollableHeight = scrollable.outerHeight() + 2*inactiveMargin;
// Do not cache wrapperOffset, because it can change when user resizes window
// We could use onresize event, but it's just not worth doing that
// var wrapperOffset = wrapper.offset();
//When user move mouse over menu
wrapper.mousemove(function(e) {
var wrapperOffset = wrapper.offset();
// Scroll menu
var top = (e.pageY - wrapperOffset.top) * (scrollableHeight - wrapperHeight) / wrapperHeight - inactiveMargin;
if (top < 0) {
top = 0;
}
if(wrapper.scrollTop() > top) {
$('a#up').addClass('selected');
$('a#down').removeClass('selected');
}
else {
$('a#up').removeClass('selected');
$('a#down').addClass('selected');
}
wrapper.scrollTop(top);
});
}
}
function productFunctionalities() {
// comportamento link homepage brand
$('.brand_link').attr('href', '#').attr('target', '_self');;
// comportamento per link a dettaglio famiglie di prodotto
$('.famiglie_prodotti').each(function() {
var link = $(this).attr('href');
$(this).click(function() {
getProductData(link);
return false;
})
});
}
function getProductData(link) {
$('.carousel_menu a.active').removeClass('active');
$('.carousel_menu a').each(function() {
if(link.indexOf($(this).attr('href'))!=-1) {
$(this).addClass('active');
}
});
$.post(link.replace('#','/'), function(data) {
$('.col_box .col_grid').after(getFamigliaProdottiDettaglio(data));
$('.col_box .col_grid').toggle();
$('.col_box .col_grid:first').remove();
},
null,
'json');
}
function getFamigliaProdottiDettaglio(data) {
var html = ''+
'
'+
'
'+data.name+'
'+
'
'+data.description+'
'+
((/(\/it\/)/.test(window.location.href)) ? '
Caratteristiche tecniche
' : '
Technical data
') +
data.caratteristiche +
'
'+
'
'+
'

'+
'
';
return html;
}
function searchFunctionalities() {
$('#go').click(function() {
if(/(\/it\/)/.test(window.location.href)) {
window.location.href="/it/search?q="+escape($('#search').attr('value'));
}
if(/(\/en\/)/.test(window.location.href)) {
window.location.href="/en/search?q="+escape($('#search').attr('value'));
}
if(/(\/ch\/)/.test(window.location.href)) {
window.location.href="/ch/search?q="+escape($('#search').attr('value'));
}
});
}
function newsItemsPageHeight() {
var container = $('#tab1.back_big_news'),
height = 0;
if (container.length) {
height = container.height();
container.find('.elenco_news,.menu_news').css('height', height);
}
}
// search functionalities
$(document).ready(function() {
mainFunctionalities();
productFunctionalities();
searchFunctionalities();
// $("div.arc ul li ul").hide();
// newsItemsPageHeight()
});