$(document).ready( function(){
	$("#header-area li:first").addClass("first");
	$("#header-area li:last").addClass("last");
	
	$("#guldkorn ol a").click(function(){
		var idx = $(this).attr("rel");
		$("#guldkorn ul li").addClass("hidden").removeClass("active");
		$("#guldkorn ul li").eq(idx).removeClass("hidden").addClass("active");
		
		
		$("#guldkorn ol img").attr("src","/uploads/template/images/bullet-unselected.png");
		$(this).find("img").each(function(){
			$(this).attr("src","/uploads/template/images/bullet-selected.png");
		});
		
		return false;
	});
	
	if( $("#case-info li").size() > 1 ){
		$("#case-info li").addClass("hidden");
		$("#case-info li:random").removeClass("hidden");
	}
	
	$(".e-zine .tilmeld-badge .cms_submit").click(function(){
		valCheck = 0;
		$(this).closest("form").find(".cms_textfield:first").each(function(){
			if ( $(this).val() == "" ){ valCheck = 1 }
		});
		
		if(valCheck > 0){
			$(".nms_error:first").removeClass("JShidden");
			return false;
		} else {
			return true;
		}
		//return false;
	});
	
});
		
(function ($) {
	// VERTICALLY ALIGN FUNCTION
	$.fn.vAlign = function() {
		return this.each(function(i){
			var ah = $(this).height();
			var ph = $("html").height();
			var mh = (ph - ah) / 2;
			if ( ah < 1 ) mh = mh / 2;
			$(this).css('margin-top', mh);
		});
	};
})(jQuery);


jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
{
    random: function(a, i, m, r) {
        if (i == 0) {
            jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
        };
        return i == jQuery.jQueryRandom;
    }
});
