document.write('<script type="text/javascript" src="/portal/javascript/prototype.js"></script>'); 
document.write('<script type="text/javascript" src="/portal/javascript/contextMenu.js"></script>');
document.write('<script type="text/javascript" src="/portal/javascript/shortcut.js"></script>');
document.write('<script type="text/javascript" src="/portal/javascript/directUpload.js"></script>');
document.write('<script type="text/javascript" src="/portal/javascript/AC_RunActiveContent.js"></script>');

var overlayZIndex = 0;
var overlayLoadingDelay;
var overlayBackgroundEffect;
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
var ie6 = false; 
var ie7 = false; 
var ie8 = false; 
var browserIE = false;

var path=window.location.pathname;
var contextPath=path.substring(1,path.length);
contextPath='/'+contextPath.substring(0,contextPath.indexOf('/'));
var blankUrl=contextPath+"/util/view/blank.htm";
var GlobalJs = true;

if(document.all)
{ 
	if (navigator.appVersion.indexOf("MSIE 6.")!=-1) ie6=true;
	else
	if (navigator.appVersion.indexOf("MSIE 7.")!=-1) ie7=true;
	else
	if (navigator.appVersion.indexOf("MSIE 8.")!=-1) ie8=true;
} 

if (navigator.appVersion.indexOf("MSIE ") != -1) browserIE = true;

offsetX = 0;
offsetY = 20;
var toolTipSTYLE="";
function initToolTips()
{
  if(ns4||ns6||ie4)
  {
    if(ns4) toolTipSTYLE = document.toolTipLayer;
    else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
    else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
    if(ns4) document.captureEvents(Event.MOUSEMOVE);
    else
    {
      toolTipSTYLE.visibility = "visible";
      toolTipSTYLE.display = "none";
    }
    document.onmousemove = moveToMouseLoc;
  }
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function toolTip(msg, ox, fg, bg)
{
  if(toolTip.arguments.length < 1) 
  {
    if(ns4) toolTipSTYLE.visibility = "hidden";
    else toolTipSTYLE.display = "none";
  }
  else 
  {
    if(toolTip.arguments.length > 1)
    {
	  offsetX=ox;
    }
	else
	{
      offsetX=0;
	}
	moveToMouseLoc();
	if(!fg) fg = "#777777";
    if(!bg) bg = "#FFFFFF";
    var content =
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg +
    '"><td align="center"><font face="sans-serif" color="' + fg +
    '" size="-2">&nbsp\;' + msg +
    '&nbsp\;</font></td></table></td></table>';
    if(ns4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    if(ns6)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block'
    }
    if(ie4)
    {
      document.all("toolTipLayer").innerHTML=content;
      toolTipSTYLE.display='block'
    }
  }
}
function moveToMouseLoc(e)
{
try
{
  if(ns4||ns6)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else
  {
		x = event.x + document.body.scrollLeft;
    	y = event.y + document.body.scrollTop;
  }
  toolTipSTYLE.left = x + offsetX;
  toolTipSTYLE.top = y + offsetY;
  }
  catch(error)
  {
  }
  return true;
}


function MM_preloadImages() { 
  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() { 
  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) {
  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() { 
  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];}
}

var remote;
function openPopup(initHtmlFile,winName)
{
	var width=400;
	var height=180;
	if (ie7)
	{
		width=750;
		height=294;
	}
	var newWindow=GP_AdvOpenWindow(initHtmlFile,winName,'fullscreen=no,toolbar=no,location=no,status=yes,menubar=no,scrollbars=auto,resizable=yes',width,height,'center','ignoreLink','',0,'');
	//return document.MM_returnValue;
	return newWindow;
}

function checkBlank()
{
if (document.userid_form.elements[0].value == "" || document.userid_form.elements[1].value == ""){
  alert('Please enter user name and password.\nBitte geben Sie Benutzername und Passwort ein.');
   return false;
}
return true;
}
function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) 
  {
	if (document.all || document.layers || document.getElementById) 
	{
		w = screen.availWidth; h = screen.availHeight;
	}
	if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
	if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
	if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;
  }
  popupWindow = window.open(theURL,winName,features);
  if (popupWindow.opener == null) 
  { 
  	popupWindow.opener = self;  
  }
  popupWindow.opener.name = "opener";
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;

/*
	if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) { popupWindow[wp].opener = self;  popupWindow[wp].opener.name = "opener";}
  if (document.all || document.layers || document.getElementById) 
  {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") 
	{
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; 
	}
    if (autoCloseTime && autoCloseTime > 0) 
	{
		popupWindow[wp].document.body.onbeforeunload = function() 
		{
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	
		}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); 
	  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; 
	}
  }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
  */
  return popupWindow;
}
function checksubmit(initHtmlFile,winName)
{
  if (checkBlank())
  {
	var newWindow=openPopup(initHtmlFile,"popup");
	
	var newMethod=true;
	if (newMethod)
	{
		var actionUrl=document.userid_form.action; 
		if (actionUrl.indexOf("disableGoto=true")==-1)
		{
			document.userid_form.action=actionUrl+"?disableGoto=true";
		}
		var gotoUrl=document.userid_form.goto.value;
		reloadOnClose(newWindow,gotoUrl);
	}

	//prüfen ob ausgeblendeter Submit-Button vorhanden ist -> dann Formular über Submit-Button abschicken 
	//damit autocomplete funktioniert
	if(document.getElementById('userIDFormSubmitButton')!=null)	
	{
		window.setTimeout("document.getElementById('userIDFormSubmitButton').click();", 300);
	}else
	{
		window.setTimeout("document.userid_form.submit();", 300);
	}
  }
}

function setButtonEnabled(buttonId, enable)
{
	if (enable) $(buttonId).removeClassName('buttonDisabled');
	else $(buttonId).addClassName('buttonDisabled');
}

function reloadOnClose(win,reloadUrl)
{
	if (win && !win.closed)
	{
		window.setTimeout(function(){reloadOnClose(win,reloadUrl)}, 100); 
	}
	else
	{
		location.href=reloadUrl;
	}
	
}

function checkEnter(e,initHtmlFile)
{ 	var characterCode 

	 if(e && e.which)
	 { 		 e = e
		 characterCode = e.which 
	 }
	 else
	 {
	 	 try
		 {
			 e = event
			 characterCode = e.keyCode 
		 } catch (Error){}
	 }


	 if(characterCode == 13)
	 { 	checksubmit(initHtmlFile);
		 return false
	 }
	 else
	 {
	 	return true
	 }


}


var refer=true;
function showComboPanel() 
{
	obj=MM_findObj("comboPanel");
	if (refer) 
	{
	  	obj.style.visibility="visible";
	  	refer=false;
	}
	else 
	{
		obj.style.visibility="hidden";
		refer=true;
	}
}


var refer2=true;
function showComboPanel2() 
{
	obj=MM_findObj("comboPanel2");
	if (refer2) 
	{
		obj.style.visibility="visible";
		refer2=false;
	}
	else 
	{
		obj.style.visibility="hidden";
		refer2=true;
	}
}

function scrollToElement(elementId)
{
	obj=MM_findObj(elementId);
//	alert(obj);
	obj.scrollIntoView(true)
//	alert("test");
}

function showElement(elementId)
{
	obj=MM_findObj(elementId);
	obj.style.visibility="visible";
//	alert(obj);
}

function hideElement(elementId)
{
	obj=MM_findObj(elementId);
	obj.style.visibility="hidden";
//	alert(obj);
}

var ajaxXmlHttp = false;

function getAjaxInstance(key)
{
	var ajaxInstance=null;

	if (typeof(XMLHttpRequest) != 'undefined') 
	{
		ajaxInstance = new XMLHttpRequest();
//			alert(ajaxInstance);
//			ajaxInstance.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			//ajaxXmlHttp.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
			//ajaxXmlHttp.setRequestHeader("Content-Transfer-Encoding", "8bit");
	}
	if (!ajaxInstance) 
	{
		// Internet Explorer 6 und älter
		try {
			ajaxInstance  = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				ajaxInstance  = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				ajaxInstance  = false;
			}
		}
	}
	if (!ajaxInstance) 
	{
		alert("error creating ajax instance");
	}
	return ajaxInstance;
}
ajaxXmlHttp=getAjaxInstance();


function ajaxLoad(url,elementId,asynchronous,afterLoad,evalScripts)
{
	if (evalScripts && evalScripts!=null)
	{
		if (afterLoad!=null)
		{
			if (asynchronous==false)
			{
				new Ajax.Updater(elementId, url, {   
					asynchronous: false,
					onComplete: afterLoad,
					evalScripts: true
				}); 
			}
			else
			{
				new Ajax.Updater(elementId, url, {   
					onComplete: afterLoad,
					evalScripts: true
				}); 
			}
		}
		else
		{
			if (asynchronous==false)
			{
				new Ajax.Updater(elementId, url, {   
					asynchronous: false,
					evalScripts: true
				}); 
			}
			else
			{
				new Ajax.Updater(elementId, url, {
 					evalScripts: true
				}); 
			}
		}
	}
	else
	{
		if (afterLoad)
		{
			if (asynchronous==false)
			{
				new Ajax.Updater(elementId, url, {   
					asynchronous: false,
					onComplete: afterLoad
				}); 
			}
			else
			{
				new Ajax.Updater(elementId, url, {   
					onComplete: afterLoad
				}); 
			}
		}
		else
		{
			if (asynchronous==false)
			{
				new Ajax.Updater(elementId, url, {   
					asynchronous: false
				}); 
			}
			else
			{
				new Ajax.Updater(elementId, url); 
			}
		}
	}
}

function ajaxLoadSynchronous(url,elementId)
{
	return ajaxLoad(url,elementId,false);
}

function ajaxLoadString(url)
{
	var result;
	new Ajax.Request(url, {
	  asynchronous: false,
	  onComplete: function(response) {
    	if (200 == response.status)
      		result = response.responseText;
  		}
	});

	return result;
}

function openEditorWindow(url)
{	
	GP_AdvOpenWindow(url,'','fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes',1000,750);
}

