///////////////////////////////////////////
//
//Javascripte zum Editor
//
///////////////////////////////////////////
var nextstep='';
var noerror=true;
function error_test()
{
	noerror=false;
	//alert('script error');
	return true;
}
window.onerror = error_test;

loadaction=false;
version=navigator.appVersion;//load mac ns ie styles
if (document.all) //neuer Browser
{
	if (navigator.platform == "Netscape")
	{
		document.write("<link rel=stylesheet type=\"text/css\" href=\"tool_css/nstyle.css\">");
	}	
	else {
		document.write("<link rel=stylesheet type=\"text/css\" href=\"tool_css/mstyle.css\">");
	}
} 
else //alter Browser
{
	if (navigator.platform == "MacPPC") //Mac
	{
		document.write("<link rel=stylesheet type=\"text/css\" href=\"tool_css/mstyle.css\">");
	}	
	else 
	{
		if (version.substr(0,1) <= "4") //Windows
		{
			document.write("<link rel=stylesheet type=\"text/css\" href=\"tool_css/nstyle.css\">");
		}
		else
		{
			document.write("<link rel=stylesheet type=\"text/css\" href=\"tool_css/mstyle.css\">");
		}
	}
}

function onload_image_upload()//mac resize
{
	if (navigator.appVersion.indexOf("Mac")>0)
		{
			window.resizeTo(800,280);
		}
	self.focus();
}

function onload_standardpopup()//mac resize
{
	if (navigator.appVersion.indexOf("Mac")>0)
		{
			Window.resizeTo(800,560);
			//f.focus();
		}
	//self.focus();
}


function filldatum(welches)//datumfunktion
{
	eval("document.send."+welches+".value=document.send."+welches+"_jahr.value+'-'+document.send."+welches+"_monat.value+'-'+document.send."+welches+"_tag.value;");
}

function popup_upload(URL)//upload popup
{
	//alert(URL);
	window.open(URL,"tk_imageupload",'toolbar=no,top=20,left=100,width=800,height=280,directories=no,status=yes,scrollbars=no,resizable=no,menubar=no,dependent=yes');	
	return false;
}

function popup_standard(URL)//edit popup
{
	
	f=window.open(URL,"admin_tool_edit",'toolbar=no,top=20,left=100,width=800,height=600,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no,dependent=yes');	
	return false;
}

function popup_code(site,name)//edit popup
{
	nextstep=site;
	nextname=name;
	f=window.open('bestaetigung.html',"enter_code",'toolbar=no,top=300,left=400,width=350,height=100,directories=no,status=no,scrollbars=no,resizable=no,menubar=no,dependent=yes');	
	return false;
}

function chechboxrechne(welches,anzahl)//checkbox funktion
{
	eval("document.send."+welches+".value='0';")
	wert=1;
	alt=0;
	for(i=1;i<=anzahl;i++)
	{
		alt=wert;
		wert=wert*2;
		if (eval("document.send."+welches+"_checkbox_"+i))
		if (eval("document.send."+welches+"_checkbox_"+i+".checked"))
		{
			eval("document.send."+welches+".value=((document.send."+welches+".value*1)+((wert*1)-(alt*1)));");
		}
		
	}
	return false;
}


function chechboxadd(welches,anzahl)//checkbox funktion
{
	var xstring='';
	for(i=0;i<=anzahl-1;i++)
	{
		
		eval("my_value=document.send."+welches+"_checkbox_"+i+".value;")
		if (eval("document.send."+welches+"_checkbox_"+i+".checked"))
		{
			if (xstring!='')xstring+=',';
			xstring+=my_value;
		}
		eval("document.send."+welches+".value=xstring");
	}
	return false;
}

function tablechange(welche,x,y)//tebellen funktion
{
	var table='';
	var foundtable='';
	found=0;
	notfound=0;
	for (iy=1;iy<=y;iy++)
		{
			var intable='';
			found=0;
			trenner='';
			for (ix=1;ix<=x;ix++)
				{
					if (ix!=1){intable=intable+'}#|||#{';}
					eval("dazu=document.send."+welche+ix+"_"+iy+".value;");
					if (dazu!=''){found=1}
					intable=intable+dazu;
				}
			if (iy!=1){trenner='}#***#{';}
			if (found==1)
				{
					table=table+foundtable;
					table=table+trenner+intable;
					notfound=0;
					foundtable='';
				}
				else
				{
					foundtable=foundtable+trenner+intable;
					notfound++;
				}
		}
	eval("document.send."+welche+".value=table;");
}


function mod(wert,myitem)
{

if (myitem.checked){
	wert=wert.replace(/x/,'1');
} else {
	wert=wert.replace(/x/,'0');
}
return wert;
}

