jQuery(function() { //let's recenter layers recenter_layers_21_488(); //let's hide all the layers reset_content_fade_21_488(); //let's switch out all the bg images with the relevant size banner_bg_loader_21_488(); //let's switch out layer images to the correct size banner_image_loader_21_488(); //let's initiate bx slider $('#banner_21_488 .banner_inner').bxSlider({ mode: 'fade', speed: 400, auto: true, autoControls: false, pause: 5000, controls: false, pager: false, infiniteLoop: true, //slider layer animation onSliderLoad: function(currentIndex){ //console.log(currentIndex); setTimeout(function(){ content_fade_21_488(currentIndex); },250); }, onSlideAfter: function(slideElement, oldIndex, newIndex){ //console.log(slideElement); content_fade_21_488(newIndex); }, onSlideBefore: function(slideElement, oldIndex, newIndex){ //console.log(slideElement); reset_content_fade_21_488(); }, }); $('#banner_21_488 .bx-pager').css('bottom', '0px'); $('#banner_21_488 .bx-wrapper').css('marginBottom', '0px'); }); function content_fade_21_488(index) { //put the layer animation functions here - generate switches here in server side code to handle individual layer transitions jQuery('#banner_21_488 .banner_item').eq(index).find('.transition_layer').each(function(){ //let's get the animation time for this var this_layer=this; var transition_type=jQuery(this_layer).attr('data-transition-type'); var transition_delay=jQuery(this_layer).attr('data-transition-delay'); var transition_time=jQuery(this_layer).attr('data-transition-time'); var data_x_pos=jQuery(this_layer).attr('data-x-pos'); var data_y_pos=jQuery(this_layer).attr('data-y-pos'); if(transition_type=='2' || transition_type=='6') {//slide from top //position top to correct place jQuery(this_layer).css({top:'-'+(jQuery(this_layer).height()+20)+'px'}); //make visible if(transition_type=='2') jQuery(this_layer).css({'opacity': 1}); } else if(transition_type=='3' || transition_type=='7') {//slide from top //position top to correct place jQuery(this_layer).css({top: (jQuery(this_layer).parent().height()+20)+'px'}); //make visible if(transition_type=='3') jQuery(this_layer).css({'opacity': 1}); } else if(transition_type=='4' || transition_type=='8') {//slide from left //position left to correct place jQuery(this_layer).css({left: '-'+(jQuery(this_layer).width()+20)+'px'}); //make visible if(transition_type=='4') jQuery(this_layer).css({'opacity': 1}); } else if(transition_type=='5' || transition_type=='9') {//slide from right //position left to correct place jQuery(this_layer).css({left: (jQuery(this_layer).parent().width()+20)+'px'}); //make visible if(transition_type=='5') jQuery(this_layer).css({'opacity': 1}); } setTimeout(function(){ jQuery(this_layer).animate({ opacity:1, left: data_x_pos+'%', top: data_y_pos+'%', }, Number(transition_time)); }, Number(transition_delay)); }); } function reset_content_fade_21_488() { jQuery('.transition_layer').css({'opacity': 0}); } function recenter_layers_21_488() { //console.log('recenter'); jQuery('#banner_21_488 .banner_item .banner_item_layer').each(function(){ //console.log('here2'); var default_pos=jQuery(this).attr('data-default-pos'); var banner_width=jQuery('#banner_21_488').width(); var layer_width=jQuery(this).width(); if(jQuery(this).attr('data-refactor-pos-x')=='true') { //console.log(default_pos); /* if(default_pos.indexOf('2-')!=-1) console.log('right'); else if(default_pos.indexOf('1-')!=-1) console.log('center');*/ if(default_pos.indexOf('1-')!=-1) {//center //console.log(this); //var left=(((banner_width/2)-(layer_width/2))/banner_width)*100; var left=(((banner_width-layer_width)/2)/banner_width)*100; left=left-0.5; jQuery(this).css({left: left+'%'}); jQuery(this).attr('data-x-pos',left); //console.log(jQuery(this).attr('id')+' '+left+' '+jQuery(this).css('left')); } else if(default_pos.indexOf('2-')!=-1) {//right var left=(((banner_width-(layer_width+15))/banner_width)*100)-0.5; //console.log('right: '+left); jQuery(this).css({left: left+'%'}); jQuery(this).attr('data-x-pos',left); } } /*var banner_height=jQuery('#banner_21_488 .banner_item:first-child').height(); var layer_height=jQuery(this).height(); if(jQuery(this).attr('data-refactor-pos-y')=='true') { if(default_pos.indexOf('-1')!=-1) {//middle var top=((((banner_height-(layer_height-15))/2)/banner_height)*100)-1.85; top=top-0.5; jQuery(this).css({top: top+'%'}); } else if(default_pos.indexOf('-2')!=-1) {//bottom //console.log(banner_height+' '+layer_height); var top=((banner_height-(layer_height+15))/banner_height)*100; //console.log('bottom: '+top); jQuery(this).css({top: top+'%'}); jQuery(this).attr('data-y-pos',top); } }*/ }); } function banner_bg_loader_21_488() { var banner_width=jQuery('header').width(); if(banner_width>2000) { //original jQuery('#banner_21_488 .banner_item').each(function(){ var path=jQuery(this).css('backgroundImage'); if(path && path.length>0 && path!='none') { //console.log(path); jQuery(this).css('backgroundImage', path.replace('/xsmall/','/original/')); } }); } else if(banner_width>1200) { //large jQuery('#banner_21_488 .banner_item').each(function(){ var path=jQuery(this).css('backgroundImage'); if(path && path.length>0 && path!='none') { //console.log(path); jQuery(this).css('backgroundImage', path.replace('/xsmall/','/large/')); } }); } else if(banner_width>992) { //medium jQuery('#banner_21_488 .banner_item').each(function(){ var path=jQuery(this).css('backgroundImage'); if(path && path.length>0 && path!='none') { //console.log(path); jQuery(this).css('backgroundImage', path.replace('/xsmall/','/medium/')); } }); } else if(banner_width>768) { //small jQuery('#banner_21_488 .banner_item').each(function(){ var path=jQuery(this).css('backgroundImage'); if(path && path.length>0 && path!='none') { //console.log(path); jQuery(this).css('backgroundImage', path.replace('/xsmall/','/small/')); } }); } } function banner_image_loader_21_488() { var banner_width=jQuery('#banner_21_488').width(); if(banner_width>2000) { //original jQuery('#banner_21_488 .banner_item .banner_layer img').each(function(){ var path=jQuery(this).attr('src'); if(path && path.length>0 && path!='none') { //console.log(path); jQuery(this).attr('src', path.replace('/xsmall/','/original/')); } }); } else if(banner_width>1200) { //large jQuery('#banner_21_488 .banner_item img').each(function(){ var path=jQuery(this).attr('src'); if(path && path.length>0 && path!='none') { //console.log(path); jQuery(this).attr('src', path.replace('/xsmall/','/large/')); } }); } else if(banner_width>992) { //medium jQuery('#banner_21_488 .banner_item .banner_layer img').each(function(){ var path=jQuery(this).attr('src'); if(path && path.length>0 && path!='none') { //console.log(path); jQuery(this).attr('src', path.replace('/xsmall/','/medium/')); } }); } else if(banner_width>768) { //small jQuery('#banner_21_488 .banner_item .banner_layer img').each(function(){ var path=jQuery(this).attr('src'); if(path && path.length>0 && path!='none') { //console.log(path); jQuery(this).attr('src', path.replace('/xsmall/','/small/')); } }); } } jQuery(window).resize(function() { scale_banner_21_488(); }); jQuery(document).ready(function() { scale_banner_21_488(); }); function scale_banner_21_488() { var banner_width=jQuery('#banner_21_488').width(); var ratio=banner_width/2500; var new_banner_height=700*ratio; jQuery('#banner_21_488 .banner_item').css({'height': new_banner_height+'px', 'fontSize': ratio+'em'}); jQuery('#banner_21_488 .bx-viewport').css({'height': new_banner_height+'px'}); //recenter_layers_21_488(); }