function showPleaseWait()
{
	var pleaseWaitPanel=document.getElementById('pleaseWaitPanel');
	if(pleaseWaitPanel) pleaseWaitPanel.style.display = 'block';
}

function hidePleaseWait()
{
	var pleaseWaitPanel=document.getElementById('pleaseWaitPanel');
	if(pleaseWaitPanel) pleaseWaitPanel.style.display = 'none';
}


function beginLoading()
{
	if (window.addEventListener)
	window.addEventListener("load", endLoading, false)
	else if (window.attachEvent)
	window.attachEvent("onload", endLoading)

	pwTimer=window.setTimeout("showPleaseWait()",2000);
}

function endLoading()
{
	hidePleaseWait();
	window.clearTimeout(pwTimer);
}

function MM_dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v4.01
  //Copyright 1998 Macromedia, Inc. All rights reserved.
  var i,j,aLayer,retVal,curDrag=null,curLeft,curTop,IE=document.all,NS4=document.layers;
  var NS6=(!IE&&document.getElementById), NS=(NS4||NS6); if (!IE && !NS) return false;
  retVal = true; if(IE && event) event.returnValue = true;
  if (MM_dragLayer.arguments.length > 1) {
    curDrag = MM_findObj(objName); if (!curDrag) return false;
    if (!document.allLayers) { document.allLayers = new Array();
      with (document) if (NS4) { for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
        for (i=0; i<allLayers.length; i++) if (allLayers[i].document && allLayers[i].document.layers)
          with (allLayers[i].document) for (j=0; j<layers.length; j++) allLayers[allLayers.length]=layers[j];
      } else {
        if (NS6) { var spns = getElementsByTagName("span"); var all = getElementsByTagName("div"); 
          for (i=0;i<spns.length;i++) if (spns[i].style&&spns[i].style.position) allLayers[allLayers.length]=spns[i];}
        for (i=0;i<all.length;i++) if (all[i].style&&all[i].style.position) allLayers[allLayers.length]=all[i]; 
    } }
    curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;
    curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;
    curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;
    curDrag.MM_dropBack=dropBack; curDrag.MM_dropJS=dropJS;
    curDrag.MM_everyTime=et; curDrag.MM_dragJS=dragJS;
    curDrag.MM_oldZ = (NS4)?curDrag.zIndex:curDrag.style.zIndex;
    curLeft= (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft; 
    if (String(curLeft)=="NaN") curLeft=0; curDrag.MM_startL = curLeft;
    curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop; 
    if (String(curTop)=="NaN") curTop=0; curDrag.MM_startT = curTop;
    curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop-cU;
    curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop+cD;
    curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!
    document.onmousedown = MM_dragLayer; document.onmouseup = MM_dragLayer;
    if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  } else {
    var theEvent = ((NS)?objName.type:event.type);
    if (theEvent == 'mousedown') {
      var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
      var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
      var maxDragZ=null; document.MM_maxZ = 0;
      for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[i];
        var aLayerZ = (NS4)?aLayer.zIndex:parseInt(aLayer.style.zIndex);
        if (aLayerZ > document.MM_maxZ) document.MM_maxZ = aLayerZ;
        var isVisible = (((NS4)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);
        if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {
          var parentL=0; var parentT=0;
          if (NS6) { parentLayer = aLayer.parentNode;
            while (parentLayer != null && parentLayer.style.position) {             
              parentL += parseInt(parentLayer.offsetLeft); parentT += parseInt(parentLayer.offsetTop);
              parentLayer = parentLayer.parentNode;
          } } else if (IE) { parentLayer = aLayer.parentElement;       
            while (parentLayer != null && parentLayer.style.position) {
              parentL += parentLayer.offsetLeft; parentT += parentLayer.offsetTop;
              parentLayer = parentLayer.parentElement; } }
          var tmpX=mouseX-(((NS4)?pageX:((NS6)?parseInt(style.left):style.pixelLeft)+parentL)+MM_hLeft);
          var tmpY=mouseY-(((NS4)?pageY:((NS6)?parseInt(style.top):style.pixelTop) +parentT)+MM_hTop);
          if (String(tmpX)=="NaN") tmpX=0; if (String(tmpY)=="NaN") tmpY=0;
          var tmpW = MM_hWidth;  if (tmpW <= 0) tmpW += ((NS4)?clip.width :offsetWidth);
          var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += ((NS4)?clip.height:offsetHeight);
          if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
              || maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }
      if (curDrag) {
        document.onmousemove = MM_dragLayer; if (NS4) document.captureEvents(Event.MOUSEMOVE);
        curLeft = (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
        curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
        if (String(curLeft)=="NaN") curLeft=0; if (String(curTop)=="NaN") curTop=0;
        MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;
        document.MM_curDrag = curDrag;  curDrag.MM_SNAPPED=false;
        if(curDrag.MM_toFront) {
          eval('curDrag.'+((NS4)?'':'style.')+'zIndex=document.MM_maxZ+1');
          if (!curDrag.MM_dropBack) document.MM_maxZ++; }
        retVal = false; if(!NS4&&!NS6) event.returnValue = false;
    } } else if (theEvent == 'mousemove') {
      if (document.MM_curDrag) with (document.MM_curDrag) {
        var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
        var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
        newLeft = mouseX-MM_oldX; newTop  = mouseY-MM_oldY;
        if (MM_bL!=null) newLeft = Math.max(newLeft,MM_bL);
        if (MM_bR!=null) newLeft = Math.min(newLeft,MM_bR);
        if (MM_bT!=null) newTop  = Math.max(newTop ,MM_bT);
        if (MM_bB!=null) newTop  = Math.min(newTop ,MM_bB);
        MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;
        if (NS4) {left = newLeft; top = newTop;}
        else if (NS6){style.left = newLeft; style.top = newTop;}
        else {style.pixelLeft = newLeft; style.pixelTop = newTop;}
        if (MM_dragJS) eval(MM_dragJS);
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mouseup') {
      document.onmousemove = null;
      if (NS) document.releaseEvents(Event.MOUSEMOVE);
      if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS
      if (document.MM_curDrag) with (document.MM_curDrag) {
        if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&
            (Math.pow(MM_targL-((NS4)?left:(NS6)?parseInt(style.left):style.pixelLeft),2)+
             Math.pow(MM_targT-((NS4)?top:(NS6)?parseInt(style.top):style.pixelTop),2))<=MM_tol) {
          if (NS4) {left = MM_targL; top = MM_targT;}
          else if (NS6) {style.left = MM_targL; style.top = MM_targT;}
          else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
          MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT; }
        if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);
        if(MM_dropBack) {if (NS4) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}
        retVal = false; if(!NS) event.returnValue = false; }
      document.MM_curDrag = null;
    }
    if (NS) document.routeEvent(objName);
  } return retVal;
}

function getAbsolutePos(element) {
	var r = { x: element.offsetLeft, y: element.offsetTop };

	do{
		element = element.offsetParent;
		r.x += element.offsetLeft;
		r.y += element.offsetTop;
	}while (element.id!="content" && element.offsetParent.id!="content")
	return r;
}

function changeFrameMode(url,hideId,showId,hideId2,showId2,hideId3,showId3)
{
	$(hideId).hide();
	$(showId).show();
	if (hideId2!=null) $(hideId2).hide();
	if (showId2!=null) $(showId2).show();
	
	if (hideId3!=null) 
	{
		elem=$(hideId3);
		if (elem!=null) elem.hide();
	}
	if (showId3!=null) 
	{
		elem=$(showId3)
		if (elem!=null) elem.show();
	}
	
	
//	if (hideId2!=null) new Effect.Fade(hideId2);
//	if (hideId2!=null) new Effect.SwitchOff(hideId2);
//	if (showId2!=null) new Effect.Grow(showId2);

	new Ajax.Request(url); 
//window.frames["loader"].window.location=url;
}

function changeFrameModeClass(frameId)
{
	var channelFrame = document.getElementById(frameId);

	if (channelFrame.className.indexOf("frameModeNormal") != -1)
	{
		channelFrame.className=channelFrame.className.replace("frameModeNormal","frameModeMinimized");
	}
	else if (channelFrame.className.indexOf("frameModeMinimized") != -1)
	{
		channelFrame.className=channelFrame.className.replace("frameModeMinimized","frameModeNormal");
	}

}

/// Context menu

var state = false;

function showContextMenu(eid, pid, mid,contextWidth,contextHeight,contextLeft,contextTop)
{
	var offsetLeft = document.getElementById('base').style.left;
	var offsetLeftNr = parseInt(offsetLeft.substring(0,(offsetLeft.length-2)))+contextLeft;
	document.getElementById('contextMenuDiv').style.left = offsetLeftNr+"px";
	
	var offsetTop = document.getElementById('base').style.top;
	var offsetTopNr = parseInt(offsetTop.substring(0,(offsetTop.length-2)))+contextTop;
	document.getElementById('contextMenuDiv').style.top = offsetTopNr+"px";
	
	document.getElementById('contextMenuDiv').style.width=contextWidth+"px";
	document.getElementById('contextMenuDiv').style.height=contextHeight+"px";
	document.getElementById('contextMenu').style.width=contextWidth+"px";
	document.getElementById('contextMenu').style.height=contextHeight+"px";
	document.getElementById('contextMenu').src="../../util/contextMenu/master.jsp?eid="+eid+"&pid="+pid+"&mid="+mid;
	document.getElementById('contextMenuDiv').style.visibility='visible';
}

function scaleHeightToBrowserOnResize(elementID, reduceBy, minHeight, initialResize)
{
	if (initialResize!="false")
	{
		Event.observe(window, 'load', function(){
			scaleHeightToBrowserWorker(elementID, reduceBy, minHeight);
		});
	}
	Event.observe(window, 'resize', function(){
		scaleHeightToBrowserWorker(elementID, reduceBy, minHeight);
	});

}

function scaleHeightToBrowserWorker(elementID, reduceBy, minHeight)
{
	elem=$(elementID);

	var bodyElement=null;
	for (var i=0; i<document.body.childNodes.length && bodyElement==null; i++)
	{
		if (document.body.childNodes[i].nodeName == "DIV")
		{
			bodyElement=document.body.childNodes[i];
		}
	}

	var bwidth=Element.getWidth(bodyElement);
	var bheight=Element.getHeight(bodyElement);

	var wwidth=document.viewport.getWidth();
	var wheight=document.viewport.getHeight();

	var ewidth=Element.getWidth(elem);
	var eheight=Element.getHeight(elem);

	var rwheight=wheight-reduceBy;

	var delta=rwheight-bheight;
	eheight=eheight+delta;
	
	if (eheight<minHeight) eheight=minHeight;

	elem.style.height = eheight + "px";
}

function onReloadPortlet(channelId, afterOnReloadFunction)
{
	Event.observe(window, "load", function() {  
		if (parent!=self) 
		{
			var reloadIds=fep.getParameterValues("reloadId");
			if (reloadIds==null) reloadIds=new Array("channelId_"+channelId);
			if (reloadIds!=null)
			{
				for (var i=0;i<reloadIds.length;i++)
				{
					var newContent = $(reloadIds[i]);
					if (newContent!=null)
					{
						parent.fep.reloadContent(reloadIds[i],newContent.innerHTML, false);				
					}
				}
			}
		}
				
		if (afterOnReloadFunction!=null) afterOnReloadFunction.call();
	});
}

function createDraggable(channelId, options)
{
	new Draggable(channelId, options);
}

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_validateForm() 
{ //v4.0
	if (document.getElementById)
	{
		var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		var language = 'en';
		if ((args[args.length-1])=='de') language = 'de'; // language kann als letzer Parameter angehaengt werden
		for (i=0; i<(args.length-2); i+=3) 
		{ 
			test=args[i+2]; 
			val=document.getElementById(args[i]);
						
			if (val) 
			{ 
				nm=val.name; 
				var nmUpper = nm.charAt(0).toUpperCase() + nm.slice(1); //Erster Buchstabe Uppercase
				if ((val=val.value)!="") 
				{
					if (test.indexOf('isEmail')!=-1) 
					{ 
						p=val.indexOf('@');
						if (p<1 || p==(val.length-1)) 
						{
							if (language=='de')
							{
								errors+='- '+nmUpper+' muss eine E-Mail Adresse enthalten.\n';	
							}
							else
							{
								errors+='- '+nmUpper+' must contain an e-mail address.\n';
							}
						}	
					} 
					else if (test!='R') 
					{ 
						num = parseFloat(val);
						if (isNaN(val))
						{
							if (language=='de')
							{
								errors+='- '+nmUpper+' muss eine Nummer enthalten.\n';
							}
							else
							{
								errors+='- '+nmUpper+' must contain a number.\n';
							}
						}	
						if (test.indexOf('inRange') != -1) 
						{ 
							p=test.indexOf(':');
							min=test.substring(8,p); max=test.substring(p+1);
							if (num<min || max<num) 
							{
								if (language=='de')
								{
									errors+='- '+nmUpper+' muss eine Nummer zwischen '+min+' und '+max+' enthalten.\n';
								}
								else
								{
									errors+='- '+nmUpper+' must contain a number between '+min+' and '+max+'.\n';
								}
							}
						} 	
					} 
				} 
				else if (test.charAt(0) == 'R')
				{
					if (language=='de')
					{
						errors += '- '+nmUpper+' ist ein Pflichtfeld.\n'; 
					}
					else
					{
						errors += '- '+nmUpper+' is required.\n'; 
					}
				}
			}
		} 
	if (errors) 
	{
		if (language=='de')
		{
			alert('Folgende Fehler sind aufgetreten:\n'+errors);
		}
		else
		{
			alert('The following error(s) occurred:\n'+errors);
		}
	}
	document.MM_returnValue = (errors == '');
	} 
}

function submitEditorAppzTemplateForm(language)
{
	MM_validateForm('name','','R',language);
	if(document.MM_returnValue)
	{
		document.form1.submit();
	}
	else
	{
		$('saveButton').removeClassName('buttonDisabled');
	}
}
function openMaximizedWindow(url)
{
	var w = 1024, h = 768;
	if (document.all || document.layers || document.getElementById) 
	{
		w = screen.availWidth; h = screen.availHeight;
	}
	var win = window.open(url, '_blank','width='+w+',height='+h+',left=0,top=0, scrollbars=yes');
	win.moveTo(-10,-25);
}

function selectStyle(styleName) 
{
	window.frames["loader"].window.location=contextPath+"/util/userProfile/setUserProfile.jsp?reloadParent=true&userProfile.style=" + styleName;
}
function selectZoom(delta) 
{
	if (delta)
	{
		var value=document.body.style.zoom;
		if (!value) value=1;
		else value=parseFloat(value);
		value+=delta;
		if (value==0) value=0.1;
		document.body.style.zoom=value;
		new Ajax.Request(contextPath+"/util/userProfile/setUserProfile.jsp?userProfile.zoom=" + value); 
//		window.frames["loader"].window.location=contextPath+"/util/userProfile/setUserProfile.jsp?userProfile.zoom=" + value;
	}
	else
	{
		document.body.style.zoom=1;
		new Ajax.Request(contextPath+"/util/userProfile/setUserProfile.jsp?userProfile.zoom=NULL"); 
//		window.frames["loader"].window.location=contextPath+"/util/userProfile/setUserProfile.jsp?userProfile.zoom=NULL";
	}
}

function enableEditing(pinEditId)
{		
	var divId='loadingFrame';
	if(pinEditId && typeof pinEditId == "string")
	{		
		divId+='_'+pinEditId;	
	}		
	try
	{				
		document.getElementById(divId).style.display='none';		
	}
	catch(e)
	{
		//alert(e);
	}	
}	
	
function right(e) {
	var msg = "Function Disabled!";
	if (navigator.appName == 'Netscape' && e.which == 3) {
		alert(msg);
		return false;
	}
		if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
		alert(msg);
		return false;
	}
	else return true;
}

