var ie = navigator.userAgent.toLowerCase().indexOf("msie")>-1 && navigator.userAgent.toLowerCase().indexOf("opera")< 0;
var ie7 = navigator.userAgent.toLowerCase().indexOf("msie 7.")>-1;

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
}
else
	MSDetect = "true";


<!-- ************************************************** -->

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 MM_preloadImages() { //v3.0
  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() { //v3.0
  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 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";
		}
	}
}

<!-- ************************************************** -->

function HideDiv (para_name)
{
	var para = FIND (para_name);
	if (para)
	{
		para.style.visibility = "hidden";
		para.style.display = "none";
	}
}

<!-- ************************************************** -->

function ShowDiv (para_name)
{
	var para = FIND (para_name);
	if (para)
	{
		para.style.visibility = "visible";
		para.style.display = "block";
	}
}

<!-- ************************************************** -->

function SwapMenuIcon (icon_image)
{
	if (icon_image)
	{
		var srcname = icon_image.src;
		var gif_pos = srcname.indexOf (".gif");
		var name_pos = srcname.indexOf ("_open");
		var newname = "";
		if (name_pos >= 0)
			newname = srcname.substr (0, name_pos) + "_close";
		else
		{
			name_pos = srcname.indexOf ("_close");
			newname = srcname.substr (0, name_pos) + "_open";
		}
		newname += ".gif";
		icon_image.src = newname;
	}
}

<!-- ************************************************** -->

function Hilight (icon_image)
{
	if (icon_image)
	{
		var srcname = icon_image.src;
		var gif_pos = srcname.indexOf (".gif");
		var active_pos = srcname.indexOf ("_active");
		var newname = "";
		if (active_pos >= 0)
			newname = srcname.substr (0, active_pos);
		else
			newname = srcname.substr (0, gif_pos) + "_active";
		newname += ".gif";
		icon_image.src = newname;
	}
}

<!-- ************************************************** -->

function Mark (row, mode)
{
	row.bgColor= (mode) ? '#DEE2F1' : '#ffffff';
}

<!-- ************************************************** -->

function SetOpenIcon (icon_id)
{
	Hilight (FIND (icon_id));
}

<!-- ************************************************** -->

function toggleSel (chkBox) 
{
	checkSubTasks(chkBox, chkBox.checked);
}

<!-- ************************************************** -->

function checkSubTasks(chkBox, value) 
{
	var elems = document.getElementsByTagName("input");
	var i = 0;
	for (i = 0; i <= elems.length-1; i++) 
	{
		if ((elems[i].type == "checkbox") && (elems[i].id.substr(0, chkBox.id.length) == chkBox.id) && (elems[i].id.length > chkBox.id.length)) 
		{
			elems[i].checked = value;
			checkSubTasks(elems[i], value);
		}
	}
}

<!-- ************************************************** -->

function NumStr (string, length)
{
	var result = "";
	var zerocount = length - string.length;
	if (zerocount > 0)
	{
		for (i = 0; i != zerocount; i++)
			result += "0";
	}
	result += string;
	return result;
}

<!-- ************************************************** -->

