

function corePopUp(page, name, details) {
   	newWin=window.open(page, name, details);
   	newWin.focus();
}

function corePrintPopUp(path){
  var wnd = window.open(path,'Printversion','width=620,height=450,scrollbars=1,resizable=1,status=1,toolbar=0,menubar=0,locationbar=0');
  wnd.focus();
}

function openPopUp(url, name, settings){
var popUpName = name;
eval(popUpName + " = window.open('"+ url +"','"+ name +"','"+ settings +"')");
}

function openWindow(type, param) {
	var wnd;
	switch(type) {
		case "internet":
			wnd = window.open(param,'internet','');
			break;
		case "kpt":
			if(window.name=='tree_content'||
			   window.name=='content'||
			   window.name=='onlineanwalt'||
			   window.name=='popUpWindow')
			{
				if (this.parent.parent.window.opener!=null)
					// frame onlineanwalt
					this.parent.parent.window.opener.location=param;
				else if (this.parent.window.opener!=null)
					// frame content/tree_content
					this.parent.window.opener.location=param;
				else
					// target window with name 'kpt'
					wnd = window.open(param,'kpt','');
			}		
			else
			{
				if (window.name==''||window.name=='kpt')
					window.location=param;
				else
					wnd = window.open(param,'kpt','');
			}
			break;
		case "onlineanwalt":
		case "gesetze":
		case "casetex":
			var sUrl="";
			if (param!="")
			{
				var sUrl="?url=%2f"+type+"%2f"+param;
				while(sUrl.search("/")>=0)
					sUrl=sUrl.replace("/","%2f");
			}
			wnd = window.open('/kpt/onlineanwalt/'+sUrl,'onlineanwalt','width=800,height=600,scrollbars=1,resizable=1,status=0,toolbar=0,menubar=0,locationbar=0');
			break;
		case "kompass":
		case "sitemap":
			var sUrl=param;
			if (param!="")
			{
				if (param.substring(0,10).toLowerCase()=="/channels/")
					sUrl=param.substring(9,param.length);
			}
			if (type=="sitemap")
			{
				wnd = window.open(sUrl,'kompass','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=350,height='+(screen.availHeight-10)+',left=0,top=0');

			}
			else
			{
				wnd = window.open(sUrl,'kompass','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=600,height=600,left=0,top=0');
				wnd.resizeTo(600,600);
			}
			wnd.focus();
			break;
		case "guidedtour":
			var sUrl=param;
			wnd = window.open(sUrl,'guidedtour','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=800,height=640,left=0,top=0');
			wnd.focus();
			break;
	}
	if(wnd) wnd.focus();
}

function getOpenerURL()
{ // checks for sitemap the URL of the base - window, where the sitempa is called
	var openerPath, getOpenerURL, openerSearchStr;
	getOpenerURL= top.opener.window.location.href;
	openerSearchStr = top.opener.window.location.search;
	if(openerSearchStr) 
		getOpenerURL = getOpenerURL.replace(openerSearchStr,'')
	openerPath = getOpenerURL.indexOf(topObjHandle+"/");
	openerPath = getOpenerURL.slice(openerPath, getOpenerURL.length);
	return openerPath;
}

//opens the Kompass popup window and shows the search results.
//this function is called from the compass navigation panel at the left side in the main kpt window.
function openSearchWindow(link)
{
	try{
		link = link + escape(document.forms[0]["searchtext"].value);
		//link = encodeURI(link);
		var kompassWindow = window.open(link,'kompass','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=350,height=500,left=0,top=0');
		kompassWindow.moveTo(0,0);
		kompassWindow.resizeTo(screen.availWidth-250,screen.availHeight);
		kompassWindow.focus();		
	}
	catch(e)
	{}
	if(kompassWindow) kompassWindow.focus();
	return false;
}

//usefull in the event mytextfield.onkeydown() to fire the button click event of the assigned button.
//this function is called from the compass navigation panel at the left side in the main kpt window.
function controlEnterKeyHit(buttonUniqueId)
{
	if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) 
	{
		try
		{
			document.all[buttonUniqueId].click();
		}
		catch(e){}
		return false;
	} 
	
	else return true;
}

//cancels the form submit event, if the given field is not empty
//used for the search input fields
//this function is called from the compass and inform navigation panels at the left side in the main kpt window.
//at last, the function clears the value (the entered text) of the input field
function cancelFormSubmit(inputFieldId)
{
	try
	{
		if (document.all[inputFieldId].value != null && document.all[inputFieldId].value != "")
		{
			document.all[inputFieldId].value = "";
			return false;
		}	
	}
	catch(e){}
	return true;
}
