function $(strID)
{
    return document.getElementById(strID);
}

/* Stadtauswahl */
function toggleCitySelection()
{
    if ($('selectCityMenu').style.display == 'none' | $('selectCityMenu').style.display == '')
    {
        $('selectCityMenu').style.display = 'block';    
        $('selectLocationMenu').style.display = 'none';    
    }
    else
    {
        $('selectCityMenu').style.display = 'none';    
    }
}
function hideCitySelection()
{
    if ($('selectCityMenu').style.display == 'block')
    {
        $('selectCityMenu').style.display = 'none';    
    }
}

/* Locationauswahl */
function toggleLocationSelection()
{
    if ($('selectLocationMenu').style.display == 'none' | $('selectLocationMenu').style.display == '')
    {
        $('selectLocationMenu').style.display = 'block';    
        $('selectCityMenu').style.display = 'none';    
    }
    else
    {
        $('selectLocationMenu').style.display = 'none';    
    }
}
function hideLocationSelection()
{
	try
	{
	    if ($('selectLocationMenu').style.display == 'block')
	    {
	        $('selectLocationMenu').style.display = 'none';    
	    }
	}
	catch (e)
	{
	}
}

/* Contentdropdown */
function toggleContentSubmenu()
{
	try
	{
		if ($('contentSubmenuWrapper').style.display == 'block')
		{
			$('contentSubmenuWrapper').style.display = 'none';
		}
		else
		{
			$('contentSubmenuWrapper').style.display = 'block';
		}		
	}
	catch (e)
	{
	}
}
function hideContentSubmenu()
{
    try
    {
		$('contentSubmenuWrapper').style.display = 'none';
    }
    catch (e)
    {
    }
}


/* Alle Selections ausblenden */
function hideSelections()
{
	hideCitySelection();
	hideLocationSelection();
	hideContentSubmenu();
}

/* Newsletter */
function clearNewsletterInput()
{
    if ($('fNewsletterEmail').value == 'Deine E-Mail-Adresse')
    {
        $('fNewsletterEmail').value = '';    
    }
}

/* Top-Banner-Rotation */
function rotateBanner(arrAllBanners, intIndex)
{
    if (arrAllBanners.length > 0)
    {
        obj = $('bannerTop');
        a   = arrAllBanners;
        
        pos      = a[intIndex]["banner"].lastIndexOf('.');
        filetype = a[intIndex]["banner"].substr(pos+1).toLowerCase();

		if (filetype == 'swf')
		{
	        content  = '<a href="'+a[intIndex]["url"]+'" target="'+a[intIndex]["target"]+'">';
			content += '<object style="height: 90px; width: 100%;" data="admin/uploads/'+a[intIndex]["banner"]+'" type="application/x-shockwave-flash"><param name="movie" value="admin/uploads/'+a[intIndex]["banner"]+'"><param name="quality" value="high"><param name="scale" value="exactfit"><param name="menu" value="true"><param name="bgcolor" value="none"></object>';
			content += '</a>';
		}
		else
		{
	        content  = '<a href="'+a[intIndex]["url"]+'"';
	        content += ' title="'+a[intIndex]["beschreibung"]+'"';
	        content += ' target="'+a[intIndex]["target"]+'">';
	        content += '<img src="admin/uploads/'+a[intIndex]["banner"]+'"';
	        content += ' alt="'+a[intIndex]["banner"]+'" style="border: none; margin-bottom: 10px;" /></a>';
		}
        
        obj.innerHTML = content;

		oldIndex = intIndex;
		
        if (a.length > 1 & a[intIndex]["anzeigedauer"] > 0)
        {
            if (intIndex == a.length-1)
            {
                intIndex = 0;        
            }
            else
            {
                ++intIndex;
            }
            
            window.setTimeout(
                function ()
                {
                    rotateBanner(a, intIndex);
                },
                a[oldIndex]["anzeigedauer"]*1000
            );
        }
    }
}

/* Show more */
function showMoreEvents()
{
	var ADD_HEIGHT = 5*27;

	if ( parseInt($("eventsDiv").style.height) < parseInt($("eventsDiv").origHeight - ADD_HEIGHT - 30) )
	{
		var baseHeight = parseInt($("eventsDiv").style.height);
	
		$('eventsDiv').morph('height: ' + (baseHeight + ADD_HEIGHT) + 'px', 1.0);
	}
	else
	{
		$('eventsDiv').morph('height: ' + parseInt($("eventsDiv").origHeight) + 'px', 1.0);
		$("buttonMoreEvents").style.display = 'none';		
	}
}

function showMoreGalleries()
{
	var ADD_HEIGHT = 119*5+2;

	if ( parseInt($("galleryWrapper").style.height) < parseInt($("galleryWrapper").origHeight - ADD_HEIGHT - 70) )
	{
		var baseHeight = parseInt($("galleryWrapper").style.height);
	
		$('galleryWrapper').morph('height: ' + (baseHeight + ADD_HEIGHT) + 'px', 1.0);
	}
	else
	{
		$('galleryWrapper').morph('height: ' + parseInt($("galleryWrapper").origHeight) + 'px', 1.0);
		$("buttonMoreGalleries").style.display = 'none';		
	}
}

function dump(obj)
{
    var out = '';
    for (var i in obj)
    {
        out += i + ": " + obj[i] + "\n";
    }
    alert(out);
}
