HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/deensekroon.komma-mediadesign.nl/wwwroot/js/deensekroon_main.js
// JavaScript Document

var aniblock = new Array();
aniblock['in'] = new Array();
aniblock['out'] = new Array();

var currentBannerImage = 1;
var numLargeBanner = 1;
var largeBannerIntv = null;

var currentProductImage = 1;
var numLargeProduct = 1; 

var isIE = navigator.userAgent.match(/MSIE/i) != null;

var bannerInterval = 10000;


// IE CHECK
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))  // If Internet Explorer, return version number
{
	$('html').addClass('ie');
	$('head').append('<link rel="stylesheet" type="text/css" href="/css/style-ie.css"/>')
}

$(document).ready(function(){
	
	initProductImages();
	
	initBannerHover();
	initButtonHover();	
	initResizer();
	initAside();
	initColorFilter();
	initFieldPlaceHolders();

    initClothingStockCheck();




    $('marquee').marquee();

    $('#select_size').customSelect();

    $('.showGalleryImages').click(function(){
        var str = $(this).attr('data-galstr');
        var index = $(this).attr('data-index');

        showProductImages(str,index);
    });


    $('.colorBar').each(function()
    {
        var color = $(this).attr('data-color');
        var id = $(this).attr('id');
        colorBar(id,color);
    });

	if($('.swiper-container').size())
	{
		var mySwiper = new Swiper ('.swiper-container', {
			// Optional parameters
			speed : 600,
			autoplay: 3000,
			loop: true
		})
	}

    numLargeBanner = $('#large-banner-mask').children().size();
});

function colorBar(id,color){
	$('#'+id).css({backgroundColor:'#'+color});	
}


function initBannerHover(){
	largeBannerIntv = setTimeout(largeBannerNext,bannerInterval);
	//set positions / opacity
	$('#largebannercount1').addClass('active');
	var speed = 150;
}

function largeBannerNext(){
	clearTimeout(largeBannerIntv);
	largeBannerIntv = setTimeout(largeBannerNext,bannerInterval);
	var speed = 500;
	$('#bannerimage'+currentBannerImage).stop().animate({ opacity : 0},speed,function(){ $(this).css({ display: 'none' });	});
	$('#largebannercount'+currentBannerImage).removeClass('active');
	if(currentBannerImage != numLargeBanner){
		currentBannerImage++;
	}
	else{
		currentBannerImage = 1;
	}
	$('#largebannercount'+currentBannerImage).addClass('active');
	$('#bannerimage'+currentBannerImage).css({ display: 'block' });
	$('#bannerimage'+currentBannerImage).stop().animate({ opacity : 1},speed);
}

function largeBannerPrev(){
	clearTimeout(largeBannerIntv);
	largeBannerIntv = setTimeout(largeBannerNext,bannerInterval);
	var speed = 500;
	$('#largebannercount'+currentBannerImage).removeClass('active');
	$('#bannerimage'+currentBannerImage).stop().animate({ opacity : 0},speed,function(){ $(this).css({ display: 'none' });	});
	if(currentBannerImage != 1){
		currentBannerImage--;
	}
	else{
		currentBannerImage = numLargeBanner;
	}
	$('#largebannercount'+currentBannerImage).addClass('active');
	$('#bannerimage'+currentBannerImage).css({ display: 'block' });
	$('#bannerimage'+currentBannerImage).stop().animate({ opacity : 1},speed);
}

function initButtonHover(){
	//btnhover
	$('.btnhover').each(function() {
       	$(this).hover(function(){
	   		$(this).stop().animate({ opacity: 1 },200);
		},
		function(){
	   		$(this).stop().animate({ opacity: 0 },200);
		});
	});
	
	$('.btnhover-extra').each(function() {
		$(this).hover(function(){
	   		$(this).children('.over').stop().animate({ opacity: 1 },100);
		},
		function(){
	   		$(this).children('.over').stop().animate({ opacity: 0 },100);
		});
	});
}

function initProductImages(){
	
	$('img.preload').each(function() {
		//get url to load
		var src = $(this).attr('data-src');
		//load image
		$(this).attr('src', src);
		//detect finish loading
		
		$(this).one('load', function() {
		  // do stuff
		  //image opacity to 1
			if(!$(this).hasClass('collection_hover')) $(this).animate({opacity: 1 }, 300);
			//loader opacity to zero
			$(this).parent().children('.loading').animate({opacity: 0 }, 300, function(){
				//on finish remove loader
				$(this).remove();
			});		  
		}).each(function() {
		  if(this.complete) $(this).load();
		});
		
		
		/*$(this).load(function(){ 
			//image opacity to 1
			if(!$(this).hasClass('collection_hover')) $(this).animate({opacity: 1 }, 300);
			//loader opacity to zero
			$(this).parent().children('.loading').animate({opacity: 0 }, 300, function(){
				//on finish remove loader
				$(this).remove();
			}); 
		} );*/
	});    

	
	//hover images 	
	$('.product-thumb-image').hover(function(){ $(this).children('a').children('.collection_hover').stop().animate({opacity: 1},200); }, 
									function(){ $(this).children('a').children('.collection_hover').stop().animate({opacity: 0},200); });	
}

function changeMaskHeight(mask, holder){
	var targetH = $('#'+holder).height();
	if($('#'+mask).height() != targetH){
		$('#'+mask).stop().animate({ height : targetH+'px' },400);	
	}
	else{
		$('#'+mask).stop().animate({ height : 0 },400);	
	}
}

function initProductHover(){
	
}

