function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

function getObj(obj)
{
	if (document.getElementById)
	{
		return document.getElementById(obj);
	}
	else if (document.all)
	{
		return document.all.eval(obj);
	}
}

function show_imgbox(img)
{
	var imgbox="<img src=\""+img+"\" border=\"0\">";
	var iBox=getObj("img_box");
	scrollX=0;
	scrollY=0;
	if (document.documentElement && document.documentElement.scrollTop)
	{
		scrollX=document.documentElement.scrollLeft;
		scrollY=document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		scrollX=document.body.scrollLeft;
		scrollY=document.body.scrollTop;
	}
	
	bild=new Image();
	bild.src=img;
	breite=bild.width;
	hoehe=bild.height;
	iBox.style.width=breite+"px";
	iBox.style.height=hoehe+"px";
	
	px=event.clientX+scrollX;
	py=event.clientY+scrollY;
	
	if(event.clientY-hoehe<0)
	{
		py+=2;
	}
	else
	{
		py-=hoehe+6;
	}
	
	if(event.clientX-breite<0)
	{
		px+=2;
	}
	else
	{
		px-=breite+6;
	}
	
	iBox.style.left=px;
	iBox.style.top=py;
	if(iBox.name!=img || iBox.style.visibility!="visible")
	{
		iBox.innerHTML=imgbox;
		iBox.style.visibility="visible";
	}
	iBox.name=img;
}

function hide_imgbox()
{
	var iBox=getObj("img_box");
	iBox.name="img_box";
	iBox.style.visibility="hidden";
	iBox.style.left="-500px";
}


function PreviewImage(img,img_preview)
{
	img=img.replace(/\+/g,"%2B");
	eval(img_preview).location.href="/inc/img_preview.php?img="+img;
}

function checkInputLength(objId,m)
{
	var l=getObj(objId).value.length;
	getObj('lbl_'+objId+'_chars').innerHTML='Noch '+(m-l>0 ? m-l : 0)+' Zeichen';
	if (l>m)
	{
		//alert(m+' Zeichen müssen reichen.');
		getObj(objId).value=getObj(objId).value.substr(0,m);
		return false;
	}
	else
	{
		return true;
	}
}