/* *************************************************************
	CROSSBROWSER-FUNKTIONEN ---START
************************************************************* */

// Browsertyp ermitteln (und in B_Type speichern)
var B_Type = new crossBrowserType();
function crossBrowserType() {
	this.IE = false;
	this.NS4 = false;
	this.NS6 = false;
	this.id = "";

	if (document.all) {this.IE = true; this.id = "IE";}
	else if (document.getElementById) {this.NS6 = true; this.id = "NS6";}
	else if (document.layers) {this.NS4 = true; this.id = "NS4";}
}

// Mausposition zur?ckgeben
var crossMouseX, crossMouseY;
if (B_Type.NS4) document.captureEvents(Event.MOUSEMOVE);

function crossMousePosition(e) {
	if (B_Type.IE) {
		crossMouseX=event.x + document.body.scrollLeft;
		crossMouseY=event.y + document.body.scrollTop;
	}
	else {crossMouseX=e.pageX; crossMouseY=e.pageY;}
}


// browserspezifisches DHTML-Objekt anhand von ID zur?ckgeben
function crossGetObject(id) {
	var obj = null;
	if (B_Type.IE) obj=document.all[id];
	else if (B_Type.NS6) obj=document.getElementById(id);
	else if (B_Type.NS4) obj=document.layers[id];
	return obj;
}

// Text in DHTML-Objekt ausgeben
function crossWrite(obj, text) {

	if (B_Type.IE) obj.innerHTML = text;
	else if (B_Type.NS6) obj.innerHTML = text;
	else if (B_Type.NS4) {
		obj.document.open();
		obj.document.write(text);
		obj.document.close();
	}
}

// verf?gbare Fensterbreite ermitteln
function crossInnerWindowWidth() {
	var val;
	if (B_Type.IE) val=document.body.clientWidth;
	else if (B_Type.NS6) val=window.innerWidth;
	else if (B_Type.NS4) val=window.innerWidth;
	return val;
}

// tats?chliche Fensterbreite ermitteln
function crossOuterWindowWidth() {
	var val;
	if (B_Type.IE) val=document.body.offsetWidth;
	else if (B_Type.NS6) val=window.outerWidth;
	else if (B_Type.NS4) val=window.outerWidth;
	return val;
}

// verf?gbare Fensterh?he ermitteln
function crossInnerWindowHeight() {
	var val;
	if (B_Type.IE) val=document.body.clientHeight;
	else if (B_Type.NS6) val=window.innerHeight;
	else if (B_Type.NS4) val=window.innerHeight;
	return val;
}

// Scroll-Position ermitteln, "y" = vertikal, "x" = horizontal
function crossGetScroll(achse) {
	var val;
	if (!achse || achse == "y") {  // vertikale Achse
		if (B_Type.IE) val=document.body.scrollTop;
		else if (B_Type.NS6) val=window.pageYOffset;
		else if (B_Type.NS4) val=window.pageYOffset;
	}
	else {  // horizontale Achse
		if (B_Type.IE) val=document.body.scrollLeft;
		else if (B_Type.NS6) val=window.pageXOffset;
		else if (B_Type.NS4) val=window.pageXOffset;
	}
	return val;
}

// Scroll-Position setzen
function crossSetScroll(x, y) {
	window.scrollTo(x, y);
}

// Objekt positionieren x/y
function crossMoveTo(obj, x, y) {
	if (B_Type.IE) {obj.style.pixelLeft=x; obj.style.pixelTop=y;}
	else if (B_Type.NS4) {obj.left=x; obj.top=y;}
	else if (B_Type.NS6) {obj.style.left=x+"px"; obj.style.top=y+"px";}
}

// Objekt-Position ermitteln
function crossGetPositionX(obj) {
	if (B_Type.IE) return obj.style.pixelLeft;
	else if (B_Type.NS4) return obj.left;
	else if (B_Type.NS6) return parseInt(obj.style.left);
}
function crossGetPositionY(obj) {
	if (B_Type.IE) return obj.style.pixelTop;
	else if (B_Type.NS4) return obj.top;
	else if (B_Type.NS6) return parseInt(obj.style.top);
}

