
var activetask = "";
var Selectedfoto = "";

// Die aktuellen Mauskoordinaten
var mousex; var mousexcorr; var mousexcorr2;
var mousey; var mouseycorr;

document.onmousemove = getXY;
document.onmouseup = mymouseup;



function formatZahl(zahl, k, fix, hidenull) {
    if(!k) k = 0;
    var neu = '';
 
	var dec_point = '.';
	var thousands_sep = String.fromCharCode(160);
 
    // Runden
    var f = Math.pow(10, k);
    zahl = '' + parseInt(zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ;
 
    // Komma ermittlen
    var idx = zahl.indexOf('.');
 
    // fehlende Nullen einfügen
    if(fix)    {
         zahl += (idx == -1 ? '.' : '' )
         + f.toString().substring(1);
    }
	var sign = zahl < 0;
	if(sign) zahl = zahl.substring(1);
    idx = zahl.indexOf('.');
 
	// Nachkommastellen ermittlen
    if( idx == -1) idx = zahl.length;
    else neu = dec_point + zahl.substr(idx + 1, k);
 
 
    while(idx > 0)    {
        if(idx - 3 > 0)
        neu = thousands_sep + zahl.substring( idx - 3, idx) + neu;
        else
        neu = zahl.substring(0, idx) + neu;
        idx -= 3;
    }
    if ((hidenull) && (zahl == 0)) {return '';} else {return (sign ? '-' : '') + neu;}
}


function encodeentities (text) {
var returntext = text;
returntext = returntext.replace(/\"/g,"&quot;");
return returntext;
}

function sendformviaajax (button) {
	document.body.style.cursor = 'wait';
	button.style.cursor = 'wait';
	var dataobj = {};
	dataobj[button.name] = button.value;
	var options = {
		data: dataobj,
		success: function() {
			document.body.style.cursor = 'default';
			button.style.cursor = 'pointer';
			alert("Daten wurden gespeichert!"); 
		}
	};
	$(button.form).ajaxSubmit(options);
	return false;
}

function sendandremoveviaajax (button,remove,alldata,postfunc) {
	Entscheidung = Ask (unescape('Bitte best%E4tigen Sie das Entfernen!'));
	if (Entscheidung == true) {
		$(remove).fadeTo(1700,0.3);
		document.body.style.cursor = 'wait';
		button.style.cursor = 'wait';

		if (alldata == true) {
			var dataobj = {};
			dataobj[button.name] = button.value;
			var options = { 
				data: dataobj,
				success: function() {
					document.body.style.cursor = 'default';
					button.style.cursor = 'pointer';
					$(remove).remove();
					if (typeof postfunc != "undefined") {eval (postfunc);}
				}
			};
			$(button.form).ajaxSubmit(options);
		}
		else {
			buttondata = button.name + "=" + button.value + "&seccheck=" + button.form.elements['seccheck'].value;
			$.ajax({
				url: button.form.action,
				type: 'POST',
				data: buttondata,
				success: function(data) {
					document.body.style.cursor = 'default';
					button.style.cursor = 'pointer';
					$(remove).remove();
					if (typeof postfunc != "undefined") {eval (postfunc);}

				}
			});
		}
	}
	return false;
}

function sendandremoveviaajaxtest (button,remove,alldata,postfunc) {
	Entscheidung = Ask (unescape('Bitte best%E4tigen Sie das Entfernen!'));
	if (Entscheidung == true) {
		$(remove).fadeTo(1700,0.3);
		document.body.style.cursor = 'wait';
		button.style.cursor = 'wait';

		if (alldata == true) {
			var dataobj = {};
			dataobj[button.name] = button.value;
			var options = { 
				data: dataobj,
				success: function() {
					document.body.style.cursor = 'default';
					button.style.cursor = 'pointer';
					$(remove).remove();
					if (typeof postfunc != "undefined") {eval (postfunc);}
				}
			};
			$(button.form).ajaxSubmit(options);
		}
		else {
			buttondata = button.name + "=" + button.value + "&seccheck=" + button.form.elements['seccheck'].value;
alert (buttondata);
			$.ajax({
				url: button.form.action,
				type: 'POST',
				data: buttondata,
				success: function(data) {
					document.body.style.cursor = 'default';
					button.style.cursor = 'pointer';
					$(remove).remove();
					if (typeof postfunc != "undefined") {eval (postfunc);}

				}
			});
		}
	}
	return false;
}


function sendandreplaceviaajax (button,replace,replacetarget) {
	document.body.style.cursor = 'wait';
	button.style.cursor = 'wait';
	var dataobj = {};
	dataobj[button.name] = button.value;
	if (replacetarget != true) {replacetarget = false;}
	var options = { 
		target: replace,
		replaceTarget: replacetarget,
		data: dataobj,
		success: function() {
			document.body.style.cursor = 'default';
			button.style.cursor = 'pointer';
		}
	};
	$(button.form).ajaxSubmit(options);
	return false;
}

function sendandreplace2viaajax (button,replace,alldata) {
	document.body.style.cursor = 'wait';
	button.style.cursor = 'wait';

	if (alldata == true) {
		var dataobj = {};
		dataobj[button.name] = button.value;
		var options = { 
			data: dataobj,
			success: function(xml) {
				$(replace).replaceWith($(xml).find(replace));
				document.body.style.cursor = 'default';
				button.style.cursor = 'pointer';
			}
		};
		$(button.form).ajaxSubmit(options);
	}
	else {
		buttondata = '';
		if (typeof alldata == 'boolean') {buttondata = button.name + "=" + button.value + "&seccheck=" + button.form.elements['seccheck'].value;}
		if (typeof alldata == 'string') 
			{
			var alldataidsplit = alldata.split(" ");
			for (var tx=0; tx<alldataidsplit.length; tx++)
				{
				if (typeof $(alldataidsplit[tx]).attr("name") != "undefined") {buttondata = buttondata + "&" + $(alldataidsplit[tx]).attr("name") + "=" + $(alldataidsplit[tx]).val();}
				}
			buttondata = buttondata + "&seccheck=" + button.form.elements['seccheck'].value;
			}
		$.ajax({
			url: button.form.action,
			type: 'POST',
			data: buttondata,
			success: function(xml) {
				$(replace).replaceWith($(xml).find(replace));
				document.body.style.cursor = 'default';
				button.style.cursor = 'pointer';
			}
		});
	}

	return false;
}


function sendandappendviaajax (button,target,content,alldata) {
	document.body.style.cursor = 'wait';
	button.style.cursor = 'wait';

	if (alldata == true) {
		var dataobj = {};
		dataobj[button.name] = button.value;
		var options = { 
			data: dataobj,
			success: function(xml) {
				$(target).append($(xml).find(content));
				document.body.style.cursor = 'default';
				button.style.cursor = 'pointer';
			}
		};
		$(button.form).ajaxSubmit(options);
	}
	else {
		buttondata = button.name + "=" + button.value + "&seccheck=" + button.form.elements['seccheck'].value;
		$.ajax({
			url: button.form.action,
			type: 'POST',
			data: buttondata,
			success: function(xml) {
				$(target).append($(xml).find(content));
				document.body.style.cursor = 'default';
				button.style.cursor = 'pointer';
			}
		});
	}

	return false;
}

function sendandinsertbeforeviaajax (button,target,content,alldata,postfunc) {
	document.body.style.cursor = 'wait';
	button.style.cursor = 'wait';

	if (alldata == true) {
		var dataobj = {};
		dataobj[button.name] = button.value;
		var options = { 
			data: dataobj,
			success: function(xml) {
				$(target).before($(xml).find(content));
				document.body.style.cursor = 'default';
				button.style.cursor = 'pointer';
				if (typeof postfunc != 'undefined') {eval(postfunc);}
			}
		};
		$(button.form).ajaxSubmit(options);
	}
	else {
		buttondata = button.name + "=" + button.value + "&seccheck=" + button.form.elements['seccheck'].value;
		$.ajax({
			url: button.form.action,
			type: 'POST',
			data: buttondata,
			success: function(xml) {
				$(target).before($(xml).find(content));
				document.body.style.cursor = 'default';
				button.style.cursor = 'pointer';
				if (typeof postfunc != 'undefined') {eval(postfunc);}
			}
		});
	}

	return false;
}


function stringmatch (string,pattern,flags)
	{
	var RegObj = new RegExp(pattern,flags);
	return RegObj.test(string);
	}

function stringfind (string,pattern,flags)
	{
	var RegObj = new RegExp(pattern,flags);
	return RegObj.exec(string);
	}


function checkbox_tool (hier,vorsilbe,modus)
	{
	var inputs = document.getElementsByTagName('input');
	for (var f=0; f<inputs.length; f++)
		{
		if (inputs[f].id)
			{
			var idsplit = (inputs[f].id).split("-");
			if (idsplit[0] == vorsilbe) 
				{
				if (stringmatch(modus,'check','')) {inputs[f].checked = hier.checked;}
				if (stringmatch(modus,'disable','')) {if (hier.checked) {inputs[f].disabled = true;} else {inputs[f].disabled = false;}}
				}
			}
		}
	}





function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}




function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function getDocWidth() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}

