function checkReady(){
var resizeTimer = null,
videoInit = false;
window.setVideoProportion = function() {
jQuery('.video-background').each(function(){
var container = jQuery(this),
mejsContainer = container.find('.mejs-container'),
video = container.find('video'),
videoHeight = video.attr('height'),
videoWidth = video.attr('width'),
videoProportion = videoWidth / videoHeight,
parent = container.parent(),
parentHeight = parent.height(),
parentWidth = parent.width(),
parentProportion = parentWidth / parentHeight,
proportion = parentHeight / videoHeight,
centerX, centerY;
if (parentProportion >= videoProportion) {
proportion = parentWidth / videoWidth;
}
container.width(proportion*videoWidth);
container.height(proportion*videoHeight);
centerX = ((parentWidth >> 1) - (container.width() >> 1)) | 0;
centerY = ((parentHeight >> 1) - (container.height() >> 1)) | 0;
container.css({ 'left': centerX, 'top': centerY });
mejsContainer.css({width: '100%', height: '100%'});
container.find('.video-preload').css('display', 'none');
});
};
window.resizeHandler = function(){
if(jQuery(window).height() < 600){
$('.w-map-h').css("height","200px");
$('#over_map').css("height","100%");
}
else{
$('.w-map-h').css("height","360px");
$('#over_map').css("height","100%");
}
var H_home_text = jQuery('#text_hover_reel').height();
if(jQuery(window).width() > 620){
$('.home-heading-line').css("font-size","67px");
//Div delle 5 ragioni
$('.5reason').css("float","none");
//Logo
$('#logo').attr("src","/img/clogo0.png");
//Immagine visto vicino a ragione
$('.img_reason_1').css("margin-top","0px");
$('.img_reason_1').css("margin-left","5px");
$('.img_reason_2').css("margin-top","0px");
$('.img_reason_2').css("margin-left","5px");
$('.img_reason_3').css("margin-top","0px");
$('.img_reason_3').css("margin-left","5px");
$('.img_reason_4').css("margin-top","0px");
$('.img_reason_4').css("margin-left","5px");
$('.img_reason_5').css("margin-top","0px");
$('.img_reason_5').css("margin-left","5px");
$('.5reason_1').css("font-size","20px");
$('.5reason_2').css("font-size","20px");
$('.5reason_3').css("font-size","20px");
$('.5reason_4').css("font-size","20px");
$('.5reason_5').css("font-size","20px");
$('.5reason_1').css("width",(jQuery('#title_reason').width()-60) + "px");
$('.5reason_2').css("width",(jQuery('#title_reason').width()-60) + "px");
$('.5reason_3').css("width",(jQuery('#title_reason').width()-60) + "px");
$('.5reason_4').css("width",(jQuery('#title_reason').width()-60) + "px");
$('.5reason_5').css("width",(jQuery('#title_reason').width()-60) + "px");
$('#5reason').css("left","50%");
if(jQuery(window).width() > 800)
$('#5reason').css("margin-left",-(jQuery('#5reason').width()/5) + "px");
else
$('#5reason').css("margin-left",-(jQuery('#5reason').width()/4) + "px");
if(language == "I"){
$('#prog_1').html("WEB, E-COMMERCE & CONFIGURATORE ONLINE");
$('#prog_2').html("Salone espositivo virtuale");
$('#prog_3').html("Training Virtuale");
$('#prog_4').html("In-store Experience");
}
else{
$('#prog_1').html("WEB, E-COMMERCE & ON-LINE CONFIGURATOR");
$('#prog_2').html("VIRTUAL LOUNGE EXPERIENCE");
$('#prog_3').html("VIRTUAL Training");
$('#prog_4').html("In-store Experience");
}
}
else{
if(language == "I"){
$('#prog_1').html("WEB, E-COMMERCE & CONFIGURATORE ONLINE+");
$('#prog_2').html("Salone espositivo virtuale+");
$('#prog_3').html("Training Virtuale+");
$('#prog_4').html("In-store Experience+");
}
else{
$('#prog_1').html("WEB, E-COMMERCE & ON-LINE CONFIGURATOR+");
$('#prog_2').html("VIRTUAL LOUNGE EXPERIENCE+");
$('#prog_3').html("VIRTUAL TRAINING+");
$('#prog_4').html("In-store Experience+");
}
$('.home-heading-line').css("font-size","40px");
$('.5reason_1').css("width",(jQuery('#title_reason').width()-30) + "px");
$('.5reason_2').css("width",(jQuery('#title_reason').width()-30) + "px");
$('.5reason_3').css("width",(jQuery('#title_reason').width()-30) + "px");
$('.5reason_4').css("width",(jQuery('#title_reason').width()-30) + "px");
$('.5reason_5').css("width",(jQuery('#title_reason').width()-30) + "px");
$('#5reason').css("left","0px");
$('#5reason').css("margin-left","0px");
$('.5reason_1').css("float","left");
$('.5reason_1').css("font-size","16px");
$('.5reason_2').css("float","left");
$('.5reason_2').css("font-size","16px");
$('.5reason_3').css("float","left");
$('.5reason_3').css("font-size","16px");
$('.5reason_4').css("float","left");
$('.5reason_4').css("font-size","16px");
$('.5reason_5').css("float","left");
$('.5reason_5').css("font-size","16px");
//Immagine visto vicino a ragione
if(jQuery('.5reason_1').height()>26)
$('.img_reason_1').css("margin-top","16px");
else
$('.img_reason_1').css("margin-top","0px");
$('.img_reason_1').css("margin-left","0px");
if(jQuery('.5reason_2').height()>26)
$('.img_reason_2').css("margin-top","16px");
else
$('.img_reason_2').css("margin-top","0px");
$('.img_reason_2').css("margin-left","0px");
if(jQuery('.5reason_3').height()>26)
$('.img_reason_3').css("margin-top","16px");
else
$('.img_reason_3').css("margin-top","0px");
$('.img_reason_3').css("margin-left","0px");
if(jQuery('.5reason_4').height()>26)
$('.img_reason_4').css("margin-top","16px");
else
$('.img_reason_4').css("margin-top","0px");
$('.img_reason_4').css("margin-left","0px");
if(jQuery('.5reason_5').height()>26)
$('.img_reason_5').css("margin-top","16px");
else
$('.img_reason_5').css("margin-top","0px");
$('.img_reason_5').css("margin-left","0px");
//Logo
$('#logo').attr("src","/img/clogo0_mobile.png");
}
$('#text_hover_reel').css("margin-top","-"+ H_home_text/2 + "px" );
var body = jQuery('body'),
header = jQuery('.l-header'),
firstSection = jQuery('.l-section').first(),
headerTop = 0,
scrollOffsetTolerance = 0,
H = jQuery(window).height()-0,// Browser window height
W = jQuery(window).width()- 0,// Browser window width
h = window.headerHeight = header.height()-0,// header height, calculated depending on window width
hh,
f = jQuery('.l-footer').height()-0;// footer height, affects .l-main bottom margin
jQuery('.l-main').css('margin-bottom', f+'px');
firstSection.css({'height': ''});
hh = firstSection.height()- 0;
if (body.hasClass('headerpos_top'))
{
if (body.hasClass('hometype_fullscreen')) {
firstSection.css({'height': Math.max((H-h), hh)+'px'});
}
if (body.hasClass('headertype_sticky')) {
firstSection.css({'margin-top': h+'px'});
}
}
if (body.hasClass('headerpos_bottom'))
{
if (body.hasClass('hometype_fullscreen')) {
firstSection.css({'height': Math.max((H-h), hh)+'px', 'margin-bottom': h+'px'});
headerTop = Math.max((H-h), hh);
} else {
firstSection.css({'margin-bottom': h+'px'});
headerTop = hh;
}
}
if (body.hasClass('headerpos_outside'))
{
if (body.hasClass('hometype_fullscreen')) {
firstSection.css({'height': Math.max(H, hh)+'px', 'margin-bottom': h+'px'});
headerTop = Math.max(H, hh);
} else {
firstSection.css({'margin-bottom': h+'px'});
headerTop = hh;
}
}
header.css('top', headerTop+'px');
if (body.hasClass('headertype_sticky')) {
scrollOffsetTolerance = h-1;
}
if (videoInit) {
window.setVideoProportion();
} else {
videoInit = true;
jQuery('.video-background video').mediaelementplayer({
enableKeyboard: false,
iPadUseNativeControls: false,
pauseOtherPlayers: false,
iPhoneUseNativeControls: false,
AndroidUseNativeControls: false,
videoWidth: '100%',
videoHeight: '100%',
success: function (mediaElement, domObject) {
window.setVideoProportion();
jQuery(domObject).css('display', 'block');
}
});
}
var linkScroll = function(event, link) {
event.preventDefault();
event.stopPropagation();
// jQuery.smoothScroll({
// offset: -scrollOffsetTolerance,
// scrollTarget: link.hash
// });
jQuery("html, body").animate({
scrollTop: jQuery(link.hash).offset().top-scrollOffsetTolerance+"px"
}, {
duration: 1200,
easing: "easeInOutQuint"
});
};
jQuery('a[class="w-logo-link"][href="#"]').off('click').click(function(event) {
event.preventDefault();
event.stopPropagation();
jQuery("html, body").animate({
scrollTop: 0
}, {
duration: 1200,
easing: "easeInOutQuint"
});
});
jQuery('a[class="w-toplink"]').off('click').click(function(event) {
event.preventDefault();
event.stopPropagation();
jQuery("html, body").animate({
scrollTop: 0
}, {
duration: 1200,
easing: "easeInOutQuint"
});
});
jQuery('a[href^="#"][href!="#"]').off('click').die('click').live('click',function(event) {
linkScroll(event, this);
});
jQuery('.l-header .w-nav').each(function () {
var nav = jQuery(this),
navControl = nav.find('.w-nav-control'),
navList = nav.find('.w-nav-list.level_1'),
navSubLists = navList.find('.w-nav-item.with_sublevel .w-nav-list'),
navAnchors = nav.find('.w-nav-anchor'),
navRunning = false,
mobileNavWidth = 1023;
if (window.mobileNavWidth !== undefined) {
mobileNavWidth = window.mobileNavWidth-0;
}
if (W <= mobileNavWidth) {
var listOpen = false,
navSubControls = navList.find('.w-nav-item.with_sublevel .w-nav-hint');
if (! nav.hasClass('touch_enabled')) {
nav.addClass('touch_enabled');
navList.css({display: 'none'});
navSubLists.css({display: 'none'});
}
navControl.off('click').click(function() {
if (! navRunning) {
navRunning = true;
if (listOpen) {
navList.slideUp(250, function(){
navRunning = false;
});
listOpen = false;
} else {
navList.slideDown(250, function(){
navRunning = false;
});
listOpen = true;
}
}
});
navSubControls.off('click').click(function() {
if (! navRunning) {
navRunning = true;
var subList = jQuery(this).closest('.w-nav-item-h').find('.w-nav-list').first(),
subListOpen = subList.data('subListOpen'),
currentNavItem = jQuery(this).closest('.w-nav-item');
if (subListOpen) {
subList.slideUp(250, function(){
navRunning = false;
currentNavItem.removeClass('open');
});
subListOpen = false;
} else {
subList.slideDown(250, function(){
navRunning = false;
currentNavItem.addClass('open');
});
subListOpen = true;
}
subList.data('subListOpen', subListOpen);
}
return false;
});
navAnchors.click(function() {
if (W <= mobileNavWidth) {
navRunning = true;
navList.slideUp(250, function(){
navRunning = false;
});
listOpen = false;
}
});
} else {
nav.removeClass('touch_enabled');
nav.find('.w-nav-item').removeClass('open');
navList.css({height: '', display: ''});
navSubLists.css({height: '', display: ''});
navControl.off('click');
}
});
var scrollTimer = false,
scrollHandler = function(){
var scrollPosition = parseInt(jQuery(window).scrollTop(), 10);
if (scrollPosition >= H) {
jQuery('.w-toplink').addClass('active');
} else {
jQuery('.w-toplink').removeClass('active');
}
if (body.hasClass('headertype_sticky') && (body.hasClass('headerpos_bottom') || body.hasClass('headerpos_outside'))) {
if (scrollPosition > headerTop) {
header.css({ position: 'fixed', top: 0});
} else {
header.css({ position: '', top: headerTop});
}
}
// jQuery('.w-nav-item.active').removeClass('active');
//Move trough each menu and check its position with scroll position then add current class
jQuery('.w-nav-item a[href^=#]').each(function() {
var thisHref = jQuery(this).attr('href');
if (jQuery(thisHref).length) {
var thisTruePosition = parseInt(jQuery(thisHref).offset().top, 10),
thisPosition = thisTruePosition - h;
if(scrollPosition >= thisPosition) {
jQuery('.w-nav-item.active').removeClass('active');
jQuery('.w-nav-item a[href='+ thisHref +']').parent().parent().addClass('active');
jQuery('.w-cart').each(function(){
if (jQuery(this).hasClass('status_empty')) {
jQuery(this).css('display', '');
}
});
jQuery(thisHref).find('.w-cart').css('display', 'block');
}
}
});
//If we're at the bottom of the page, move pointer to the lal-section-hst section
var bottomPage = parseInt(jQuery(document).height(), 10) - parseInt(jQuery(window).height(), 10);
if(scrollPosition === bottomPage || scrollPosition >= bottomPage) {
var thisHref = jQuery('.w-nav-item a[href^=#]:last').attr('href');
if (jQuery(thisHref).length) {
jQuery('.w-nav-item.active').removeClass('active');
jQuery('.w-nav-item a[href^=#]:last').parent().parent().addClass('active');
}
}
};
window.clearTimeout(scrollTimer);
scrollHandler();
jQuery(window).scroll(function(){
window.clearTimeout(scrollTimer);
scrollTimer = window.setTimeout(function(){
scrollHandler();
}, 10);
});
};
window.resizeHandler();
jQuery(window).resize(function(){
window.clearTimeout(resizeTimer);
resizeTimer = window.setTimeout(function(){
window.resizeHandler();
}, 50);
});
}