// Config:
var ballonBack = "#8a0c14";  // Hintergrundfarbe
var ballonText = "#ffffff";  // Text und Randfarbe
var ballonBreite = "";        // Ballon-Breite (Vorgabewert)
var ballonBorder = 0;      // Randstärke
var ballonFont = "Arial";
var ballonClass = "ttip" ;
var ballonDir = 0;         // Ausrichtung; 0=rechts 1=links
var ballonVDir = 0;        // Ausrichtung; 0=unten 1=oberhalb
var ballonChangeVDir = 40;    // Schwellwert für Wechsel der 
			      // V-Ausrichtung am unteren Rand
var ballonSpace = 10;        // Abstand vom Cursor
var ballonShow = false; // Anzeige aktiv/inaktiv

var Ballon = null;        // das DIV-Objekt
var IFrame = null;
var b_Breite;             // aktueller Speicher für Ballonbreite
var b_Dir, b_VDir;
var b_Hoehe;

// Ballon-Objekt (div) festlegen
function setBallon(id, breite, bgcolor) {
		
	document.onmousemove = cursorMove;
	
	if (breite && breite>20) b_Breite = breite;
	if (bgcolor) ballonBack = bgcolor;
	Ballon = crossGetObject(id);
  IFrame = crossGetObject("BallonFrame");
	if (Ballon == null) {
		alert("keine Unterstützung für Ballon-Infos");
		showBallon = noBallon; hideBallon = noBallon;
	}
	ballonShow = false;
}
function noBallon() {} // functionsaufrufe abfangen
document.write('<meta name="scripts">');

// Ballon kreieren und anzeigen
function showBallon(msg,breite, dir,  bgcolor) {
	var b_Back;
	var relWidth, relHeight;

	if (Ballon == null) return;
	if (breite && breite>20) b_Breite = breite;
	else b_Breite=ballonBreite;
	if (bgcolor) b_Back=bgcolor;
	else b_Back=ballonBack;
  
  msg = '<div style="background-color: ' + b_Back + '; padding: 3px; font-family: ' + ballonFont + '; color: ' + ballonText + ';">' + msg + '</div>';
  //     msg = '<div style="background-color: ' + b_Back + '; padding: 3px; margin-left: 25px; font-family: ' + ballonFont + '; color: ' + ballonText + ';width:'  +breite +'px;">' + msg + '</div>';
  /*
	msg = '<table  style="margin-left:25px;" border="0" cellpadding="' + ballonBorder + '" cellspacing="0"><tr><td width="250"><table border="0" cellpadding="3" cellspacing="0" bgcolor="' + b_Back + '" style="padding: 3px;"><tr><td style="text-align: left;"><font face="'  + ballonFont + '" color="' + ballonText + '" class="' + ballonClass + '">' + msg + '</font></td></tr></table></td></tr></table>';//msg = '<table  style="margin-left:25px;" border="0" cellpadding="' + ballonBorder + '" cellspacing="0" bgcolor="' + ballonText + '"><tr><td><table border="0" cellpadding="3" cellspacing="0" width="100%" bgcolor="' + b_Back + '" style="padding: 3px;"><tr><td style="text-align: left;"><font face="'  + ballonFont + '" color="' + ballonText + '" class="' + ballonClass + '">' + msg + '</font></td></tr></table></td></tr></table>';
 */
  
  if (!dir) b_Dir = ballonDir;
	else b_Dir = dir;
	relWidth = crossInnerWindowWidth() + crossGetScroll("x");
	relHeight = crossInnerWindowHeight() + crossGetScroll("y");
	if (crossMouseX + b_Breite + ballonSpace > relWidth) 
		{b_Dir = 1;}
	else if (crossMouseX < b_Breite + ballonSpace) b_Dir = 0;
	b_VDir = ballonVDir;
	if (crossMouseY + ballonChangeVDir > relHeight) b_VDir = 0;
	else if (crossMouseY - ballonChangeVDir < 0) b_VDir = 0;
	crossWrite(Ballon, msg);
	ballonShow = true;
	crossShowObject(Ballon);
  
  b_Hoehe = Ballon.offsetHeight;
  
}

function hideBallon() {
	if (Ballon == null) return;
  crossHideObject(Ballon);
	ballonShow=false;
	crossMoveTo(Ballon, -200, 0);
  
  if (B_Type.IE)
    crossMoveTo(IFrame, -200, 0);
  
}

// der Maus folgen
function cursorMove(e) {
	var posX, posY;
	
	crossMousePosition(e);

	if (ballonShow) {
		
		if (b_Dir==0) {
			posX = crossMouseX + ballonSpace; 
			if (b_VDir==0) {posY = crossMouseY + ballonSpace;}
			else {posY = crossMouseY - ballonChangeVDir;}
		}
		else {
			posX = crossMouseX-b_Breite-ballonSpace;
			if (b_VDir==0) {posY = crossMouseY + ballonSpace;}
			else {posY = crossMouseY - ballonChangeVDir;}
		}
    
    if (B_Type.IE)
      posY += document.documentElement.scrollTop;
    
    // Tooltip oben platzieren
    posY -= b_Hoehe;
    
    posX += 25;
    
    //console.log(posY);
    
		crossMoveTo(Ballon, posX, posY);
    
    if (B_Type.IE) {
      
      IFrame.style.height = b_Hoehe;
      crossMoveTo(IFrame, posX, posY);
      
    }
    
	}
}

window.onload = function() {
  
  setBallon("BallonTip");
  
  loadElement = document.getElementById("wait_msg");
  
  if (loadElement)
    loadElement.style.display = "none";
  
}