function initPopupMenu() {

	window.addEvent('domready', function(){

		popupSettings = {
				  tl: { radius: 3 },
				  tr: { radius: 3 },
				  bl: { radius: 3 },
				  br: { radius: 3 },
				  antiAlias: true,
				  autoPad: false,
				  validTags: ["div"]
			  };
		
		var popupCurvyObject = new curvyCorners(popupSettings, "popupMenu");
		popupCurvyObject.applyCornersToAll();
		
		$each($$(".popupMainItem"), function(popupItem, index){

			var popupMenu = popupItem.getElement('div');
			// ausblenden des Elements
			if(popupMenu) 
			{
				popupItem.popupMenu = popupMenu;			
				popupMenu.fade('hide');
				popupMenu.setStyle('z-index', 2000);
				popupMenu.shadow = popupMenu.dropShadow();
			
				popupItem.addEvent("mouseover", function()
				{
					if(this.popupMenu)
					{
						$clear(this.popupMenu.timeout);
						this.popupMenu.fade('in');
						if(this.popupMenu.shadow)
							this.popupMenu.shadow.fade(this.popupMenu.shadow.getStyle('opacity'), 0.3);
					};
				});
	
				popupItem.addEvent("mouseout", function()
				{
					if(this.popupMenu)
					{
						var fadeOutFunction = function(){
							this.fade('out');
							if(this.shadow)
								this.shadow.fade('out');
						};
						this.popupMenu.timeout = fadeOutFunction.delay(1000, this.popupMenu);
					};
				});
			};
		});
	});
	
}

Element.implement({
	dropShadow: function(options) {

	    // define defaults
        var options = $merge({
            id: "dropShadow" + $random(100,1000),
            x: 0, // offset from parent
            y: -2,
            border: "1px none #000",
            background: "#555",
            opacity: 0.3,
            zIndex: this.getStyle("z-index").toInt() - 1 // behind parent
        }, options);

        // only apply shadow on absolutely positioned elements
        if (this.getStyle("position") != "absolute")
            return this;

        var c = this.getCoordinates();

        var theElement = new Element("div", {
            id: options.id,
            styles: {
                position: "absolute",
                left: 0 + options.x,
                top: 25 + options.y,
                width: c.width + 3,
                height: c.height + 7,
                background: options.background,
                zIndex: options.zIndex,
				opacity: 0.3
            },
			opacity: 0
        }).injectBefore(this);

        // store the shadow id into the element
        this.set("data-related", options.id);

        return theElement;
    } // end dropShadow
});

var activeBox = null;

function initStartbox() {

	window.addEvent('domready', function(){

		$each($$(".startseiteBox"), function(startseiteBox, index){

			var imageBox = startseiteBox.getElement('div.image');
			var menuBox = startseiteBox.getElement('div.menu');
			menuBox.setStyle('height', '0px');
			menuBox.setStyle('display', 'none');
	
			imageBox.addEvent("mouseover", function()
			{
				if(activeBox == this)
					return;
					
				if(activeBox)
				{
					var menuBox = activeBox;
					menuBox.setStyle('height', '0px');
					menuBox.setStyle('display', 'none');
					
					var oldImagebox = menuBox.getParent();
					var image = oldImagebox.getElement('img');
					image.src = image.src.substr(0, image.src.length - 11) + ".jpg";
					
					var textBox = oldImagebox.getParent().getElement('div.text');
					textBox.setStyle('display', 'block');
				};
				
				
				var image = this.getElement('img');
				var menuBox = this.parentNode.getElement('div.menu');
				
				var menuContent = menuBox.getElement('div.menuContent');
				if(menuContent.innerHTML != '')
				{
				 image.src = image.src.substr(0, image.src.length - 4) + "_active.jpg";
				 menuBox.setStyle('height', 'auto');
				 menuBox.setStyle('display', 'block');
				
				 var textBox = this.parentNode.getElement('div.text');
				 textBox.setStyle('display', 'none');
				
				 activeBox = menuBox;
				}else
				 activeBox = 0;
			});
		});
	});
}

function initDistrictOverview() {
	
	window.addEvent('domready', function(){

		$each($$("area.tooltipp"), function(tooltipp, index){
			new Tips(tooltipp);
		});
	});
}
