$(document).ready(function(){

	// Hide all the elements with class "hidden"
	$(".hidden").hide();
	
	// Make some selects autosubmit their form
	$("select.autosubmit").bind("change", function() {
		form = $(this).parents('form:first');
		form.submit();
	});
	
	// Make external links open in new windows
	$("a.external").attr('target','_blank');
	
	// Make links on the body_text always open in new windows
	$(".body_text a").attr('target','_blank');
	
	// Set the ribbon with
	$("#header nav li").each(function(index, el) {
		if ($(el).hasClass("active")) {
			var width = $(el).outerWidth(false) / 2 + "px";
			var cssObj = {
				"border-right-width": width,
				"border-left-width": width
			}
			$(el).children("span").css(cssObj);
		}
	});
	
	//Toggle - Just add the class "toggle" to the button and "toggle_wrapper" to the container.
    //The target is defined by a main controller with class "toggle_controller"
    $(".toggle").click(function () {
            var parent = $(this).parents(".toggle_controller:first");
            parent.find(".toggle_wrapper").slideToggle("slow");
            $(this).toggleClass("contract");
    });
	
	// ColorBox lightbox
	$("a[rel='lightbox']").colorbox({transition:"fade"});

});
