
ms_OptionalJump="";
ms_OnLoadMessageTitle="";
ms_OnLoadMessageText="";
ms_OnLoadMessageInfo="";
ms_OnLoadMessageLink="";
ms_OnLoadMessageTarget="";

// -------------------------------------------------------------------------------------------------------------------

function closeWnd()
{
	window.name="fgfgfg";
};

// -------------------------------------------------------------------------------------------------------------------

function OptionalJump(as_OptionalJump)
{
  if (as_OptionalJump.length == 0)
	return;

  location.hash="#" + as_OptionalJump;
  return;
}

// -------------------------------------------------------------------------------------------------------------------
function ShowMessage(as_Title, as_Text, as_Info, as_Link, as_Linktarget)
{
    if (as_Title.length == 0 || as_Text.length == 0)
	return;

    if(as_Info.length > 0)
	InfoBox(as_Title, as_Text, as_Info, as_Link, as_Linktarget);
     else
	MessageBox(as_Title, as_Text);
}

// -------------------------------------------------------------------------------------------------------------------

function MessageBox(as_Title, as_Text)
{
  w = window.open("", "MESSAGEBOX", "dependent=yes,resizable=yes,status=no,menubar=no,locationbar=no,width=250,height=100");

  w.document.writeln("<HTML><TITLE>" + as_Title + "</TITLE><BODY bgcolor=lightsteelblue>");
  w.document.writeln("<TABLE width=100% border=0 cellspacing=0 cellpadding=0><TR valign=center><TH><FONT FACE=ARIAL>");
  w.document.writeln(as_Text);
  w.document.writeln("<FORM><INPUT TYPE=BUTTON onBlur='this.focus()' onClick='window.close()' value='   Close   '> </FORM>");
  w.document.writeln("</TH></TR></TABLE>");
  w.document.writeln("</BODY></HTML>");
  w.document.close();
 // w.document.forms[0].elements[0].focus();

}

// -------------------------------------------------------------------------------------------------------------------

function InfoBox(as_Title, as_Text, as_Info, as_Link, as_Linktarget)
{
  w = window.open("", "MESSAGEBOX", "dependent=yes,resizable=yes,status=no,menubar=no,locationbar=no,width=400,height=200");

  w.document.writeln("<HTML><TITLE>" + as_Title + "</TITLE>");
  w.document.writeln("<link rel=stylesheet type=\"text/css\" href=\"/CSS/Basis.css\">");
  w.document.writeln("<BODY bgcolor=lightsteelblue>");
  w.document.writeln("<TABLE width=100% border=0 cellspacing=0 cellpadding=0><TR ALIGN=LEFT valign=TOP><TH>");

  if(as_Link.length > 0)
  {
	w.document.writeln("<A href=\"" + as_Link + "\" target=\"" + as_Linktarget + "\">");
	w.document.writeln("<IMG src=\"/IMAGE/joblink.gif\" alt=\"Protokoll\" BORDER=0>");
  }

  w.document.writeln(as_Text + "<hr>");
  if(as_Link.length > 0)
	  w.document.writeln("</A>");

  w.document.writeln("<i>" + as_Info + "</i><hr>");

  w.document.writeln("<FORM><INPUT TYPE=BUTTON onBlur='this.focus()' onClick='window.close()' value='   Schliessen   '> </FORM>");
  w.document.writeln("</TH></TR></TABLE>");
  w.document.writeln("</BODY></HTML>");
  //w.document.close();
 // w.document.forms[0].elements[0].focus();
}

// -------------------------------------------------------------------------------------------------------------------

function ScrollToEnd()
{
  y = document.all.Doc.offsetHeight;
  window.scrollTo(0,y);
}

// -------------------------------------------------------------------------------------------------------------------
// Ajax-Requests


var http_request = false;
var responseText = "";	// == Caption MinVal MaxVal Current Prozent Infotext
var dummyNr = 0;		// Wird hochgezählt, damit request nicht gecached wird

