Estate.Kinderstad = (function() {
	function jobsSwitchDisplay(el, className) {
		if (jQuery(el).next().size() > 0 && jQuery(el).next().is("h5") == false) {
			jQuery(el).next().toggleClass(className)
			if (jQuery(el).next().next().size() > 0 && jQuery(el).next().next().is("h5") == false) {
				jobsSwitchDisplay(jQuery(el).next(), className)
			}
		}
	}

	/* START PUBLIC */
	return {
		HomepageAnimation: function() {
			var initialWidth = jQuery("#VisualAnimation").width();
			jQuery("#VisualAnimation").width(0);
			jQuery("#VisualAnimation").show();
			jQuery("#VisualAnimation").animate({ width: initialWidth + "px" }, 5000, function() { jQuery("#GaVerder").fadeIn() });
			jQuery("#VisualAnimation").mouseover(function() {
				jQuery("#Mouseover").slideDown(500)
			})
			jQuery("#VisualAnimation").mouseout(function() {
				jQuery("#Mouseover").slideUp(500)
			})
		},

		HomepageSections: function() {
			var i = 1
			for (var i; i <= 4; i++) {
				jQuery("#SectionLinks1 li.item" + i + " a").data("counter", i);
				jQuery("#SectionLinks1 li.item" + i + " a").mouseover(function() {
					var element = jQuery("#SectionLinks2 li.item" + jQuery(this).data("counter") + " span")
					jQuery(element).stop(true, true)
					jQuery(element).slideDown(250)
				})
				jQuery("#SectionLinks1 li.item" + i + " a").mouseout(function() {
					var element = jQuery("#SectionLinks2 li.item" + jQuery(this).data("counter") + " span")
					jQuery(element).stop(true, true)
					jQuery(element).slideUp(250)
				})
			}
		},

		JobsAccordion: function() {
			jQuery("#JobsAccordion h5:gt(0)").each(function() {
				jobsSwitchDisplay(this, "displayNone")
			})
			jQuery("#JobsAccordion h5").each(function() {
				jQuery(this).click(function() {
					jobsSwitchDisplay(this, "displayNone")
					Estate.Kinderstad.AddStylingToMain()
				})
			})
		},

		SetApplyEvents: function() {
			jQuery("#ApplyJob").click(function() {
				Estate.Kinderstad.ShowDivPopup()
			})
		},

		ShowDivPopup: function() {
			jQuery("#divPopupWindow").slideDown(250);
			jQuery("#divPopupBackground").css("opacity", 0)
			jQuery("#divPopupBackground").show()
			jQuery("#divPopupBackground").animate({ opacity: 0.5 }, 250);
			jQuery("a.logo img").hide()
			jQuery("#CloseApplyForm").click(function() {
				Estate.Kinderstad.HideDivPopup()
			})
		},

		HideDivPopup: function() {
			jQuery("#divPopupWindow").slideUp(250);
			jQuery("#divPopupBackground").animate({ opacity: 0 }, 250, function() { jQuery("#divPopupBackground").hide() });
		},

		SetBackgroundIE6: function() {
			jQuery("#divPopupBackground").css("height", jQuery("body").height() + "px")
		},

		AddStylingToMain: function() {
			if (jQuery("#Main").size() > 0) {
				if (jQuery("#Main").height() > 537) {
					jQuery("#Main").addClass("mainBorder")
				} else {
					jQuery("#Main").removeClass("mainBorder")
				}
			}
		}
	}
	/* END PUBLIC */
})();