// Objekt anzeigen
function crossShowObject(obj) {
	if (B_Type.IE || B_Type.NS6) {obj.style.visibility="visible";}
	else if (B_Type.NS4) {obj.visibility="show";}
}
// Objekt ausblenden
function crossHideObject(obj) {
	if (B_Type.IE || B_Type.NS6) {obj.style.visibility="hidden";}
	else if (B_Type.NS4) {obj.visibility="hide";}
}


// Hintergrund-Farbe setzen
function crossBackgroundColor(color, obj) {
	if (typeof obj == "undefined") {document.bgColor=color; return;}
	if (B_Type.IE || B_Type.NS6) {obj.style.backgroundColor=color;}
	else if (B_Type.NS4) {obj.document.bgColor=color;}
}


// Hintergrund-Bild setzen
function crossBackgroundImage(obj, img) {
	if (B_Type.IE || B_Type.NS6) {obj.style.backgroundImage="url(" + img + ")";}
	else if (B_Type.NS4) {obj.background.src = img;}
}

/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

/* *************************************************************
	CROSSBROWSER-FUNKTIONEN ---END
************************************************************* */

function validateTextarea(form) {
    try {
      if (document.forms[form].description.value.length > 160)  {
        var content = document.forms[form].description.value.substring(0, 160);
        document.forms[form].description.value = content;
        alert("Das Sms darf maximal 160 Zeichen lang sein!");
      }
    } catch(e) {
    } 
  }


function AllMessages() {
  for(var x = 0; x < document.forms[1].elements.length; x++) { 
    var y = document.forms[1].elements[x];
    if(y.name != 'select_all') 
      if(y.name != 'absnumber') y.checked = document.forms[1].select_all.checked;
    }
  }
  
function AllCheckBoxes(id) {
  for(var x = 0; x < document.forms[id].elements.length; x++) { 
    var y = document.forms[id].elements[x];
    if(y.name != 'select_all') 
      if(y.name != 'absnumber') {
        if (y.name != 'checkbox')
          y.checked = document.forms[id].select_all.checked;
      }
    }
  }  

function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function send(form) {
  document.forms[form].submit();
  }
  
function sendForm(form) {
  document.forms[form].submit();
  }
  
function sendFormText(form) {
  document.forms[form].text.value = 'true';
  document.forms[form].submit();
  }
  
function sendForm(form, attrib) {
  document.forms[form].action.value = attrib;
  document.forms[form].submit();
  }
  
function sendFormWithAlert(form, attrib, text) {
  var name = prompt(text, "");
  if (name != null) {
    document.forms[form].collectionname.value = name;
    document.forms[form].action.value = attrib;
    document.forms[form].submit();
    }
  }  
  
function sendUser(form, attrib) {
  document.forms[form].action.value = attrib;
  document.forms[form].newuser.value = 'true';
  document.forms[form].submit();
  }
  
function sendImport(form, attrib) {
  document.forms[form].action.value = attrib;
  document.forms[form].loaddata.value = 'true';
  document.forms[form].submit();
  }  

function sendUserSubscription(form) {
  document.forms[form].newusersubscription.value = 'true';
  document.forms[form].submit();
  }
  
function newSubscription(form) {
  document.forms[form].action.value = '';
  document.forms[form].newsubscription.value = 'true';
  document.forms[form].submit();
  } 
  
function newSubscriptionfilter(form) {
  document.forms[form].action.value = '';
  document.forms[form].newsubscriptionfilter.value = 'true';
  document.forms[form].submit();
  }     
  
function importSubscription(form) {
  document.forms[form].action.value = '';
  document.forms[form].loaddata.value = 'true';
  document.forms[form].submit();
  }    
  
function tabbedpane(form, tabswitch, editmode, action) {
  document.forms[form].tabswitch.value = tabswitch;
  document.forms[form].editmode.value = editmode;
  document.forms[form].action.value = action;
  document.forms[form].submit();
}

function tabbedpanepreview(form, tabswitch, editmode, action, titlevalue, unsubscribevalue, editdatavalue) {
  document.forms[form].titlevalue.value = titlevalue;
  document.forms[form].unsubscribevalue.value = unsubscribevalue;
  document.forms[form].editdatavalue.value = editdatavalue;

  document.forms[form].tabswitch.value = tabswitch;
  document.forms[form].editmode.value = editmode;
  document.forms[form].action.value = action;
  document.forms[form].submit();
}
       	  
