if (typeof(nl) == "undefined") {
	var nl = {}
}
if (typeof(nl.ggdhartvoorbrabant) == "undefined") {
	nl.ggdhartvoorbrabant = {}
}


nl.ggdhartvoorbrabant.Accordion = (function() {
	/* START PUBLIC */
	return {
		Init: function(selector) {
			// Set list
			jQuery(selector + " dt").removeClass("active");
			jQuery(selector + " dd").hide();
			
			// Set click event
			jQuery(selector + " dt").click(function() {
				if(jQuery(this).hasClass("active")){
					jQuery(this).next("dd:visible").slideUp(400);
					jQuery(this).removeClass("active");
				} else {
					jQuery(this).parent().find("> dt").removeClass("active");
					jQuery(this).addClass("active");
					if (jQuery(this).next("dd").is(":hidden")) {
						jQuery(this).parent().find("> dd:visible").slideUp(400);
						jQuery(this).next("dd").slideDown(600);
					}
				}
				
			})
		}
	}
	/* END PUBLIC */
})();






nl.ggdhartvoorbrabant.NieuwsbriefCheck = (function() {
    /* START PUBLIC */
    return {
        Init: function(selector) {
            // Set list
            jQuery(selector).val("")
            jQuery(selector).bind('blur', function() {
                mailcheck = jQuery(this).parent().find('span.tag_mailcheckMessage:visible')
                if (jQuery(mailcheck).size() > 0) {
                    alert(jQuery(mailcheck).text())
                    setTimeout(function() { jQuery(this).focus(); }, 50);
                }
            })
        }
    }
    /* END PUBLIC */
})();




nl.ggdhartvoorbrabant.PositionPager = (function() {
    
    var totalWidth
    var pagerWidth
    
    /* START PUBLIC */
    return {
        Init: function(selector) {
			totalWidth = jQuery(selector).width();
			pagerWidth = jQuery(selector).find("div.pager").width();
			jQuery(selector).find("div.pager").css("left", (totalWidth-pagerWidth)/2);
			
			//.css( propertyName, value ) 
        }
    }
    /* END PUBLIC */
})();




nl.ggdhartvoorbrabant.carrousel = (function() {
	var root
	var timer
	var pause
	var config = {
		interval: 10000
	}
	
	function start() {
		var href
		var activeButton
		
		jQuery(root).data("mode", "play")
		switchSlide()
		
		jQuery(root).find("ol.carrouselButtons li a").each(function(index) {
			href = jQuery(this).attr("href")
			activeButton = jQuery(root).find("ol.carrouselContent li").eq(index)
			jQuery(activeButton).css("cursor", "pointer")
			jQuery(activeButton).data("url", href)
			jQuery(activeButton).click(function() {
				document.location = jQuery(this).data("url")
			})
		})

		jQuery(root).append("<div class='pause' />")
		pause = jQuery(root).find(".pause")
		jQuery(pause).css("background-position", "0 -50px")
		jQuery(pause).click(function() {
			if (jQuery(root).data("mode") == "pause") {
				start()
			} else {
				stop()
			}
		})
		
		timer = setInterval("nl.ggdhartvoorbrabant.carrousel.SwitchSlide()", config.interval)
	}

	function stop() {
		jQuery(root).data("mode", "pause")
		jQuery(pause).css("background-position", "0 0")
		clearInterval(timer)
	}
	
	function switchSlide() {
		var previousActiveItem = jQuery(root).find('li.active')

		jQuery(root).find(".active").removeClass("active")
		jQuery(previousActiveItem).next().addClass('active')
		if (jQuery(root).find('li.active').size() == 0) {
			jQuery(root).find('li:first-child').addClass('active')
		}
	}
	
	
	
	
	/* START PUBLIC */
	return {
		Init: function(selector) {
			root = jQuery(selector)
			start()
		},
		
		SwitchSlide: function() {
			switchSlide()
		}
	}
	/* END PUBLIC */
})();