function trap()
{
  if(document.images)
    {
    for(i=0;i<document.images.length;i++)
      {
      document.images[i].onmousedown = right;
      document.images[i].onmouseup = right;
      }
    }
  }
  
 	function closeOverlayFrame() 
	{
		document.getElementById('ContainerOverlayDiv').style.display='none';
		document.getElementById('ContainerOverlayBg').style.display='none';
		if (ie6) document.getElementById('ContainerOverlayIframe').style.display='none';
		document.body.style.overflow='visible';
		document.body.scroll='yes';
	}
	
	//alert("document.cookie:"+document.cookie);
	
	function showOverlayFrame(url)
	{
		try
		{
			document.getElementById('ContainerOverlayDiv').style.display='block';
			document.getElementById('ContainerOverlayBg').style.display='block';
			if (ie6) document.getElementById('ContainerOverlayIframe').style.display='block';
			ajaxLoad(url,"ContainerOverlayDiv");
			document.body.scroll='no';
			document.body.style.overflow='hidden';
		}
		catch(Error)
		{
		}
	}

// Funktion zum Öffnen von Links in MHTs in neuem Fenster
function openLinkInMHT(url)
{
	var openUrl = url;
	GP_AdvOpenWindow(openUrl,'userprofile','fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,channelmode=no,directories=no',500,300,'center','ignoreLink','',0,'',0,1,5,'');
	return;
}

var virtualClipboard=null;
function setClipboard(val)
	{
		try
		{
			if(document.all && window.clipboardData && window.clipboardData.setData)
			{
//				alert("set Clipboard: "+val);
				window.clipboardData.setData("Text",val);
//				var cliboardValue=window.clipboardData.getData("Text");
//				alert("cliboardValue: "+cliboardValue);
			}
			else
			{
//				alert(virtualClipboard+" -> "+val);
	//			alert("set virtualClipboard: "+val);
				virtualClipboard=val;
	//			(new Clipboard()).copy(val);
			}
		}
		catch(error)
		{
			alert(error.description+" "+error.message+" "+error.number);
		}
	}
	
	// ***************************************************************************************************
	function getClipboard()
	{
		try
		{
			if(document.all && window.clipboardData && window.clipboardData.getData)
			{
				return window.clipboardData.getData("Text");
			}
			else
			{
				return virtualClipboard;
	//			return(new Clipboard()).paste();
			}
		}
		catch(error)
		{
			//alert(error.description);
		}
	}
	
	function getClipboardAsync(callbackFunction)
	{
		if (ie6)
		{
			value=getClipboard();
			if (callbackFunction) callbackFunction(value);
		}
		else
		{
			callClipboardHelperFrame(function(helperFrame){
				try
				{				
					var value=helperFrame.contentWindow.getClipboard();
					if (callbackFunction) callbackFunction(value);
				}
				catch(e)
				{
				}	
			});
		}
	}

	function setClipboardAsync(val, callbackFunction)
	{
		if (ie6)

		{
			setClipboard(val);
			if (callbackFunction) callbackFunction();
		}
		else
		{
			callClipboardHelperFrame(function(helperFrame){
				try
				{				
					helperFrame.contentWindow.setClipboard(val);
					if (callbackFunction) callbackFunction();
				}
				catch(e)
				{
				}	
			});
		}
	}


	var callbackHelperIFrameReady=false;
	var callbackHelperIFrame=null;
	function callClipboardHelperFrame(func)
	{
		var helperFrame=document.getElementById("clipboardHelper");
		
		if (callbackHelperIFrameReady==false)
		{
			if (helperFrame!=null)
			{
				window.setTimeout(function(){callClipboardHelperFrame(func)}, 200); 
				return;
			}
		
//			alert("setzen "+func);
			callbackHelperIFrame=func;
			var clipdiv = document.createElement("div");
			clipdiv.style.position='absolute';
//			clipdiv.style.top='20px';
//			clipdiv.style.left='20px';
			clipdiv.innerHTML = "<iframe id='clipboardHelper' width='18' height='0' frameborder='0' name='clipboardHelper' src='"+contextPath+"/util/ClientBridge/clipboard.jsp'></iframe>";
			document.body.insertBefore(clipdiv, document.body.firstChild);
//			$('tb_parentDirectory').parentNode.insertBefore(clipdiv, $('tb_parentDirectory'));
		}
		else
		{
			func(helperFrame);
		}
	}
	
	function bodyOnloadIFrame()
	{
		var helperFrame=document.getElementById("clipboardHelper");
		callbackHelperIFrame(helperFrame);
		callbackHelperIFrameReady=true;
//		callbackHelperIFrame=null;
	}

