/**
 * Bootstrap.js - JavaScript bootstrapper
 * 
 * @author Webstores <info at webstores dot nl>
 *         Copyright (c) Webstores internet totaalbureau <http://www.webstores.nl/>
 */
	
// Utilities
WS.Util.externalLinks();
WS.Util.rowClick();
WS.Util.fixPlaceholders();

// Messages
MessageBar.init();

// IE6 fixes
if(/msie 6/i.test(navigator.userAgent)) {
	MessageBar.show('warning', '<h1>U gebruikt een zeer oude versie van Internet Explorer</h1><p>Voor een optimale ervaring is het aan te raden om de <a href="http://www.microsoft.com/netherlands/windows/internet-explorer/" title="De laatste versie van Internet Explorer downloaden" rel="external">laatste versie van Internet Explorer</a> te installeren, of te kiezen voor een alternatieve browser zoals <a href="http://www.mozilla.com/firefox/" title="Mozilla Firefox downloaden" rel="external">Firefox</a>, <a href="http://www.google.com/chrome" title="Google Chrome downloaden" rel="external">Chrome</a>, <a href="http://www.apple.com/nl/safari/" title="Apple Safari downloaden" rel="external">Safari</a> of <a href="http://www.opera.com/" title="Opera downloaden" rel="external">Opera</a>.</p>');
	WS.Util.fixIE6HoverList();
}

// Carousels
if($('#spotlight-visuals').length) {
	$('#spotlight-visuals').jcarousel({
		scroll: 1,
		animation: 'slow',
		auto: 7,
		wrap: 'both',
		buttonNextHTML: null,
		buttonPrevHTML: null,
		initCallback: function(carousel) {
			$('#spotlight-controls li').each(function(i) {
				$(this).bind('click', function(e) {
					e.preventDefault();
					carousel.stopAuto();
					carousel.scroll(i + 1);
					carousel.startAuto();
				});
			});
			
			carousel.clip.hover(function() {
				carousel.stopAuto();
			}, function() {
				carousel.startAuto();
			});
		},
		itemVisibleInCallback: {
			onBeforeAnimation: function(carousel, slide, index, state) {
				$('#spotlight-controls li:nth-child(' + index + ')').addClass('selected');
			}
		},
		itemVisibleOutCallback: {
			onBeforeAnimation: function(carousel, slide, index, state) {
				$('#spotlight-controls li:nth-child(' + index + ')').removeClass('selected');
			}
		}
	});
}

// Validation
$('form.generated').validate();

// Tabs
$('#product-details').tabs();

// Shadowbox
Shadowbox.init({
	overlayOpacity: 0.8,
	troubleElements: ['select']
});

