﻿function genPreviewVereinstext() {
	var previewtext = document.getElementById('beschreibung_kurz').value;
	var preele = document.getElementById('prehl');
	preele.innerHTML = previewtext;
}
function init_cloning(obj,what) {
	switch(what) {
	case 'TR':
		var parent=obj;
		while((parent.tagName!='table' || parent.id=='undefined') && parent.parentNode) {
			parent=parent.parentNode;
			if(parent.tagName=='TABLE' && parent.id!='undefined') {
				eval(parent.id+'_clone=new clone()');
				eval(parent.id+'_clone.table=parent');
				obj.onclick=new Function('',parent.id+'_clone.clone'+what+'()');
				eval(parent.id+'_clone.clone'+what+'()');
				return;
			}
		}
	}
}
function clone() {
	this.index=0;
	this.cloneTR=function() {   
		this.index++;
		this.objClone = this.table.rows[this.table.rows.length-1].cloneNode(true);
		this.childs=this.objClone.getElementsByTagName("*");
		for(i=0; i<this.childs.length; i++) {
			if(this.childs[i].tagName.match(/textarea|input|select/i)) {
				if(this.childs[i].tagName=='INPUT' && this.childs[i].type=='text') {
					this.childs[i].removeAttribute('value');
				}
				this.childs[i].name=String(this.childs[i].name).replace(/\[\d*\]$/,'['+this.index+']');
			}
		}
		this.table.getElementsByTagName("tbody")[0].appendChild(this.objClone)
	}
}