function disableRightClick(e)
  {
  var message = "Der Rechtsklick ist beim Beergame nicht erlaubt!";

  if(!document.rightClickDisabled) // initialize
    {
     if(document.layers)
      {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
      }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
    }
  if(document.layers || (document.getElementById && !document.all))
    {
    if (e.which==2||e.which==3)
      {
      alert(message);
      return false;
      }
    }
  else
    {
    alert(message);
    return false;
    }
  }
  
function sendNewMail(form) {

  document.forms[form].submit();
}

function sendNewMail(form, attrib) {

  document.forms[form].action.value = attrib;
  document.forms[form].submit();
  
}

     
function getDescription() {     				      
  if (browser.isIE5up) {
  } else if (browser.isGecko) {
	var isMidasEnabled = false;
	document.getElementById('descriptionFrame').contentDocument.designMode = "on";
	try {
	  document.getElementById('descriptionFrame').contentWindow.document.execCommand("undo", false, null);
	  isMidasEnabled = true;
	} catch (e) {
	  isMidasEnabled = false;
	}
	if (isMidasEnabled) {
	} else {
	  return;
	}
  } else {
	return;
  }     				      
  var html;
  try {
	html = document.getElementById('descriptioniframe').contentWindow.document.body.innerHTML;
  } catch (e) {
	html = document.getElementById('descriptioniframe').value;
  }
  document.forms[0].description.value = html; 
}  
  
function getHeader() {     				      
  if (browser.isIE5up) {
  } else if (browser.isGecko) {
	var isMidasEnabled = false;
	document.getElementById('headerFrame').contentDocument.designMode = "on";
	try {
	  document.getElementById('headerFrame').contentWindow.document.execCommand("undo", false, null);
	  isMidasEnabled = true;
	} catch (e) {
	  isMidasEnabled = false;
	}
	if (isMidasEnabled) {
	} else {
	  return;
	}
  } else {
	return;
  }       
       				      
  var html;
  try {
	html = document.getElementById('headeriframe').contentWindow.document.body.innerHTML;
  } catch (e) {
	html = document.getElementById('headeriframe').value;
  }
  document.forms[0].header.value = html; 
}  
  
function getFooter() {     				      
  if (browser.isIE5up) {
  } else if (browser.isGecko) {
	var isMidasEnabled = false;
	document.getElementById('footerFrame').contentDocument.designMode = "on";
	try {
	  document.getElementById('footerFrame').contentWindow.document.execCommand("undo", false, null);
	  isMidasEnabled = true;
	} catch (e) {
	  isMidasEnabled = false;
	}
	if (isMidasEnabled) {
	} else {
	  return;
	}
  } else {
	return;
  }       				   		      
  var html;
  try {
	html = document.getElementById('footeriframe').contentWindow.document.body.innerHTML;
  } catch (e) {
	html = document.getElementById('footeriframe').value;
  }
  document.forms[0].footer.value = html; 
}

/* ******************************************************************
	   TOOLTIPS ---START
****************************************************************** */


// integriert: Crossbrowser-Funktionen von "cross.js"

// Config:
var ballonBack = "#00ff77";  // Hintergrundfarbe
var ballonText = "#000000";  // Text und Randfarbe
var ballonBreite = 200;        // Ballon-Breite (Vorgabewert)
var ballonBorder = 1;      // Randst?rke
var ballonFont = "Arial";
var ballonDir = 0;         // Ausrichtung; 0=rechts 1=links
var ballonVDir = 0;        // Ausrichtung; 0=unten 1=oberhalb
var ballonChangeVDir = 65;    // 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 b_Breite;             // aktueller Speicher f?r Ballonbreite
var b_Dir, b_VDir;
var ballonContext = "/";

// Ballon-Objekt (div) festlegen
function setBallon(id, breite, bgcolor, bcontext) {

	document.onmousemove = cursorMove;

	if (breite && breite>20) b_Breite = breite;
	if (bgcolor) ballonBack = bgcolor;
	Ballon = crossGetObject(id);
	if (Ballon == null) {
		alert("keine Unterst?tzung f?r Ballon-Infos");
		showBallon = noBallon; hideBallon = noBallon;
	}
	ballonShow = false;
    ballonContext = bcontext;
}
function noBallon() {} // functionsaufrufe abfangen
document.write('<meta name="scripts" content="TOOLTIPS">');