function mymouseup (e)
{
if (typeof dragresizemode != "undefined") {dragstop(); resizestop();}
}

function getXY(e) {
    if(!e) e = window.event;
    var body = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ?
    window.document.documentElement : window.document.body || null;
    
    mousey = e.pageY ? e.pageY : e.clientY + body.scrollTop;
    mousex = e.pageX ? e.pageX : e.clientX + body.scrollLeft;

	mousexcorr = ((window.innerWidth - mousex) < 150)? (mousex - 150) : (mousex);
	mousexcorr2 = ((window.innerWidth - mousex) < 140)? (mousex - 100) : (mousex);
	mouseycorr = ((window.innerHeight - mousey) < 100)? (mousey - 150) : (mousey);

if (typeof dragresizemode != "undefined") {dragresizemousemove();}

} 


var onloadactions = new Array();
onloadactions.push('checkforFolders();');
onloadactions.push('InitHelpBalloons();');


window.onload = Pageloaded;

/* $(document).ready(function() {Pageloaded();}); */

var postformcheck = '';
var postformcheckreturn = false;

function findLableForControl(el) {
   var idVal = el.id;
   labels = document.getElementsByTagName('label');
   for( var i = 0; i < labels.length; i++ ) {
      if (labels[i].htmlFor == idVal)
           return labels[i];
   }
}