function OutputDate (lang)
{
	var thisdate = new Date();
	var m_de  	= new Array ("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
	var m_en		= new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	var result 	= "";
	var month  	= thisdate.getMonth();
	var daystr	= thisdate.getDate() + "";
	
	result += daystr + (lang=="de" ? "." : "") + "&#160;";
	result += (lang == "de" ? m_de[month] : m_en[month]) + "&#160;";
	result += thisdate.getYear() + "&#160;";
	result += NumStr (thisdate.getHours() + "", 2) + ":" + NumStr (thisdate.getMinutes() + "", 2) + "&#160;";
	return result;
}

<!-- ************************************************** -->

function winOpen(url, breite, hoehe) 
{
      // Errechnet Koordinaten, um das Popup zentriert zu platzieren
      links = (screen.width/2)-(breite/2);
      oben = (screen.height/2)-(hoehe/2);
      window.open(url,"popup","height="+hoehe+",width="+breite+",status = no,toolbar = no,menubar = no,location = no,resizable = no,titlebar = no,scrollbars = no,fullscreen = no,top ="+oben+",left ="+links);
}

<!-- ************************************************** -->

var scaling = 0;
var scaling_factor = 2;

function ScaleFontSize (object_name, scale_factor)
{
	var obj = FIND (object_name);
	if (obj)
	{
		scaling += scale_factor;
		scaling = Math.min (Math.max (scaling, 0), 2);
		SkaleFontSizeObjects (obj, scaling);
		var fontsize = FIND ('font_size');
		if (fontsize) 
			fontsize.style.fontSize = 10 + scaling;
	}
}

<!-- ************************************************** -->

function SkaleFontSizeObjects (obj, scaling)
{
	SkaleFontSizeObjectsTyped (obj, "h1", 16, scaling);
	SkaleFontSizeObjectsTyped (obj, "h2", 14, scaling);
	SkaleFontSizeObjectsTyped (obj, "h3", 13, scaling);
	SkaleFontSizeObjectsTyped (obj, "p", 12, scaling);
	SkaleFontSizeObjectsTyped (obj, "td", 12, scaling);
	SkaleFontSizeObjectsTyped (obj, "a", 12, scaling);
	SkaleFontSizeObjectsTyped (obj, "span", 12, scaling);
}

<!-- ************************************************** -->

function SkaleFontSizeObjectsTyped (root_object, object_name, default_size, scaling)
{
	var objects = root_object.getElementsByTagName (object_name);
	if (objects)
	{
		var count_objects = objects.length;
		var i;
		for (i = 0; i != count_objects; i++)
		{
			objects[i].style.fontSize = default_size + scaling_factor * scaling;
			SkaleFontSizeObjects (objects[i], scaling);
		}
	}
}

<!-- ************************************************** -->

function PageNavOk (buttonname)
{
	var enabled = true;
	if (!page_nr && (buttonname == 'img_page_first' || buttonname == 'img_page_prev'))
		enabled = false;
	else if (page_nr == page_count - 1 && (buttonname == 'img_page_next' || buttonname == 'img_page_last'))
		enabled = false;
		
	return enabled;
}

<!-- ************************************************** -->

function PageNavSetStatus (buttonname)
{
	var button_obj = FIND (buttonname);
	if (button_obj)
		button_obj.src = img_path + buttonname.substr (4) + (PageNavOk (buttonname) ? "" : "_inactive") + ".gif";
}

<!-- ************************************************** -->

function PageNav (buttonname)
{
	var new_page_nr = page_nr;
	switch (buttonname)
	{
		case "img_page_first":
			new_page_nr = 0;
			break;
		case "img_page_prev":
			new_page_nr = Math.max (--new_page_nr, 0);
			break;
		case "img_page_next":
			new_page_nr = Math.min (++new_page_nr, page_count - 1);
			break;
		case "img_page_last":
			new_page_nr = page_count - 1;
			break;
	}
	if (new_page_nr != page_nr)
	{
		PageNewPage (new_page_nr);
	}
}

<!-- ************************************************** -->

function PageNavSelect (selectobj)
{
	PageNewPage (selectobj.value - 0);
}

<!-- ************************************************** -->

function ShowDefaultPage (default_page_id)
{
	PageNavInit();
	var open_page_nr = -1;
	var query_page_id;
	var urlstr = document.URL + "";
	var query_page_pos = urlstr.indexOf ("#");
	if (query_page_pos != -1)
	{
		query_page_id = urlstr.substr (query_page_pos + 12);
		open_page_nr = GetPageNr (query_page_id);
	}

	if (open_page_nr == -1)
	{
		open_page_nr = GetPageNr (default_page_id);
	}
	
	PageNewPage (open_page_nr, true);
}


<!-- ************************************************** -->

function GetPageNr (page_id)
{
	var i; 
	var result = -1;

	for (i = 0; i != page_count; i++)
	{
		if (String (page_ids[i]) == String (page_id))
		{
			result = i;
		}
	}
	
	return result;	
}

<!-- ************************************************** -->

function PageNewPage (new_page_nr, firsttime)
{
	if (!firsttime)
	{
		ShowPara ('para' + page_ids[page_nr], false);
		ShowPara ('para_buttons' + page_ids[page_nr], false);
	}
	
	page_nr = new_page_nr;
	ShowPara ('para' + page_ids[page_nr], true);
	ShowPara ('para_buttons' + page_ids[page_nr], true);
	
	var inputfield = FIND ("input_page_nr");
	if (inputfield) 
		inputfield.value = (page_nr + 1) + "";
	
	var selectbox = FIND ('page_select');
	if (selectbox)
		selectbox.value = new_page_nr;
		
	PageNavInit();
}

<!-- ************************************************** -->

function PageNavInput()
{
	var inputfield = FIND ("input_page_nr");
	if (inputfield)
	{
		var user_input = inputfield.value - 1;
		if (isNaN (user_input) || user_input < 0 || user_input > page_count - 1 || user_input == page_nr)
			inputfield.value = (page_nr + 1) + "";
		else
			PageNewPage (user_input);
	}
	return false;
}

<!-- ************************************************** -->

function PageNavInit()
{
	PageNavSetStatus ('img_page_first');
	PageNavSetStatus ('img_page_prev');
	PageNavSetStatus ('img_page_next');
	PageNavSetStatus ('img_page_last');
	var inputfield = FIND ("input_page_nr");
	if (inputfield) 
		inputfield.value = (page_nr + 1) + "";
}

<!-- ************************************************** -->

var glossary_on = false;


function ShowGlossary (on_title, off_title, page_type)
{
	glossary_on = !glossary_on;
	if (glossary_on)
	{
		if (page_type == 'HELP') FIND ('JL_container_content').style.backgroundImage = "url(s.gif)";
		HideDiv ("contentcontainer");
		ShowDiv ("glossarycontainer");
		SetText ("glossarybutton", off_title);
	}
	else
	{
		if (page_type == 'HELP') FIND ('JL_container_content').style.backgroundImage = "url(ri/report2006/images/keydata_bg.jpg)";
		ShowDiv ("contentcontainer");
		HideDiv ("glossarycontainer");
		SetText ("glossarybutton", on_title);
	} 
}

<!-- ************************************************** -->

function BuildGlossary()
{
	for (var glossary_word in glossary) 
	{
		document.write ("<tr>");
		document.write ("<td class='title'>" + glossary_word + "<td />");
		document.write ("<td>" + glossary[glossary_word] + "<td />");
		document.write ("</tr>");
	}
}


<!-- ************************************************** -->

function BookmarkPage (url_name, error_message) 
{ 
	if (window && window.external)
	{
		window.external.AddFavorite (window.location.href, url_name); 
	}
	else
	{
		alert (error_message); 
	}
}

<!-- ************************************************** -->

var help_on = 0;
var help_show_how_to = true;

function ActivateHelp (on_title, off_title, help_show_how_to_text)
{
	help_on = !help_on;
	
	if (help_on)
	{
		HilightHelpAllObjs (true);
		SetText ("helpbutton", off_title);
	}
	else
	{
		HilightHelpAllObjs (false);
		HideDiv ("help_popup");
		SetText ("helpbutton", on_title);
	}
	if (help_show_how_to) alert (help_show_how_to_text);
	help_show_how_to = false;
}

<!-- ************************************************** -->

function HilightHelpAllObjs (onoff)
{
		HilightHelpObjs ('table', onoff);
		HilightHelpObjs ('a', onoff);
		HilightHelpObjs ('p', onoff);
		HilightHelpObjs ('td', onoff);
		HilightHelpObjs ('span', onoff);
}

<!-- ************************************************** -->

function HilightHelpObjs (type, onoff)
{
	var allObjects = document.getElementsByTagName (type);
	var color = onoff ? "#6CA2CB" : "";
//	var border = onoff ? "#ff0000 1px dotted" : "0px";
	var ObjClass;


	for (i = 0; i < allObjects.length; i++)
	{
		ObjClass = allObjects[i].className + "";
		if (ObjClass.indexOf ("helppopup") != -1)
		{
			allObjects[i].style.backgroundColor = color;
//			allObjects[i].style.border = border;
		}
	}
	
}

<!-- ************************************************** -->

function ShowHelp (obj, help_id)
{
	if (help_on)
	{
		BubbleInfo (help [help_id]);
	//	SetAttrib (obj, "title", help [help_id]);
	//	obj.style.backgroundColor = "#f9f300";
		obj.style.cursor = "help";
	}
}

<!-- ************************************************** -->

function HideHelp (obj)
{ 
	if (help_on)
	{
		BubbleInfoOff();
	//	SetAttrib (obj, "title", "");
	//	obj.style.backgroundColor = "";
		obj.style.cursor = "";
	}
}

<!-- ************************************************** -->

function SetText (node_id, text)
{
	var elem = FIND (node_id);
	if (elem)
		elem.firstChild.nodeValue = text;
}

<!-- ************************************************** -->

function SetAttrib (node, attrib_name, attrib_value)
{
	if (node)
	{
		var new_attrib = document.createAttribute (attrib_name);
		new_attrib.nodeValue = attrib_value;
		node.setAttributeNode (new_attrib);
	}
}

<!-- ************************************************** -->

document.onmousemove = GetPos;
var mouse_posx = 0;
var mouse_posy = 0;
var menu_preview = "";

function GetPos (event)
{
	if (ie)
	{
		mouse_posx = window.event.clientX + document.body.scrollLeft;
		mouse_posy = window.event.clientY + document.body.scrollTop;
	}
	else
	{
		mouse_posx = event.pageX;
		mouse_posy = event.pageY;
	}
	// window.status = "mouse: " + mouse_posx + "/" + mouse_posy + " - win: " + (window.event.clientX + document.body.scrollLeft) + "/" + (window.event.clientY + document.body.scrollTop) + " - document: " + window.event.clientX + "/" + window.event.clientY + " - winsize: " + jlGetWinInfo ("docwidth") + "/" + jlGetWinInfo ("docheight");
}

<!-- ************************************************** -->

function BubbleInfoGlossary (glossary_word)
{
	BubbleInfo (glossary [glossary_word]);
}

<!-- ************************************************** -->

function BubbleInfo (bubble_text)
{
	var bubble_obj = FIND ("glossary_bubble");
	if (bubble_obj)
	{
		SetText ("text_glossary_bubble", bubble_text);
		if (mouse_posy + 12 > jlGetWinInfo ("docheight") - 50)
		{	
			bubble_obj.style.top = ""; 
			bubble_obj.style.bottom = 20 - ((ie) ? (ie7 ? document.body.scrollTop  : 0) : window.pageYOffset); 
		}
		else
		{
			bubble_obj.style.top = mouse_posy + 12;
			bubble_obj.style.bottom = ""; 
		}
		if (mouse_posx + 200 > jlGetWinInfo ("docwidth") - 10)
		{
			bubble_obj.style.right = 20 - ((ie) ? document.body.scrollLeft : window.pageXOffset);
			bubble_obj.style.left = "";
		}
		else
		{
			bubble_obj.style.left = mouse_posx + 12;
			bubble_obj.style.right = "";
		}
		ShowDiv ("glossary_bubble");
	}
}

function RealEscape (intext)
{
	var i = 0;
	var result = "";
	for (i = 0; i < intext.length; i++)
	{
		result += "&#" + intext.charCodeAt(i) + ";";
	}

	return result;
}

<!-- ************************************************** -->

function BubbleInfoOff()
{
		HideDiv ("glossary_bubble");
}

<!-- ************************************************** -->
function MarkGlossaryWords (root_obj_name)
{
	if (glossary)
	{
		var root_obj = FIND (root_obj_name);
		if (root_obj)
		{
			var marked_content = root_obj.innerHTML;
			var counter = 0;
			var marked_word;
			var word_pos;
			var last_word_pos;
	
			for (var glossary_word in glossary) 
			{
				word_pos = marked_content.indexOf (glossary_word);
				while (word_pos != -1)
				{
					if (marked_content.substr (word_pos - 13, 10) != "BubbleInfo")
					{
						marked_word = "<span class='glossary_word' onmousemove='BubbleInfoGlossary (\"" + RealEscape (glossary_word) + "\")' onmouseout='BubbleInfoOff()'>" + RealEscape (glossary_word) + "</span>";
						marked_content = marked_content.replace (glossary_word, marked_word);
					}
					last_word_pos = word_pos;
					word_pos = (marked_content.substr (word_pos + marked_word.length)).indexOf (glossary_word);
					if (word_pos != -1) word_pos += last_word_pos + marked_word.length;
				}
			}
			root_obj.innerHTML = marked_content;
		}
	}
}

<!-- ************************************************** -->

function jlGetWinInfo (info_type)
{
	var result = 0;
	switch (info_type)
	{
		case "width": result = ie ? document.body.clientWidth : window.innerWidth; break;
		case "height": result = ie ? document.body.clientHeight : window.innerHeight; break;
		case "docwidth": result = ie ? document.body.clientWidth + document.body.scrollLeft : window.innerWidth; break;
		case "docheight": result = ie ? document.body.clientHeight + document.body.scrollTop : window.innerHeight; break;
	}
	return result;
}

