$(document).ready(function() {
	if ($('.tabs a')) {
		$('.tabs a').click(function () { 
			$('.tabs li').removeClass('selected');
			$(this).parent().addClass('selected');
			$('.tab').removeClass('show');
			$('#' + $(this).attr('rel')).addClass('show');
		});
	}
	$('#myselectbox1').selectbox();
	$('#myselectbox2').selectbox();
	$('#myselectbox3').selectbox();
	$('#myselectbox4').selectbox();
	$('#myselectbox5').selectbox({inputValue: 'Selecteer onderdeel...'});
	$('#myselectbox6').selectbox({inputValue: 'Selecteer merk...'});
	$('#myselectbox7').selectbox({inputValue: 'Selecteer model...'});
	$('#myselectbox8').selectbox({inputValue: 'Selecteer type...'});
	$('#myselectbox9').selectbox({inputValue: 'Selecteer onderdeel...'});
	jQuery('#thumbs').jcarousel({
		scroll: 1,
		animation: 'normal'
	});
	hs.graphicsDir = 'public/images/graphics/';
    hs.outlineType = 'rounded-white';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.outlineType = 'rounded-white';
	hs.fadeInOut = true;
	hs.dimmingOpacity = 0.6;
	hs.registerOverlay({
		html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
		position: 'top right',
		fade: 2
	});
	$(".enlarge").jqzoom({
		zoomWidth: 350,	
        zoomHeight: 352,
		xOffset: 9,
        yOffset: -9,
		title : false
	});
	if ($('#chreg')) {
		$('#chreg input').change(function () { 
			$('.reg').removeClass('visible');
			$('#' + $(this).parent().attr('class')).addClass('visible');
		});
	}
	$('a.numplus').click(function () { 
		var numvalue = $(this).parent().children('input');
		var nval = parseInt(numvalue.attr('value'));
		if (nval > 0) { numvalue.attr('value', nval + 1); }
	});
	$('a.numminus').click(function () { 
		var numvalue = $(this).parent().children('input');
		var nval = parseInt(numvalue.attr('value'));
		if (nval > 1) { numvalue.attr('value', nval - 1); }
	});
	
	$('a.close').click(function() { 
		$('.over').hide(); 
		$('.overlay').hide();
		window.location = "http://www.brabebo.nl/"
		return false;
	});
	colsScroll();
	bottomTotal();

});

$(window).load(function() { $('.overlay').height($('body').height()); });

$(window).scroll(function() {
	colsScroll();
	bottomTotal();
});

function bottomTotal() {
	var a1 = $(window).scrollTop() + $(window).height();
	var b1 = $('#list').offset().top + $('#list').height();
	var c1 = $('#wrap').offset().top + $('#wrap').height();
	var d1 = 0;
	if (c1 < a1) { d1 = a1 - b1 - (a1 - c1); }
	else { d1 = a1 - b1; }
	if (d1 > 315) { $('#total').css('margin-top', d1 - 315); }
	else { $('#total').css('margin-top', 10); }
}

function colsScroll() {
	if (($('.left-col').height() < $(window).height()) || ($('.right-col').height() < $(window).height())) { 
		var a1 = $(window).scrollTop() + $(window).height();
		var b1 = 0;
		if ($('.left-col').height() > $('.right-col').height()) { b1 = $('.left-col').height(); }
		else { b1 = $('.right-col').height(); }
		var c1 = $('#wrap').height();
		var d1 = 0;
		if (a1 > c1) { d1 = a1 - c1; }
		if (d1 <= 0) { 
			if ($(window).scrollTop() < $('.header').height()) { 
				$('.left-col').css('margin-top', 0);
				$('.right-col').css('margin-top', 0);
			}
			else { 
				$('.left-col').css('margin-top', $(window).scrollTop() - $('.header').height());
				$('.right-col').css('margin-top', $(window).scrollTop() - $('.header').height());
			}
		}
	}
	
}
