function butOn(button, pos)
{ 
	if (document.images && button.length > 0) 	
	{
		document.images[button].src = '/images/nav_' + button + '_on.png'; 		
	}
} 

function butOff(button)
{ 
	if (document.images) 
	{
		 document.images[button].src = '/images/nav_' + button + '_off.png'; 
	}
}

var whites = new Array('bridge_0', 'bridge_1', 'bridge_2', 'bridge_3');

function bridgeOn(pos, eckbild)
{
	document.images[whites[0]].src = eckbild;
	document.images[whites[1]].src = '/images/nav_highlight_klammer_aussen.gif';
	document.images[whites[2]].src = '/images/nav_highlight_klammer_mitte.gif';
	document.images[whites[3]].src = '/images/nav_highlight_klammer_aussen.gif';
	
	for (i = 4; i < 4 + pos*4; i++)
	{
		document.images['bridge_' + i].src = '/images/px_weiss.gif';		
		whites[i] = 'bridge_' + i;
		
		for (j = pos*4 - 1; j > 4; j = j - 4)
		{
			document.images['bridge_' + j].src = '/images/trans.gif';
		}
	}
	
}

function bridgeOff()
{
	for (i = 0; i < whites.length; i++)
	{
		document.images[whites[i]].src = '/images/trans.gif';
	}
}
var win;
function openWin(url,width,height,scrollbars)
	{
		var posx = screen.width/2 - width/2;  
		var posy = screen.height/2 - height/2;
		var propsZ=(document.all)?('top=' + posy + ',left=' + posx):('screenX=' + posx + ',screenY=' + posy);
		var props = 'width=' + width + ',height=' + height + ',scrollbars=' +scrollbars + ',' + propsZ;
		
		if ( win && !win.closed )
			alert( 'Ein Bearbeitungsfenster ist bereits offen.\nSchliessen Sie bitte das Fenster bevor Sie fortfahren.' );
		else
		{
			win = window.open(url, "", props);			
		}
	}	

function writeSubnav(pos)
{
	if (document.layers)
	{
		document.submenu_ns.top = 126;
		document.submenu_ns.left = findLeft(27);
		with(document.submenu_ns.document)
		{
			open();
			write('<span class="subnav">');
			write(cats[pos]);
			write('</span>');
			close();
		}
	}
	
	else if (document.all)
	{
		document.all.submenu.innerHTML = cats[pos];
	}
	
	else if (document.documentElement)
	{
		document.getElementById('submenu').innerHTML = cats[pos];
	}
}

function writeTableBlock(cnt)
{
if (document.layers)
	{
		document.tbns.top = 410;
		document.tbns.left = 170;
		with(document.tbns.document)
		{			
			open();
			write(cnt);
			close();
		}
	}
	
	else if (document.all)
	{
		document.all.tableBlock.innerHTML = cnt;
	}
	
	else if (document.documentElement)
	{
		document.getElementById('tableBlock').innerHTML = cnt;
	}
}

function openWin(url,width,height,scrollbars)
	{
		var posx = screen.width/2 - width/2;  
		var posy = screen.height/2 - height/2;
		var propsZ=(document.all)?('top=' + posy + ',left=' + posx):('screenX=' + posx + ',screenY=' + posy);
		var props = 'width=' + width + ',height=' + height + ',scrollbars=' +scrollbars + ',' + propsZ;
		
		window.open(url, "", props);
	}	
	
// Globale Variable für findLeft
var LAYOUT_WIDTH        = 754;


// Neue x-Position berechnen, wenn das Fenster größer ist
function findLeft( width )
{
   return ( width + getContentOffset( LAYOUT_WIDTH ) );
}

// Breite des Clientfensters berechnen
function getClientWidth()    {
   var clWidth = -1;
      if (document.all) clWidth = document.body.clientWidth
   else clWidth  = window.outerWidth - 12;

   return clWidth;
}


// Offset zum Rand berechnen
function getContentOffset( contentWidth )    {
   var balken        = 0;
   var pageOffset = 0;
   var Scrollbars = false;
      if (document.all) {
       clWidth  = document.body.clientWidth;
       clHeight = document.body.clientHeight;
   } else {               clWidth  = window.outerWidth - 28;
       if (parseFloat(navigator.appVersion) >= 5 && navigator.appName=="Netscape") {               clHeight = window.innerHeight;
           Scrollbars = ( clHeight < document.height );
       } else {
           Scrollbars = window.scrollbars.visible;
       }
   }
      if (Scrollbars) balken = 15;
   if (clWidth > contentWidth) pageOffset = Math.round( ( clWidth - contentWidth ) / 2 );
   //    pageOffset -= balken;
   return pageOffset;
}

function centerBgIE()
{
	if(document.all)
	{	
		if(document.body.clientWidth % 2 > 0) 
		{
			document.all.kopf.style.backgroundPosition = getContentOffset( LAYOUT_WIDTH ) - 1;
		}		
		else 
		{
			document.all.kopf.style.backgroundPosition = 'center';
		}
	}	
}

function goDelete(target)
{		
	var sicher = confirm("Sicher löschen?");
	
	if (sicher) 
	{
		document.forms[0].action = target;
		document.forms[0].submit();
	}
}

function format(obj, textarea, tag) 
{
	
	var pad = obj.elements[textarea];
	
	if ( document.selection ) 
	{
		var sel = document.selection.createRange();
		if ( !sel.text  )
		{
			alert ( "Bitte markieren Sie zuerst einen Textabschnitt" );
			return;	
		}		
	}
	var _selection = document.selection ? sel.text : "<text>";
	
		
	switch( tag )
	{
		case 'a':
			openWin('/bo/formatLink.php', 500, 300, 'no');					
			break;
	
		default:
			if ( document.selection  && sel != null )
				sel.text = "[" + tag + "]" + _selection + "[/" + tag + "]";
			
			else
			{
				var formatted = prompt("Bitte, geben Sie den zu formattierenden Text ein: ", "<text>");
				formatted = "[" + tag + "]" + formatted + "[/" + tag + "]";
				pad.value += formatted;
				pad.focus();
			}
	}			
		
	
}


// Uebertragung von Options von einem Select ins andere
function selectPages()
{
	
	m1len = m1.length ;
  		
	for ( i=0; i<m1len ; i++)
	{
       	if (m1.options[i].selected == true ) 
		{
           	m2len = m2.length;
           	m2.options[m2len]= new Option(m1.options[i].text, m1.options[i].value, true, true);
       	}
   	}

   	for ( i = (m1len -1); i>=0; i--)
	{
       	if (m1.options[i].selected == true ) 
		{
           	m1.options[i] = null;
       	}
   	}
}

function unselectPages() 
{
   	m2len = m2.length ;
	
       for ( i=0; i<m2len ; i++)
	{
           if (m2.options[i].selected == true ) 
		{
               m1len = m1.length;
               m1.options[m1len]= new Option(m2.options[i].text);
           }
       }
       for ( i=(m2len-1); i>=0; i--) 
	{
           if (m2.options[i].selected == true ) 
		{
               m2.options[i] = null;
           }
       }
}

function selectAll()
{
	for (i=0; i<m2.length; i++) 
	{
		m2.options[i].selected = true;
	}
}