function realcheckne()
{
myitems=new Array();
if (document.send.home) myitems[myitems.length]='document.send.home';
if (document.send.styleguide) myitems[myitems.length]='document.send.styleguide';
if (document.send.projektarchiv) myitems[myitems.length]='document.send.projektarchiv';
//if (document.send.projektmanagment) myitems[myitems.length]='document.send.projektmanagment';
if (document.send.bilddatenbank) myitems[myitems.length]='document.send.bilddatenbank';

var out=false;
for (i=0;i<=myitems.length-1;i++)
{
	 eval('if ('+myitems[i]+') if ('+myitems[i]+'.options['+myitems[i]+'.selectedIndex].value!=document.send.alles.options[document.send.alles.selectedIndex].value) {out=true;}');
}
return out;
}

function setcheckbox(myselectbox,mycheckbox)
{
	if ((myselectbox)&&(mycheckbox))
	{
		if (myselectbox.options[myselectbox.selectedIndex].value==0)
		{
			mycheckbox.checked=false;
		}
	}
}

function setselect(myitem)
{
	var found=0;
	var leser=0;
	if (myitem)
	{ 
		for (i=0;i<=myitem.options.length-1;i++)
		{
				if (document.send.alles.options[document.send.alles.selectedIndex].value==myitem.options[i].value)
				{
					myitem.options[i].selected=true;
					found=1;
				}
				if (myitem.options[i].value==1) leser=i;
			
		}
	
		if (found==0)
		{
			myitem.options[leser].selectedIndex=leser;
		}
	}
}

var onrun=0;

function getvalue(myitem)
{
	existiert=false;
	eval('if ('+myitem+') existiert=true;');

	if ((existiert)&&(myitem!=''))
	{
		var myvalue='';
		eval('myvalue='+myitem+'.options['+myitem+'.selectedIndex].value;');
		return myvalue;
	}
	else return -1;
}

function setvalue(myitem,value)
{
	setbyvalue_found=0;
	eval("setbyvalue_lang="+myitem+".options.length-1;");
	for(i_setbyvalue=0;i_setbyvalue<=setbyvalue_lang;i_setbyvalue++)
	{
		eval("if ("+myitem+".options[i_setbyvalue].value==value) setbyvalue_found=i_setbyvalue;");
	}
	eval(myitem+".selectedIndex=setbyvalue_found;");
}

