function trim(s) {
	s=s.replace(/\rn/,"");
	s=s.replace(/\r/,"");
	s=s.replace(/\n/,"");
	s=s.replace(/\t/,"");
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
 // alert("|"+s+"|");
  return s;
}

<!-- POPUP-SCRIPT -->

<!-- POPUP-SCRIPT -->

function showBox(i) {
	var box = getBoxen();
	box[i].style.display = "block";
}

function hideBox(i) {
	var box = getBoxen();

	if(box[i].style.display == "block"){
		box[i].style.display = "none";
	}
}

function toggleBox(i) {
	var box = getBoxen();

	for(x=0; x < box.length; x++){
		if(x==i){
		  if(box[i].style.display == "block"){
				box[i].style.display = "none";
			}else{
				box[i].style.display = "block";
			}
		}else{
			box[x].style.display = "none";
		}
	}
}


function getBoxen(){
	// Define the name of the id for the div which will be open
	var divID = "box_open";

	var div = new Array();
	var boxen = new Array();

    div = document.getElementsByTagName("div");
    for(var x=0; x<div.length; x++){
    	if(div[x].id == divID){
			boxen.push(div[x]);
		}else{
    		/*alert('falsches div');*/
    	}
    }
    return boxen;
}


// N E W   D R O P D O W N
// N E W   D R O P D O W N
// N E W   D R O P D O W N


function dropdownById(id, val) {
	var box = document.getElementById(id);

	if(box){
	  if(box.style.display == "block"){
			box.style.display = "none";
		}else{
			box.style.display = "block";
		}
	}
	if(val){
		var box_label = document.getElementById(id+'_label');
		var box_value = document.getElementById(id+'_value');

		if(box_label){
			box_label.innerHTML=val
		}else{
			alert('no label');
		}

		if(box_value && val){
			box_value.value=val;
		}else{
			alert('no hidden value');
		}
	}
	return false;
}

function dropdown(th, val) {
	var parent = th.parentNode;
	var id = parent.id;
	var box = document.getElementById(id);
	var box_label = document.getElementById(id+'_label');
	var box_value = document.getElementById(id+'_value');


	if(box){
	  if(box.style.display == "block"){
			box.style.display = "none";
		}else{
			box.style.display = "block";
		}
	}

	if(box_label){
		box_label.innerHTML=th.innerHTML;
	}else{
		alert('no label');
	}

	if(box_value && val){
		box_value.value=val;
	}else{
		alert('no hidden value');
	}
	return false;
}
