function corcarousel_initCallback(carousel) {
	jQuery('#c-next').click(function() {
		carousel.next();
		return false;
	});

	jQuery('#c-prev').click(function() {
		carousel.prev();
		return false;
	});
}

function bestelNu() {
	jQuery('#bestel-form').submit();
}

function bestellingAfronden() {
	jQuery('#bestel-stap1').submit();
}

function resizeRandom() {
	var picHeight = jQuery('#hl-pic-product').attr('height');
	var picWidth = jQuery('#hl-pic-product').attr('width');
	var maxHeight = 190;
	var maxWidth = 305;
	var newHeight = maxHeight - picHeight;
	var newWidth = maxWidth - picWidth;
	newHeight = newHeight / 2;
	newWidth = (newWidth / 2) - 60;

	if(picHeight < 150 && picHeight > 40) {
		jQuery('#hl-pic-product').css('padding-top', newHeight + 'px');
	}
	
	jQuery('#hl-pic-product').css('padding-left', newWidth + 'px');
}

jQuery(function() {
	if(jQuery('#hl-pic-product').length) {
		resizeRandom();
	}

	if(jQuery('#c-items').length) {
	    jQuery("#c-items").jcarousel({
	        scroll: 1,
			auto: 4,
			wrap: 'last',
	        initCallback: corcarousel_initCallback,
	        buttonNextHTML: null,
	        buttonPrevHTML: null
	    });
	}
	
	if(jQuery('a.lightbox').length) {
		jQuery('a.lightbox').lightBox({
			imageLoading: '/assets/images/design/loading.gif',
			imageBtnClose: '/assets/images/design/closelabel_nl.gif',
			imageBtnPrev: '/assets/images/design/prevlabel_nl.gif',
			imageBtnNext: '/assets/images/design/nextlabel_nl.gif'
		});
	}
	
	jQuery('#bestel-nu').click(function() {
		bestelNu();
	});
	jQuery('#bestel-nu span').click(function() {
		bestelNu();
	});
	jQuery('.row .cta-blue').click(function() {
		bestellingAfronden();
	});
	jQuery('.row .cta-blue span').click(function() {
		bestellingAfronden
	});
	jQuery('.row input[type=text]').keyup(function(e) {
		if(e.which == 13) {
			bestellingAfronden();
		}
	});
});