// Ballon kreieren und anzeigen
function showBallon(msg, dir, breite, 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 = '<table width=' + b_Breite + ' border=0 cellpadding=' + ballonBorder + ' cellspacing=0 bgcolor=\"' + ballonText + '\"><tr><td><table width=100% border=0 cellpadding=3 cellspacing=0 bgcolor=\"' + b_Back + '\"><tr><td class="text" valign="top"><img src="' + ballonContext + '/pix/crystal/help.gif" height="16" width="16" alt="Help"></td><td class="text">' + msg + '</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 = 1;
	else if (crossMouseY - ballonChangeVDir < 0) b_VDir = 0;
	crossWrite(Ballon, msg);
	ballonShow = true;
	crossShowObject(Ballon);
}
// Ballon kreieren und anzeigen
function showImage(msg, dir, breite, 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 = '<table width=' + b_Breite + ' border=0 cellpadding=' + ballonBorder + ' cellspacing=0 bgcolor=\"' + ballonText + '\"><tr><td><table width=100% border=0 cellpadding=3 cellspacing=0 bgcolor=\"' + b_Back + '\"><tr><td class="text"><img src="/media/media/files/' + msg + '" border="0"></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 = 1;
	else if (crossMouseY - ballonChangeVDir < 0) b_VDir = 0;
	crossWrite(Ballon, msg);
	ballonShow = true;
	crossShowObject(Ballon);
}

function hideBallon() {
	if (Ballon == null) return;
	crossHideObject(Ballon);
	ballonShow=false;
	crossMoveTo(Ballon, -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;}
		}
		crossMoveTo(Ballon, posX, posY)
	}
}

/* ******************************************************************
	   TOOLTIPS ---END
****************************************************************** */

//###############################################################################
//bestFunctions ----------------------------------------------------------------#
//###############################################################################
//var out=window.open("",'_blank');out=out.document;out.writeln("<br>");

var Iframe; //iframe hinter div-layer, der das dropdownmenue im ie ueberdeckt
var countRows=6;		//speichert aktuelle Anzahl der Zeilen, die angezeigt werden koennen
var countRows_old=6;	//speichert die alte Anzahl der Zeilen
var minRows=3;				//mindestanzahl an Zeilen, die angezeigt werden sollen
var BestRowDisplay; //zeigt an, wie viele Zeilen sich bei einer bestimmten Fenstergroesse angezeigt werden koennen (sollte zb. td-Element sein)
var BestDisplay;	//Referenz zum Div-Objekt, in dem die Tabelle tatsaechlich angezeigt wird
var bestrowheight=18;	//Hoehe einer Zeile in Pixel (fuer die Berechnung der Anzahl)

// verfuegbare Fensterbreite ermitteln (inkl. beim IE6)
function bestInnerWindowHeight(){
	var val;
	//Explorer 6 Strict Mode
	/*if (document.documentElement && document.documentElement.clientWidth){
		 val=document.documentElement.clientHeight;
		 out.writeln("djf?laskdjf?laksdjf?laskdjf<br>");
	}
	 // other Explorers
	else */if (B_Type.IE){
		val=document.body.clientHeight;
	}
	//others
	else if (B_Type.NS6){
		val=window.innerHeight;
	}
	else if (B_Type.NS4){
		val=window.innerHeight;
	}
	return getPixel(val);
}

// verfuegbare Fensterbreite ermitteln (inkl. beim IE6)
function bestInnerWindowWidth() {
	var val;
	//Explorer 6 Strict Mode
	/*if (document.documentElement && document.documentElement.clientHeight) val=document.documentElement.clientWidth;
	// other Explorers
	else */if (B_Type.IE) val=document.body.clientWidth;
	//others
	else if (B_Type.NS6) val=window.innerWidth;
	else if (B_Type.NS4) val=window.innerWidth;
	return getPixel(val);
}

function bestGetOuterWidth(obj){
	var theWidth=obj.style.width+bestGetBoundaryWidth(obj);
	
	if(obj instanceof HTMLDivElement)
		if(B_Type.IE)
			theWidth=obj.style.width;

	return theWidth;
}

function bestGetOuterHeight(obj){
	var theHeight=obj.style.height;
	theHeight+=bestGetBoundaryHeight(obj);
	return theHeight;
}

