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 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);
//	alert("scaleHeightToBrowserWorker elem="+elem+" elementID="+elementID+" reduceBy="+reduceBy+" minHeight="+minHeight);

	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);


	// hier passiert der fehler	
	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;
	
//	window.status="["+i+"] bwidth="+bwidth+" bheight="+bheight+" wwidth="+wwidth+" wheight="+wheight+" ewidth="+ewidth+" eheight="+eheight ;
	/*
	var newHeight = document.body.clientHeight - reduceBy;
	if (newHeight < minHeight)
		newHeight = minHeight;

	document.getElementById(elementID).style.height = newHeight;
	*/
}

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);				
					}
				}
			}
		}
				
		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)
	{		
		divId+='_'+pinEditId;	
	}		
	try
	{				
		document.getElementById(divId).style.display='none';		
	}catch(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)
 	{
 		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;
 		document.body.appendChild(infoBubble);

 		var infoBubbleArrow = document.createElement('div');
 		infoBubbleArrow.className = "infoBubbleArrow_"+infoType;
 		infoBubbleArrow.id = "infoBubbleArrow_"+targetElement.id;
 		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";
 		}

 		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";
 		}
 	}
 	function removeInfoBubble(targetElement)
 	{
 		var targetElement = $(targetElement);
 		if(document.getElementById("infoBubble_"+targetElement.id)!=null)
 		{
 			document.body.removeChild(document.getElementById("infoBubble_"+targetElement.id));
 			document.body.removeChild(document.getElementById("infoBubbleArrow_"+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)
{
	return escape(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 '<':
						encodedText=encodedText+("&lt;");
						break;
					case '>':
						encodedText=encodedText+("&gt;");
						break;
					case '\"':
						encodedText=encodedText+("&quot;");
						break;
					case '\'':
						encodedText=encodedText+("&#039;");
						break;
					case '\\':
						encodedText=encodedText+("&#092;");
						break;
					case '&':
						encodedText=encodedText+("&amp;");
						break;
					default:
						encodedText=encodedText+String.fromCharCode(character);
				}
			}
		}
	}
	return encodedText;
}

function getPageDimensions() {

	var db = document.body;
	var dde = 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 showOverlayBackground(value)
{
	var overlayBackground=document.getElementById("overlayBackground");
	if (value==true)
	{
		if (overlayBackground!=null)
		{
			overlayBackground.style.display="block";
		}
		else
		{

			var pageDimensions = this.getPageDimensions()
			if(ie6)
			{
				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.height=pageDimensions[1]+"px";
					overlayBackgroundIframe.style.width="100%";
					overlayBackgroundIframe.style.position="absolute";
					overlayBackgroundIframe.style.left="0px";
					overlayBackgroundIframe.style.top="0px";
					overlayBackgroundIframe.id="overlayBackgroundIframe";
					document.body.appendChild(overlayBackgroundIframe);
				}
			}

			overlayBackground = document.createElement('div');
			overlayBackground.className="ContainerOverlayBg";
			overlayBackground.style.height=pageDimensions[1]+"px";
			overlayBackground.style.width="100%";
			overlayBackground.style.backgroundColor="black";
			overlayBackground.style.position="absolute";
			overlayBackground.style.left="0px";
			overlayBackground.style.top="0px";
			overlayBackground.style.display="block";
			overlayBackground.style.filter="alpha(opacity=20)";
			overlayBackground.style.opacity="0.20";
			overlayBackground.style.zIndex=1000000;
			overlayBackground.id = "overlayBackground";
			document.body.appendChild(overlayBackground);
			
		}
	}
	else
	{
		if (overlayBackground!=null)
		{
			overlayBackground.style.display="none";
		}
		if(ie6)
		{
			var overlayBackgroundIframe=document.getElementById("overlayBackgroundIframe");
			if (overlayBackgroundIframe!=null)
			{
				overlayBackgroundIframe.style.display="none";
			}	
		}
	}
}

var overlayWindowMap=null;

