File: D:/HostingSpaces/SBogers10/spire.komma-mediadesign.nl/wwwroot/js/spire.js
var activeLi = null;
var toggle = 0;
$(document).ready(function(){
var ctaSpeed =150;
$('.ctaButton').hover(function(){
$('.hover',this).stop().animate({ opacity: 1 },ctaSpeed);
//$('.up',this).stop().animate({ opacity: 0 },ctaSpeed);
},function(){
$('.hover',this).stop().animate({ opacity: 0 },ctaSpeed);
// $('.up',this).stop().animate({ opacity: 1 },ctaSpeed);
});
$('.menubalk .notActive a').hover(function(){
$(this).stop().animate({color: "#E50000"}, "fast");
},function(){
$(this).stop().animate({color: "#ffffff"}, "fast");
});
$('#sideMenu .notActive a').hover(function(){
$(this).stop().animate({color: "#638DBB"}, "fast");
},function(){
$(this).stop().animate({color: "#C4C4C4"}, "fast");
});
$('.blauweLink').hover(function(){
$(this).stop().animate({backgroundColor: "#638DBB"}, "fast");
},function(){
if($(this).parent().hasClass("active")){
}else{
$(this).stop().animate({backgroundColor: "#184E7F"}, "fast");
}
});
$('.smallColumn').hover(function(){
$("> .title .titelText h2", this).stop().animate({color: "#638DBB"}, "fast");
$("> .leesMeer", this).stop().animate({height: "40px"}, "fast");
},function(){
$("> .title .titelText h2", this).stop().animate({color: "#184E7F"}, "fast");
$("> .leesMeer", this).stop().animate({height: "11px"}, "fast");
});
$('.smallColumn').click(function(){
window.location.href = $('.leesMeer a',this).attr('href');
});
$('#submenu li').click(function(){
window.location.href = $('a',this).attr('href');
});
// $('#komma').hover(function(){
// $("> a", this).stop().animate({color: "#ffffff"}, "fast");
// },function(){
// $("> a", this).stop().animate({color: "#808080"}, "fast");
// });
if($('#fotogallery').length){
var activeFoto = 0;
var totalFotos = $("#fotogallery .images li").length;
var galleryPlay = true;
$("#fotogallery li").eq(0).css({'display':'block'});
$("#fotogalleryMenu li").eq(0).toggleClass("active");
function fotoRotateGallery(){
if(galleryPlay){
$.doTimeout( 4000, function(){
if(galleryPlay){
$("#fotogallery li").eq(activeFoto).fadeOut('slow');
$("#fotogalleryMenu li").eq(activeFoto).toggleClass("active");
activeFoto = activeFoto + 1;
if(activeFoto == totalFotos){ activeFoto = 0; }
$("#fotogalleryMenu li").eq(activeFoto).toggleClass("active");
$("#fotogallery li").eq(activeFoto).fadeIn('slow');
fotoRotateGallery();
}
});
}
}
fotoRotateGallery();
$('#fotogalleryMenu li').each(function(index) {
$(this).click(function(e){
if(index != activeFoto){
if(index == 0 && index == totalFotos){
}else{
e.preventDefault;
clickFotoAction(index);
}
}
});
});
function clickFotoAction(newFotoActive){
$("#fotogallery li").eq(activeFoto).fadeOut('slow');
$("#fotogalleryMenu li").eq(activeFoto).toggleClass("active");
galleryPlay = false;
$("#fotogalleryMenu li").eq(newFotoActive).toggleClass("active");
$("#fotogallery li").eq(newFotoActive).fadeIn('slow');
activeFoto = newFotoActive;
}
}
$('#contactBlockCTA').click(function(e){
e.preventDefault();
window.location.href = $('.telephone a',this).attr('href');
});
/*
* Color text hover
*/
var speed = 100;
$('a','#categoryMenu').hover(function(){ if(!$(this).parent().hasClass('active')) $(this).stop().animate({color: '#ffffff'},speed) },function(){ if(!$(this).parent().hasClass('active'))$(this).stop().animate({color: '#b2b2b2'},speed) });
$('a','#hoofdmenu').hover(function(){ if(!$(this).parent().hasClass('active')) $(this).stop().animate({color: '#E50000'},speed) },function(){ if(!$(this).parent().hasClass('active'))$(this).stop().animate({color: '#ffffff'},speed) });
// $('a','#footermenu').hover(function(){ if(!$(this).parent().hasClass('active')) $(this).stop().animate({color: '#E50000'},speed) },function(){ if(!$(this).parent().hasClass('active'))$(this).stop().animate({color: '#ffffff'},speed) });
// $('a','#sideMenu').hover(function(){ if(!$(this).parent().hasClass('active')) $(this).stop().animate({color: '#E50000'},speed) },function(){ if(!$(this).parent().hasClass('active'))$(this).stop().animate({color: '#ffffff'},speed) });
// $('a','#footerSubmenu').hover(function(){ if(!$(this).parent().hasClass('active')) $(this).stop().animate({color: '#ffffff'},speed) },function(){ if(!$(this).parent().hasClass('active'))$(this).stop().animate({color: '#808080'},speed) });
// $('a','#footer.x2 #footerSubmenu').hover(function(){ if(!$(this).parent().hasClass('active')) $(this).stop().animate({color: '#E50000'},speed) },function(){ if(!$(this).parent().hasClass('active'))$(this).stop().animate({color: '#ffffff'},speed) });
$('a','#hoofdmenu.x2').hover(function(){ if(!$(this).parent().hasClass('active')) $(this).stop().animate({color: '#E50000'},speed) },function(){ if(!$(this).parent().hasClass('active'))$(this).stop().animate({color: '#565656 '},speed) });
$('a','#categoryMenu.x2').hover(function(){ if(!$(this).parent().hasClass('active')) $(this).stop().animate({color: '#E50000'},speed) },function(){ if(!$(this).parent().hasClass('active'))$(this).stop().animate({color: '#565656'},speed) });
/*
* BlockItem hover
*/
$('li','#blockItemList').hover(
function(){
$('.borderTop',this).stop().animate({opacity: 1 },200);
$('p',this).stop().animate({color: '#E50000'},200);
$('.labelDown',this).css({ backgroundPosition: '-400px -50px' });
},function(){
$('.borderTop',this).stop().animate({opacity: 0 },200);
$('p',this).stop().animate({color: '#000000'},200);
$('.labelDown',this).css({ backgroundPosition: '-370px -50px' });
}
);
/*
* Submit Button
*/
$('.submitForm').click(function(e){
e.preventDefault();
var form = '#'+$(this).parent('form').attr('id');
$(form).submit();
});
/*
* Reset values forms
*/
var reset = '.resetValue';
$(reset).each(function(){
var label = $(this).attr('data-label');
if($(this).val()!=label)
{
$(this).css({color:'#777777'});
}
});
$(reset).focus(
function(){
var label = $(this).attr('data-label');
$(this).css({color:'#777777'});
if($(this).val()==label)
{
$(this).val('');
}
}
);
$(reset).blur(
function()
{
if($(this).val()=="")
{
$(this).css({color:'#BBBBBB'});
var label = $(this).attr('data-label');
$(this).val(label);
}
}
);
/*
* SimpleHover
*/
var target = '.simpleHover';
$(target).hover(function()
{
var hover = $('.hover',this);
$(hover).stop().animate({ opacity: 1 },200);
},
function()
{
var hover = $('.hover',this);
$(hover).stop().animate({ opacity: 0 },200);
})
//contact open map button
var mapOpen = false;
$('#openMap').click(function(){
if(mapOpen){
mapOpen = false;
$('> .text', this).html("open map");
$('#map_holder').stop().animate({"height": "210px"}, "slow");
}else{
mapOpen = true;
$('> .text', this).html("close map");
$('#map_holder').stop().animate({"height": "350px"}, "slow");
}
});
// Awards pop-up
$(".adwardPopUp").colorbox({ title : 0, close : '' });
$(".wtbPopUp").colorbox({ fixed: true, height: 600, title : 0, close : '' });
// ACCORDION
$("#faq_list li").each(function(){
var closedH = $('.faq_header',this).height() + parseInt($('.faq_header',this).css('padding-top')) + parseInt($('.faq_header',this).css('padding-bottom'));
var openH = closedH + $('p',this).height()+50;
// is open -> close
$(this).css({ height: closedH+'px'});
$(".faq_header", this).css({backgroundColor: $(this).attr('data-color')});
$('.faq_text',this).css({ height: openH - closedH+'px'});
});
$("#faq_list li").click(function(){
var closedH = $('.faq_header',this).height() + parseInt($('.faq_header',this).css('padding-top')) + parseInt($('.faq_header',this).css('padding-bottom'));
var openH = closedH + $('p',this).height()+50;
if($(this).height() > closedH)
{
// is open -> close
$(this).stop().animate({ height: closedH+'px'},200);
$('.faq_number',this).html('+');
$('.faq_number',this).css({ left: '11px' });
$(this).removeClass('open');
$(".faq_header", this).stop().animate({backgroundColor: $(this).attr('data-color')}, 100);
$("h3", this).stop().animate({color: "#444"}, 100);
}
else
{
// is closed -> open
$(this).stop().animate({ height: openH+'px'},200);
$('.faq_number',this).html('-');
$('.faq_number',this).css({ left: '14px' });
$(this).addClass('open');
$(".faq_header", this).stop().animate({ backgroundColor: "#E50000"}, 100);
$("h3", this).stop().animate({color: "#fff"}, 100);
}
})
$("#faq_list li").hover(function(){
$(".faq_header", this).stop().animate({ backgroundColor: "#E50000"}, 100);
$("h3", this).stop().animate({color: "#fff"}, 100);
$(".faq_number", this).stop().animate({color: "#fff"}, 100);
},function(){
if(! $(this).hasClass('open'))
{
$(".faq_header", this).stop().animate({ backgroundColor: $(this).attr('data-color')}, 100);
$("h3", this).stop().animate({color: "#444"}, 100);
$(".faq_number", this).stop().animate({color: "#E50000"}, 100);
}
});
$('a','.contactInfo').hover(function(){
$(this).stop().animate({color: "#E50000"}, 100);
},function()
{
$(this).stop().animate({color: "#000000"}, 100);
});
/*
Back to top
*/
var $btn = $('#back_to_top');
$btn.click(function()
{
$('html,body').stop().animate({ scrollTop: 0 },'slow');
});
if(typeof $('#back_to_top_holder').offset() !== 'undefined' && typeof $('#back_to_top_product').offset() !== false){ $('#back_to_top_holder').attr('data-y', $('#back_to_top_holder').offset().top); }
if(typeof $('#back_to_top_product').offset() !== 'undefined' && typeof $('#back_to_top_product').offset() !== false){ $('#back_to_top_product').attr('data-y', $('#back_to_top_product').offset().top); }
if(typeof $('.shop-now-side').offset() !== 'undefined' && typeof $('.shop-now-side').offset() !== false){ $('.shop-now-side').attr('data-y', $('.shop-now-side').offset().top); }
$(window).scroll(function()
{
if(typeof $('#back_to_top_holder').offset() != 'undefined'){
var $holder = $('#back_to_top_holder');
var $footer = $('#productsFilter .footer');
var y = $holder.attr('data-y');
var x = $holder.offset().left;
var marge = 100;
var maxY = $('#footer').offset().top - $holder.height() - $footer.height() - marge;
if($(window).scrollTop() >= y)
{
if($(window).scrollTop() >= maxY)
{
var dif = $(window).scrollTop() - maxY;
$holder.css({ position: 'fixed', left: x, top: -1*dif + 'px' });
$footer.css({ position: 'fixed', left: x, top: (-1*dif + 90) + 'px', bottom: 'auto' });
}
else
{
$holder.css({ position: 'fixed', left: x, top: 0 });
$footer.css({ position: 'fixed', left: x, top: '90px', bottom: 'auto' });
}
}
else
{
$holder.css({ position: 'relative', left: 0, top: 0 });
$footer.css({ position: 'absolute', left: 0, top: 'auto', bottom: '-45px' });
}
}
if(typeof $('#back_to_top_product').offset() != 'undefined'){
var $holder2 = $('#back_to_top_product');
var $footer2 = $('#ctaBlock .footer');
var y = $holder2.attr('data-y');
var x = $holder2.offset().left;
// height footer: 45px;
var marge = 100;
var maxY = $('#footer').offset().top - $holder2.height() - $footer2.height() - marge;
if($(window).scrollTop() >= y)
{
if($(window).scrollTop() >= maxY)
{
var dif = $(window).scrollTop() - maxY;
$holder2.css({ position: 'fixed', left: x, top: -1*dif + 'px' });
$footer2.css({ position: 'fixed', left: x, top: (-1*dif + 310) + 'px', bottom: 'auto' });
}
else
{
$holder2.css({ position: 'fixed', left: x, top: 0 });
$footer2.css({ position: 'fixed', left: x, top: '310px', bottom: 'auto' });
}
}
else
{
$holder2.css({ position: 'relative', left: 0, top: 0 });
$footer2.css({ position: 'absolute', left: 0, top: 'auto', bottom: '-45px' });
}
}
if(typeof $('.shop-now-side').offset() != 'undefined'){
var $stickyShop = $('.shop-now-side');
var y = $stickyShop.attr('data-y');
var x = $stickyShop.offset().left;
// height footer: 45px;
var marge = 100;
var maxY = $('#footer').offset().top - $stickyShop.height() - marge;
if($(window).scrollTop() >= y)
{
$stickyShop.addClass('is-sticky');
if($(window).scrollTop() >= maxY) {
var dif = $(window).scrollTop() - maxY;
$stickyShop.css({position: 'fixed', left: x, top: -1*dif + 'px'});
}
else {
$stickyShop.css({position: 'fixed', left: x, top: 0});
}
}
else
{
$stickyShop.removeClass('is-sticky');
$stickyShop.css({ position: 'relative', left: 0, top: 0 });
}
}
});
});
/********************** SEARCH HEADER ****************************/
var activeLi = null;
var toggle = 0;
$(document).ready(function(){
/*
* Header search
*/
var searchCat = '#header-search-category';
var ul = $('ul',searchCat);
var numItems = $('li',ul).size();
var lineHeight = 32;
var newH = numItems*lineHeight;
$(searchCat).click(function(e)
{
if(toggle == 0)
{
/*
* Slide down
*/
$(ul).stop().animate({ height: newH+'px' },300);
toggle = 1;
}
else
{
/*
* Slide up
*/
$(ul).stop().animate({ height: '32px' },300);
toggle = 0;
if($(e.target).is('li'))
{
var li = e.target;
/*
* Choice is made
*/
if( ! $(li).hasClass('choose'))
{
var label = $(li).html();
var url = $(li).attr('data-url');
var chosenList = '<li data-url="' + url + '" class="active">' + label + '</li>';
if(activeLi != null)
{
$('li',ul).eq(activeLi).removeClass('active');
$('li',ul).eq(activeLi).css({color: '#777777'});
}
activeLi = $(li).index();
$(li).addClass('active');
$('li',ul).eq(0).remove();
$(ul).prepend(chosenList);
$('input','#header-search-keyword').css({opacity: 1 },300);
}
}
}
});
/*
* List items hover
*/
$('li',ul).hover(function()
{
if( ! $(this).hasClass('choose') && ! $(this).hasClass('active') ) $(this).stop().animate({backgroundColor: "#638DBB", color: '#ffffff'}, 50);
},
function()
{
if( ! $(this).hasClass('choose') && ! $(this).hasClass('active')) $(this).stop().animate({backgroundColor: "#ffffff", color: '#777777'}, 50);
if($(this).hasClass('active')) $(this).stop().animate({backgroundColor: "#ffffff", color: '#444444'}, 50);
});
$(document).keydown(function(e)
{
if(e.keyCode == 13)
{
if($('#search_keyword').is(":focus"))
{
e.preventDefault();
submitForm();
}
}
});
/*
* Search field
*/
$('#submitSearch').click(function()
{
submitForm();
});
/*
* Search field
*/
var reset = '#search_keyword';
$(reset).each(function(){
var label = $(this).attr('data-label');
if($(this).val()!=label)
{
$(this).css({color:'#444444'});
}
});
$(reset).focus(
function(){
var label = $(this).attr('data-label');
$(this).css({color:'#444444'});
if($(this).val()==label)
{
$(this).val('');
}
}
);
$(reset).blur(
function()
{
if($(this).val()=="")
{
$(this).css({color:'#BBBBBB'});
var label = $(this).attr('data-label');
$(this).val(label);
}
}
);
});
function submitForm()
{
var searchField = '#search_keyword';
var label = $(searchField).attr('data-label');
if($(searchField).val() != label && $(searchField).val() != '')
{
var keyword = $(searchField).val();
// prepare data
var forbidden = new Array("'", '"', '\\', '/', ';', ';', '|', '>', '<', '[', ']', '!','?', '@', '#', '$', '%', '^', '&', '*', '(', ')','+','=','{','}','`', '~', '.', ',');
for(var i=0;i<forbidden.length;i++)
{
keyword = keyword.replace(forbidden[i],'');
}
keyword = keyword.replace(' ','-');
keyword = keyword.toLowerCase();
//window.location.href = '/'+url+'/search/'+keyword+'/';
window.location.href = '/results/' + keyword + '/';
}
}
/********************** ACTIVATE HOME SLIDER ****************************/
if( $('body').hasClass('home'))
{
// Set div
var $slider = $('#homeProductSlider');
// Initialize Image Slider
$slider.imageSlider({
nav : '#homeGalleryNav',
loop : 4000,
speed : 1500
});
// Resize slider for current window size
resizeSlider();
// Handle window resize
$(window).resize(function(){
resizeSlider();
});
}
// Resize function
// Optimized for Spire website
function resizeSlider()
{
var size = {
width: window.innerWidth || document.body.clientWidth,
height: window.innerHeight || document.body.clientHeight
};
// Slider ratio
var ratio = 2560 / 620;
var minHeight = 310;
// Resize slider
// Min height is 310, width is 1280 at that point.
if($slider.width() > minHeight * ratio)
{
// Resize container
$slider.width(size.width);
$slider.height($slider.width() / ratio);
// Resize slider
$slider.data('imageSlider').adjust();
}
else
{
// Resize container
$slider.width(size.width);
$slider.height(minHeight);
// Resize slider
$slider.data('imageSlider').adjust();
}
}