function Formularcheck ()
	{
	var Elemente = this.elements;
	var u = 0;
	var abbruch = "nein";
	var doalert = "ja";
	while (u < Elemente.length)
		{
		if (Elemente[u].getAttribute("required") == "required")
			{
			if (Elemente[u].type == 'radio')
				{
				var Elementform = Elemente[u].form;
				var Elementname = Elemente[u].name;
				var RadioElemente = Elementform.elements[Elementname];
				var RadioChecked = "nein";
				for (var i = 0; i < RadioElemente.length; i++)
					{
					if (RadioElemente[i].checked == true) {RadioChecked = 'ja';}
					}
				if (RadioChecked == "nein") {abbruch = "ja"; findLableForControl(Elemente[u]).style.border = '1px solid red';}
				else {findLableForControl(Elemente[u]).style.border = '';}
				}
			else
				{
				if (Elemente[u].value == '') {abbruch = "ja"; Elemente[u].style.border = '1px solid red';}
				else {Elemente[u].style.border = '';}
				}
			}
		u++;
		}

	var seccheckfield = this.elements['seccheck'];
	if (seccheckfield) {}
	else {abbruch = "ja"; doalert = "nein"; alert ('Sie haben keine Berechtigung, diese Aktion durchzufuehren.');}

	if (document.getElementById('emailcentersender')) {var rueckwert = checkSender(document.getElementById('emailcentersender')); if (rueckwert == false) {abbruch = "ja"; doalert = "nein";}}
	if (abbruch == "ja") {if (doalert == "ja") {alert (unescape('Eine oder mehrere notwendige Angaben fehlen. Bitte erg%E4nzen Sie diese.'));} return false;}
	else {if (postformcheck != '') {eval(postformcheck);} return true;}
	}

function Formularcheck2 (object)
	{
	var Elemente = object.elements;
	var u = 0;
	var abbruch = "nein";
	while (u < Elemente.length)
		{
		if (Elemente[u].getAttribute("required") == "required")
			{
			if (Elemente[u].value == '') {abbruch = "ja"; Elemente[u].style.border = '1px solid red';}
			else {Elemente[u].style.border = '';}
			}
		u++;
		}
	if (abbruch == "ja") {alert (unescape('Eine oder mehrere notwendige Angaben fehlen. Bitte erg%E4nzen Sie diese.')); return false;}
	else {if (postformcheck != '') {eval(postformcheck);} return true;}
	}


var waitforresponse = null;

function openbox (element,width,height,url)
{
var ypositionqc = mousey - (height/2); if (ypositionqc < 70) {ypositionqc = 70;}
var xpositionqc = (getDocWidth()/2) - (width/2);
document.getElementById(element).style.top = ypositionqc + "px";
document.getElementById(element).style.left = xpositionqc + "px";
if (document.getElementById(element).lastChild)
	{
	document.getElementById(element).lastChild.style.width = width + "px";
	document.getElementById(element).lastChild.style.height = height + "px";
	}
if (document.getElementById(element).firstChild)
	{
	document.getElementById(element).firstChild.style.width = width + "px";
	}

document.getElementById('blackoverlaydefault').style.height = getDocHeight() + "px";
document.getElementById('blackoverlaydefault').style.zIndex = "48";
document.getElementById(element).style.display = "block";
document.getElementById(element).style.zIndex = "49";
document.getElementById('blackoverlaydefault').style.display = "block";

waitforresponse = url;
}

function confirmbox ()
{
if (waitforresponse) 
	{
	var splitmode = waitforresponse.split(":");
	if (splitmode[0] == 'link') {window.location.href = splitmode[1]; waitforresponse = null;}
	if (splitmode[0] == 'input') 
		{
		var newinput = document.createElement("input");
		newinput.type = 'hidden';
		newinput.name = splitmode[1];
		if (document.getElementById(splitmode[2]))
			{
			document.getElementById(splitmode[2]).appendChild(newinput);
			document.getElementById(splitmode[2]).submit();
			}
		}
	}
}

