function setPointer(theRow, thePointerColor, theNormalBgColor)
{
    var theCells = null;

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var currentColor = null;
    var newColor     = null;
    // Opera does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        } // end for
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = newColor;
        }
    }

    return true;
}



function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors = '\n'; }
  } if (errors) alert('Bitte Name, Vorname und Kürzel kontrollieren\n\n'+errors);
  document.MM_returnValue = (errors == '');
}

function openWin( windowURL, windowName, windowFeatures ) {
        return window.open( windowURL, windowName, windowFeatures ) ;
}

function del(Ziel,Datei) {
	if( confirm("Möchten Sie \""+Datei+"\" aus diesem Verzeichnis löschen?") ) { 
	window.location.href = Ziel; }
}
function delFromAll(Ziel,Datei) {
	if( confirm("Möchten Sie \""+Datei+"\" wirklich aus ALLEN Verzeichnissen löschen?") ) { 
	window.location.href = Ziel; }
}

function delFolder(element) {
	if(confirm('Möchten Sie wirklich '+element.title+'?')) 
		return true;
	else
		return false
}
function copyDefault(element){
	element.parentNode.getElementsByTagName('input')[0].value=element.lastChild.nodeValue;
}
function copyKat(element,value){
	var options=element.parentNode.getElementsByTagName('option');
	for(var i=0; i<options.length; i++) {
		if(options[i].value==value)
			options[i].selected=true;
		else
			options[i].selected=false;
	}
}

function delRechte(element) {
	//if(confirm("Möchten Sie diese Funktion für \""+Benutzer+"\" wirklich löschen?")){
	if(confirm('Möchten Sie wirklich '+element.title+'?')) 
		return true;
	else
		return false
}

function delRubrikArtikel(Ziel,Rubrik) {
	if( confirm("ACHTUNG: auch die zu dieser Rubrik zugewiesenen Artikel werden gelöscht!\nMöchten Sie die Rubrik \""+Rubrik+"\" trotzdem löschen?") ) { 
	window.location.href = Ziel; }
}

function delRubrik(Ziel,Rubrik) {
	if( confirm("Möchten Sie die Rubrik \""+Rubrik+"\" wirklich löschen?") ) { 
	window.location.href = Ziel; }
}

function delArtikel(Ziel,Artikel) {
	if( confirm("Möchten Sie den Artikel \""+Artikel+"\" wirklich löschen?") ) { 
	window.location.href = Ziel; }
}

function delUser(element){
	if(confirm('Möchten Sie wirklich '+element.title+'?')) 
		return true;
	else
		return false
}

function delFunction(Ziel,Charge) {
	if( confirm("Möchten Sie die Funktion \""+Charge+"\" wirklich löschen?") ) { 
	window.location.href = Ziel; }
}

function delMilestone(Ziel,Milestone) {
	if( confirm("Möchten Sie \""+Milestone+"\" wirklich löschen?") ) { 
	window.location.href = Ziel; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function checkformular(){
 if(document.upload.inUnterverzeichnis.checked == true){
  document.upload.Tiefe.disabled = false;

 }
 else{
  document.upload.Tiefe.disabled = true;
 }
}

function setBenutzername(){
 if(document.loginform.s_username.value == ""){
	 if(document.loginform.s_gruppe.value != ""){
		document.loginform.s_username.value = document.loginform.s_email.value;
     }
  } else {
   if(document.loginform.s_gruppe.value == "") {
	    document.loginform.s_username.value = "";
   }
  }
 }
//sigea
function addLoadEvent(func){
	if(window.addEventListener){
		window.addEventListener('load',func,false);
	}else if(window.attachEvent){
		window.attachEvent('onload',func);
	}else{
		var oldonload = window.onload;
		if (typeof window.onload != 'function'){
			window.onload = func;
		}else{
			window.onload = function(){
				oldonload();
				func();
			}
		}
	}
}

function insertAfter(newElement,targetElement){
	var parent = targetElement.parentNode;
	if (parent.lastChild == targetElement){
		parent.appendChild(newElement);
	}else{
		parent.insertBefore(newElement,targetElement.nextSibling);
	}
}

function addClass(element,value){
	if(!element.className){
		element.className = value;
	}else{
		if(element.className.indexOf(value) == -1){
			var newClassName = element.className;
			newClassName+= " ";
			newClassName+= value;
			element.className = newClassName;
		}
	}
}
function removeClass(element,value){
	if(element.className){
		var pattern= new RegExp(value);
		element.className=element.className.replace(pattern,'');
	}
}

function checkDate(date){
	var pattern= new RegExp("^[0-9]{1,2}\\D[0-9]{1,2}\\D([0-9]{2}){1,2}$");
	if(date.search(pattern)==-1){
		return false;
	}else{
		date = date.replace(/\D/g,'.');
		var tempDate=date.split('.');
		if(parseInt(tempDate[0],10)<1 || parseInt(tempDate[0],10)>31){
			return false;
		}else if(parseInt(tempDate[1],10)<1 || parseInt(tempDate[1],10)>12){
			return false;
		}else if((parseInt(tempDate[2],10)>99 && parseInt(tempDate[2],10)<1900) || parseInt(tempDate[2],10)>2100){
			return false;
		}else{
			return true;
		}
	}
}
function checkTime(time){
	var pattern= new RegExp("^[0-9]{1,2}\\D[0-9]{1,2}$");
	if(time.search(pattern)==-1){
		return false;
	}else{
		time = time.replace(/\D/g,':');
		var tmpTime=time.split(':');
		if(parseInt(tmpTime[0],10)<0 || parseInt(tmpTime[0],10)>24){
			return false;
		}else if(parseInt(tmpTime[1],10)<0 || parseInt(tmpTime[1],10)>59){
			return false;
		}else{
			return true;
		}
	}
}

function trimString(thisString){
	if(thisString!=''){
		while(thisString.substring(0,1)==' '){
			thisString = thisString.substring(1, thisString.length);
		}
		while(thisString.substring(thisString.length-1, thisString.length)==' '){
			thisString = thisString.substring(0,thisString.length-1);
		}
	}
	return thisString;
}
// http://javascript.crockford.com/memory/leak.html
function purge(d){
	var a = d.attributes, i, l, n;
	if(a){
		l = a.length;
		for (i = 0; i < l; i += 1){
			n = a[i].name;
			if (typeof d[n] === 'function'){
				d[n] = null;
			}
		}
	}
	a = d.childNodes;
	if(a){
		l=a.length;
		for (i = 0; i < l; i += 1){
			purge(d.childNodes[i]);
		}
	}
}
