/*-----------------------------------------------
- JavaScript
- by Mathias Fischer
- contact@trendfischer.de
-----------------------------------------------*/

/*-----------------------------------------------
- Standard Variablen
-----------------------------------------------*/
var debug="";
var liststyle="list-item";


/*-----------------------------------------------
- Helfer-Funktionen
-----------------------------------------------*/

//Alias für document.getElementById()
function $(id){return document.getElementById(id);}

//Verberge Elemente, die Javascript brauchen
function ifjs(html){document.write(html);}

function nl2br(text){
	while(text.indexOf("\n")!=-1)
		text=text.replace("\n","<br/>");
	return text;
}

function popup(element,x,y,scroll){
	neu = window.open(element.href, "stdedit", "width="+x+",height="+y+",left=0,top=0,scrollbars="+scroll);
	neu.focus();
	if(!neu)
		return true;
	return false;
}

function swap(element){
	if(element.style.display=="none")
		show(element.id);//element.style.display="block";
	else
		hide(element.id,1);//element.style.display="none";
}

function fade(id,time){
	
}

var hides=new Array();

function hide(styleelements,time){
  var elements=styleelements.split(" ");
  for(var key in elements){
    hides[elements[key]]=window.setTimeout('$("'+elements[key]+'").style.display="none"',time);
  }
}

function show(styleelements){
  var elements=styleelements.split(" ");
  for(var key in elements){
    document.getElementById(elements[key]).style.display="block";
    if(hides[elements[key]])
      window.clearTimeout(hides[elements[key]]);
  }
}



function switchlang(lang){
  var loc = location.href; 
  loc = loc.replace(/&?lang=../,''); 
  if(loc.indexOf('?')!=-1)
    loc = loc+'&'; 
  else
    loc = loc+'?'; 
  location.href=loc+'lang='+lang;
  return false;
}

/*-----------------------------------------------
- Form-Funktionen
-----------------------------------------------*/

function dynamicHeight(node,charsInLine,minLines,maxLines){
	var lines=0;
	var breakpos=0;
	node.onkeyup =function(){dynamicHeight(node,charsInLine,minLines,maxLines);};
	node.onkeypress =function(){dynamicHeight(node,charsInLine,minLines,maxLines);};
	while((breakpos = node.value.indexOf("\n",breakpos+1))!=-1)
		lines++;
	lines+=(node.value.length/charsInLine);
	lines+=3;
	if(lines<maxLines && lines > minLines )
		node.style.height=lines+"em";
	if(lines<minLines)
		node.style.height=minLines+"em";
	if(lines>maxLines)
		node.style.height=maxLines+"em";
	nodePrint(node,"Chars: "+node.value.length+" Lines: "+lines);
}

/*-----------------------------------------------
- DOM-Funktionen
-----------------------------------------------*/

//Verstecke Elemente eine Liste nach einem Filter
function filterList(id,filter){
	var root=$(id);
	for(var j=0;j<root.childNodes.length;j++){
		child=root.childNodes[j];
		if(child.nodeName=="LI"){
			if(child.innerHTML.toLowerCase().indexOf(filter.toLowerCase()) !=-1)
				child.style.display=liststyle;
			else
				child.style.display="none";
		}
	}
}

//Workaround for the IE6 :hover-disability
 function overlist(rootelement) {
    list=rootelement.getElementsByTagName("LI");
    for(var i in list){
      list[i].onmouseover=function(){this.className+=" over";}
      list[i].onmouseout=function(){this.className=this.className.replace(" over", "");}
    }
  }

/*-----------------------------------------------
- AJAX-Unterstützung
-----------------------------------------------*/

//Den IE vorbereiten
/*@cc_on @if (@_win32 && @_jscript_version >= 5) if (!window.XMLHttpRequest)
window.XMLHttpRequest = navigator.userAgent.toLowerCase().indexOf('msie 5') == -1 ?
	function() { return new ActiveXObject('Msxml2.XMLHTTP') } :
	function() { return new ActiveXObject('Microsoft.XMLHTTP') };
@end @*/


