var TalentumBlogg = function() {
	return {	
		init: function() {
			TalentumBlogg.archive.init();
			TalentumBlogg.comment.init();
			TalentumBlogg.newWindow.init();
		}
	};
}();

TalentumBlogg.archive = function() {
	return {
		init: function() {
			Talentum.eventHandler.register("click", ".archive a", function(e) {
				var sibling = this.nextSibling.nodeType != 3 ? $(this.nextSibling) : $(this.nextSibling.nextSibling);
				if (sibling) {
					if ($(sibling.parentNode).hasClass("active")) {
						$(sibling.parentNode).removeClass("active");
					} else {
						$(sibling.parentNode).addClass("active");
					}
				}
			});
		}
	};
}();

TalentumBlogg.comment = function() {
	return {
		init: function() {
			Talentum.eventHandler.register("click", ".toggle-new-comment", function(e) {
				var commentForm = $$("create-new-comment");
				commentForm.setStyle(DOMEffects.getOpacityRule(0));
				commentForm.setStyle("display", "block");
				commentForm.show({ duration: 500 });
			});
			Talentum.eventHandler.register("click", "#create-new-comment .cancel", function() {
				var commentForm = $$("create-new-comment");
				if (commentForm) {
					commentForm.setStyle("display", "none");
				}
			});
		}
	};
}();

TalentumBlogg.newWindow = function() {
	return {
		init: function(){
			Talentum.eventHandler.register("click", "a.open-in-new", function(){
				window.open(this.href, "_blank");
			});
		}
	};
}();

// Override functions we don't want to run.
Talentum.comment = function() {
	return {
		init: function() {}
	};
}();

Talentum.addAnchors = function() {
	return {
		init: function() {}
	}
}();

TalentumBlogg.init();