function changeright(item,realm,id,change,spezial)
{
	var spezial='';
	if (document.send.netzadmin)
	if(document.send.netzadmin.checked==true) spezial=1;
	if (item)	if (spezial==1)	
	{
		item.value="spezial=1";	
		if(document.getElementById)
		{
			document.getElementById('netz_1').style.visibility='hidden';
			document.getElementById('netz_2').style.visibility='hidden';
			document.getElementById('netz_3').style.visibility='hidden';
			document.getElementById('netz_4').style.visibility='hidden';
			document.getElementById('netz_5').style.visibility='hidden';
		}
	}
	else
	if (onrun==0)
	{
	onrun=1;
	var rechte=new Array();
	rechte[1]='00110x00';
	rechte[2]='00111x00';
	rechte[3]='01111x00';
	rechte[0]='00000000';
	rechte[99]='11111110';
	
	if (document.send.alles)
	if ((document.send.alles.selectedIndex!=0)&&(change==1))
	{
		
		setselect(document.send.home);
		setselect(document.send.styleguide);
		setselect(document.send.bilddatenbank);
		setselect(document.send.projektmanagment);
		setselect(document.send.projektarchiv);
		
		if (getvalue("document.send.alles")==99)
		{
			setvalue("document.send.alles",1);
			setselect(document.send.home);
			setselect(document.send.styleguide);
			setselect(document.send.bilddatenbank);
			setselect(document.send.projektarchiv);
			setvalue("document.send.alles",'bereichsspezifisch');
			setselect(document.send.projektmanagment);
			setvalue("document.send.alles",99);
			
		}
		if (getvalue("document.send.alles")==1)
		{
			
			setselect(document.send.home);
			setselect(document.send.styleguide);
			setselect(document.send.bilddatenbank);
			setselect(document.send.projektarchiv);
			setvalue("document.send.alles",'bereichsspezifisch');
			setselect(document.send.projektmanagment);
			setvalue("document.send.alles",1);
		}
		
	}
	else
	{
		
		if (realcheckne())
		{
			if (getvalue("document.send.alles")==99)
			{
				
				if (      ((getvalue("document.send.home")!=1)&&(getvalue("document.send.home")!='-1'))
					||((getvalue("document.send.styleguide")!=1)&&(getvalue("document.send.styleguide")!='-1'))
					||((getvalue("document.send.bilddatenbank")!=1)&&(getvalue("document.send.bilddatenbank")!='-1'))
				    	||((getvalue("document.send.projektarchiv")!=1)&&(getvalue("document.send.projektarchiv")!='-1'))
				    	||((getvalue("document.send.projektmanagment")!=0)&&(getvalue("document.send.projektmanagment")!='-1'))    )
				    {
				    	setvalue("document.send.alles",'bereichsspezifisch');
				    }
			}
			else if 
			   (getvalue("document.send.alles")=='bereichsspezifisch')
			{
				if (      ((getvalue("document.send.home")!=1)&&(getvalue("document.send.home")!='-1'))
					||((getvalue("document.send.styleguide")!=1)&&(getvalue("document.send.styleguide")!='-1'))
					||((getvalue("document.send.bilddatenbank")!=1)&&(getvalue("document.send.bilddatenbank")!='-1'))
				    	||((getvalue("document.send.projektarchiv")!=1)&&(getvalue("document.send.projektarchiv")!='-1'))
				    	||((getvalue("document.send.projektmanagment")!=0)&&(getvalue("document.send.projektmanagment")!='-1'))    )
				    {
				    	setvalue("document.send.alles",'bereichsspezifisch');
				    }
				    else
				    {
				    	setvalue("document.send.alles",1);
				    }
			}
			else
			{	
				setvalue("document.send.alles",'bereichsspezifisch');
			}
		}
	}
	item.value='';
	if (getvalue("document.send.alles")!=99)
	{
		var my_test='00001000';
		if (document.send.home) if (mod(rechte[getvalue("document.send.home")],document.send.homedl)>my_test)my_test=mod(rechte[getvalue("document.send.home")],document.send.homedl);
		if (document.send.styleguide) if (mod(rechte[getvalue("document.send.styleguide")],document.send.styleguidel)>my_test)my_test=mod(rechte[getvalue("document.send.styleguide")],document.send.styleguidel);
		if (document.send.bilddatenbank) if (mod(rechte[getvalue("document.send.bilddatenbank")],document.send.bilddatenbankl)>my_test)my_test=mod(rechte[getvalue("document.send.bilddatenbank")],document.send.bilddatenbankl);
		if (document.send.projektmanagment) if (mod(rechte[getvalue("document.send.projektmanagment")],document.send.projektmanagmentl)>my_test)my_test=mod(rechte[getvalue("document.send.projektmanagment")],document.send.projektmanagmentl);
		if (document.send.projektarchiv) if (mod(rechte[getvalue("document.send.projektarchiv")],document.send.projektarchivl)>my_test)my_test=mod(rechte[getvalue("document.send.projektarchiv")],document.send.projektarchivl);
		
		
		item.value=realm+'0='+my_test+'<br>';
		item.value+=realm+(id)+'=11111111<br>';
		if (document.send.home) {item.value+=realm+(id+1)+'='+mod(rechte[getvalue("document.send.home")],document.send.homedl)+"<br>";}
		else {item.value+=realm+(id+1)+'=00001000<br>';}
		if (document.send.styleguide){item.value+=realm+(id+2)+'='+mod(rechte[getvalue("document.send.styleguide")],document.send.styleguidedl)+"<br>";}
		else {item.value+=realm+(id+2)+'=00001000<br>';}
		if (document.send.bilddatenbank) {item.value+=realm+(id+3)+'='+mod(rechte[getvalue("document.send.bilddatenbank")],document.send.bilddatenbankdl)+"<br>";}
		else {item.value+=realm+(id+3)+'=00001000<br>';}
		if (document.send.projektmanagment) {item.value+=realm+(id+4)+'='+rechte[getvalue("document.send.projektmanagment")].replace(/x/,'0')+"<br>";}
		else {item.value+=realm+(id+4)+'=00001000<br>';}
		if (document.send.projektarchiv) {item.value+=realm+(id+5)+'='+mod(rechte[getvalue("document.send.projektarchiv")],document.send.projektarchivdl);}
		else {item.value+=realm+(id+5)+'=00001000';}
	}
	else
	{
		item.value=realm+'0=11111110<br>';
		item.value+=realm+(id)+'=11111111<br>';
		item.value+=realm+(id+1)+'=11111110<br>';
		item.value+=realm+(id+2)+'=11111110<br>';
		item.value+=realm+(id+3)+'=11111110<br>';
		item.value+=realm+(id+4)+'=00000000<br>';
		item.value+=realm+(id+5)+'=11111110';
		
	}
	setcheckbox(document.send.home,document.send.homedl);
	setcheckbox(document.send.styleguide,document.send.styleguidedl);
	setcheckbox(document.send.bilddatenbank,document.send.bilddatenbankdl);
	setcheckbox(document.send.projektmanagment,document.send.projektmanagmentdl);
	setcheckbox(document.send.projektarchiv,document.send.projektarchivdl);
	
	onrun=0;
	document.getElementById('netz_1').style.visibility='visible';
	document.getElementById('netz_2').style.visibility='visible';
	document.getElementById('netz_3').style.visibility='visible';
	document.getElementById('netz_4').style.visibility='visible';
	document.getElementById('netz_5').style.visibility='visible';
	
	}
	
}

function drucken(was)
{
	f=window.open(was,"drucken",'toolbar=yes,top=100,left=100, width=800,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no,dependent=no');	
}