function closebox (element)
{
document.getElementById(element).style.display = 'none';
if (document.getElementById('blackoverlay')) {document.getElementById('blackoverlay').style.display = 'none';}
if (document.getElementById('blackoverlaydefault')) {document.getElementById('blackoverlaydefault').style.display = 'none';}
waitforresponse = null;
}

function Pageloaded ()
{



/* if (document.forms[0]) {document.forms[0].reset();} */
/* if (document.forms[1]) {document.forms[1].reset();} */

if ((onloadactions[onloadactions.length - 1] != 'InitDrehplan();') && (onloadactions[onloadactions.length - 1] != 'InitCashflow();')) {onloadactions.push('if (document.getElementById(\'pageloading\')) {$(\'#pageloading\').fadeOut(500);}');}


var i = 0;
while (i < onloadactions.length)
	{
	eval(onloadactions[i]);
	i++;
	}


var Formulare = document.forms;
var i = 0;
while (i < Formulare.length)
	{
	Formulare[i].onsubmit = Formularcheck;
	i++;
	}
if (document.getElementById(onloadfocus)) {document.getElementById(onloadfocus).focus();}
}

var onloadfocus = '';
var Timeout = "";
var Menuzu = "";

function switchvisible (Identifier)
{
var Status = document.getElementById(Identifier).style.display;
if (Status == "none") 
	{
	document.getElementById(Identifier).style.display = "block";
	Menuzu = "nein";
	Timeout = window.setTimeout("switchvisible('" + Identifier + "')", 2000);
	}
else 
	{
	document.getElementById(Identifier).style.display = "none";
	window.clearTimeout(Timeout);
	}
}

function menuridein (Identifier)
{
	window.clearTimeout(Timeout);
}

function menurideout (Identifier)
{
	if (Menuzu != "ja") {Timeout = window.setTimeout("switchvisible('" + Identifier + "')", 2000);}
}

function takeovervalue (Wert,Identifiera,Identifierb)
{
document.getElementById(Identifiera).value = Wert;
document.getElementById(Identifierb).style.display = "none";
Menuzu = "ja";
window.clearTimeout(Timeout);
}

var activeselect = "";

function resetpdfload ()
	{
	activeselect.options[0].text = unescape("bitte w%E4hlen");
	activeselect.style.backgroundColor = ''; activeselect.style.color = '';
	}

function loadpdf (element)
	{
	if (element.value != '')
		{
		window.location.href = element.value + "&t=" + Math.random();
		element.selectedIndex = 0;
		element.options[0].text = "bitte warten...";
		element.style.backgroundColor = '#ffffbb'; element.style.color = '#000000';
		activeselect = element;
		window.setTimeout('resetpdfload()',11000);
		}
	else
		{
		alert (unescape('Dieses PDF-Dokument ist derzeit noch nicht verf%FCgbar.'));
		element.selectedIndex = 0;
		}
	}


function bildkopf() 
	{
	if (document.getElementById('bildkopfdiv'))
		{
		if (document.getElementById('bildkopfdiv').style.display == "inline") 
			{
			document.getElementById('bildkopfdiv').style.display = "none";
			}
		else 
			{
			var Leftwertkorr = mousex - 90; var Topwertkorr = mousey - 30; if (Leftwertkorr < 10) {Leftwertkorr = 10;}
			document.getElementById("bildkopfdiv").style.left = Leftwertkorr + "px";
			document.getElementById("bildkopfdiv").style.top = Topwertkorr + "px";
			document.getElementById('bildkopfdiv').style.display = "inline";
			}
		}

	}


function setFieldValue (id,value)
{
document.getElementById(id).value = value;
if ($('#'+id).attr("onchangefunction")) {eval($('#'+id).attr("onchangefunction"));}
}

function InitHelpBalloons ()
{
var Elemente = document.getElementsByTagName("*");
for (var i = 0; i < Elemente.length; i++)
	{
	var title = Elemente[i].getAttribute("title");
	if (title == "null") {title = "";}
	if (title == null) {title = "";}
	if (title == "[object]") {title = "";}
	if (Elemente[i].getAttributeNode("title")) 
		{
		if ((title != "") && (!Elemente[i].onmousemove)) 
			{
			Elemente[i].setAttribute("hovertitle",Elemente[i].getAttribute("title"));
			Elemente[i].removeAttribute("title");
			Elemente[i].onmousemove = function (evt) 
				{
				evt = (evt) ? evt : ((window.event) ? window.event : "");
				var elem = (evt.target) ? evt.target : evt.srcElement;
				var text = elem.getAttribute('hovertitle');
				if (!elem.getAttributeNode('hovertitle')) {text = elem.parentNode.getAttribute("hovertitle");}
				if (text == null) {text = "";} text = text.replace(/\[br\]/g, "<br/>");
				document.getElementById('meinAbsatz').innerHTML = text;
				document.getElementById('meinAbsatz').style.top = (mousey + 8) + "px";
				document.getElementById('meinAbsatz').style.left = (mousexcorr2 + 15) + "px";
				document.getElementById('meinAbsatz').style.zIndex = "50";
				document.getElementById("meinAbsatz").style.display = "inline";
				}
			Elemente[i].onmouseout = function (event) 
				{
				document.getElementById('meinAbsatz').innerHTML = '';
				document.getElementById('meinAbsatz').style.display = "none";
				}
			}
		}
	}
}

