/*
 * Created on 02.01.2010
 * Copyright (c) Andreas Bauer <andreas.bauer@creaktif.de>
 */

var openedDialog = "";
var maxOpacity = 0;
var delay = 5;
var timer;

function ShowInfoDialog(element)
{
	if (openedDialog.length > 0)
		HideInfoDialog(openedDialog);
		
	document.getElementById(element).style.display = "block";
	openedDialog = element;
	
	maxOpacity = 0;
	
	// Fade-In mit Alpha Tween
	FadeIn(element);
}

function HideInfoDialog(element)
{
	if (openedDialog == element)
	{
		document.getElementById(element).style.display = "none";
		openedDialog = "";
	}
}

function FadeIn(element)
{
	if (CheckBrowserName("MSIE"))
	{
		/* Funktioniert nicht fuer Microsoft Internet Explorer wenn AlphaImageLoader
		 * benutzt wird.
		 */
	}
	else
	{
		maxOpacity = maxOpacity + 0.04;
		
		/* 100% entspricht 1.5 und mehr */
		if (maxOpacity <= 1.5)
		{
			document.getElementById(element).style.opacity = maxOpacity;
			timer = setTimeout(function() { FadeIn(element); }, delay);
		}
		else
		{
			clearTimeout(timer);
			maxOpacity = 0;
		}
	}
}

function CheckBrowserName(name)
{
	// Prueft anhand des uebergebenen Namen welcher Browser verwendet wird
	var agent = navigator.userAgent.toLowerCase();  
	
	if (agent.indexOf(name.toLowerCase())>-1)
		return true;  

	return false;
}
