	var logonWindow = null;
	
	var logonWindowHandler = null;
	
	function openLink(oid,openType,linkType,windowOpenProps) {		
		url = location.pathname;
		pos = url.lastIndexOf('/');
		if (pos > 1) {
			url = url.substr(0,pos);
		}

		if (typeof(linkType)=='undefined' || linkType=='co' || linkType=='me' ) 
			{
			oid=replaceMODEInOID(oid, portalChannel);
			oid=replaceNOCACHEInOID(oid);
			if (document.location.pathname.length >= 5)
				{
				if (document.location.pathname.substr(document.location.pathname.length - 4, 4) == ".jsp")
					{
					var strTemplatePath = document.location.pathname.substr(0, document.location.pathname.length - 4);
					url = url + "/c2c_start.jsp?aoid="+oid + "&aop=" + strTemplatePath;
					}
				else
					url = url + "/" + oid + ".html" + location.search ;
				}
			} 
		else 
			url = oid;

		switch (openType) {
			case "1": {
				location.href = url;
				break;
				}
			case "2": {
				newWindow = window.open(url);
				newWindow.focus();
				break;
				}
			case "3": {
				newWindow = window.open(url,'newWindow',windowOpenProps);
				newWindow.focus();
				break;
				}
			case "4": {
				frmContent = window.frames[contentFrameName];
				if (typeof(frmContent)=='undefined') {
					window.location.href = url;				
				} else {
					frmContent.location.href = url;
				}
				break;
				}
			default : {
				location.href = url;
				}
		}
	}

	function showLogon(objLogonPanel, strLogonText, strLogoffText) {				
	if ( objLogonPanel!=null ) {
			if ( getCookie('icon_cda_user')!=null ) {
			objLogonPanel.innerText=strLogoffText;
			} else  {
			objLogonPanel.innerText=strLogonText;
		 	}		
	}
	}
	
	function loginDialog() {
		userCookie=getCookie('icon_cda_user');			  
		if ( userCookie == null  ) {
		  logonWindowHandler = window.setInterval("checkLogonWindow()", 500);
		  logonWindow = window.open(strURL, "logon", "menubar=0,resizeable=0,status=0,height=180,width=350,left=100,top=100");
		} else {
		  // celete the cookie by setting its expiry date to be sometime in the past
		  var now = new Date();
		  var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);

		  document.cookie = escape("icon_cda_user") + '=' 
		           + '; EXPIRES=' + yesterday.toGMTString()
		           + '; PATH=/';

		  if (startURL.length>0) {
		    window.location.href = 'http://'+window.location.host + startURL;
		  } else {
  		    window.location.reload();
		  }
		}
	}
	
	
	function submitsearch(wContent) {
		searchFrm=wContent.document.SearchForm;
		if (searchFrm.s_term.value=='') {
			alert('Please insert a search value!');
		} else {
			searchFrm.action=wContent.location.href;
			searchFrm.submit();
		}
	}

	function newSearch(wContent) {
		wContent.document.SearchForm.submit();
	}
	
	function checkLogonWindow() {
		if (logonWindow != null) {
			if (logonWindow.closed) {			
				window.clearInterval(logonWindowHandler);
				logonWindow = null;
			
				strNewURL=null;
			    userCookie=getCookie('icon_cda_user');
			  
				if ( userCookie!= null  ) {
				// replace in Object ID the parameter "NO_CACHE" , not a very easy task
				top_url = window.location.href;
														
				if ( typeof(window.frames[0])=='undefined' ) {
				   nav_url=top_url;
				} else {
				   nav_url_loc = window.frames[0].location;	
				   nav_url=nav_url_loc.href;
				}
				strNewURL=replaceNOCACHE(top_url,nav_url);
				}
				
				if ( strNewURL!=null ) {
				  window.location.href=strNewURL;
				 } else {
				  window.location.reload();
				 }							   
				
			} else {
				//logonWindow.focus();
			}
		}
	}
	
	function getCookie(sName)
	{
	  // cookies are separated by semicolons
	  var aCookie = document.cookie.split("; ");
	  for (var i=0; i < aCookie.length; i++)
	  {
	    // a name/value pair (a crumb) is separated by an equal sign
	    var aCrumb = aCookie[i].split("=");
	    if (sName == aCrumb[0])
	      return unescape(aCrumb[1]);
	  }
	
	  // a cookie with the requested name does not exist
	  return null;
	}

	
	function replaceNOCACHE(aURL,bURL) {			
				arrayURL =aURL.split(',');
				lenArrayURL=arrayURL.length;
				OID=arrayURL[lenArrayURL-2];				
				if ( OID==null ) {
				    arrayURL2 =bURL.split(',');
					lenArrayURL2=arrayURL2.length;
					OID=arrayURL2[lenArrayURL2-2];	
					if ( OID==null) return null;
					arrayOID=OID.split('-');
					arrayOID[16]='7';								
					strOID=arrayOID.join('-');
					strNewURL=arrayURL[0]+'/1,,' + strOID + ',00.html';		
				
				   return strNewURL;	
				}
				
				arrayOID=OID.split('-');
				arrayOID[16]='7';								
				strOID=arrayOID.join('-');
				arrayURL[lenArrayURL-2]=strOID;
				strNewURL=arrayURL.join(',');
				
			return strNewURL;
	}
	
	function replaceNOCACHEInOID(OID) {																		
		 userCookie=getCookie('icon_cda_user');
		 if ( userCookie!= null  ) {
				arrayOID=OID.split('-');
				arrayOID[16]='31';								
				strOID=arrayOID.join('-');			
			} else {
				strOID=OID;
				}
		return strOID;
	}

	// Bugfix start
	// Defect 4955 fixed (Back in der CDA funktioniert nicht)
	function replaceMODEInOID(OID, portalChannel) {																		
		arrayOID=OID.split('-');
		if( portalChannel ) {
			arrayOID[10]='1';								
		} else {
			arrayOID[10]='0';								
		}
		strOID=arrayOID.join('-');			
		return strOID;
	}
	// Bugfix end
	
	function replaceNoCacheInTemplateAndOid(source) {
		 userCookie=getCookie('icon_cda_user');
		 if (( userCookie!= null ) && (source.indexOf('c2c_singleFrame_NoCache')==-1)) {
			arrayURL = source.split(',');
			lenArrayURL=arrayURL.length;
			oldOID=arrayURL[lenArrayURL-2];
			newOID='';
			if ( oldOID!=null ) {
				newOID = replaceNOCACHEInOID(oldOID);
			}
			if ((newOID!=null) && (newOID.length>0)) {
				source = source.replace( oldOID, newOID );
			}

			source = source.replace( 'c2c_singleFrame', 'c2c_singleFrame_NoCache' );
		}
		return source;
	}

	//dummy for ICON 3_1
	function swapImage() {
		//var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
		//if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
	//dummy for ICON 3_1
	function swapImgRestore() { //v3.0
		//var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
