function $(id)
{
	if(document.getElementById)
    return document.getElementById(id);
  else if(document.all)
    return document.all.id;
  else
    return false;
}
function $$(id)
{
	return document.getElementsByName(id);
}

// PopUp öffnen
function wopen1(url,ziel)
{
  window.open(url,ziel,'resizable=yes,status=yes,scrollbars=yes,menubar=yes,toolbar=yes,location=yes');
}
function wopen12(url,ziel,width,height)
{
  window.open(url,ziel,'width='+width+',height='+height+'resizable=no,status=yes,scrollbars=auto,menubar=no,toolbar=no,location=no');
}
function wopen2(url,ziel)
{
  window.open(url,ziel,'resizable=yes,status=no,scrollbars=auto,menubar=no,toolbar=no,location=no');
}
function wopen13(url,ziel,width,height)
{
  window.open(url,ziel,'width='+width+',height='+height+'resizable=no,status=yes,scrollbars=yes,menubar=no,toolbar=no,location=no');
}

// NL-Info anzeigen
function ShowInfo(id, img)
{
  info = $(id);
  info.style.display = 'block';
  if(img!=null)
  {
    $('premotiv').src  = motiv[img].src;
    info.style.height  = motiv[img].height+'px';
    info.style.width   = motiv[img].width+'px';
    info.style.padding = '0px';
  }
}

// NL-Info ausblenden
function HideInfo()
{
  info.style.display = 'none';
}

// NL-Info Position aktualisieren
function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function updateInfo(e)
{
  var posx = 20;
  var posy = 20;

  if (typeof e != "undefined")
  {
    posx += e.pageX;
    posy += e.pageY;
  }
  else if (typeof window.event !="undefined")
  {
    posx += truebody().scrollLeft+event.clientX;
    posy += truebody().scrollTop+event.clientY;
  }

  var docwidth =document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15;
  var docheight =document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight);

  //window.status='posx: ' + posx + ' posy: ' + posy;
  if(info!=null)
  {
    if (posx + parseInt(info.style.width) + 3 > docwidth)
      posx=posx-parseInt(info.style.width)-(20*2);

    if (posy-truebody().scrollTop+parseInt(info.style.height)>truebody().clientHeight)
      posy=posy-parseInt(info.style.height)-20;

    info.style.left = posx + 'px';
    info.style.top  = posy + 'px';
  }
}

// Anfahrtskizze einblenden
function ShowCard()
{
  if(!zoom_in)
    zoom_in = true;
  pcard = $('p_skizze');
  card = $('skizze');
  pcard.style.display = 'block';
  card.style.display = 'block';
  if(card_height<388)
  {
    card_height += 5;
    if(card!=null)
    {
      pcard.style.height = card_height + 'px';
      card.style.height = card_height + 'px';
    }
    timer = window.setTimeout("ShowCard()",0.1);
  }
}

// Anfahrtskizze ausblenden
function HideCard()
{
  if(zoom_in)
    zoom_in = false;
  pcard = $('p_skizze');
  card = $('skizze');
  if(card_height>0)
  {
    card_height -= 10;
    if(card!=null)
    {
      pcard.style.height = card_height + 'px';
      card.style.height = card_height + 'px';
    }
    timer = window.setTimeout("HideCard()",0.1);
  }
  else
  {
    pcard.style.display = 'none';
    card.style.display = 'none';
  }
}

// Anfahrtskizze
function Card()
{
  window.clearTimeout(timer);
  if(!zoom_in)
    timer = window.setTimeout("ShowCard()",0.1);
  else
    timer = window.setTimeout("HideCard()",0.1);
}
// Tooltipps erstellen
function Tooltipp()
{
	var thisObj = this;
	var dickeTooltip = document.getElementById('dickeTooltip');

    var body = null;
    if(window.document.compatMode && window.document.compatMode == "CSS1Compat")
      body = window.document.documentElement;
    else if(window.document.body)
      body = window.document.body;

	this.show = function(event)
	            {
	              if(!event) var event = window.event;
	              var x = (event.pageX) ? event.pageX : event.clientX + body.scrollLeft;
	              var y = (event.pageY) ? event.pageY : event.clientY + body.scrollTop;
	              dickeTooltip.innerHTML =  this.attributes['title'].nodeValue;
	              this.attributes['title'].nodeValue = '';
	              dickeTooltip.style.top = y+'px';
	              dickeTooltip.style.display = 'block';
	              var breite = dickeTooltip.offsetWidth;
	              dickeTooltip.style.left = (x - Math.round(breite/2))+'px';
	            }

	this.hide = function()
	            {
	              dickeTooltip.style.display = 'none';
	              this.attributes['title'].nodeValue = dickeTooltip.innerHTML;
	            }
}

window.onload = function()
                {
                  tooltipp = new Tooltipp();
                  allElements = document.getElementsByTagName("*");
                  for (i in allElements)
                  {
                    if (allElements[i].attributes && allElements[i].attributes['title'] && allElements[i].attributes['title'].nodeValue)
                    {
                      allElements[i].onmouseover = tooltipp.show;
                      allElements[i].onmouseout = tooltipp.hide;
                      //window.status = allElements[i].attributes['title'].nodeValue;
                    }
                  }
                }

// Globale Variablen initialisieren
var zoom_in = false;
var card_height = 0;
var info = null;
var timer = null;

document.onmousemove = updateInfo;