$(document).ready(function() {

	$('#webshopDetail .item .colorselect').change(function (ev) {
		$('.figure img', $(this).parents('.item')).attr('src', '/dynamisch/colors/tn_' + $(this).val().split(/\|/).pop());
		$('.figure a', $(this).parents('.item')).attr('href', '/dynamisch/colors/' + $(this).val().split(/\|/).pop());
	});

	$('#webshopDetail .item .colorselect').each(function () {
		$('.figure img', $(this).parents('.item')).attr('src', '/dynamisch/colors/tn_' + $(this).val().split(/\|/).pop());
		$('.figure a', $(this).parents('.item')).attr('href', '/dynamisch/colors/' + $(this).val().split(/\|/).pop());
	});

	$('#webshopDetail .item .figure a').nyroModal();

	$('a.del').click(function (ev) {
		if (!confirm('Weet u het zeker?')) ev.preventDefault();
	});

	$('#quoteform').submit(function (ev) {
		errs = [];
		$('.required', $(this)).each(function (i) {
			if ($(this).val() == '') {
				t = $(this).siblings('label').html();
				t = '- ' + t.substr(0, t.length - 2);
				errs.push(t);
			}
		});
		if (errs.length > 0) {
			alert('U heeft de volgende verplichte velden niet ingevoerd:\n\n' + errs.join('\n'));
			ev.preventDefault();
		}
	});

});
