var BROWSER = "UNKNOWN";
var BROWSER_VERSION = "UNKNOWN";
var BROWSER_GENERATION;
var NS4 = false;
		
/*--------------------------------------------------------------------------------------------------------------*/

if (navigator.appName != null)  // get browser app name
{
	if (navigator.userAgent.indexOf("Opera") != -1)
		BROWSER = "Opera";
	else if (navigator.appName == "Microsoft Internet Explorer")
		BROWSER = "ie";
	else if (navigator.appName == "Netscape")
		BROWSER = "nn";
}

if (navigator.appVersion != null)  // get browser version number
{
	BROWSER_VERSION = navigator.appVersion;
	var index = BROWSER_VERSION.indexOf (" ");
	BROWSER_VERSION = BROWSER_VERSION.substring (0, index);
	
	if (BROWSER == "ie") // fix for ie 5.0 appVersion bug
	{                                         // (returns 4.0 version number)
	
		BROWSER_VERSION = navigator.appVersion.substring (navigator.appVersion.indexOf("MSIE") + 5);
		BROWSER_VERSION = BROWSER_VERSION.substring (0, BROWSER_VERSION.indexOf (";"));
	}
	else
	{
		BROWSER_VERSION = navigator.appVersion.substring (0, navigator.appVersion.indexOf(" "));
	}
}

BROWSER_GENERATION = BROWSER_VERSION.substring (0, BROWSER_VERSION.indexOf (".")) - 0;

if (BROWSER == 'nn' && BROWSER_GENERATION < 5)
		NS4 = true;
else 	NS4 = false;


/*--------------------------------------------------------------------------------------------------------------*/
function OpenWindow (win_href, win_title, win_width, win_height, win_center, with_scrollbars, win_resizable, with_bar)
{

	if (win_height > screen.availHeight - 50)
		win_height = screen.availHeight - 50;

	win_width = win_width - 0;
	if (with_scrollbars == 'true')
	{
		win_width += 20;
	}
	
	var win_flags = "width=" + win_width + ",height=" + win_height;
	win_flags += ",resizable=yes,dependent=yes";
	
	if (with_scrollbars == 'true')
	{
		win_flags += ",scrollbars=yes";
	}
	
	if (win_center)
	{
		var win_left = Math.ceil ((screen.availWidth - win_width) / 2);
		var win_top  = Math.ceil ((screen.availHeight - win_height) / 3);
		win_flags	+= ",left=" + win_left + ",top=" + win_top;
	}
	
	win_flags += ",resizable=" + ((win_resizable == "true") ? "yes" : "no");
	win_flags += ",location=" + ((with_bar == "true") ? "yes" : "no");
	win_flags += ",menubar=" + ((with_bar == "true") ? "yes" : "no");
	win_flags += ",toolbar=" + ((with_bar == "true") ? "yes" : "no");

//	alert (win_flags);
	 
	window.open (win_href, win_title, win_flags);
}


/*--------------------------------------------------------------------------------------------------------------*/
function FIND(item) 
{
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}


/*--------------------------------------------------------------------------------------------------------------*/

function ShowPara (para_name)
{
	var para = FIND (para_name);

	if (para)
	{
		if (para.style.visibility != "visible")
		{
			para.style.visibility = "visible";
			para.style.display = "block";
		}
		else
		{
			para.style.visibility = "hidden";
			para.style.display = "none";
		}
	}
}

document.onmousemove = GetPos;
var mouse_posx;
var mouse_posy;
var menu_preview = "";

function GetPos (event)
{
	if (BROWSER == "ie")
	{
		mouse_posx = window.event.clientX + document.body.scrollLeft;
		mouse_posy = window.event.clientY + document.body.scrollTop;
	}
	else
	{
		mouse_posx = event.pageX + window.pageXOffset;
		mouse_posy = event.pageY + window.pageYOffset;
	}

	
}

/*--------------------------------------------------------------------------------------------------------------*/

function HighLight (id, col)
{
	var elem = document.getElementById(id);
	if (elem) 
	{
		elem.style.backgroundColor = (col) ? col: '#A9DFCC';
	}
}