function bestGetInnerWidth(obj){
	var theWidth=obj.style.width;
	
	if(obj instanceof HTMLDivElement)
		if(B_Type.IE)
			theWidth-= bestGetBoundaryWidth(obj);

	return theWidth;
}

function bestGetInnerHeight(obj){
	var theHeight=obj.style.height;
	return theHeight;
}

function bestSetInnerWidth(obj,theWidth){
	if(B_Type.IE)
		theWidth+bestGetBoundaryWidth(obj);

	obj.style.width=theWidth+"px";
}

function bestSetOuterWidth(obj,theWidth){
	if(B_Type.IE){}
	else
		theWidth-=bestGetBoundaryWidth(obj);

	obj.style.width=theWidth+"px";
}

function bestSetOuterHeight(obj,theHeight){
	obj.style.height=(theHeight-bestGetBoundaryHeight(obj))+"px";
}

function bestSetInnerHeight(obj,theHeight){
	obj.style.height=theHeight+"px";
}

//liefert die Breiten des uebergebenen Objekts nicht width Angaben (also padding + border + margin)
function bestGetBoundaryWidth(obj){
	var theWidth=0;
	if(obj.style.paddingLeft!="")
		theWidth+= getPixel(obj.style.paddingLeft) + getPixel(obj.style.paddingRight);
	if(obj.style.borderLeft!="")
		theWidth+= getPixel(obj.style.borderLeftWidth) +  getPixel(obj.style.borderRightWidth);
	if(obj.style.marginLeft!="")
		theWidth+= getPixel(obj.style.marginLeft) +  getPixel(obj.style.marginRight);
	return theWidth;
}

//liefert die Breiten des uebergebenen Objekts nicht height Angaben (also padding + border + margin)
function bestGetBoundaryHeight(obj){
	var theHeight=0;
	if(obj.style.paddingTop!="")
		theHeight+= getPixel(obj.style.paddingTop) + getPixel(obj.style.paddingBottom);
	if(obj.style.borderTop!="")
		theHeight+= getPixel(obj.style.borderTopWidth) +  getPixel(obj.style.borderBottomWidth);
	if(obj.style.marginTop!="")
		theHeight+= getPixel(obj.style.marginTop) +  getPixel(obj.style.marginBottom);
	return theHeight;
}

function getPixel(txt){
		//out.writeln("getPixel(txt["+txt+"],pixel[");
	var pixel=0;
	if(isNaN(txt)){

		if(typeof(txt)=="undefined" || txt=="" || txt==null)
			pixel=0;
		else if(txt.indexOf("px") > (-1))
			pixel=eval(txt.substring(0,txt.indexOf("px")));//eval wegen String -> int
	}else
		pixel=txt;
		
		//out.writeln(pixel+"])-END<br>");
	return pixel;
}

//Ballon, der File-Details enthaelt kreieren und anzeigen
function bestShowFilePreview(theMsg, dir, breite, bgcolor,name,uploadname,created,filesize,description,resolution) {
	var b_Back;
	if (Ballon == null) return;
	if (breite && breite>50) b_Breite = breite;
	else b_Breite=ballonBreite;
	if (bgcolor) b_Back=bgcolor;
	else b_Back=ballonBack;
	
	//erstelle vorschauinhalt...
	msg = '<table style="border:thin solid black;"><tr><td><table width=' + b_Breite + ' border=0 cellpadding=' + ballonBorder + ' cellspacing=0 bgcolor="' + b_Back + '"><tr>';
	if(theMsg!=null && theMsg!='null' && theMsg!='')
		msg+= '<td><table width=100% border=0 cellpadding=3 cellspacing=0 bgcolor="' + b_Back + '"><tr><td class="text"><img src="' + theMsg + '" border="0"></td></tr></table></td>';
	msg+= '<td><table><tr><td nowrap="true" class="titletext" nowrap="true"><b>'+name+'</b></td></tr><tr><td><hr noshade="true" size="1px"></td></tr><tr><td nowrap="true" class="text">'+uploadname+'</td></tr><tr><td nowrap="true" class="text">'+created+'</td></tr></tr><tr><td nowrap="true" class="text">'+filesize+'</td></tr>';
	if(resolution!=null && resolution!='null' && resolution!='')
		msg+= '<tr><td class="text" nowrap="true">'+resolution+' px</td></tr>';
	if(description!=null && description!='null' && description!='')
		msg+= '<tr><td class="text" nowrap="true">'+description+'</td></tr>';
	msg+= '</table></td></tr></table></td></tr></table>';
	
	if (!dir) b_Dir = ballonDir;
	else b_Dir = dir;

	//verhindert, dass der div-layer unter den unteren rand hinaus geschoben und dadurch das  fenster vergroessert wird (gilt fuer beide variablen)
	ballonChangeVDir=20;
	var ballonChangeDir=20;

	//horizontal--------------------------------------
	b_Dir=0;//standardmaeszig rechts
	if (crossMouseX + Ballon.offsetWidth + ballonSpace + ballonChangeDir> bestInnerWindowWidth()) 
		{b_Dir = 1;}
	else if (crossMouseX < Ballon.offsetWidth + ballonSpace + ballonChangeDir) b_Dir = 0;
	//vertikal----------------------------------------
	b_VDir=0;//standardmaeszig unten
	
	if (crossMouseY < ballonChangeVDir + Ballon.offsetHeight + ballonSpace) b_VDir = 0;
	else if (crossMouseY + Ballon.offsetHeight + ballonChangeVDir > bestInnerWindowHeight()) b_VDir = 1;

	crossWrite(Ballon, msg);
	if (B_Type.IE) {
		Iframe.width=Ballon.offsetWidth;
		Iframe.height=Ballon.offsetHeight;
	}
	ballonShow = true;
	bestShowBallonTip();
}

