function loadaktion(aktion)
{
	parent.mainframe.location.href='web.php?action=' + aktion;
}

function loadaktion2(aktion)
{
	document.location.href='web.php?action=' + aktion;
}

function loadaktion3(aktion)
{
	document.location.href='action.php?page=' + aktion;
}

function loadpage()
{
	parent.mainframe.location.href='web.php';
}

function showpage(id)
{
	document.location.href='web.php?page=' + id;
}

function showurl_blank(url)
{
	win = window.open(url);
	win.focus;
}

function editor_hideDiv(id) {
   document.getElementById(id).style.visibility = "hidden";
   document.getElementById(id).style.display = "none";
}

function gen_popup(page,id)
{
	var w = 100;
	var h = 100;
	myleft=(screen.width)?(screen.width-w)/2:100;
	mytop=(screen.height)?(screen.height-h)/2:100;
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=auto,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";
	win=window.open(page + '.popup.php?dat=' + id,'Popup',settings);
	win.focus();
}

function load_popup(page,id,w,h,sb)
{
	myleft=(screen.width)?(screen.width-w)/2:100;
	mytop=(screen.height)?(screen.height-h)/2:100;
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=" + sb + ",location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";
	win=window.open(page + '.popup.php?dat=' + id,'Popup',settings);
	win.focus();
}

function print_page(id,dat,cat)
{
	var w = 600;
	var h = 500;
	myleft=(screen.width)?(screen.width-w)/2:100;
	mytop=(screen.height)?(screen.height-h)/2:100;
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open('print_page.php?dat=' + id + '&s=' + dat + '&sk=' + cat,'PrintPage',settings);
	win.focus();
}

/*===============================*/
/* onMouseOver Menü */
function getX(elm)
{
	x = elm.offsetLeft;
	if(!elm.offsetParent) return x;
	else return (x+getX (elm.offsetParent));
}

function changePos(elm1,elm2,elm3)
{
	var x = getX(document.getElementById(elm1));
	/*document.getElementById(elm2).style.left=x;*/
}

function hide_menu_all(mall)
{
	for(var i=1;i<=mall;i++)
	{
		hide_menu(i);
	}
}
   
function hide_menu(submenu)
{
	document.getElementById(submenu).style.visibility = 'hidden';
}
   
function menu(submenu,mall)
{
	/*hide_menu_all(mall);*/
	document.getElementById(submenu).style.visibility = 'visible';
}
/*===============================*/

function window_move_to()
{
	var x = (screen.width / 2) - (document.body.clientWidth / 2);
	var y = (screen.height / 2) - (document.body.clientHeight / 2);
	window.moveTo(x, y);
}

function resizeToContent()
{
	var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1);

	if (isOpera)
		return;

	if (isMSIE) {
		try { window.resizeTo(10, 10); } catch (e) {}

		var elm = document.body;
		var width = elm.offsetWidth;
		var height = elm.offsetHeight;
		var dx = (elm.scrollWidth - width) + 4;
		var dy = elm.scrollHeight - height;
		
		try { window.resizeBy(dx, dy); } catch (e) {}
		window_move_to();
	} else {
		window.scrollBy(1000, 1000);
		if (window.scrollX > 0 || window.scrollY > 0) {
			window.resizeBy(window.innerWidth * 2, window.innerHeight * 2);
			/*window.sizeToContent();*/
			window.scrollTo(0, 0);
			var x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0);
			var y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0);
			window.moveTo(x, y);
		}
	}
};

var oldContent="";
function CheckLen(Target,ml)
{
	var maxlength    =    ml;    //die maximale Zeichenlänge
    var CharsLeft    =    0;        //verbleibende Zeichen
    var breakLines    =    0;        //anzahl Zeilenumbrüche
    var theChar        =    "";        //zu testendes Zeichen
    StrLen=Target.value.length;
    if (StrLen==1&&Target.value.substring(0,1)==" ")
    {
        Target.value="";
        StrLen=0;
    }

    if (StrLen>maxlength)
    {
        Target.value=Target.value.substring(0,maxlength);
        CharsLeft=0;
    }
    else
    {
        CharsLeft=maxlength-StrLen;
    }
    for(var i=0; i<StrLen; i++)
    {
        theChar = Target.value.substring(i,i+1);
        if(theChar == "\n")
        {
            breakLines++;
        }
    }
    if(breakLines>9)        //mehr als 10 Umbrüche
    {
        Target.value = oldContent;
    }
    else if(oldContent!=Target.value)
    {
        oldContent  = Target.value;
    }
    document.Formname.Anzahl.value=CharsLeft;
    document.Formname.Brl.value=breakLines;
}