function sendRequest(url, sync)
{
	if (window.XMLHttpRequest) // Mozilla, Safari,...
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/plain');		// Zumindest bisher nur immer nur Text
      }
	}
	else if (window.ActiveXObject) // IE
	{
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}

	if (!http_request)
	{
		alert('Fehler beim Erzeugen eines Ajax-Requests.');
		return false;
	}
	http_request.onreadystatechange = alertContents;
	if(sync == null)
		http_request.open('GET', url, true);
	else
		http_request.open('GET', url, sync);

	http_request.send(null);
	return true;
}
function postRequest(url, formParams, sync)
{
	if (window.XMLHttpRequest) // Mozilla, Safari,...
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/plain');		// Zumindest bisher nur immer nur Text
      }
	}
	else if (window.ActiveXObject) // IE
	{
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}

	if (!http_request)
	{
		alert('Fehler beim Erzeugen eines Ajax-Post-Requests.');
		return false;
	}
	http_request.onreadystatechange = alertContents;
	http_request.open('POST', url, sync);
	http_request.setRequestHeader("Content-Type","text/plain");
	//http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http_request.send(formParams);
	return true;
}

function alertContents()
{
	if (http_request.readyState == 4)
	{
		if (http_request.status == 200)
		{
			responseText = http_request.responseText;			
		}
		else
		{
			alert('There was a problem with the request:' + http_request.status );
		}		
	}
}

function disableElementTree(tree)
{
	if(tree.hasChildNodes())
	{
		for(var i=0; i < tree.childNodes.length; ++i)
		{
			disableElementTree(tree.childNodes[i]);
		}
	}
	else
	{
		if( tree.nodeType == 1)
		{
			var dis = document.createAttribute("disabled");
			dis.nodeValue = "true";
			tree.setAttributeNode(dis);
		}
	}
}

function enableElementTree(tree)
{
	if(tree.hasChildNodes())
	{
		for(var i=0; i < tree.childNodes.length; ++i)
		{
			enableElementTree(tree.childNodes[i]);
		}
	}
	else
	{
		if( tree.nodeType == 1)
		{
			tree.removeAttribute("disabled");
		}
	}
}

function formToQuery(formId)
{
	var query = "";
	var form = document.getElementById(formId);

	if(form == null)
		return "";

	for(var i=0; i < form.length; ++i)
	{
		query += form[i].name + "=" + escape(form[i].value) + "&";
	}

	return query;
}

// -------------------------------------------------------------------------------------------------------------------
// Fold

// fold		true/false	falten ja/nein
// id			name			eindeutige ID oder Anfang einer Id, wenn element gesetzt
// tagname	type			Ein HTML-Tag, i.d.R. "tr"

function foldElements(fold, id, tagname)
{
	var obj = null;
	var displayStyle = (fold) ? "none" : "";

	// nur ein Element ein/ausblenden
	if(! tagname || tagname == "")
	{
		obj = document.getElementById(id);
		if(obj)
			obj.style.display=displayStyle;
	}
	else
	{
		obj = document.getElementsByTagName(tagname);
		for(var i=0; i < obj.length; ++i)
		{
			if(obj[i].id && obj[i].id.substring(0, id.length) == id)
			{
				obj[i].style.display=displayStyle;
			}
		}
	}
}

function foldElementsAuto(id, tagname)
{
	var obj = null;

	// nur ein Element ein/ausblenden
	if(! tagname || tagname == "")
	{
		obj = document.getElementById(id);
		if(obj)
			if (obj.style.display == "none")
          obj.style.display="";
        else
          obj.style.display="none";
	}
	else
	{
		obj = document.getElementsByTagName(tagname);
		for(var i=0; i < obj.length; ++i)
		{
			if(obj[i].id && obj[i].id.substring(0, id.length) == id)
			{
				if (obj[i].style.display == "none")
          obj[i].style.display="";
        else
          obj[i].style.display="none";
          
			}
		}
	}
}


