			function popupRulesComments() {
				window.open( "/regler_kommentarer", "myWindow",
				"status = 1, height = 400, width = 630, resizable = 0")
			}

			function popupRules() {
				window.open( "/regler2", "myWindow",
				"status = 1, height = 600, width = 700, resizable = 0")
			}

			function toggle( e ){
				e = e ? e : window.event;

				var list = document.getElementById('bloggers');
				var obj = document.getElementById('menuBloggar');

				if(list.style.display != 'block' ){
					list.style.display = 'block';
					obj.className = 'activeMenu';
					document.body.onclick = toggle;
					e.cancelBubble = true;
					return false;
				}
				else {
					list.style.display = 'none';
					obj.className = '';
					document.body.onclick = null;
				}
			}
			function openMilla(e) {
				if (document.getElementById('showMillaDiv').style.display!="block") {
					document.getElementById('showMillaDiv').style.display="block";
					document.getElementById('whatIsMilla').style.display="none";
					return false;
				}
				document.getElementById('showMillaDiv').style.display="none";
				return false;
			}
			$(document).ready(function () {
				$(".openMilla").bind("click", openMilla);
			});

			function closeMilla() {
				document.getElementById('showMillaDiv').style.display="none";
				document.getElementById('whatIsMilla').style.display="block";
			}

			function openRules(e) {
				var y = (e.pageY);
				var x = (e.pageX);
				document.getElementById('showRulesDiv').style.display="block";
				document.getElementById('showRulesDiv').style.left=x + 40 + "px";
				document.getElementById('showRulesDiv').style.top=y + 10 + "px";

				return false;
			}
			$(document).ready(function () {
				$(".openRules").bind("click", openRules);
			});

			function closeRules() {
				document.getElementById('showRulesDiv').style.display="none";
			}

			function openComment(id) {
				document.getElementById(id).style.display = "block";
				return false;
			}

			function closeComment(id) {
				document.getElementById(id).style.display = "none";
				return false;
			}

			function toggleCrowdcastingBox(triggerEl) {
				if ($('#crowdCastingTop').is(":hidden")) {
					$('#crowdCastingTop').slideDown(
						500,
						function() { 
							$('#crowdCastingTop img.closeCrowdCasting').fadeIn(200);
							$('#crowdTab').addClass( 'expanded-crowd' );
						}
					);
				}
				else {
					$('#crowdCastingTop img.closeCrowdCasting').fadeOut(
						50,
						function() {
							$('#crowdCastingTop').slideToggle(500);
							$('#crowdTab').removeClass( 'expanded-crowd' );
						}
					);
				}
			}

			function toggleSubjectContainerAllContent(container, link) {
				$(link).blur();
				container = $(container);
				container.slideToggle(500);
				$(link).toggleClass("showAll").toggleClass("hideAll");
			}

			function toggleSubjectContainerBlogLinks(container, parent, link) {
				$(link).blur();
				container = $(container);
				container.data("currentParent", parent);
				container.slideToggle(
					500,
					function() {
						container.children('.linkToBlogInput').focus();
					}
				);
				$(link).toggleClass("linkToBlog").toggleClass("linkToBlogVisible");
			}

			function togglePageBlogLinkDialog(parent, subjectTitle) {
				var container = $('#globalLinkToBlog');
				if (parent) {
					if (container.is(":hidden")) {
						$('p.subject', container).html(subjectTitle);
					}
					else {
						$('p.subject', container).fadeOut(
							100,
							function() {
								$('p.subject', container).html(subjectTitle).fadeIn(100);
							}
						);
					}
					$('input.name', container).attr('value','');
					$('input.title', container).attr('value','');
					$('input.url', container).attr('value','');
					$('p.error', container).each(
						function(i) {
							$(this).removeClass('error');
						}
					);
					$('input', container).each(
						function(i) {
							$(this).attr("readonly", "");
						}
					);
					$(".button.add", container).show();
					$(".button.load", container).hide();
					$('.message', container).hide();
					$('.inputs', container).show();

					var yPos = (($(window).height() - container.height()) / 2) + $(window).scrollTop() - 50;
					//if (container.is(":hidden")) {
						container.css("top", yPos);
						//container.css("opacity", 0);
						//container.show();
						container.slideDown(
							300,
							function() {
								$('.closeGlobalLinkToBlog', container).fadeIn(300);
							}
						);
					//}
					$('.linkToBlogContainer', container).data("currentParent", parent);
				}
				else {
					container.hide();
					$('.closeGlobalLinkToBlog', container).hide();
				}
			}

			function addBlogLink(container) {
				container = $(container);
				var parent = container.data("currentParent");
				var name = $('input.name', container).attr('value');
				var title = $('input.title', container).attr('value');
				var url = $('input.url', container).attr('value');
				$('input', container).each(
					function(i) {
						$(this).attr("readonly", "readonly");
					}
				);
				$('p.error', container).each(
					function(i) {
						$(this).removeClass('error');
					}
				);
				$(".button.add", container).hide();
				$(".button.load", container).show();
				$.getJSON(
					"/bloglink/add",
					{ parent: parent, name: name, title: title, url: url },
					function(data) {
						if (data.node != container.data("currentParent")) return;
						if (data.result == "ERROR") {
							$('input', container).each(
								function(i) {
									$(this).attr("readonly", "");
								}
							);
							for (var error in data.errors) {
								$('p.'+error, container).addClass('error');
							}
							$(".button.add", container).show();
							$(".button.load", container).hide();
						}
						else {
							$('p.error', container).each(
								function(i) {
									$(this).removeClass('error');
								}
							);
							$(".button.load", container).hide();
							$('.inputs', container).slideUp(
								100,
								function() {
									$('.message', container).html(data.message).fadeIn(250);
								}
							);
						}
					}
				);
			}