function closeOverlayWindow(nameOrWindow,dontHideOverlayBackground)
{
	if (self==parent) closeOverlayWindowInternal(nameOrWindow,dontHideOverlayBackground);
	else parent.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 (overlayWindowMap!=null)
	{
		overlayWindowMap.unset(name);
	}

	if (overlayWindowMap==null || overlayWindowMap.keys().length==0) 
	{
		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 openOverlayWindow(url,name,width,height,modal,left,top)
{
	if (self==parent) 
	{
		openOverlayWindowInternal(url,name,width,height,modal,left,top,self);
	}
	else
	{
		parent.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";
	closeOverlayWindow(name);
	
	if (modal!=false) showOverlayBackground(true);

	if (width==null) width="400px"; else width=""+width;
	if (height==null) height="300px"; else height=""+height;

	var extHeight;
	var marginTop;

	var extWidth;
	var marginLeft;

	
	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.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');
	overlayWindow.style.width=width+extWidth;
	overlayWindow.style.height=height+extHeight;
	if(!ie6) overlayWindow.style.position="fixed"; else	overlayWindow.style.position="absolute";
	overlayWindow.style.zIndex=1000001;
	if (left==null)
	{
		left="50%";
		overlayWindow.style.left=left;
		overlayWindow.style.marginLeft="-"+(Math.floor(width/2))+extWidth;
	}
	else
	{
		left=""+left;
		if (left.indexOf("px")==-1 && left.indexOf("%")==-1) left=left+"px"; 
		overlayWindow.style.left=left;
	}

	if (top==null)
	{
		if(!ie6) top="50%"; else { top=(document.documentElement.scrollTop+(document.documentElement.offsetHeight/2))+"px"; }
		overlayWindow.style.top=top;
		overlayWindow.style.marginTop="-"+(Math.floor(height/2))+extHeight;
	}
	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,"");
	
	____opener = opener;
	window.setTimeout(function(){iFrameWindow.opener=____opener;}, 500); 
	return iFrameWindow;
}
var ____opener;

var __dialogCallbackHash;
function openDialog(dialogType,title,text,callback,width,height)
{
	if (!__dialogCallbackHash) __dialogCallbackHash = new Hash();
	id=toURLParameter(dialogType);
	title=toURLParameter(title);
	text=toURLParameter(text);
	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="+title+"&text="+text+"&callback="+callback,dialogType,width,height);
}
function openHelp(helpItem,path)
{	
	var url=contextPath+'/util/help/master.jsp';
	if(helpItem && helpItem.length>0)
	{
		url+='?showItem='+helpItem;
		if(path && path.length>0) url+='&itemPath='+itemPath;
	}
	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 newContent = fep.getReloadContent(content, reloadIds[i]);
   						fep.reloadContent(reloadIds[i],newContent);
    				}
    			}

    			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)
{
	if (content && elementId)
	{
		var contentWithoutScripts=content.stripScripts();
		var contentScripts=content.extractScripts();

		if (ie6 ||ie7 ||ie8)
		{
			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];
				}
			}
			$(elementId).innerHTML=contentWithoutScriptsAndStyles;
		}
		else $(elementId).innerHTML=contentWithoutScripts;

		
		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); 
				}
				catch(err)
				{
				  	alert(err);
				}
			}
		}

	}
}

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);
			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'), '');
}

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()
{
	//sollten wir diese funktion irgendwann mal wieder loswerden - funzt das hier trotzdem noch
	if (!Event.observe_orig) Event.observe_orig = Event.observe;
	
	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_orig(item, "focus", function(event)
		{
			var element = event.findElement(); 
			if (element.title == element.value)
			{
				element.value="";
				element.style.color='';
			}
		});
		
		Event.observe_orig($(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.approvalProcessForm).select(".titleAsExampleValue");
	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.approvalProcessForm).select(".titleAsExampleValue");
	for (var i = 0; i < items.length; i++)
	{
		var item = $(items[i].id);
		if (item.value == "") item.value=item.title;
	}
}