function pm_getvalue(formular,feld,wert) { 
opener.document.formular.feld.value=wert; 
} 

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";}
}

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;}
}

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;
}

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();
	}
}

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;
}

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;
}

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;
}

function crossGetScroll(achse)
{
	var val;
	if (!achse || achse == "y")
	{
		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
	{
		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;
}

function crossSetScroll(x, y)
{
	window.scrollTo(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";}
}

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);
}

function crossShowObject(obj)
{
	if (B_Type.IE || B_Type.NS6) {obj.style.visibility="visible";}
	else if (B_Type.NS4) {obj.visibility="show";}
}

function crossHideObject(obj)
{
	if (B_Type.IE || B_Type.NS6) {obj.style.visibility="hidden";}
	else if (B_Type.NS4) {obj.visibility="hide";}
}

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;}
}

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;}
}

var TTBack = "#FFFFFF";
var TTText = "#000000";
var TTBreite = 200;
var TTBorder = 1;
var TTFont = "Arial";
var TTDir = 0;
var TTVDir = 0;
var TTChangeVDir = 65;
var TTSpace = 10;
var TTShow = false;
var TT = null;
var b_Breite;
var b_Dir, b_VDir;

function setTT(id, breite, bgcolor)
{
	document.onmousemove = cursorMove;
	if (breite && breite>20) b_Breite = breite;
	if (bgcolor) TTBack = bgcolor;
	TT = crossGetObject(id);
	if (TT == null)
	{
		alert("keine Unterstützung für ToolTip-Infos");
		showTT = noTT; hideTT = noTT;
	}
	TTShow = false;
}
function noTT() {}

function showTT(msg, dir, breite, bgcolor)
{
	var b_Back;
	var relWidth, relHeight;

	if (TT == null) return;
	if (breite && breite>20) b_Breite = breite;
	else b_Breite=TTBreite;
	if (bgcolor) b_Back=bgcolor;
	else b_Back=TTBack;
	msg = '<table width=' + b_Breite + ' border=0 cellpadding=' + TTBorder + ' cellspacing=0 bgcolor=\"' + TTText + '\"><tr><td><table width=100% border=0 cellpadding=2 cellspacing=0 bgcolor=\"' + b_Back + '\"><tr><td id=tooltip_header>Information</td></tr><tr><td id=tooltip>' + msg + '</td></tr></table></td></tr></table>';
	if (!dir) b_Dir = TTDir;
	else b_Dir = dir;
	relWidth = crossInnerWindowWidth() + crossGetScroll("x");
	relHeight = crossInnerWindowHeight() + crossGetScroll("y");
	if (crossMouseX + b_Breite + TTSpace > relWidth) 
		{b_Dir = 1;}
	else if (crossMouseX < b_Breite + TTSpace) b_Dir = 0;
	b_VDir = TTVDir;
	if (crossMouseY + TTChangeVDir > relHeight) b_VDir = 1;
	else if (crossMouseY - TTChangeVDir < 0) b_VDir = 0;
	crossWrite(TT, msg);
	TTShow = true;
	crossShowObject(TT);
}

function hideTT()
{
	if (TT == null) return;
	crossHideObject(TT);
	TTShow=false;
	crossMoveTo(TT, -200, 0);
}

function cursorMove(e)
{
	var posX, posY;
	
	crossMousePosition(e);

	if (TTShow)
	{
		if (b_Dir==0)
		{
			posX = crossMouseX + TTSpace; 
			if (b_VDir==0) {posY = crossMouseY + TTSpace;}
			else {posY = crossMouseY - TTChangeVDir;}
		}
		else
		{
			posX = crossMouseX-b_Breite-TTSpace;
			if (b_VDir==0) {posY = crossMouseY + TTSpace;}
			else {posY = crossMouseY - TTChangeVDir;}
		}
		crossMoveTo(TT, posX, posY)
	}
}
