/**
* THE CREW Homepage
*/
//SC.loadFancybox();
SC.init_the_crew_homepage = function()
{
// Build Header (slide)
var initHeader = function()
{
// Don't instanciate slideshow (on header)
$('.homepage_slideshow .slideshow').css({'visibility':'hidden'}).addClass('toDelete');
// Init slider
scHeadSlider.init( $('div.homepage_slideshow') );
};
// Add an animated bg (on desktop versions)
var initBackgroundAnimation = function()
{
if (!is_TABLET && !is_MOBILE && !isOldIE)
{
if (swfobject.hasFlashPlayerVersion('10.0.42.0'))
{
//var swf_path = SC.getAssetsUrl();
$('body').addClass('bg_anim').prepend('
')
var timestamp = new Date().getTime();
var ts = (is_IE ? '?ts='+timestamp : '');
var flashvars = { };
//var params = { 'allowScriptAccess':'always', 'allownetworking':'always', 'quality':'low', /*'bgcolor':'#101113',*/ 'wmode':'opaque' };
var params = { 'allowScriptAccess':'always', 'allownetworking':'always', 'quality':'low', 'bgcolor':'#101113', 'wmode':'transparent' };
var attributes = { };
swfobject.embedSWF('common/swf/tc_home_bg.swf'+ts, 'tc_bg_anim_swf', '2000', '990', '10.0.42', 'expressInstall.swf', flashvars, params, attributes);
//$('#tc_bg_anim_swf').flash({swf:swf_path+'tc_home_bg.swf', width:2000, height:990, scale:'noscale', salign:'t'});
$('#tc_bg_anim_mask').css({'opacity':0}).show().stop().animate({'opacity':1},/*500*/500, function() {
$('#tc_bg_anim').show();
$(this).stop().animate({'opacity':0}, {duration:/*2500*/8000, queue:false});
});
}
}
};
// MAIN INIT
initHeader();
//initHighlightsCarousel();
//initNewsFeed();
window.setTimeout(function() { initBackgroundAnimation(); }, /*2000*/0);
SC.unloadWidgetKeysEvents();
};
/**
* TC Home slider
*/
var scHeadSlider =
{
_container: null,
_nb_items: 0,
_current_slide: 0,
init: function(el)
{
this._container = el;
var nb = 0, str = str2 = over1 = over2 = '';
var bg_src, $slider = $(el).find('.slide-images');
$(el).find('div').first().addClass('toDelete');
// Parse all items
$slider.find('.slide-image').each(function(k,v)
{
// Get background
var $bg = $(v).find('img').first(),
bg_src = $bg.attr('src');
$bg.remove();
// Check over img
over1 = over2 = '';
var $bg_over = $(v).find('.slider-img-over img').first(),
bg_over_src = $bg_over.attr('src')
if (bg_over_src != undefined)
{
over1 = 'slide-image-out';
over2 = '';
$bg_over.remove();
}
// Get content
str2 = $(v).find('div.richtext').html();
// Store for new content
str+= ' '+over2+''+str2+'
';
nb++;
});
// Append new content
$(el).prepend('');
$('.backward').addClass('jc_home_backward');
$('.forward').addClass('jc_home_forward');
$('#homepage_slideshow_jc').append( $('.jc_home_backward') ).append( $('.jc_home_forward') );
// Reparse logos
//$('#homepage_slideshow_jc .slide-image div img').each(function(k,v) { $(v).appendTo( $('#homepage_slideshow_jc .slide'+k+' .slide-image-logo') ); });
// Hide slides contents
$('#homepage_slideshow_jc li.slide-image div.slide-content').css({ 'margin-left':'0px', 'opacity':0 });
// Remove previous content
$(el).find('.toDelete').remove();
// Instanciate JC
if (nb <= 1) $('.jc_home_backward,.jc_home_forward').hide();
$('#homepage_slideshow_jc').jCarouselLite(
{
btnPrev: '.jc_home_backward',
btnNext: '.jc_home_forward',
//btnGo: pagination,
//btnGo: $('.slide-tabs a'),
visible: 1,
scroll: 1,
start: 0,
circular: (nb > 1) ? true : false,
//circular: false,
vertical: false,
mouseWheel: false,
//auto:0,
auto:15000,
speed:250,
beforeStart: function(a) { scHeadSlider.hideContent(a); },
afterEnd: function(a) { scHeadSlider.showContent(a); }
});
// Instanciate events
this.initEvents();
},
initEvents: function()
{
// when windows is resized
$(window).on('resize', function(e) { scHeadSlider.setSizes(); });
// first slide anim
scHeadSlider.hideContent( $('#homepage_slideshow_jc .jc_li:eq(1)'), 0 );
setTimeout( function(){ scHeadSlider.showContent( $('#homepage_slideshow_jc .jc_li:eq(1)') ); }, 1000/*2200*/ );
// slide over
$(this._container)
.off('mouseover').on('mouseover', '.slide-image-out', function(e) { $(this).find('.slide-image-over').show(); })
.off('mouseout').on('mouseout', '.slide-image-out', function(e) { $(this).find('.slide-image-over').hide(); });
// Videos links
//$(this._container).find('a.link-video').off('click').on('click', function(e) { e.preventDefault(); scHeadSlider.playVideo(this); });
$(this._container).swipe( {
swipeLeft:function(event, direction, distance, duration, fingerCount) { $('a.jc_home_forward').click(); },
swipeRight:function(event, direction, distance, duration, fingerCount) { $('a.jc_home_backward').click(); }
});
},
setSizes: function()
{
var el = scHeadSlider._container;
$slider = $(el).find('.slide-images');
this._nb_items = $slider.find('.slide-image').length;
var _cw = $('#homepage_slideshow_jc').width(); // current width
var _cl = parseInt( $slider.css('left') ); // current left
var _ci = (_cl * -1) / _cw; // current item
// Set new width (and position)
var item_width = parseInt($(window).width());
$slider.find('.slide-image').css('width', item_width+'px');
$slider.css({ 'width': (item_width * scHeadSlider._nb_items)+'px', 'left': (item_width * _ci)*-1+'px' });
$('#homepage_slideshow_jc').css('width', item_width+'px');
},
showContent: function(slide)
{
//$(slide).find('.slide-image-logo').css('margin-left','-400px').stop().animate({ 'margin-left':'-480px', 'opacity':1 },250);
$(slide).find('.slide-inner').addClass('current').css('margin-left','-400px').stop().animate({ 'margin-left':'-480px', 'opacity':1 },350);
},
hideContent: function(slide, opt_time)
{
time = opt_time === undefined ? 250 : opt_time;
$(slide).find('.slide-inner').removeClass('current').stop().animate({ 'margin-left':'-400px', 'opacity':0 },time);
//$(slide).find('.slide-image-logo').stop().animate({ 'margin-left':'-400px', 'opacity':0 },350);
},
playVideo: function(el)
{
var url = $(el).attr('href');
$.fancybox(el, {
transitionIn : 'none',
transitionOut : 'none',
width : 800,
height : 480,
type : 'iframe',
href : url,
padding : [8, 12, 82, 8],
centerOnScroll : true,
//autoSize : false,
helpers : { title : { type : 'inside' } }
});
}
};