var isIE=document.all?true:false;
var isDOM=document.getElementById?true:false;
var isNS4=document.layers?true:false;

/* _w : which ID (1) or (2) */
/* _h : (h)ide or (s)how */


function toggleT(_w,_h) {
	if (isDOM)
		{
		if (_h=='s') document.getElementById(_w).style.display='block';
		if (_h=='h') document.getElementById(_w).style.display='none';
		}
	else if (isIE) {
		if (_h=='s') eval("document.all."+_w+".style.display='block';");
		if (_h=='h') eval("document.all."+_w+".style.display='none';");
		}
	else if(isNS4)
		{
		if (_h=='s') eval("document.layers['"+_w+"'].display='block';");
		if (_h=='h') eval("document.layers['"+_w+"'].display='none';");
		}
	}


window.addEvent('domready', function(){
	var hilfe = new Tips($$('.hilfe'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
			onShow: function(toolTip) {
			this.fx.start(1);
		},
			onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
			
});


// Ende: ToolTips (MooTools)


var tn_on_id=-1;
function tn_lo(id) {if (tn_on_id!=id) {tn_set(id,"lo");}}
function tn_hi(id) {if (tn_on_id!=id) {tn_set(id,"hi");}}
function tn_on(id) {tn_set(tn_on_id,"lo"); tn_on_id=id; tn_set(tn_on_id,"on");}
function tn_set(id,mode)
{
	var className="tn";
	var obj=null;
	if (mode=="hi") {className+="_hi";} else if (mode=="on") {className+="_on";}
	if (id>=0) {obj=document.getElementById('tn_'+id);}
	if (obj) {obj.className=className;}
}


// functions for window handling
var isopen=false;

function winClose(winname)
{ winname.close(); }

function lexilaunch(newURL, newName, newFeatures, orgName)
{ if( (isopen) && (!remote.closed) ){ winClose(remote); }
  var remote = window.open(newURL, newName, newFeatures);
  remote.window.opener.name = orgName;
}

// PopUp-Fenster

function popupWindow(url,titel,zusatz) {
		  newWindow = window.open(url,"titel",zusatz);
		  newWindow.focus();
		}
		
// PopUp-Fenster: ENDE

// Schriftgroessen anpassen

function FontSize(_size, _targets, _exceptions) {
	this.size = _size || 11;
	this.min = 9;
	this.max = 16;
	this.targets = _targets || ['fsTextbody','fsInfoBox','fsHeadnormal'];
	this.exceptions = _exceptions || 'haferbrei#hirsebrei#';
	this.lucky = this.checkBrowser();
}
FontSize.prototype = {
larger : function() {
	(this.size < this.max) ? ++this.size : this.size;
	if (this.lucky) this.scale();
},
smaller : function() {
	(this.size > this.min) ? --this.size : this.size + 'px';	 
	if (this.lucky) this.scale();
},
scale : function() {
	var oTarget = null;
	for (var k = 0; k < this.targets.length; k++) {
		oTarget = document.getElementById(this.targets[k]);
		if (oTarget) this.changeSize(oTarget);  
	}
},
changeSize : function(oo) {
	if (oo.style) {
		oo.style.fontSize = this.size + 'px';
		oo.style.lineHeight = '1.3em';
	}
	for (var k = 0; k < oo.childNodes.length; k++) if (this.exceptions.indexOf((oo.childNodes[k].id || '#') + '#') == -1) this.changeSize(oo.childNodes[k]);
},
checkBrowser : function() {
	if (document.all && document.getElementById) return true;
	if (navigator.userAgent.indexOf('Netscape6/') >= 0 || navigator.userAgent.indexOf('Gecko') >= 0) return true;
	return false;
},
inc : function(oo) {
	this.larger();
	if (oo) oo.blur();
	return false;	
},
dec : function(oo) {
	this.smaller();
	if (oo) oo.blur();
	return false;	
}
}
font_size = new FontSize();

// Schriftgroessen anpassen: ENDE

// PNG-Problemloesung im IE

function fixPNG(myImage) 
{
	try {
		if (window.ie6){
			myImage = $(myImage);
			var vis = myImage.getStyle('display') != 'none';
			if(!vis) myImage.setStyle('display','block');
			var width = $(myImage).offsetWidth;
			var height = $(myImage).offsetHeight;
			if(!vis) myImage.hide();
			var replacement = new Element('span', {
				id:(myImage.id)?myImage.id:'',
				'class':(myImage.className)?myImage.className:'',
				title:(myImage.title)?myImage.title:(myImage.alt)?myImage.alt:'',
				styles: {
					display: 'inline-block',
					width: width,
					height: height,
					filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='" 
						+ myImage.src + "', sizingMethod='scale');"
				},
				src: myImage.src
			});
			if(myImage.style.cssText) {
				try {
					var styles = {};
					var s = myImage.style.cssText.split(';');
					s.each(function(style){
						var n = style.split(':');
						styles[n[0]] = n[1];
					});
					replacement.setStyle(styles);
				} catch(e){ dbug.log('fixPNG1: ', e)}
			}
			if(replacement.cloneEvents) replacement.cloneEvents(myImage);
			myImage.replaceWith(replacement);
		}
	} catch(e) {dbug.log('fixPNG2: ', e)}
};
if(window.ie6) window.addEvent('domready', function(){$$('img.hilfe,img.fixPNG').each(function(png){fixPNG(png)});});

// ENDE: PNG-Problemloesung