var W = (function () {
	return {	
		init: function () {
			W.external.init();
			W.iframeFix.init();
		}
	};
}());

W.external = (function () {
	var DOMReady = function () {
		$("body").delegate("a[rel=external], a[rel=generator]", "click", function (e) {
			e.preventDefault();
			window.open(this);
			}).attr("title", function () {
			var title = $(this).attr("title");
			if(typeof(title) === "undefined" || title === "") {
				$(this).attr("title", "Öppnas i ett nytt fönster");
			} else {
				$(this).attr("title", "Öppnas i ett nytt fönster - " + title);
			}
		}); 
	};

	return {
		init: function () {
			$(document).ready(DOMReady);
		}
	};
}());

W.iframeFix = (function () {
	return {
		init: function () {
			if ($.browser.mozilla) {
				$(document).ready(function() {
					var $iframes = $("iframe");
					if ($iframes.length > 0) {
						$iframes.bind("load.fix", function () {
							$(this).unbind("load.fix");
							this.contentWindow.location.href = this.src;
						});
					}
				});
			}
		}
	};
})();

W.init();