// *** Funktion zum entfernen von Leerzeichen eines Strings
	function removeWhitespaces(s)
	{
	  	return s.replace( /\s/g, "" );
	}
	
	function EMail(s)
	{
		 var a = false;
		 var res = false;
		 if(typeof(RegExp) == 'function')
		 {
		  var b = new RegExp('abc');
		  if(b.test('abc') == true){a = true;}
		 }
		
		 if(a == true)
		 {
		  reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
						   '(\\@)([a-zA-Z0-9\\-\\.]+)'+
						   '(\\.)([a-zA-Z]{2,4})$');
		  res = (reg.test(s));
		 }
		 else
		 {
		  res = (s.search('@') >= 1 &&
				 s.lastIndexOf('.') > s.search('@') &&
				 s.lastIndexOf('.') >= s.length-5)
		 }
		 return(res);
 	}
	
	function publishFile(fid)
	{
		publishFile(fid,3);
	}
	
	function publishFile(fid, publishLevel)
	{
		publishEntry(fid,publishLevel);
	}

	function publishEntry(eid, publishLevel)
	{
		if(publishLevel==undefined)
		{
			publishLevel=3;
		}
		try
		{
			window.frames["loader"].window.location= contextPath+"/util/HomepageExplorer/functions/publish/publishEntry.jsp?eid="+eid+"&publishLevel="+publishLevel;
		}
		catch(e)
		{
			window.open(contextPath+"/util/HomepageExplorer/functions/publish/publishEntry.jsp?eid="+eid+"&publishLevel="+publishLevel,"resizable,scrollbars=auto,width=500,height=200,left=100,top=100");
		}
	}

 	var eventMatchers = 
	{    
		'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,    
		'MouseEvents': /^(?:click|mouse(?:down|up|over|move|out))$/  
	}  
	var defaultOptions = {    pointerX: 0,    pointerY: 0,    button: 0,    ctrlKey: false,    altKey: false,    shiftKey: false,    metaKey: false,    bubbles: true,    cancelable: true  }    
	simulate = function(element, eventName) 
	{
		var options = Object.extend(defaultOptions, arguments[2] || { });    
		var oEvent, eventType = null;       
		element = $(element);        
		for (var name in eventMatchers) 
		{      
			if (eventMatchers[name].test(eventName)) 
			{ 
				eventType = name; 
				break;
			}    
		}
		if (!eventType) throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');     
		if (document.createEvent) 
		{      
			oEvent = document.createEvent(eventType);      
			if (eventType == 'HTMLEvents') 
			{
				oEvent.initEvent(eventName, options.bubbles, options.cancelable);
			}
			else
			{
				oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView, options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);      
			}      
			element.dispatchEvent(oEvent);    
		}
		else
		{ 
			options.clientX = options.pointerX;
			options.clientY = options.pointerY;
			oEvent = Object.extend(document.createEventObject(), options); 
			element.fireEvent('on' + eventName, oEvent);   
		}
		return element;
	}
 	
 	function createInfoBubble(targetElement,infoText,alignment,distance,offset,infoType,event,createBackgroundIframe)
 	{
 		var targetElement = $(targetElement);
 		
 		if(alignment==null) var alignment = "right";
 		if(distance==null) var distance = 40;
 		if(offset==null) var offset = 5;
 		if(infoType==null) var infoType = "error";
		
 		var infoBubble = document.createElement('div');
 		infoBubble.className = "infoBubble_"+infoType;
 		infoBubble.id = "infoBubble_"+targetElement.id;
 		infoBubble.style.zIndex=$(targetElement).style.zIndex+100;
 		document.body.appendChild(infoBubble);

 		var infoBubbleArrow = document.createElement('div');
 		infoBubbleArrow.className = "infoBubbleArrow_"+infoType;
 		infoBubbleArrow.id = "infoBubbleArrow_"+targetElement.id;	
 		infoBubbleArrow.style.zIndex=$(targetElement).style.zIndex+99;
 		document.body.appendChild(infoBubbleArrow);

 		infoBubble.innerHTML = infoText;

 		var targetX = Element.cumulativeOffset($(targetElement)).left;
 		var targetY = Element.cumulativeOffset($(targetElement)).top;
 		var targetWidth = Element.getWidth($(targetElement));
 		var targetHeight = Element.getHeight($(targetElement));

 		var bubbleWidth = Element.getWidth($(infoBubble));
 		var bubbleHeight = Element.getHeight($(infoBubble));

 		var arrowWidth = 1;
 		var arrowHeight = 1;
 		
 		if(alignment=="right" || alignment=="left")	
 		{
 			arrowWidth = distance+offset;
 			infoBubbleArrow.style.width = arrowWidth+"px";
 			infoBubbleArrow.style.height = "1px";
 		}		
 		else if(alignment=="top" || alignment=="bottom")
 		{
 			arrowHeight = distance+offset;
 			infoBubbleArrow.style.height = arrowHeight+"px";
 			infoBubbleArrow.style.width = "1px";
 		}
 		else if(alignment=="mouse")
 		{
 			/*arrowHeight = distance;
 			if(arrowHeight<0)arrowHeight=arrowHeight*(-1);
 			arrowHeight = arrowHeight+offset;
 			infoBubbleArrow.style.height = arrowHeight+"px";
 			infoBubbleArrow.style.width = "1px";*/
 		}

 		if(alignment=="right")
 		{
 			infoBubble.style.left = targetX+targetWidth+distance+"px";
 			infoBubble.style.top = targetY+targetHeight/2-bubbleHeight/2+"px";
 		
 			infoBubbleArrow.style.left = targetX+targetWidth+distance-arrowWidth+"px";
 			infoBubbleArrow.style.top = targetY+targetHeight/2-arrowHeight/2+"px";
 		}
 		if(alignment=="left")
 		{
 			infoBubble.style.left = targetX-bubbleWidth-distance+"px";
 			infoBubble.style.top = targetY+targetHeight/2-bubbleHeight/2+"px";
 		
 			infoBubbleArrow.style.left = targetX-distance+"px";
 			infoBubbleArrow.style.top = targetY+targetHeight/2+arrowHeight/2+"px";
 		}
 		if(alignment=="top")
 		{
 			infoBubble.style.left = targetX+targetWidth/2-bubbleWidth/2+"px";
 			infoBubble.style.top = targetY-bubbleHeight-distance+"px";
 		
 			infoBubbleArrow.style.left = targetX+targetWidth/2-arrowWidth/2+"px";
 			infoBubbleArrow.style.top = targetY-arrowHeight+offset+"px";
 		}
 		if(alignment=="bottom")
 		{
 			infoBubble.style.left = targetX+targetWidth/2-bubbleWidth/2+"px";
 			infoBubble.style.top = targetY+targetHeight+distance+"px";
 		
 			infoBubbleArrow.style.left = targetX+targetWidth/2-arrowWidth/2+"px";
 			infoBubbleArrow.style.top = targetY+targetHeight-offset+"px";
 		}
 		if(alignment=="mouse")
 		{
 	 		
	 		targetX = Event.pointerX(event);
			targetY = Event.pointerY(event);
	
			infoBubble.style.left = targetX+"px";
 			infoBubble.style.top= targetY+distance+"px";
 			
 		}
		
		if (createBackgroundIframe)
		{
			document.body.appendChild(new Element("iframe", {id:"infoBubbleIframe_"+targetElement.id,src: "/portal/util/view/blank.htm", frameborder: "0", style: "position: absolute; border-style:none; top:" + infoBubble.style.top + "; left:" + infoBubble.style.left + "; width: " + bubbleWidth + "px; height: " + bubbleHeight + "px"}));
			document.body.appendChild(new Element("iframe", {id:"infoBubbleArrowIframe_"+targetElement.id,src: "/portal/util/view/blank.htm", frameborder: "0", style: "position: absolute; border-style:none; top:" + infoBubbleArrow.style.top + "; left:" + infoBubbleArrow.style.left + "; width: " + Element.getWidth($(infoBubbleArrow)) + "px; height: "+Element.getHeight($(infoBubbleArrow))+"px"}));
		}
 	}
 	function removeInfoBubble(targetElement)
 	{
 		var targetElement = $(targetElement);
 		if($("infoBubble_"+targetElement.id)!=null)
 		{
 			document.body.removeChild($("infoBubble_"+targetElement.id));
 			document.body.removeChild($("infoBubbleArrow_"+targetElement.id));
			if ($("infoBubbleIframe_"+targetElement.id)) document.body.removeChild($("infoBubbleIframe_"+targetElement.id));
			if ($("infoBubbleArrowIframe_"+targetElement.id)) document.body.removeChild($("infoBubbleArrowIframe_"+targetElement.id));
 		}
 	}
	
	getCaretInfo = function(oTextarea) 
		{
			var docObj = oTextarea.ownerDocument;
			var result = {start:0, end:0, caret:0};
			
			if (navigator.appVersion.indexOf("MSIE")!=-1) {
				if (oTextarea.tagName.toLowerCase() == "textarea") {
					if (oTextarea.value.charCodeAt(oTextarea.value.length-1) < 14) {
						oTextarea.value=oTextarea.value.replace(/34/g,'')+String.fromCharCode(28);
					}
					var oRng = docObj.selection.createRange();
					var oRng2 = oRng.duplicate();
					oRng2.moveToElementText(oTextarea);
					oRng2.setEndPoint('StartToEnd', oRng);
					result.end = oTextarea.value.length-oRng2.text.length;
					oRng2.setEndPoint('StartToStart', oRng);
					result.start = oTextarea.value.length-oRng2.text.length; 
					result.caret = result.end;
					if (oTextarea.value.substr(oTextarea.value.length-1) == String.fromCharCode(28)) {
						oTextarea.value = oTextarea.value.substr(0, oTextarea.value.length-1);
					}			
				} else {
					var range = docObj.selection.createRange();
					var r2 = range.duplicate();			
					result.start = 0 - r2.moveStart('character', -100000);
					result.end = result.start + range.text.length;	
					result.caret = result.end;
				}			
			} else {
				result.start = oTextarea.selectionStart;
				result.end = oTextarea.selectionEnd;
				result.caret = result.end;
			}
			if (result.start < 0) {
				 result = {start:0, end:0, caret:0};
			}	
			return result;
		}

		function setCaretPosition (el, iCaretPos)
		{			
			if (el.selectionStart || el.selectionStart == "0" || el.setSelectionRange) // Firefox
			{				
				
				el.setSelectionRange(iCaretPos, iCaretPos)
			}else  if (document.selection) // IE
			{		
				var range

				range = document.selection.createRange()

				if (el.type == "text") // textbox
				{
					range.moveStart("character", -el.value.length);
					range.moveEnd("character", -el.value.length);
					range.moveStart("character", iCaretPos);
					range.select()
				}else // textarea
				{
				range.collapse(false);
				range.move("character", iCaretPos - el.value.length + (el.value.split("\n").length -1));				
				range.select()
				}
			}			
		}