// der Maus folgen
function bestCursorMove(e) {
	var posX, posY;

	crossMousePosition(e);

	if (ballonShow) {
		
		if (b_Dir==0) {//rechts
			posX = crossMouseX + ballonSpace;
			if (b_VDir==0)//unten
				{posY = crossMouseY + ballonSpace;}
			else//oben
			 {posY = crossMouseY - Ballon.offsetHeight - ballonSpace;}
		}
		else {//links
			posX = crossMouseX - Ballon.offsetWidth - ballonSpace;
			if (b_VDir==0)//unten
				{posY = crossMouseY + ballonSpace;}
			else //oben
				{posY = crossMouseY - Ballon.offsetHeight - ballonSpace;}
		}
		bestMoveTo(posX, posY);
	}
}

// Objekt positionieren x/y
function bestMoveTo( x, y) {
	if(x+Ballon.offsetWidth > bestInnerWindowWidth())
		x=bestInnerWindowWidth()-Ballon.offsetWidth-3;
	if(y+Ballon.offsetHeight > bestInnerWindowHeight())
		y=bestInnerWindowHeight()-Ballon.offsetHeight-3;
	if (B_Type.IE) {
		Ballon.style.pixelLeft=x;
		Ballon.style.pixelTop=y;
		Iframe.style.pixelLeft=x; //schiftet den iframe fuer den ie mit
		Iframe.style.pixelTop=y;
	}
	else if (B_Type.NS4) {Ballon.left=x; Ballon.top=y;}
	else if (B_Type.NS6) {Ballon.style.left=x+"px"; Ballon.style.top=y+"px";}
}

// Ballon-Objekt (div) festlegen
function bestSetBallon(id,iframe_id, breite, bgcolor, bcontext) {

	document.onmousemove = bestCursorMove;

	if (breite && breite>50) b_Breite = breite;
	if (bgcolor) ballonBack = bgcolor;
	Ballon = crossGetObject(id);
	if(B_Type.IE){
		Iframe = crossGetObject(iframe_id);
		if(Iframe == null){
			Ballon = null;
			alert("keine Unterstuetzung fuer Ballon-Infos im Internet Explorer.");
			showBallon = noBallon; hideBallon = noBallon;
		}
	}
	if (Ballon == null) {
		alert("keine Unterstuetzung fuer Ballon-Infos");
		showBallon = noBallon; hideBallon = noBallon;
	}
	ballonShow = false;
    ballonContext = bcontext;
}

// BallonTip anzeigen
function bestShowBallonTip() {
	if (B_Type.IE) {
		Ballon.style.visibility="visible";
		Iframe.style.visibility="visible";
		}
	else if (B_Type.NS6) {Ballon.style.visibility="visible";}
	else if (B_Type.NS4) {Ballon.visibility="show";}
}

