function printdirect()
{
	var dociframe = frames['documentwindow'];
	if(!dociframe)
	{
		dbg(iERR, "printdirect\n!dociframe");
		return false;
	}
	{
		var src = g_sCurrentSrc;
		if((src != null) && (src.indexOf("_scaffold.htm") > 2))
		{
			var sOnlyAnchor = frames['documentwindow'].window.location.hash.toLowerCase().replace(/#/, "");
			frames['documentwindow'].window.scaffold_printdoc(sOnlyAnchor,sOnlyAnchor,0);
			return false;
		}
	}
	dociframe.focus();
	dociframe.print();
	return false;
}
function add2outputman(oLnk,sBeanName, sAli, bReloadAfterOK)
{
	if((sAli == null) || (sAli == "") && (__scaffoledlnk_clicked_ali != null))
	{
		sAli = __scaffoledlnk_clicked_ali;
	}
	
    var s="jsessionid="+sessionid;
    
	var sParams = "object="+sBeanName+"&invalidatesession=false&ajaxcall=1&alias="+sAli+"&action=add2outputman&tmpstmp="+(new Date()).getMilliseconds();
    var sUrl 	= getpath(removeparams(self.location.href))+"/standard/jsp/shiajaxcommunicator.jsp;"+s+"?"+sParams;
    var sContent= s + "&" + sParams;
    var myreq 	= getHTTPObject();
	
    if (myreq == null)
    {
        dbg(iERR, "add2outputman\n!myreq");
        return false;
    }
    if(true)
    {
        function add2outputman_response()
        {
            if(myreq == null)
            {
                dbg(iERR, "add2outputman_response\n!myreq");
                return false;
            }
            if (myreq.readyState    != 4)           //4 == "Complete" in ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
                return;
            if (!responseIsSuccess(myreq))
                return;
            var sAnswer = trim(myreq.responseText);
			if (sAnswer.length != 1)
			{
				dbg(iERR, "add2outputman_response\n!sAnswer:'"+sAnswer+"'");
				return false;
			}
			if(sAnswer == "2")
			{
				msgbox(oLnk,"Das Dokument ist bereits im Ausgabemanager.", sBeanName, false, false, true);
				return false;
			}
			if(sAnswer == "1")
			{
				msgbox(oLnk,"Das Dokument wurde im Ausgabemanager hinzugefügt.", sBeanName, bReloadAfterOK, false, true);
				return false;
				//alert("Das Dokument wurde im Ausgabemanager hinzugefügt.");
				try
				{
					reloadmypage(sBeanName);
				}
				catch(e)
				{
					try
					{
						reloadmypage("dummybean");
					}
					catch(e2) {}
				}
				return false;
			}
			
			alert("Bitte, wählen Sie ein gültiges Dokument!");
            return false;
        }
    }
    myreq.onreadystatechange = add2outputman_response;
    myreq.open("POST", sUrl, true);
    myreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    if (window.XMLHttpRequest)
    {
        myreq.send(sContent);
    }
    else if (window.ActiveXObject)  // branch for IE/Windows ActiveX version
    {
       myreq.send(sContent);
    }	
	return false;	
}
 function limitedSearchPopUp(popId,framepopId,start)
 { 
 	var popupDiv 		= document.getElementById(popId);
	var popupDivIframe 	= document.getElementById(framepopId);
    if(!popupDiv || !popupDivIframe)
	{
		//alert(popupDivIframe+"\n"+popupDiv+"\n"+popId+"\n"+framepopId);
    	return;
	}
     var topPos = getPosTop(start);
     
     popupDiv.style.top 	= topPos +18+"px";
     popupDiv.style.left 	= getPosLeft(start)+"px";
     popupDivIframe.style.top	= getPosTop(start)+18+"px";
     popupDivIframe.style.left	= getPosLeft(start)+"px";
     
     var pos = 500;
     
     if(popupDiv.style.display=='none')
	 {
         dojo.lfx.explode(start,framepopId, pos).play();
         dojo.lfx.explode(start,popId, pos).play();
     }
     else
	 {
         dojo.lfx.implode(popId, start, pos).play();
         dojo.lfx.implode(framepopId, start, pos).play();
     }
 }
 
var g_onfocushitlistdropdown_checked = false;
function onfocushitlistdropdown(select, sBeanName)
{
	if(g_onfocushitlistdropdown_checked)
		return;
	g_onfocushitlistdropdown_checked = true;
	
	if(select.options.length > 2)
	{
		return;
	}
	if(select.options.length == 2)
	{
		if(select.options[1].value != "")
		{
			return;
		}
	}
    var s="jsessionid="+sessionid;
	var sParams = "object="+sBeanName+"&invalidatesession=false&ajaxcall=1&action=getFilterOptionsAsList&tmpstmp="+(new Date()).getMilliseconds();
    var sUrl 	= getpath(removeparams(self.location.href))+"/standard/jsp/shiajaxcommunicator.jsp;"+s+"?"+sParams;
    var sContent= s + "&" + sParams;
    var myreq 	= getHTTPObject();
	
    if (myreq == null)
    {
        dbg(iERR, "onfocushitlistdropdown\n!myreq");
        return false;
    }
    if(true)
    {
        function onfocushitlistdropdown_response()
        {
            if(myreq == null)
            {
                dbg(iERR, "onfocushitlistdropdown_response\n!myreq");
                return false;
            }
            if (myreq.readyState    != 4)           //4 == "Complete" in ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
                return;
            if (!responseIsSuccess(myreq))
                return;
            var sAnswer = trim(myreq.responseText);
			if (sAnswer.length < 1)
			{
				dbg(iERR, "onfocushitlistdropdown_response\n!sAnswer:'"+sAnswer+"'");
				return false;
			}
			
			var aAnswer 		= sAnswer.split("</option>");
			var iValueBegin 	= "<option value=\"".length;
			var iValidEntries 	= 0;
			for(var i=0; i < aAnswer.length; i++)
			{
				if(trim(aAnswer[i]) == "") continue;
				if(iValidEntries < 1)
				{
					iValidEntries++;
					continue;	//"Suche eingrenzen" can be let unchanged
				}
				var iValueEnd = aAnswer[i].indexOf('\"', iValueBegin);
				var sValue 	  = aAnswer[i].substring(iValueBegin, iValueEnd);
				var sLabel 	  = aAnswer[i].substring(aAnswer[i].indexOf('>', iValueEnd)+1);
				var sStyle 	  = "";//"margin-left:0em";

				var sLastSl = "";
				if(true)
				{
					for(var iS=0; iS < sLabel.length; iS++)
					{
						if(sLabel.charAt(iS) != String.fromCharCode(160))break;
						sLastSl += (String.fromCharCode(160) + String.fromCharCode(160));
					}
					if(sLastSl.length > 0)
					{
						//sLabel = sLastSl + sLabel.substring(sLastSl.length() * "&nbsp;".length);
						//sStyle = "margin-left:"+(sLastSl.length/4)+"em";
					}
				}
				/*
				if(true)
				{
					var iStyle 	  = aAnswer[i].indexOf(" style=\"");
					if (iStyle > 1)
						sStyle = aAnswer[i].substring(iStyle + " style=\"".length, aAnswer[i].indexOf('\"', iStyle + " style=\"".length+ 1));
				}
				*/
				if(iValidEntries < 2)
				{
					select.options[select.options.length-1] = new Option(sLabel,sValue,false,false);
					iValidEntries++;
					continue;
				}
				var o = new Option(sLabel,sValue,false,false);
				if(sStyle != "")
				{
					o.setAttribute("style",sStyle);
				}
				select.options[select.options.length] = o;
				iValidEntries++;
			}
			//ie: how to open select again?
            return false;
        }
    }
    myreq.onreadystatechange = onfocushitlistdropdown_response;
    myreq.open("POST", sUrl, true);
    myreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    if (window.XMLHttpRequest)
    {
        myreq.send(sContent);
    }
    else if (window.ActiveXObject)  // branch for IE/Windows ActiveX version
    {
       myreq.send(sContent);
    }
	return false;
}
function onchangehitlistdropdown_ajax(select, sBeanName, sAli)
{
    var s="jsessionid="+sessionid;
	var sParams = "object="+sBeanName+"&invalidatesession=false&alias="+sAli+"&ajaxcall=1&action=onChangeFilter&tmpstmp="+(new Date()).getMilliseconds();
    var sUrl 	= getpath(removeparams(self.location.href))+"/standard/jsp/shiajaxcommunicator.jsp;"+s+"?"+sParams;
    var sContent= s + "&" + sParams;
    var myreq 	= getHTTPObject();
	
    if (myreq == null)
    {
        dbg(iERR, "onchangehitlistdropdown_ajax\n!myreq");
        return false;
    }
    if(true)
    {
        function onchangehitlistdropdown_ajax_response()
        {
            if(myreq == null)
            {
                dbg(iERR, "onchangehitlistdropdown_ajax_response\n!myreq");
                return false;
            }
            if (myreq.readyState    != 4)           //4 == "Complete" in ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
                return;
            if (!responseIsSuccess(myreq))
                return;
            self.location.href = "./index.jsf?from=onChangeFilter&selecttab=1&tmpstmp="+(new Date()).getMilliseconds();
            return false;
        }
    }
    myreq.onreadystatechange = onchangehitlistdropdown_ajax_response;
    myreq.open("POST", sUrl, true);
    myreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    if (window.XMLHttpRequest)
    {
        myreq.send(sContent);
    }
    else if (window.ActiveXObject)  // branch for IE/Windows ActiveX version
    {
       myreq.send(sContent);
    }
	return false;
}
function onchangehitlistdropdown_form(select, sBeanName, sAli)
{
	document.getElementById("hitlist_hitlistdropdown_selected_alias").value = sAli;
	document.getElementById("hitlistdropdownform").submit();
	return false;
}
function onchangehitlistdropdown(select, sBeanName)
{
	var sAli = select.options[select.selectedIndex].value;
	//onchangehitlistdropdown_form(select, sBeanName, sAli);
	//onchangehitlistdropdown_ajax(select, sBeanName, sAli);
	//return;
    var s=";jsessionid="+sessionid;
    self.location.href = "./"+getfilename(self.location.href)+s+"?"+sBeanName+"_hitlistdropdown_selected_alias="+sAli+"&invalidatesession=false&beanname="+sBeanName+"&t="+(new Date()).getMilliseconds();
    return false;
}
function onNewSearch(btn, sFormIDPart)
{
    var frm = null;
    while(btn)
    {
        if(btn.tagName && (btn.tagName.toLowerCase() == "form"))
        {
            frm = btn;
            break;
        }
        btn = btn.parentNode;
    }
    if(!frm)
    {
        dbg(iERR, "onNewSearch\nE1");
        return false;
    }
	for(var i=0; i < frm.elements.length; i++)
	{
		if(frm.elements[i].type == "text")
		{
			frm.elements[i].value = "";
			continue;
		}
		if(frm.elements[i].type == "select-one")
		{
			frm.elements[i].value = "";
			continue;
		}
		//alert("id:"+btn.form.elements[i].id+"\ntype:"+btn.form.elements[i].type+"\nvalue:"+btn.form.elements[i].value);
	}
	return false;
}
function msgbox(ele, sTxt, sBeanName, bReloadAfterOK, bPopupRights)
{
	msgbox(ele, sTxt, sBeanName, bReloadAfterOK, bPopupRights, true);
	return false;
}
function msgbox(ele, sTxt, sBeanName, bReloadAfterOK, bPopupRights, bAsDlg)
{
	if(typeof(ele) == "string")
	{
		ele = document.getElementById(ele);
	}
	var odiv = document.createElement("div");
	var divid = (new Date()).getMilliseconds();
	odiv.id = divid;
	odiv.style.zIndex 		= 1100;
	odiv.style.position 	= "absolute";
	odiv.style.display 		= "block";
	odiv.style.border 		= "solid 1px black";
	odiv.style.visibility 	= "visible";
	odiv.style.backgroundColor = "white";
	//document.getElementsByTagName("body")[0].appendChild(odiv);	//changes scrollpos in iframe in ie6 sometimes!
	document.getElementsByTagName("div")[0].appendChild(odiv);

	var sOnClick = "document.getElementById('"+divid+"').style.border='0px';document.getElementById('"+divid+"').innerHTML='';" + (bReloadAfterOK ? "reloadmypage('"+sBeanName+"');" : "");
	if (bAsDlg) 
		odiv.innerHTML = "<table><tr><td class='bg-color7' style='font-size:12px;font-weight:bold;font-family:arial;background:transparent url(./boorberg/images/htg/formhead.gif) repeat-x scroll left bottom;border-bottom:solid 1px #333333;vertical-align:middle;'>Nachricht</td></tr><tr><td style='font-size:11px;font-family:arial;background-color:white;'>" + sTxt + "</td></tr><tr><td style='text-align:center;'><input type=button title='OK' value='OK' onclick=\"" + sOnClick + "\" class='expandedFormopt lamelle2' style='width:80px;margin-right:10px;margin-top:2px;margin-bottom:2px;font-size:12px;font-weight:bold;font-family:arial;background:transparent url(./boorberg/images/htg/button.gif)' /></td></tr></table>";
	else 
	{
		odiv.innerHTML = "<div style='font-size:11px;font-family:arial;background-color:white;'>" + sTxt + "</div>";
	}
	
	var left= 0;
	var top	= 0;
	
	if(!ele || ((ele.offsetHeight < 2) && (ele.offsetWidth < 2)))
	{
		var iWinWidth = document.all ? (document.documentElement.clientWidth  ? document.documentElement.clientWidth  : document.body.clientWidth)  : window.innerWidth;
		var iWinHeight= document.all ? (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight) : window.innerHeight;
		left= iWinWidth/2;
		top	= iWinHeight/2;
	}
	else
	{
		if (!bPopupRights) 
		{
			left = getPosLeft(ele) - odiv.offsetWidth + ele.offsetWidth;
		}
		else
		{
			left = getPosLeft(ele) + ele.offsetWidth;
		}
		top	= getPosTop(ele) + ele.offsetHeight;
	}
	odiv.style.pixelLeft= left;
	odiv.style.pixelTop = top;
	odiv.style.left 	= left+"px";
	odiv.style.top 		= top+"px";
	return odiv;
}
function bblogout()
{
	self.location.href = "j_spring_security_logout?url="+window.location.pathname+"&t="+(new Date()).getMilliseconds();
	return false;
	self.location.href = "./standard/jsp/logout.jsp?tmpstmp="+(new Date()).getMilliseconds();
	return false;
}
function bblogin(sUrl, sParam)
{
	self.location.href = "./boorberg/static/makrolog.protected.jsp?t="+(new Date()).getMilliseconds();
	return false;
}
function dogoto(frm, sBeanName)
{
	var sGoToPara = null;
	
	if (frm['gotopara'] != null)
		sGoToPara = frm['gotopara'].value;
	if((sGoToPara == null) && (frm('gotopara') != null))
		sGoToPara = frm('gotopara').value;
	if((sGoToPara == null) || (sGoToPara == "") || (sGoToPara == " "))
	{
		return false;
	}
	var s=";jsessionid="+sessionid;
	self.location.href = "./"+getfilename(self.location.href)+s+"?"+sBeanName+"_dogoto_para="+sGoToPara+"&invalidatesession=false&beanname="+sBeanName;
	return false;
}
function bboutlooktoolbarclick(iTabClicked)
{
	self.location.href = "./index.jsf?from=tabclick&selecttab="+iTabClicked+"&tmpstmp="+(new Date()).getMilliseconds();
	return false;
}
function gotosite(iSite, sBeanName)
{
    var s=";jsessionid="+sessionid;
    self.location.href = "./"+getfilename(self.location.href)+s+"?"+sBeanName+"_hitlistdropdown_navigation="+iSite+"&invalidatesession=false&beanname="+sBeanName+"&t="+(new Date()).getMilliseconds();
    return false;	
}
function onClickedVersion(sId, sFN, sAli)
{
	IPDoLinkFS("./bbdisplay.jsp?file="+sFN);
	return false;
	var s=";jsessionid="+sessionid;
    self.location.href = "./"+getfilename(self.location.href)+s+"?gotoversion=1&VersId="+sId+"&fn="+sFN+"&doc="+sFN+"&invalidatesession=false&beanname=BBParaVer&t="+(new Date()).getMilliseconds();
    return false;
}
function onClickedContext(sId, sFN, sAli)
{
	IPDoLinkFS("./bbdisplay.jsp?file="+sFN);
	return false;
	var s=";jsessionid="+sessionid;
    self.location.href = "./"+getfilename(self.location.href)+s+"?gotocontext=1&contexttargetId="+sId+"&invalidatesession=false&beanname=BBBrowseDocs&t="+(new Date()).getMilliseconds();
    return false;
}

var __hintele = null;
function showHint(e, sHint,bRights)
{
	__hintele = msgbox(e, sHint, "sBeanName", false/*!reloadafterok*/, bRights, false/*!asdlg*/);
}
function hideHint(e, sHint)
{
	if(!__hintele)return;
	__hintele.style.visibility 	= "hidden";
}
function linksourcetabchange(iClicked)
{
	var i=0;
	while(true)
	{
		i++;
		//var elsc1 = document.getElementById("linksourcecomment1_"+i);
		//var elsc2 = document.getElementById("linksourcecomment2_"+i);
		var elsi  = document.getElementById("linksourceicon_"+i);
		if(!elsi)break;
		var elst  = document.getElementById("linksourcetext_"+i);
		var elstb = document.getElementById("linksourcetable_"+i);
		
		//elsc1.className =  ((i == iClicked) ? "" : "op");
		//elsc2.className =  ((i == iClicked) ? "" : "op");
		elsi.className =   ((i == iClicked) ? "" : "op");
		elst.className =   ((i == iClicked) ? "" : "op");
		elstb.className =  ((i == iClicked) ? "" : "op");
		
		document.getElementById("linksourcelist_"+i).style.display = ((i == iClicked) ? "inline" : "none");
		
		elstb.parentNode.style.borderBottomWidth = ((i == iClicked) ? "0px" : "1px");
	}
	return false;
}	