function togglePortalMode(portalMode)
{
	var topUrl = top.location.href;
	var topUrlHash = "";
	
	if(topUrl.indexOf('#')>0) // wenn Anker in URL, mach ihn weg (wird spaeter wieder hingemacht)
	{
		topUrlHash = topUrl.substring(topUrl.indexOf('#'));
		topUrl = topUrl.replace(topUrlHash,""); 
	}
	
	if(topUrl.indexOf('portalMode='+portalMode)>0) // wenn Modus schon an, mach ihn aus
	{
		if (topUrl.indexOf('?portalMode')>0) 
		{
			topUrl=topUrl.replace('?portalMode='+portalMode,'');
		}
		else
		{
			topUrl=topUrl.replace('&portalMode='+portalMode,'');
		}
	}
	else // wenn Modus aus, mach ihn an
	{
		if (topUrl.indexOf('?')>0)
		{
			topUrl=topUrl+'&portalMode='+portalMode;
		}
		else
		{
			topUrl=topUrl+'?portalMode='+portalMode;
		}
	}
	
	top.location.href = topUrl + topUrlHash;
}

// Gibt die Variable "text" so zurück, dass sie Unicode Zeichen maskiert und somit in den ASCII Code wandelt und für ISO-8859-1 verständlich werden.
function toURLParameter(text, isTXT)
{
	if (isTXT) return encodeURIComponent(text);
	return encodeURIComponent(toTXT(text));
}

// Gibt die Variable "text" so zurück, dass man sie in einer URL verschicken kann (z.B. für AJAX)
function toTXT(text)
{
	if (text==null) return "";
	var encodedText="";
	for (var i=0;i<text.length;i++)
	{
		var character=text.charCodeAt(i);
		if (character > 31 || character == 9 || character == 10 || character == 13)
		{
			if (character > 127)
			{
				encodedText=encodedText+"&#" + Number(character) + ";";
			}
			else
			{
				switch (character)
				{
					case 60: // <
						encodedText=encodedText+("&lt;");
						break;
					case 62: // >
						encodedText=encodedText+("&gt;");
						break;
					case 34: // "
						encodedText=encodedText+("&quot;");
						break;
					case 39: // '
						encodedText=encodedText+("&#039;");
						break;
					case 92: // \
						encodedText=encodedText+("&#092;");
						break;
					case 38: // &
						encodedText=encodedText+("&amp;");
						break;
					default:
						encodedText=encodedText+String.fromCharCode(character);
				}
			}
		}
	}
	return encodedText;
}

function getPageDimensions(iframe) {

	if(iframe==null)
	{	
		var db = document.body;
		var dde = document.documentElement;
	}
	else
	{
		var db = iframe.contentWindow.document.body;
		var dde = iframe.contentWindow.document.documentElement;
	}

	var pageWidth =  Math.max(db.scrollWidth, dde.scrollWidth, db.offsetWidth, db.clientWidth, dde.clientWidth);
	var pageHeight = Math.max(db.scrollHeight, dde.scrollHeight, db.offsetHeight, db.clientHeight, dde.clientHeight);
	
	return [pageWidth,pageHeight];
}
function showOverlayLoading()
{
	var overlayLoading=document.createElement('div');
	overlayLoading.id="overlayLoadingAnimation";
	if(ie6) overlayLoading.style.position="absolute"; else overlayLoading.style.position="fixed";
	overlayLoading.style.width="64px";
	overlayLoading.style.height="64px";
	overlayLoading.style.left="50%";
	overlayLoading.style.top="50%";
	overlayLoading.style.marginLeft="-32px";
	overlayLoading.style.marginTop="-32px";
	overlayLoading.style.zIndex=1000000+overlayZIndex-1;
	overlayLoading.style.backgroundColor="transparent";
	overlayLoading.style.backgroundImage="url(/portal/design/images/loadingAnimationOverlay.gif)";
	overlayLoading.style.backgroundRepeat="no-repeat";
	overlayLoading.style.backgroundPosition="50% 50%";
	document.body.appendChild(overlayLoading);
}
function showOverlayBackground(value)
{
	if(overlayBackgroundEffect!=null) overlayBackgroundEffect.cancel();
	
	var overlayBackground=document.getElementById("overlayBackground");
	var overlayBackgroundIframe=document.getElementById("overlayBackgroundIframe");
	var overlayLoading=document.getElementById("overlayLoadingAnimation");

	if (value==true)
	{
		var pageDimensions = this.getPageDimensions();
		if (overlayBackground!=null)
		{
			overlayBackground.style.display = "block";
			overlayBackground.style.zIndex = 1000000+overlayZIndex;
			overlayBackgroundEffect = new Effect.Opacity($('overlayBackground'), { duration: 0.3, to: 0.5 });
			if (ie6 && overlayBackgroundIframe!=null) overlayBackgroundIframe.style.display="block";
		}
		else
		{
			if(overlayBackgroundIframe!=null) document.body.removeChild(overlayBackgroundIframe);
			if(overlayLoading!=null) document.body.removeChild(overlayLoading);
			
			overlayBackground = document.createElement('div');
			overlayBackground.className = "ContainerOverlayBg";
			if(ie6)
			{ 
				var pageDimensions = this.getPageDimensions()
	
				overlayBackground.style.width = pageDimensions[0]+"px";
				overlayBackground.style.height = pageDimensions[1]+"px";
				overlayBackground.style.position = "absolute";

				// iFrame-Hinterlegung wg. Formularelementen, die sonst ueber Overlay waeren
				var overlayBackgroundIframe=document.getElementById("overlayBackgroundIframe");
				if (overlayBackgroundIframe!=null)
				{
					overlayBackgroundIframe.style.display="block";
				}
				else
				{
					overlayBackgroundIframe = document.createElement('iframe');
					overlayBackgroundIframe.src = "/portal/util/view/blank.htm";
					overlayBackgroundIframe.style.filter = "alpha (opacity=0)";
					overlayBackgroundIframe.marginWidth = 0;
					overlayBackgroundIframe.marginHeight = 0;
					overlayBackgroundIframe.frameBorder = 0;
					overlayBackgroundIframe.style.left = "0";
					overlayBackgroundIframe.style.top = "0";
					overlayBackgroundIframe.id = "overlayBackgroundIframe";
					overlayBackgroundIframe.style.width = pageDimensions[0]+"px";
					overlayBackgroundIframe.style.height = pageDimensions[1]+"px";
					overlayBackgroundIframe.style.position = "absolute";
					document.body.appendChild(overlayBackgroundIframe);
				}

			}
			else
			{ 
				overlayBackground.style.width = document.viewport.getWidth()+"px";
				overlayBackground.style.height = document.viewport.getHeight()+"px";
				overlayBackground.style.position = "fixed";
			}
			overlayBackground.style.backgroundColor = "black";
			overlayBackground.style.left = "0";
			overlayBackground.style.top = "0";
			overlayBackground.style.display = "block";
			overlayBackground.style.zIndex = 1000000+overlayZIndex;
			overlayBackground.id = "overlayBackground";
			document.body.appendChild(overlayBackground);
			$('overlayBackground').setOpacity(0.0);
	
			overlayBackgroundEffect = new Effect.Opacity($('overlayBackground'), { duration: 0.3, to: 0.5 });
			
			Event.observe(window, 'resize', function(){
				if(ie6)
				{
					var pageDimensions = this.getPageDimensions()
					overlayBackground.style.width = pageDimensions[0]+"px";
					overlayBackground.style.height = pageDimensions[1]+"px";
				}
				else
				{
					overlayBackground.style.width = document.viewport.getWidth()+"px";
					overlayBackground.style.height = document.viewport.getHeight()+"px";
				}
			});
		}
	}
	else
	{
		if (!overlayWindowMap || !overlayWindowMap.keys().length>0)
		{
			if (overlayBackground!=null)
			{
				overlayBackgroundEffect = new Effect.Opacity($(overlayBackground), { duration: 0.3, to: 0.0,
					afterFinish: function()
					{
						overlayBackground.style.display = "none";
					}
				});
			}
			if(ie6)
			{
				if (overlayBackgroundIframe!=null) overlayBackgroundIframe.style.display = "none";
			}
		}
	}
}

var overlayWindowMap=null;

function closeOverlayWindow(nameOrWindow,dontHideOverlayBackground)
{
	getTopParent().closeOverlayWindowInternal(nameOrWindow,dontHideOverlayBackground);
}

function closeOverlayWindowInternal(nameOrWindow,dontHideOverlayBackground)
{
	var name=null;
	if (nameOrWindow==null || nameOrWindow=="") name="overlayWindow";
	else
	{
		if (typeof nameOrWindow != "string")
		{
			name=nameOrWindow.name;
		}
		else
		{
			name=nameOrWindow;
		}
	}
	
	var overlayWindow=document.getElementById(name+"Container");
	if (overlayWindow!=null)
	{
		document.body.removeChild(overlayWindow);
		if(document.getElementById('overlayBackground')!=null && dontHideOverlayBackground!=true) 
		{
			document.getElementById('overlayBackground').style.zIndex-=4;
			overlayZIndex-=4;
		}
	}
	
	if (overlayWindowMap!=null)
	{
		overlayWindowMap.unset(name);
	}

	if(dontHideOverlayBackground!=true) showOverlayBackground(false);
}