//setzt BallonTip wieder auf invisible
function bestHideBallon() {
	if (Ballon == null) return;
	crossHideObject(Ballon);
	ballonShow=false;
	crossMoveTo(Ballon, -500, 0);
	if (Iframe == null) return;
	crossHideObject(Iframe);
	crossMoveTo(Iframe, -500, 0);
}

function openMediaDialog(theURL, theTitle){
	var dialog;
	if(B_Type.IE){
		dialog=window.open(theURL,theTitle,'dependent=yes,width=760,height=230,location=no,menubar=no,resizable=yes,scrollbars=yes');
	}else{
		dialog=window.open(theURL,'MedienDialog','dependent=yes,width=740,height=210,location=no,menubar=no,resizable=yes,scrollbars=yes');
		dialog.name=theTitle;
	}
}

//setzt benoetigte Events, holt benoetigte Elemente
//rowdisplay: Element zum Anzeigen, wie viele Zeilen angezeigt werden
//display: Bereich in dem die Tabelle angezeigt wird (div)
function bestSetSizing(display,rowdisplay){
		//out.writeln("------------bestSetSizing(display,rowdisplay)-Start<br>");
	BestRowDisplay=crossGetObject(rowdisplay);
	BestDisplay=crossGetObject(display);
	
	countRows_old=countRows=bestGetRows(getPixel(bestInnerWindowHeight()));
		//out.writeln("------------bestSetSizing(display,rowdisplay)-End<br>");
	bestResizing();
	window.onresize=bestResizing;
}

//wird jedes mal aufgerufen, wenn die fenstergroesse veraendert wird
function bestResizing(){
		//out.writeln("------------------------bestResizing(e)-Start<br>");
	var w=bestInnerWindowWidth();
	var h= bestInnerWindowHeight();
		//out.writeln("w/h: ("+w+"/"+h+")<br>");
	countRows=bestGetRows(h);
	if(countRows==countRows_old || countRows < minRows)
		BestRowDisplay.style.color='#6f6f6f';
	else
		BestRowDisplay.style.color='#de0000';
	BestRowDisplay.firstChild.nodeValue=countRows;
	bestFitDisplay(w,h);
	bestResizeTable();
		//out.writeln("------------------------bestResizing(e)-End<br>");
}

//berechnet wie viele Zeilen sich bei einer bestimmten Hoehe ausgehen
function bestGetRows(h){
		//out.writeln("----------bestGetRows(h)-Start<br>");
		//out.writeln("h SOLL: ("+h+");IST ("+bestInnerWindowHeight()+")<br>");
		
	var r=h-75-bestGetBoundaryHeight(BestDisplay);//sichtbare Fensterhoehe - 45 (obige Leiste) - Bound.
	r=((r-(r%bestrowheight))/bestrowheight);//damit keine Kommazahl entsteht
	if(B_Type.IE) r-=1; //workaround fuer anzeigeprob im IE
		//out.writeln("----------bestGetRows(h)-End<br>");
	return r;
}

//uebertraegt die neue Anzahl der Zeilen dem Server, der es neu berechnet.
function bestResizeTable(){
		//out.writeln("------------bestResizeTable()-Start<br>");
	if(countRows_old!=countRows && countRows>=minRows){
			//out.writeln("Wird das Formular abgesandt: "+(countRows_old!=countRows && countRows>=minRows)+"<br");
			//out.writeln("countRows_old/countRows/minRows: ("+countRows_old+"/"+countRows+"/"+minRows+")<br>");
		document.forms[0].rows.value=countRows;
		document.forms[0].action.value='resize';
		document.forms[0].submit();
	}
		//out.writeln("------------bestResizeTable()-End<br>");
}

function bestFitDisplay(w,h){
		//out.writeln("------------bestFitDisplay(w,h)-Start<br>");
	var theHeight=h-55;
	var theWidth=w-20;//20
	//out.writeln("w/h: ("+bestInnerWindowWidth()+"/"+bestInnerWindowHeight()+") SOLL");
	//out.writeln("w/h: ("+w+"/"+h+") IST");
	if(B_Type.IE){
		theWidth-=20;//wegen bestaendiger scrollbar rechts
	}

	bestSetOuterHeight(BestDisplay,theHeight);
	bestSetOuterWidth(BestDisplay,theWidth);
		//out.writeln("------------bestFitDisplay(w,h)-End<br>");
}
//###############################################################################
//bestFunctions - Ende ---------------------------------------------------------#
//###############################################################################