/**
 * Bootstrap.js - JavaScript bootstrapper
 * 
 * @author Webstores <info at webstores dot nl>
 *         Copyright (c) Webstores internet totaalbureau <http://www.webstores.nl/>
 */
$(document).ready(function() {
	
    // Utilities
    WS.Util.externalLinks();
    WS.Util.rowClick();
    WS.Util.fixPlaceholders();
	
    // IE6 fixes
    if(/msie 6/i.test(navigator.userAgent)) {
        WS.Util.fixIE6HoverList();
    }
	
    // AJAX loading
    $(document.body).ajaxStart(function() {
        $(this).addClass('loading');
    }).ajaxComplete(function() {
        $(this).removeClass('loading');
    });
	
    // Togglers
    $('.accordion').each(function() {
        switch(this.id) {
            /*case 'whatever-accordion':
				new Toggler(this).expand($(this).find('li:first-child'));
				break;*/
            default:
                new Toggler(this);
                break;
        }
    });
	
    // Validation
    $('form.generated').validate();
    $('form.generated-element').validate();
    
    // Messages
    MessageBar.init();
	
    // Carousels
    // if($('#spotlight-items').length) {
    // 	$('#spotlight-items').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: function(carousel, slide, index, state) {
    // 			$('#spotlight-controls li:nth-child(' + index + ')').addClass('selected');
    // 		},
    // 		itemVisibleOutCallback:function(carousel, slide, index, state) {
    // 			$('#spotlight-controls li:nth-child(' + index + ')').removeClass('selected');
    // 		}
    // 	});
    // }
    jQuery(function($){
        $.datepicker.regional['nl'] = {
            closeText: 'Sluiten',
            prevText: '←',
            nextText: '→',
            currentText: 'Vandaag',
            monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
            'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
            monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
            'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
            dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
            dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
            dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
            weekHeader: 'Wk',
            dateFormat: 'dd/mm/yy',
            firstDay: 1,
            isRTL: false,
            showMonthAfterYear: false,
            yearSuffix: ''
        };
        
        $.datepicker.setDefaults($.datepicker.regional['nl']);
    });

    // Datepicker
    $('input.date').datepicker({
        showOn: "button",
        buttonImage: "/img/calendar.gif",
        buttonImageOnly: false
    });
	
    // Newsticker
    $(".news-items").newsticker();
	
});

// Shadowbox
Shadowbox.init({
	overlayOpacity: 0.8,
	troubleElements: ['select']
});