function closeAllOverlayWindows()
{
	if (self==parent) closeAllOverlayWindowsInternal()
	else parent.closeAllOverlayWindowsInternal();
}

function closeAllOverlayWindowsInternal()
{
	if (overlayWindowMap!=null && overlayWindowMap.keys().length>0) 
	{
		var keys=overlayWindowMap.keys();

		for (var index = 0; index < keys.length; ++index) 
		{
			  var name = keys[index];
			  closeOverlayWindow(name);
		}
	}
}

function getTopParent()
{
	var theParent = self;
	while (theParent != theParent.parent && theParent.parent.FEP) theParent = theParent.parent;
	return theParent;
}

function resetOverlayWindow(name,axis)
{
	getTopParent().repositionOverlayWindowInternal(name,axis,false);
	getTopParent().resizeOverlayWindow(name,axis,false);
}
function repositionOverlayWindow(name,axis,init)
{
	getTopParent().repositionOverlayWindowInternal(name,axis,init);
}
function repositionOverlayWindowInternal(name,axis,init)
{
	if (name==null || name=="") name="overlayWindow";
	var overlayWindow = $(name+"Container");
	var overlayIframe = $(name+'IFrame');
	
	var iframeContentDimensions = getPageDimensions(overlayIframe);

	if(init!=null && init==true)
	{
		if(axis=='x' || axis=='both') overlayWindow.style.marginLeft = '-' + (iframeContentDimensions[0]/2) + 'px';
		if(axis=='y' || axis=='both') overlayWindow.style.marginTop =  '-' + (iframeContentDimensions[1]/2) + 'px';
	}
	else
	{
		iframeBody = $(overlayIframe.contentWindow.document.body);
		if(!ie6)
		{
			iframeBody.down('div').style.width = 'auto';
			iframeBody.down('div').style.display = 'table';
		}
		iframeContentDimensions = new Array(iframeBody.down('div').offsetWidth, iframeBody.down('div').offsetHeight);

		overlayWindow.morph('margin-top: -' + (iframeContentDimensions[1]/2) + 'px',{duration:0.3});
	}
}
function resizeOverlayWindow(name,axis,init)
{
	getTopParent().resizeOverlayWindowInternal(name,axis,init);
}
function resizeOverlayWindowInternal(name,axis,init)
{
	if (name==null || name=="") name="overlayWindow";
	var overlayWindow = $(name+"Container");
	var overlayIframe = $(name+'IFrame');
	
	var frameMargin = 0;
	var iframeContentDimensions = getPageDimensions(overlayIframe);
	
	if((ie6 || ie7) && overlayIframe && overlayIframe.contentWindow && overlayIframe.contentWindow.$$ && overlayIframe.contentWindow.$$(".frameMargin")!=null) // Breite wird sonst in alten IEs u.U. falsch berechnet
	{
		overlayIframe.contentWindow.$$(".frameMargin").each( function(item) { frameMargin+=parseInt(item.style.paddingLeft.replace(/px/g,"")) + parseInt(item.style.paddingRight.replace(/px/g,""));	} );
	}
	if(init!=null && init==true)
	{
		if(axis=='x' || axis=='both')
		{
			overlayWindow.style.width = (iframeContentDimensions[0] + frameMargin)+'px';
			overlayIframe.style.width = (iframeContentDimensions[0] + frameMargin)+'px';
		}
		if(axis=='y' || axis=='both')
		{
			overlayWindow.style.height = (iframeContentDimensions[1])+'px';
			overlayIframe.style.height = (iframeContentDimensions[1])+'px';
		}
	}
	else
	{
		iframeBody = $(overlayIframe.contentWindow.document.body);
		if(!ie6)
		{
			iframeBody.down('div').style.width = 'auto';
			iframeBody.down('div').style.display = 'table';
		}
		iframeContentDimensions = new Array(iframeBody.down('div').offsetWidth, iframeBody.down('div').offsetHeight);

		overlayWindow.morph('height:'+(iframeContentDimensions[1])+'px',{duration:0.3});
		overlayIframe.morph('height:'+(iframeContentDimensions[1])+'px',{duration:0.3});
	}
}
function openOverlayWindow(url,name,width,height,modal,left,top)
{
	getTopParent().openOverlayWindowInternal(url,name,width,height,modal,left,top,self);
}

function openOverlayWindowInternal(url,name,width,height,modal,left,top,opener)
{
		
	if (name==null || name=="") name="overlayWindow";

	var openInExistingOverlay = false;

	if(document.getElementById(name + 'Container') != null) openInExistingOverlay = true;
	
	closeOverlayWindow(name, true);

	if(!openInExistingOverlay && modal!=false) overlayZIndex+=2; else overlayZIndex-=2;

	if (modal!=false) showOverlayBackground(true);
	
	overlayZIndex+=2;

	var extHeight="";

	var extWidth="";
	
	if (width!=null)
	{
		width=""+width;
		if (width.indexOf("px")>=0) 
		{
			extWidth="px";
			width=width.replace("px","");
		}
		else
		if (width.indexOf("%")>=0) 
		{
			extWidth="%";
			width=width.replace("%","");
		} 
		else
		{
			extWidth="px";
		}
	}
	 
	if (height!=null)
	{
		height=""+height;
		if (height.indexOf("px")>=0) 
		{
			extHeight="px";
			height=height.replace("px","");
		}
		else
		if (height.indexOf("%")>=0)
		{
			extHeight="%";
			height=height.replace("%","");
		}
		else
		{
			extHeight="px";
		}
	}
	var overlayWindow = document.createElement('div');
	if (width!=null) overlayWindow.style.width=width+extWidth;
	if (height!=null) overlayWindow.style.height=height+extHeight;
	if(ie6) overlayWindow.style.position="absolute"; else overlayWindow.style.position="fixed";
	overlayWindow.style.zIndex=1000000+overlayZIndex;

	if (left==null)
	{
		overlayWindow.style.left="50%";
	}
	else
	{
		left=""+left;
		if (left.indexOf("px")==-1 && left.indexOf("%")==-1) left=left+"px"; 
		overlayWindow.style.left=left;
	}

	if (top==null)
	{
		if(!ie6) overlayWindow.style.top="50%"; else overlayWindow.style.top=(document.documentElement.scrollTop+(document.documentElement.offsetHeight/2))+"px";
	}
	else
	{
		top=""+top;
		if (top.indexOf("px")==-1 && top.indexOf("%")==-1) top=top+"px"; 
		overlayWindow.style.top=top;
	}

	overlayWindow.id = name+"Container";
	if (url==null || url=="") url=blankUrl;
	overlayWindow.innerHTML="<iframe id='"+name+"IFrame' style='background-color:transparent' name='"+name+"' frameborder='0' allowtransparency='true' scrolling='no' src='"+url+"' width='"+width+"' height='"+height+"'></iframe>";

	document.body.appendChild(overlayWindow);
	var iFrameWindow=document.getElementById(name+"IFrame");
	if( iFrameWindow.contentWindow ) iFrameWindow=iFrameWindow.contentWindow; // For IE5.5 and IE6
			
	if (overlayWindowMap==null) overlayWindowMap=new Hash();

	overlayWindowMap.set(name,"");

	overlayLoadingDelay = window.setTimeout(showOverlayLoading,1000);
	
	$(name+'IFrame').style.visibility='hidden';
	Event.observe($(name+'IFrame'), 'load', function(){
		
		var iframeContentDimensions = getPageDimensions($(name+'IFrame'));
		
		var cumulativeWidth = 0;
		var cumulativeHeight = 0;
		
		if(document.getElementById(name+'IFrame'))
		{
			if(width==null)
			{
				resizeOverlayWindow(name,'x',true);
			}
			if(height==null)
			{
				resizeOverlayWindow(name,'y',true);
			}
	
			if(left==null)
			{
				overlayWindow.style.left = '50%';
				if(width==null) repositionOverlayWindow(name,'x',true);
				else overlayWindow.style.marginLeft = '-' + (width/2) + 'px';
			}
			if(top==null)
			{
				overlayWindow.style.top = '50%';
				if(height==null) repositionOverlayWindow(name,'y',true);
				else overlayWindow.style.marginTop = '-' + (height/2) + 'px';
			}
	
			$(name+'IFrame').setOpacity(0.0);
			$(name+'IFrame').appear({ duration: 0.3, to: 1.0,
				beforeStart: function()
				{
					if(overlayWindow.offsetWidth>document.viewport.getWidth())
					{
						overlayWindow.style.position = 'absolute';
						overlayWindow.style.left = '10px';
						overlayWindow.style.marginLeft = '0';
					}
					if(overlayWindow.offsetHeight>document.viewport.getHeight())
					{
						overlayWindow.style.position = 'absolute';
						overlayWindow.style.top = '10px';
						overlayWindow.style.marginTop = '0';
					}
					$(name+'IFrame').style.visibility='visible';
				},
				afterFinish: function()
				{
					iFrameWindow.opener=opener;
					if (overlayLoadingDelay)
					{
						window.clearTimeout(overlayLoadingDelay);
						overlayLoadingDelay = null;
					}
					if(document.getElementById('overlayLoadingAnimation')!=null)
					{ 
						$('overlayLoadingAnimation').style.backgroundImage="none"; // removeChild erzeugt sonst HTTPS-Fehler in alten IEs
						document.body.removeChild($('overlayLoadingAnimation'));
					}
				}
			});
		}
	});

	return iFrameWindow;
}
var ____opener;

