/*globale Einstellung*/

// Menu einfaden
function fadeMenuIn(menuId, param){
  var menuBoxElement = $(menuId);
  if(menuBoxElement != null){
    var elDimensions = menuBoxElement.getDimensions();
    var elHeight = elDimensions.height+'px';
    var elWidth = elDimensions.width+'px';
    
    var myEffect = new Fx.Morph(menuBoxElement, {duration: 1500, transition: Fx.Transitions.Sine.easeOut});
    // set new dimensions
    myEffect.set({
      'width': '0px',
      'height': '0px',
      'display': 'block'
    });
    
    if(param != null && param == "fadeTopRight"){
      myEffect.set({
        'position': 'absolute',
        'top': '0px'
      });
    }
    
    myEffect.start({
      height: elHeight,
      width: elWidth
    });
  }
}

// Menu ausfaden
function fadeMenuOut(menuId, linkUrl){
  var menuBoxElement = $(menuId);
  if(menuBoxElement != null){
    var myEffect = new Fx.Morph(menuBoxElement, {
      duration: 1500, 
      transition: Fx.Transitions.Sine.easeOut, 
      onComplete: function(){window.location.href = linkUrl;}});
    myEffect.start({
      height: '0px',
      width: '0px'
    });
    return false;
  }
  return true;
}

// sobald sich der Mauszeiger bewegt,wird die aktuelle Position abgefragt
document.onmousemove = updateWMTT;
wmtt = null;
sizeTooltipWindow = null;

// Musik an- und ausschalten
soundIsOff = false;
function soundOnOff() {
	if (!soundIsOff) {
		document.Musik.stop();
		soundIsOff = true;
	} else {
		document.Musik.play();
		soundIsOff = false;
	}
}


function toggleFields(name) {
  if (document.getElementById) {
    if (document.getElementById(name).style.display.toUpperCase() == "NONE") {
      document.getElementById(name).style.display = "block";
    } else {
      document.getElementById(name).style.display = "none";
    }
  }
}

// Tooltips anzeigen:

function winOpen(url, breite, hoehe) {
	// Errechnet Koordinaten, um das Popup zentriert zu platzieren
	links = (screen.width/2)-(breite/2);
	oben = (screen.height/2)-(hoehe/2);
	window.open(url,"popup","height="+hoehe+",width="+breite+",status = no,toolbar = no,menubar = no,location = no,resizable = no,titlebar = no,scrollbars = no,fullscreen = no,top ="+oben+",left ="+links);
}



/* Initialisierung der Mausueberwachung */
function MouseInit()
{
	/* MSIE, Konqueror, Opera : */
  if (document.all) window.onmousemove=updateWMTT;
	/* Netscape, Mozilla : */
  else
  {
	/* Netscape6, Mozilla : */
    if (typeof(document.addEventListener)=="function")
      document.addEventListener("mousemove",updateWMTT,true);
	/* Netscape4 : */
    else
    {
      window.captureEvents(Event.MOUSEMOVE);
      window.onmousemove=updateWMTT;
    }
  }
}

// Funktion zum Abfragen der Position.
// Damit der Tooltip nicht außerhalb des Fensters angezeigt wird, wird eine Unterscheidung vorgenommen
function updateWMTT(event) {
/*
	tooltipHeight = null;

	// Position des Mauszeigers
	var mausx,mausy;

		// MSIE, Konqueror, Opera 
	  if (document.all)
	  {
	    mausx=event.clientX;
	    mausy=event.clientY;
	    if (document.body.scrollLeft)
	      mausx+=document.body.scrollLeft;
	    if (document.body.scrollTop)
	      mausy+=document.body.scrollTop;
	  } // Netscape, Mozilla :
	  else
	  {
	    mausx=event.pageX;
	    mausy=event.pageY;
  }


	// Fensterhöhe und -breite festlegen (is zwar blöd so, aber der IE mags ned anders...)
	winW = 640;
	winH = 300;

	if (wmtt != null && sizeTooltipWindow != null) {

		//aktuelle TT-Höhe
		tooltipHeight = 150;
		// der Tooltip wird am Mauszeiger positioniert
		wmtt.style.left = (mausx + 10) + "px";

		// Abfragen der Höhe des Fensters und Positionierung nach oben oder unten
		if((tooltipHeight + mausy) < winH) {
			wmtt.style.top 	= (mausy + 10) + "px";
		} else if ((tooltipHeight + mausy) > winH){
			wmtt.style.bottom = (winH - mausy -10) +"px";
		}
	}
	*/
}


// Funktion zum Anzeigen von Tooltip-Dialogen
function showWMTT(id, windowSize) {
	wmtt = document.getElementById(id);
	if(wmtt != null){
		wmtt.style.display = "block";
		sizeTooltipWindow = windowSize;
	}
}
// Funktion zum Verstecken von Tooltip-Dialogfeldern
function hideWMTT() {
	if(wmtt != null){
		wmtt.style.display = "none";
		wmtt = null;
	}
}

// Macromedia Funktionen
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