function Fensterauf (Url,width,height)
{
var Rand = Math.random();
Url = Url.replace(/random/,Rand);
var Rand2 = Math.floor(Rand*100);
var Windowname = "Window" + Rand2;
if ((width > 0) && (height > 0)) {F3 = window.open(Url,Windowname,"width=" + width + ",height=" + height + ",left=50,top=20, scrollbars=yes"); F3.focus();}
else {F3 = window.open(Url,Windowname,"width=450,height=200,left=50,top=20, scrollbars=yes"); F3.focus();}
}

function opensubmitwindow (Formular)
{
	var Zufallszahl = Math.random();
	var Fenstername = "W" + Zufallszahl;
	F1 = window.open("about:blank","Fenstername","width=450,height=400,left=50,top=50, scrollbars=yes");
	F1.focus();

	if (document.getElementById('scriptcontent')) 
		{	
		CleanCode("normal");
		HTMLCode = document.getElementById('editor').contentWindow.document.body.innerHTML;
		document.getElementById('scriptcontent').value = HTMLCode;
		}
	
	if (document.getElementById('richtextcontent')) 
		{	
		CleanCode("normal");
		HTMLCode = document.getElementById('editor').contentWindow.document.body.innerHTML;
		document.getElementById('richtextcontent').value = HTMLCode;
		}

	Formular.target = "Fenstername";
	return true;

}

var aktuellform = '';
var aktuellfrage = '';

function submitpopup (Formular)
{
aktuellform = Formular;
postformcheck = 'opensubmitwindow (aktuellform);';
return true;
}

function submitunpopup (Formular,Zusatzfunktion,Wert)
{
Formular.target = "_self";
postformcheck = '';
var Entscheidung = true;
if (Zusatzfunktion == "ask")
	{
	Entscheidung = Ask (Wert);
	postformcheck = '';
	}
if (Zusatzfunktion == "sendMail")
	{
	postformcheck = 'sendMail();';
	}

if (document.getElementById('scriptcontent')) 
	{	
	CleanCode("normal");
	HTMLCode = document.getElementById('editor').contentWindow.document.body.innerHTML;
	document.getElementById('scriptcontent').value = HTMLCode;
	}

if (document.getElementById('richtextcontent')) 
	{	
	CleanCode("normal");
	HTMLCode = document.getElementById('editor').contentWindow.document.body.innerHTML;
	document.getElementById('richtextcontent').value = HTMLCode;
	}

if (Entscheidung == true) {return true;}
if (Entscheidung == false) {return false;}
}


function sendMail ()
{
var Zufallhier = Math.random(); Zufallhier = Math.floor(Zufallhier*100000000);
document.getElementById('fotouploadhinweis').style.top = "300px";
document.getElementById('progressbar').innerHTML = "&nbsp\;<br />&nbsp\;";
document.getElementById('fotouploadhinweis').style.display = "inline";
document.getElementById('uploadtext1').innerHTML = "E-Mail wird erstellt...<br />bitte warten.";

if (document.getElementById('progressinput')) 
	{var Inputfeld = document.getElementById('progressinput'); Inputfeld.name = "mailstatus:" + Zufallhier;} 
else 
	{var Inputfeld = document.createElement('input'); Inputfeld.id = "progressinput"; Inputfeld.type = "hidden"; var Formelement = document.getElementsByTagName("form")[0]; var Erg = Formelement.insertBefore(Inputfeld,Formelement.firstChild); Inputfeld.name = "mailstatus:" + Zufallhier;}

/* document.getElementsByTagName("form")[0].target = "iframe"; */
/* document.forms[0].submit(); */
activetask = window.setInterval('httpRequest("../../uploadstatus/'+Zufallhier+'.txt")', 1000);
return true;
}