var __dialogCallbackHash;
function openDialog(dialogType,titleTXT,textTXT,callback,width,height,convertToTXT)
{
	if (!__dialogCallbackHash) __dialogCallbackHash = new Hash();
	id=toURLParameter(dialogType);
	titleTXT=toURLParameter(titleTXT,convertToTXT? false : true);
	textTXT=toURLParameter(textTXT,convertToTXT? false : true);
	if (typeof callback == 'function')
	{
		var callbackString = "callback"+Math.floor(Math.random()*1000001);
		__dialogCallbackHash.set(callbackString, callback);
		callback = '__dialogCallbackHash.unset(\"'+callbackString+'\")';
	}
	callback=toURLParameter(callback);
	openOverlayWindow(contextPath+"/util/dialog/dialog"+dialogType+".jsp?id="+id+"&title="+titleTXT+"&text="+textTXT+"&callback="+callback,dialogType,width,height);
}
function openHelp(helpItem,path,anchorValue,module)
{	
	var url=contextPath+'/util/help/master.jsp';
	if(helpItem && helpItem.length>0)
	{
		url+='?showItem='+helpItem;
		if(path && path.length>0) url+='&itemPath='+itemPath;
		if(module && module.length>0) url+='&module='+module;
		if(anchorValue && anchorValue.length>0) url+='&anchor='+anchorValue;
	}
	GP_AdvOpenWindow(url,'','fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes',1000,750);
}

function insertContentIntoField(aTag, type, id) 
{	
	if('text'==type)
	{
		var eTag='';
		var input= document.getElementById(id);			
		input.focus();
		/* für Internet Explorer */
		if(typeof document.selection != 'undefined') 
		{
			/* Einfügen des Formatierungscodes */
			var range = document.selection.createRange();
			var insText = range.text;
			range.text = aTag + insText + eTag;
			/* Anpassen der Cursorposition */
			range = document.selection.createRange();
			if (insText.length == 0) {
				range.move('character', -eTag.length);
			} else {
				range.moveStart('character', aTag.length + insText.length + eTag.length);      
			}
			range.select();
		}
		/* für neuere auf Gecko basierende Browser */
		else if(typeof input.selectionStart != 'undefined')
		{
			/* Einfügen des Formatierungscodes */
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
			/* Anpassen der Cursorposition */
			var pos;
			if (insText.length == 0) {
				pos = start + aTag.length;
			} else {
				pos = start + aTag.length + insText.length + eTag.length;
			}
			input.selectionStart = pos;
			input.selectionEnd = pos;
		}
	}else
	{				
		var the_iframe=document.getElementById(id);	
		if (the_iframe!=null)
		{				
			the_iframe.contentWindow.editInsertHtml(aTag);
		}	
	}
}


var FEP = function()
{
	
}

FEP.prototype.reloadPortletAjax = function(reloadUrl, afterOnReloadFunction)
{
	new Ajax.Request(reloadUrl, {
	  asynchronous: true,
	  encoding: "iso-8859-1",
	  onComplete: function(response) {
    		if (200 == response.status)
    		{
    			var content = response.responseText;
    			var reloadIds=fep.getParameterValues("reloadId",reloadUrl);
    			if (reloadIds==null) 
    			{
    				var reloadPortlets=fep.getParameterValues("reloadPortlet",reloadUrl);
        			if (reloadPortlets!=null)
        			{
        				reloadIds=new Array(reloadPortlets.length);
        				for (var i=0;i<reloadPortlets.length;i++)
        				{
        					reloadIds[i]="channelId_"+reloadPortlets[i];
        				}
        			}
    			}
    			
    			if (reloadIds!=null)
    			{
    				for (var i=0;i<reloadIds.length;i++)
    				{
    					var newContentOuterHtml = fep.getReloadContent(content, reloadIds[i]);
   						fep.reloadContent(reloadIds[i],newContentOuterHtml, true);
    				}
    			}

    			if (afterOnReloadFunction!=null) afterOnReloadFunction.call();
    			
    		}
    		else
    		{
    			alert('ajax error: '+reloadUrl);
    		}
  		}
	});
}



FEP.prototype.getParameter = function(key,url)
{
	var parameterValues=fep.getParameterValues(key,url);
	if (parameterValues.length>0) return parameterValues[0]; else return null;
}

FEP.prototype.getParameterValues = function(key,url)
{
	var _url;
	if (url)
	{
		_url=url;
	}
	else
	{
		_url=location.href;
	}
	var parameterValues=_url.toQueryParams()[key];
	
	if (parameterValues!=null)
	{
		if (typeof parameterValues == 'string') parameterValues=new Array(parameterValues);
	}
	return parameterValues;
}

FEP.prototype.reloadPortlet = function(reloadUrl)
{
	window.frames['loader'].window.location.replace(reloadUrl);
}

FEP.prototype.getReloadContent = function(content, reloadId)
{
	var startMarker = "<!-- beginReloadContent_"+reloadId+" -->";
	var endMarker = "<!-- endReloadContent_"+reloadId+" -->";
	var startIndex = content.indexOf(startMarker) + startMarker.length;
	var endIndex = content.indexOf(endMarker);
	return content.substring(startIndex, endIndex);
}