function returnWindowSize() {
	var myWidth = 0, myHeight = 0;
	var size = new Array();
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
  	
	size[0] = myWidth;
  	size[1] = myHeight;
	return size;
}

function initResizer(){
	$(window).resize(function() {
    	clearTimeout(this.id);
    	this.id = setTimeout(doneResizing, 500);
	});
}

function doneResizing(){
	initAside();
}

function initAside(){
	var $wrapper = $('#wrapper'),
		$aside = $('#aside'),
		timeInt = null;
		
		$wrapper.scroll(function(){
			checkAside();
			clearTimeout(timeInt);
			timeInt = setTimeout(checkAside,200);
		});		
}

function checkAside(){
	var wsize = returnWindowSize();
	var $wrapper = $('#wrapper'),
		$aside = $('#aside'),
		t = 192,
		l = $('#main').offset().left,
		block = false,
		margin = 20;
	
	var limit = $('#aside').height() - $('h1','#aside').height() + 140;
	if(limit <= 714) limit = 714;

	if(wsize[1] > limit){
		if($wrapper.scrollTop() >= t-margin){
			$aside.css({ position: 'fixed', top: margin+'px', left: l+'px'});
			if(!block){
				block=true; setTimeout(function(){ block=false; },100);
				if($aside.children('h1').height() < 40){
					$aside.children('h1').stop().animate({ height: '40px' },100);
				}
			}
		}
		else{
			$aside.css({ position: 'absolute', top: t+'px', left: 0}); 
			if(!block){
				block=true; setTimeout(function(){ block=false; },100);
				if($aside.children('h1').height() > 0){
					$aside.children('h1').stop().animate({ height: 0 },100);
				}
			}
		}
	}
	else{
		$aside.css({ position: 'absolute', top: t+'px', left: 0}); 
		if(!block){
			block=true; setTimeout(function(){ block=false; },100);
			if($aside.children('h1').height() > 0){
				$aside.children('h1').stop().animate({ height: 0 },100);
			}
		}
	}
}

//set colormenuhover & filter products by color
function initColorFilter(){
	// set menu
	$('.cblock').hover(function(){ $(this).children('.over').stop().animate({ opacity: 1},100); }, function(){ $(this).children('.over').stop().animate({ opacity: 0},100); });	
	
	$('.cblock').click(function(){
		if($('#unset-color-filter').css('display') == 'none'){
			$('#unset-color-filter').css({ display: 'block' });
			$('#unset-color-filter').click(function(){ 
				$(this).css({ display: 'none' }); 
				$('.collection-items').children('.product-cell').each(function(){
					$(this).css({ display: 'block' });	
				});
			});
		}
		
		//filter colors
		var cat = $(this).attr('data-color');
		$('.collection-items').children('.product-cell').each(function(){
			if($(this).attr('data-color') == cat){
				$(this).css({ display: 'block' });	
			}
			else{
				$(this).css({ display: 'none' });	
			}			
		});

        // reset content height

        // aside fix 140107
        var contentMinHeight = $('#aside').height()-120;
        if($('#content').height()<contentMinHeight)
        {
            $('#content').css({ minHeight: contentMinHeight+'px' });
        }
	});
}

/* Placeholder -> Search textfield & newsletter textfield */
function initFieldPlaceHolders(){
	$('.txt-holder').click(function(index, element) {
		$(this).children('input').focus();
    });	
	
	$('.txt-holder').children('input').focus(function(){
		 var lt = ($(this).parent().children('.txt-place-holder').width() + 16) * -1;
		$(this).parent().children('.txt-place-holder').stop().animate({ left: lt+'px' },200);
	});
	$('.txt-holder').children('input').blur(function(){
		if($(this).attr('value') == '') $(this).parent().children('.txt-place-holder').stop().animate({ left: 0 },200); 
	});
	
	$('#main-search-input').click(function(){ this.value = ''; });
}


function showProductImages(str, index){
    var gallery = new Gallery('body','products',true);
	var images = str.split('|');

    /*
        incoming string to create array:
        |./images/image1.jpg(src),400(w),300(h),naam van de afbeelding(alt)|./images/image2.jpg,700,600,naam van de afbeelding|enz..
    */
	for(var key=0;key < images.length; key++){
		// get info
		var temp = images[key].split(',');


		//fill array
		images[key] = new Array();
		images[key]['src'] = temp[0];
		images[key]['width'] = temp[1];
		images[key]['height'] = temp[2];
		images[key]['alt'] = temp[3];
		gallery.addImage(images[key]['src'],images[key]['width'],images[key]['height'],images[key]['alt']);
	}
	gallery.init();
	gallery.display(index);
}


/*
 * Updates the every time the size-dropdown changes
 */
function initClothingStockCheck()
{
    $('#select_size').change(function()
    {

    });
}

// Open menu
$('.open-mobile-navigation').click(function()
{
	$('.main-flexable-layout').addClass('open-navigation');
});

// Close menu
$('.close-mobile-navigation').click(function()
{
	$('.main-flexable-layout').removeClass('open-navigation');
});
// Close menu
$('.close-mobile-navigation').click(function()
{
	$('.main-flexable-layout').removeClass('open-navigation');
});

$(window).scroll(function(){

	// Get rect from header
	var rect = $('#header')[0].getBoundingClientRect();
	// Define fixable heder
	var $fixableHeader = $('.fixable-header');

	if(rect.bottom < 0)
	{
		$fixableHeader.addClass('fixed');
	}
	else{
		 $fixableHeader.removeClass('fixed');
	}

});