function checkforFolders (filter)
{
var Anker = window.location.hash;
Anker = Anker.replace(/#/,"");
var Anker2 = Anker.replace(/_SUB1/,"");
var Anker2split = new Array(0);
Anker2split = Anker2.split("-");

var TRelems = document.getElementsByTagName("TR");

for (var u=0; u<TRelems.length; u++)
	{
	var TRid = "";
	if (TRelems[u].id) {TRid = TRelems[u].id;}
	var TRid2 = TRid.replace(/_SUB1/,"");
	var TRidsplit = TRid2.split("-");
		if (TRid.match(/_SUB/g)) {
			if (filter) {if (stringmatch(TRid,filter,'gi')) {TRelems[u].style.display = "none";} else {}}
			else {TRelems[u].style.display = "none";}
		}
	}

if (Anker2split.length > 1) 
	{
	if (document.getElementById(Anker2split[0])) {subs(document.getElementById(Anker2split[0]));}
	}
if (Anker2split.length > 2) 
	{
	var subsstringhier = Anker2split[0] + "-" + Anker2split[1] + "_SUB1";
	if (document.getElementById(subsstringhier)) {subs(document.getElementById(subsstringhier));}
	}

}

function loglinecharfunc (textarea)
{
var Wert = textarea.value;
var Neuwert = Wert.substr(0,300); if (Neuwert == " ") {Neuwert = "";}
var Laenge = Neuwert.length;
textarea.value = Neuwert;
document.getElementById('loglinechars').value = 300 - Laenge;
}



function allsubs ()
{
var rowimg = document.getElementsByTagName('img');
for (var p=0; p<rowimg.length; p++)
	{
	if (rowimg[p].className == 'folderopen')
		{
		if ((rowimg[p].parentNode.parentNode.parentNode.id) && (rowimg[p].parentNode.parentNode.parentNode.nodeName.toUpperCase() == 'TR')) {subs(rowimg[p].parentNode.parentNode.parentNode);}
		if ((rowimg[p].parentNode.parentNode.id) && (rowimg[p].parentNode.parentNode.nodeName.toUpperCase() == 'TR')) {subs(rowimg[p].parentNode.parentNode);}
		}
	}
if (document.getElementById('allfoldersclosed').style.display == 'inline') {document.getElementById('allfoldersclosed').style.display = 'none'; document.getElementById('allfoldersopen').style.display = 'inline';}
else {document.getElementById('allfoldersclosed').style.display = 'inline'; document.getElementById('allfoldersopen').style.display = 'none';}
}

function subs (mainnode,datasource)
{

var Nachbarn = mainnode.parentNode.childNodes;

var modus = '';
var MainId = mainnode.id;
MainId = MainId.replace(/_SUB\w/,"");

if ((mainnode.nextSibling.style.display == "") && (!datasource)) {modus = 'none';}
else {modus = '';}

var mainnodeschon = "nein";
var k = 0;
while (k<Nachbarn.length)
	{
	if (mainnodeschon == "ja")
		{
		var Idtemp = "";
		if (Nachbarn[k].id) {Idtemp = Nachbarn[k].id;}
		Idtemp = Idtemp.replace(/_SUB\w/,"");
		var Split = new Array();
		Split = Idtemp.split("-");
		Split.pop();
		var Idtemp2 = Split.join("-");
		if (Idtemp2 == MainId) {Nachbarn[k].style.display = modus;}
		else {}
		}
	if (Nachbarn[k].id == mainnode.id) {mainnodeschon = "ja";}
	k++;
	}

var Folderpics = mainnode.getElementsByTagName("IMG");
k = 0;
while (k<Folderpics.length)
	{
	if (Folderpics[k].className == "folderopen")
		{
		if (modus == "none") {Folderpics[k].style.display = "none";}
		else {Folderpics[k].style.display = "inline";}
		}
	if (Folderpics[k].className == "folderclosed")
		{
		if (modus == "none") {Folderpics[k].style.display = "inline";}
		else {Folderpics[k].style.display = "none";}
		}
	k++;	
	}

if (datasource) {
	var datasourcesplit = datasource.split(/\s+/);
	$.ajax({
		url: datasourcesplit[0],
		type: 'GET',
		success: function(xml) {
			$(mainnode).replaceWith($(xml).find(datasourcesplit[1]));
			checkforFolders(mainnode.id + "-");
			subs(document.getElementById(mainnode.id));
		}
	});
}

}







function bewegezeilen (id,anzahl,richtung,group)
{
var Elternknoten = document.getElementById(id).parentNode; var Knotenname = document.getElementById(id).nodeName;
/* var Nachbarn = Elternknoten.getElementsByTagName(Knotenname); */
var Nachbarnpre = Elternknoten.childNodes;
var Nachbarn = new Array();

for (var u=0; u<Nachbarnpre.length; u++) {if (Nachbarnpre[u].nodeName == Knotenname) {Nachbarn.push(Nachbarnpre[u]);}}

var k = 0; var index = 0;
while (k<Nachbarn.length) {
	if (Nachbarn[k] == document.getElementById(id)) {index = k;}
	k++; }

var Movenodes = new Array(anzahl);

var t = 0; while (t < anzahl) {Movenodes[t] = Nachbarn[(index + t)]; t++;}

/* Movenodes enthaelt die Zeilen, die bewegt werden sollen */


if (Nachbarn[(index + anzahl*richtung)])
	{
	var Zielknotenarray = new Array(anzahl);
	var Zielknotenid = "";
	var t = 0; while (t < anzahl) {Zielknotenarray[t] = Nachbarn[(index + anzahl*richtung) + t]; t++;}
	Zielknotenid = Zielknotenarray[0].id;
	if ((richtung == -1) && (Zielknotenarray[0].id != ""))
		{
		g = 0;
		while (g < Movenodes.length)
			{
			var removed = Elternknoten.removeChild(Movenodes[g]);
			Elternknoten.insertBefore(removed,Zielknotenarray[0]);
			g++;
			}
		}
	if ((richtung == 1) && (Zielknotenarray[0].id != ""))
		{
		var Neuzielknoten; var Methode = "before";
		if (Nachbarn[(index + 2*anzahl*richtung)]) {Neuzielknoten = Nachbarn[(index + 2*anzahl*richtung)]; Methode = "before";}
		else {Methode = "after";}
		g = 0;
		while (g < Movenodes.length)
			{
			var removed = Elternknoten.removeChild(Movenodes[g]);
			if (Methode == "before") {Elternknoten.insertBefore(removed,Neuzielknoten);} else {Elternknoten.appendChild(removed);}
			g++;
			}
		}
	if (Zielknotenarray[0].id != "")
		{
		if (document.getElementById('constant-' + id)) {var tempcontent = document.getElementById('constant-' + id).innerHTML; document.getElementById('constant-' + id).innerHTML = document.getElementById('constant-' + Zielknotenid).innerHTML; document.getElementById('constant-' + Zielknotenid).innerHTML = tempcontent;}
		if (document.getElementById('addition-' + id)) {var tempcontent = document.getElementById('addition-' + id).value; document.getElementById('addition-' + id).value = document.getElementById('addition-' + Zielknotenid).value; document.getElementById('addition-' + Zielknotenid).value = tempcontent;}
		if (document.getElementById('addition2-' + id)) {var tempcontent = document.getElementById('addition2-' + id).value; document.getElementById('addition2-' + id).value = document.getElementById('addition2-' + Zielknotenid).value; document.getElementById('addition2-' + Zielknotenid).value = tempcontent;}
		if (document.getElementById('constvalue-' + id)) {var tempcontent = document.getElementById('constvalue-' + id).value; document.getElementById('constvalue-' + id).value = document.getElementById('constvalue-' + Zielknotenid).value; document.getElementById('constvalue-' + Zielknotenid).value = tempcontent;}

		var Sortierlistenname = "sortierung-" + group; 

			if (document.getElementById(Sortierlistenname))
			{
			var Sortierlistezeile = document.getElementById(Sortierlistenname).value; var Sortierliste = Sortierlistezeile.split("+");
	
			var Aktnummer = id; Aktnummer = Aktnummer.replace(/\D/g,""); var Aktindex = 0; var Vorhernummer = Zielknotenid; Vorhernummer = Vorhernummer.replace(/\D/g, ""); var Vorherindex = 1;
	
			for (var i = 0; i < Sortierliste.length; i++)
				{
				if (Sortierliste[i] == Aktnummer) {Aktindex = i;}
				if (Sortierliste[i] == Vorhernummer) {Vorherindex = i;}
				}
			
			Sortierliste[Aktindex] = Vorhernummer; Sortierliste[Vorherindex] = Aktnummer;
			Sortierlistezeile = Sortierliste.join("+"); document.getElementById(Sortierlistenname).value = Sortierlistezeile;
			}
		}
	}



/*
if (typeof scenerenumber != "undefined")
	{
	var Nachbarnpre2 = Elternknoten.childNodes;
	Nachbarn = new Array();
	for (var u=0; u<Nachbarnpre2.length; u++) {if (Nachbarnpre2[u].nodeName == Knotenname) {Nachbarn.push(Nachbarnpre2[u]);}}
	var bildnummer = 0;
	for (var h=0; h<Nachbarn.length; h++)
		{
		if (document.getElementById('constant-' + Nachbarn[h].id))
			{
			if (document.getElementById('constant-' + Nachbarn[h].id).getAttribute("insert") != "true") {bildnummer++; document.getElementById('constant-' + Nachbarn[h].id).innerHTML = bildnummer;}
			else {document.getElementById('constant-' + Nachbarn[h].id).innerHTML = bildnummer;}
			}
		}

	}

*/

if (typeof priorityrenumber != "undefined") {setPriority();}

}



/* function closeuploadbox ()
{
parent.document.getElementById('fotouploadhinweis').style.display = "none";
parent.document.getElementById('fotouploadhinweis').innerHTML = '<table><tr><td><img src="../pics/sanduhr.gif" border=0></td><td><span style="font-size:14px; font-family:Arial; color:#000000;"><b>Foto wird hochgeladen.<br>Bitte warten...</b></span></td></tr></table>';
parent.document.getElementById(Selectedfoto).disabled = true;
Form1.submit();
} 
*/



function Fotoauswahl (Formular,Element) { 

Selectedfoto = Element;

var Elinhalt = document.getElementById(Element).value;
if (Elinhalt != "")
   {
	if (UploadFormular == "")
	{
		UploadFormular = Formular;
		Timeoutupload = window.setTimeout("AutoUpload()", 500);
	}
   }
}

function Uploadauswahl (Formular,Element) { 

Selectedfoto = Element;

var Elinhalt = document.getElementById(Element).value;
if (Elinhalt != "")
   {
	if (UploadFormular == "")
	{
		UploadFormular = Formular;
		Timeoutupload = window.setTimeout("AutoUpload()", 100);
	}
   }
}

var UploadFormular = "";

function AutoUpload ()
{
var Zufallhier = Math.random(); Zufallhier = Math.floor(Zufallhier*100000000);
document.getElementById('fotouploadhinweis').style.top = (mousey + 10) + "px";
document.getElementById('progressbar').innerHTML = "&nbsp\;<br />&nbsp\;";
 document.getElementById('fotouploadhinweis').style.display = "inline";

if (document.getElementById('progressinput')) 
	{var Inputfeld = document.getElementById('progressinput'); Inputfeld.name = "progressbar:" + Zufallhier;} 
else 
	{var Inputfeld = document.createElement('input'); Inputfeld.id = "progressinput"; Inputfeld.type = "hidden"; var Formelement = document.getElementsByTagName("form")[0]; var Erg = Formelement.insertBefore(Inputfeld,Formelement.firstChild); Inputfeld.name = "progressbar:" + Zufallhier;}

UploadFormular.target = "iframe";
activetask = window.setInterval('httpRequest("../../uploadstatus/'+Zufallhier+'.txt")', 1500);
UploadFormular.submit();
}

function stopUpload()
{
window.frames["iframe"].location.href = "../empty.html";
window.clearInterval(activetask);
}

function resetUpload ()
{
window.frames["iframe"].location.href = "../empty.html";
var Inputs = document.getElementsByTagName("input");
for (var u=0; u<Inputs.length; u++)
	{
	if (Inputs[u].type == "file") {Inputs[u].value = "";}
	}
window.clearInterval(activetask);
document.getElementById('fotouploadhinweis').style.display = "none";
UploadFormular = "";
}







function imgscrollto(image,left,top)
{
document.getElementById(image).scrollLeft = left;
document.getElementById(image).scrollTop = top;
}

function Urlaufruf (Url)
{
var Rand = Math.random();
Url = Url.replace(/random/,Rand);
parent.window.location.href = Url;
}

function Ask (Frage) {

Frage = Frage.replace(/<br>/, "\n");

var Antwort = confirm (Frage);
if (Antwort == true) {return true;}
if (Antwort == false) {return false;}
  }



















function httpResponse (Object)
{
var responseText = Object.responseText;
var responseSplit = responseText.split("/");

if (responseSplit.length == 1) 
	{
	var toobig = "no";
	if (responseSplit[0] == "toobig") {toobig = "yes"; responseSplit[0] = unescape("Datei zu gro%DF!");}
	document.getElementById('progressbar').innerHTML = "&nbsp\;<br />" + responseSplit[0]; 
	if (toobig == "yes") {stopUpload();}
	}
else
	{
	var percent = ((responseSplit[0])*1/(responseSplit[1])*1)*100; percent = Math.floor(percent*10)/10; if (percent > 100) {percent = 100;}
	var kBytes1 = Math.floor((responseSplit[0])/1000);
	var kBytes2 = Math.floor((responseSplit[1])/1000); if (kBytes1 > kBytes2) {kBytes1 = kBytes2;}
	document.getElementById('progressbar').innerHTML = "Fortschritt: " + percent + " %<br />" + kBytes1 + " kB von " + kBytes2 + "kB";
	}

}




    function httpRequest(strURL) {
        var xmlHttpReq = false;
        // Mozilla/Safari
        if (window.XMLHttpRequest) {
            xmlHttpReq = new XMLHttpRequest();
            if (xmlHttpReq.overrideMimeType) {
                xmlHttpReq.overrideMimeType('text/xml');
                // See note below about this line
            }
        // IE
        } else if (window.ActiveXObject) { // IE
            try {
                xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
            }
        }
        if (!xmlHttpReq) {
            alert('ERROR AJAX:( Cannot create an XMLHTTP instance');
            return false;
        }   
	var strURLnew = strURL + "?" + Math.random();
        xmlHttpReq.open('GET', strURLnew, true);
        xmlHttpReq.setRequestHeader('Content-Type', 
            'application/x-www-form-urlencoded');        
        xmlHttpReq.onreadystatechange = function() { 
            httpCallback(xmlHttpReq); 
        };
        xmlHttpReq.send("");
    }
            
    function httpCallback(http_request) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                httpResponse(http_request);
            } else {
/*                alert('ERROR: AJAX request status = ' + http_request.status); */
            }
        }
    }