function MenuPreview (text)
{
	var menu_preview = FIND ("menu_preview");
	var text_menu_preview = FIND ("text_menu_preview");
	
	if (menu_preview && text_menu_preview)
	{
		if (text != menu_preview)
		{
			switch (BROWSER)
			{
				case "ie": 
					text_menu_preview.innerText = text; 
					break;
				default:
					text_menu_preview.firstChild.nodeValue = text; 
					break;
			}
		}
		
		if (text == "")
		{
			menu_preview.style.visibility = "hidden";
		}
		else
		{
			menu_preview.style.visibility = "visible";
			menu_preview.style.top = mouse_posy + 12;
			menu_preview.style.left = mouse_posx + 12;
		}
	}
	
	menu_preview = text;
}

/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------*/

var offset 				= 0;
var step					= 4;
var scr 					= 0;
var scroll_on 			= false;
var block_ypos 		= 0;
var block_height 		= 0;
var content_height 	= 400;
var delay				= 0;


/*--------------------------------------------------------------------------------------------------------------*/

function text_height (height)
{
	content_height = height;
}

/*--------------------------------------------------------------------------------------------------------------*/

function init_scroll (ypos, ysize)
{
	scr 				= ypos;
	block_height 	= ysize;
	block_ypos		= ypos;
	para = FIND ("maintext_08");
	if (para)
	{
		para.style.clip = "rect("+ offset + "px auto  "+ (block_ypos + block_height - scr) + "px auto)";
	}
}

/*--------------------------------------------------------------------------------------------------------------*/

function scroll (dir)
{
	para = FIND ("maintext_08");
	
	if (para && offset + step * dir >= 0 && offset + step * dir < content_height - block_height)
	{
		offset += (step * dir);
		scr -= (step * dir);
		para.style.clip = "rect("+ offset + "px auto  "+ (block_ypos + block_height - scr) + "px auto)";
		para.style.top = scr;
		
		/*
		document.debug.offset.value = offset;
		document.debug.scr.value = scr;
		*/
		
		if (scroll_on)
			setTimeout("scroll(" + dir + ")", delay);
	}
}

/*--------------------------------------------------------------------------------------------------------------*/

function tongle_scroll(state, dir)
{
	scroll_on = state;
	if (state)
	{
		setTimeout("scroll(" + dir + ")", delay);
	}
}

function WriteNav()
{
	document.write ('<table cellpadding="4" cellspacing="4" border="0">				<tr>					<td id="m1" onmousemove="HighLight (\'m1\', \'#BDE07A\'); MenuPreview (\'zur person\')" onmouseout="HighLight (\'m1\'); MenuPreview (\'\')" class="menu" >						<img src="images/s.gif" class="menu"/>				</td>				<td class="menu" style="background-color: #E0D47A;">psychologische&#160;beratung und&#160;behandlung</td>										<td id="m3" onmousemove="HighLight (\'m3\', \'#BDE07A\'); MenuPreview (\'mediation\')" onmouseout="HighLight (\'m3\'); MenuPreview (\'\')" class="menu">			<img src="images/s.gif" class="menu"/>					</td>					<td id="m4" onmousemove="HighLight (\'m4\', \'#BDE07A\'); MenuPreview (\'wahlpsychologische diagnostik\')" onmouseout="HighLight (\'m4\'); MenuPreview (\'\')" class="menu">	<img src="images/s.gif" class="menu"/>		</td>					<td id="m5" onmousemove="HighLight (\'m5\', \'#BDE07A\'); MenuPreview (\'supervision\')" onmouseout="HighLight (\'m5\'); MenuPreview (\'\')" class="menu">						<img src="images/s.gif" class="menu"/>					</td>					<td id="m6" onmousemove="HighLight (\'m6\', \'#BDE07A\'); MenuPreview (\'coaching\')" onmouseout="HighLight (\'m6\'); MenuPreview (\'\')" class="menu">						<img src="images/s.gif" class="menu"/>					</td>					<td id="m7" onmousemove="HighLight (\'m7\', \'#BDE07A\'); MenuPreview (\'arbeitspsychologie\')" onmouseout="HighLight (\'m7\'); MenuPreview (\'\')" class="menu">						<img src="images/s.gif" class="menu"/></td></tr></table>');

	//document.

}