FEP.prototype.reloadContent = function(elementId, content, reloadOuterHtml)
{
	if (content && elementId)
	{
		var reloadElement=$(elementId);

		var prefix="reloadTmp_";
		if (reloadOuterHtml)
		{
			var pos=content.indexOf(elementId);
			content=content.substring(0,pos)+prefix+content.substring(pos);
		}
		
		var contentWithoutScripts=content.stripScripts();
		var contentScripts=content.extractScripts();

		if (Prototype.Browser.IE)
		{
			var contentStyles = fep.extractStyles(contentWithoutScripts);
			var contentWithoutScriptsAndStyles = fep.stripStyles(contentWithoutScripts);
			if (contentStyles && contentStyles.length && contentStyles.length > 0)
			{
				document.documentElement.firstChild.appendChild(document.createElement('STYLE'));
				for (var i=0;i<contentStyles.length;i++)
				{
					document.styleSheets[document.styleSheets.length-1].cssText += contentStyles[i];
				}
			}
			
			if (reloadOuterHtml) 
			{				
				Element.replace(reloadElement,contentWithoutScriptsAndStyles);
				var reloadTmpElement=$(prefix+elementId);
				reloadTmpElement.id=elementId;
			}
			else reloadElement.innerHTML=contentWithoutScriptsAndStyles;	
		}
		else 
		{
			reloadElement.innerHTML=contentWithoutScripts;
	
			if (reloadOuterHtml)
			{
				var firstChild=reloadElement.firstChild;
				var parentReloadElement=reloadElement.parentNode;
				while (firstChild)
				{
					parentReloadElement.insertBefore(firstChild,reloadElement);	
					firstChild=reloadElement.firstChild;
				}
				parentReloadElement.removeChild(reloadElement);
				
				var reloadTmpElement=$(prefix+elementId);
				reloadTmpElement.id=elementId;
				reloadElement=null;
			}
		}
		if (contentScripts)
		{
			var allScripts=null;
			for (var i=0;i<contentScripts.length;i++)
			{
				var script=contentScripts[i];
				
				script = script.replace("<!--", "").replace("//-->", "").replace("-->","").replace(/^\s*function +(.*)\(/img, "$1 = function(");
				
				if (script.indexOf("insertVideo")==-1 && script.indexOf("document.write")==-1)
				{
					if (allScripts==null) allScripts=script; else allScripts+="\n"+script;
				}
			}
			if (allScripts!=null)
			{
				try
				{
					eval(allScripts);
					/*var myScript=document.createElement("script");
			        myScript.type="text/javascript";
			        myScript.text=allScripts;                       
			        document.body.appendChild(myScript);*/
					if (window.addEventListener)
					{
						var registry = Element.retrieve(window, 'prototype_event_registry');
						if (registry)
						{
							var responders = registry.get("reload");
							if (responders)
							{
								responders.each(function(item)
								{
									item.handler.call(window);
									item.handler = Prototype.emptyFunction;
								});
							}
						}
					}
					else if (observedEvents && observedEvents != null && observedEvents.get("reload") != null && observedEvents.get("reload").get(window) != null)
			        {
				    	var onReloadEvents = observedEvents.get("reload").get(window);
					 	for (var i = 0; i < onReloadEvents.length; i++)
					 	{
							var handler = onReloadEvents[i];
							if (typeof(handler) == 'function')
							{
								handler.call(window, event);
								onReloadEvents[i] = Prototype.emptyFunction;
							}
						}
			    	}
				}
				catch(err)
				{
				  	alert(err);
				}
			}
		}

	}
	else
	{
		if (elementId)
		{
			$(elementId).innerHTML="";	
		}
	}
}
FEP.prototype.infoMsg=function(text)
{
	var infoMsgTextArea=$("infoMsgTextArea");
	if (!infoMsgTextArea)
	{
		infoMsgTextArea=document.createElement("textarea");
		infoMsgTextArea.id="infoMsgTextArea";
		infoMsgTextArea.style.width="600px";
		infoMsgTextArea.style.height="100px";
		document.body.appendChild(infoMsgTextArea);
		infoMsgTextArea=$("infoMsgTextArea");
	}
	infoMsgTextArea.value=infoMsgTextArea.value+text+"\n";
}

FEP.prototype.StyleFragment = '<style[^>]*>([\\S\\s]*?)<\/style>';
FEP.prototype.extractStyles = function(htmlContent)
{
	var matchAll = new RegExp(fep.StyleFragment, 'img');
    var matchOne = new RegExp(fep.StyleFragment, 'im');
    return (htmlContent.match(matchAll) || []).map(function(styleTag) {
      return (styleTag.match(matchOne) || ['', ''])[1];
    });
}

FEP.prototype.updateElement = function(url, elementId, evalScripts, afterOnReloadFunction) 
{
    new Ajax.Request(url, 
	{
		method: 'get',
		onSuccess: function(transport) 
		{
			var content = transport.responseText;
			if (!evalScripts) content = content.stripScripts()
			fep.reloadContent(elementId, content, false);
			if (afterOnReloadFunction) afterOnReloadFunction();
		},
		onException: function(e)
		{
			alert("ERROR: updateElement: loading url: \n"+url+" \ninto element: " + elementId + " failed");
		}
	});
}

FEP.prototype.stripStyles = function(htmlContent) 
{
    return htmlContent.replace(new RegExp(fep.StyleFragment, 'img'), '');
}

FEP.prototype.submitFormAjax = function(url, formId, elementId, evalScripts, afterOnReloadFunction, includedElements, options)
{
	var formEle = $(formId);
	if(url == null && formEle != null) url = formEle.action;
	var method = null;
	if(formEle != null) method = formEle.method;
	if(options != null && options['method'] != null) method = options['method'];
	if(method == null || "" == method) method="get";
	var queryStringBegin = -1;
	if(url != null)
	{
		queryStringBegin = url.indexOf('?');
	}
	var parameterObject = null;
	if(queryStringBegin != -1)
	{
		var queryPart = url.substring(queryStringBegin);
		url = url.substring(0, queryStringBegin);
		parameterObject = queryPart.toQueryParams();//geht so nicht, wenn url bereits mit toURLParameter konvertiert wurde
	}
	if(options != null && options['parameters'] != null && !(options['parameters'] instanceof String))
	{
		if(parameterObject == null) parameterObject = {};
		parameterObject = $H(parameterObject).update(options['parameters']);
		parameterObject = parameterObject.toObject();
	}
	var queryString = fep.getFormQueryString(formId, parameterObject, includedElements);
	
	var ajaxOptions = options == null ? {} : options;
	
	var overrideOptions =
	{
		method: method,
		parameters: queryString,
		onSuccess: function(transport) 
		{
			var content = transport.responseText;
			if (!evalScripts) content = content.stripScripts()
			if(elementId != null) fep.reloadContent(elementId, content, options!=null&&options['reloadOuterHtml']==true);
			if (afterOnReloadFunction) afterOnReloadFunction();
		},
		onException: function(e)
		{
			alert("ERROR: updateElement: loading url: \n"+url+(queryString != "" ? ("?"+queryString) : "")+" \ninto element: " + elementId + " failed");
		}
	};
	var tempHash = $H(ajaxOptions);
	tempHash.update(overrideOptions);
	ajaxOptions = tempHash.toObject();
	
	new Ajax.Request(url, ajaxOptions);
}

FEP.prototype.getFormQueryString = function(formId, paraObject, includedElements)
{
	var parameterObject = null;
	var elementsToInclude = null;
	if(includedElements != null)
	{
		for(var i = 0, length = includedElements.length; i < length; i++)
		{
			if(elementsToInclude == null) elementsToInclude = new Array();
			elementsToInclude.push($(includedElements[i]));
		}
		parameterObject = Form.serializeElements(elementsToInclude, {hash: true});
	}
	else
	{
		parameterObject = $(formId).serialize({hash: true});
	}
	if(paraObject != null) parameterObject = $H(parameterObject).merge($H(paraObject)).toObject();
	return toQueryParamsFromObject(parameterObject);
}

function toQueryParamsFromObject(parameterObject)
{
	var queryParams = "";
	
	if(parameterObject != null && !(parameterObject instanceof String))
	{
		for(var prop in parameterObject)
		{
			var currentValue = parameterObject[prop];
			if(currentValue instanceof Array)
			{
				for(var i = 0, length = currentValue.length; i < length; i++)
				{
					if(queryParams != "") queryParams += "&";
						queryParams += (toURLParameter(prop) + "=" + toURLParameter(currentValue[i]));
				}
			}
			else
			{
				if(queryParams != "") queryParams += "&";
						queryParams += (toURLParameter(prop) + "=" + toURLParameter(currentValue));
			}
		}
	}
	return queryParams;
}

var fep=new FEP();

/** Prints the date in a string according to the given format. */
Date.prototype.formatDate = function (str) {
	var m = this.getMonth();
	var d = this.getDate();
	var y = this.getFullYear();
	var wn = this.getWeekNumber();
	var w = this.getDay();
	var s = {};
	var hr = this.getHours();
	var pm = (hr >= 12);
	var ir = (pm) ? (hr - 12) : hr;
	var dy = this.getDayOfYear();
	if (ir == 0)
		ir = 12;
	var min = this.getMinutes();
	var sec = this.getSeconds();
	s["%a"] = Calendar._SDN[w]; // abbreviated weekday name [FIXME: I18N]
	s["%A"] = Calendar._DN[w]; // full weekday name
	s["%b"] = Calendar._SMN[m]; // abbreviated month name [FIXME: I18N]
	s["%B"] = Calendar._MN[m]; // full month name
	// FIXME: %c : preferred date and time representation for the current locale
	s["%C"] = 1 + Math.floor(y / 100); // the century number
	s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
	s["%e"] = d; // the day of the month (range 1 to 31)
	// FIXME: %D : american date style: %m/%d/%y
	// FIXME: %E, %F, %G, %g, %h (man strftime)
	s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
	s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
	s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
	s["%k"] = hr;		// hour, range 0 to 23 (24h format)
	s["%l"] = ir;		// hour, range 1 to 12 (12h format)
	s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
	s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
	s["%n"] = "\n";		// a newline character
	s["%p"] = pm ? "PM" : "AM";
	s["%P"] = pm ? "pm" : "am";
	// FIXME: %r : the time in am/pm notation %I:%M:%S %p
	// FIXME: %R : the time in 24-hour notation %H:%M
	s["%s"] = Math.floor(this.getTime() / 1000);
	s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
	s["%t"] = "\t";		// a tab character
	// FIXME: %T : the time in 24-hour notation (%H:%M:%S)
	s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
	s["%u"] = w + 1;	// the day of the week (range 1 to 7, 1 = MON)
	s["%w"] = w;		// the day of the week (range 0 to 6, 0 = SUN)
	// FIXME: %x : preferred date representation for the current locale without the time
	// FIXME: %X : preferred time representation for the current locale without the date
	s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
	s["%Y"] = y;		// year with the century
	s["%%"] = "%";		// a literal '%' character

	var re = /%./g;
	if (!Calendar.is_ie5 && !Calendar.is_khtml)
		return str.replace(re, function (par) { return s[par] || par; });

	var a = str.match(re);
	for (var i = 0; i < a.length; i++) {
		var tmp = s[a[i]];
		if (tmp) {
			re = new RegExp(a[i], 'g');
			str = str.replace(re, tmp);
		}
	}

	return str;
};

createTitleAsExampleValue = function()
{
	var items = Element.select(document.body, ".titleAsExampleValue");
	for (var i = 0; i < items.length; i++)
	{
		var item = $(items[i].id);
		item.style.color='gray';
		item.value=item.title;
		Event.observe(item, "focus", function(event)
		{
			var element = event.findElement(); 
			if (element.title == element.value)
			{
				element.value="";
				element.style.color='';
			}
		});
		
		Event.observe($(item.id), "blur", function(event)
		{
			var element = event.element();
			if (element.value == "")
			{
				element.value = element.title;
				element.style.color='gray';
			}
		});
	}
}

clearTitleAsExampleText = function()
{
	var items = $(document.body).select(".titleAsExampleValue");
	if (items && items.length) for (var i = 0; i < items.length; i++)
	{
		var item = $(items[i].id);
		if (item.value == item.title) item.value="";
	}
}

showTitleAsExampleText = function()
{
	var items = $(document.body).select(".titleAsExampleValue");
	if (items && items.length) for (var i = 0; i < items.length; i++)
	{
		var item = $(items[i].id);
		if (item.value == "") item.value=item.title;
	}
}

/* in ein input type='text' so reinmachen:
 * onkeypress="return allowChars(event, this, /[A-Za-z0-9_\-.]/);"
 *       das sind dann die erlaubten zeichen:   ^^^^^^^^^^^^^
 */                              
allowChars = function(event, element, allowedChars) 
{
    var val = element.value;
    event = event || window.event;
    var charCode = typeof event.which == "number" ? event.which : event.keyCode;
    // Ensure we only handle printable keys, excluding enter and space
    if (charCode && charCode > 32) 
    {
        var keyChar = String.fromCharCode(charCode);
        var mappedChar = allowedChars.test(keyChar) ? keyChar : '';
        var start, end;
        if (typeof element.selectionStart == "number" && typeof element.selectionEnd == "number") 
        {
            // Non-IE browsers and IE 9
            start = element.selectionStart;
            end = element.selectionEnd;
            element.value = val.slice(0, start) + mappedChar + val.slice(end);

            // Move the caret
            element.selectionStart = element.selectionEnd = start + ((mappedChar!='') ? 1 : 0);
        } 
        else if (document.selection && document.selection.createRange) 
        {
            // For IE up to version 8
            var selectionRange = document.selection.createRange();
            var textInputRange = element.createTextRange();
            var precedingRange = element.createTextRange();
            var bookmark = selectionRange.getBookmark();
            textInputRange.moveToBookmark(bookmark);
            precedingRange.setEndPoint("EndToStart", textInputRange);
            start = precedingRange.text.length;
            end = start + selectionRange.text.length;

            element.value = (val.slice(0, start) + mappedChar + val.slice(end));
            if (mappedChar!='') start++;

            // Move the caret
            textInputRange = element.createTextRange();
            textInputRange.collapse(true);
            textInputRange.move("character", start - (element.value.slice(0, start).split("\r\n").length - 1));
            textInputRange.select();
        }
    }
    else
    {
    	return true;
    }
	if ($(element).readAttribute('allowCharsOnChangeObserved') != "true")
	{
		$(element).writeAttribute('allowCharsOnChangeObserved', "true");
		$(element).observe("blur", function()
		{
			var theValue = element.value;
			for (var i=0; i < theValue.length; i++)
			{
				var keyChar = theValue.charAt(i);
				if (!allowedChars.test(keyChar)) element.value = element.value.replace(keyChar, '');
			}
		});
	}
    return false;
}

function addEntryToList(value, text, id)
{		
	var elOptNew = document.createElement('option');
	elOptNew.text = text;
	elOptNew.value = value;
	var elSel = document.getElementById(id);	
	try 
	{
		elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
	}
	catch(ex) 
	{
		elSel.add(elOptNew); // IE only
	} 
}

function removeValueFromList(listId) 
{
	var listArea = document.getElementById(listId);
	for (var i = 0; i<listArea.length; i++)
	{
		
		if (listArea.options[i].selected == true)
		{ 
			listArea.options[i] = null;
		}
	}
}

function checkAllEntriesInList(id)
{
	var listArea = document.getElementById(id);
	if(listArea)
	{
		var i;		
		for (i = listArea.length - 1; i>=0; i--) 
		{
			listArea.options[i].selected=true;
		}
	}
}


