var  num = 10;	// start number of cloning

function cloner(grp) {
	this.clonecnt       =  {};
	this.clonecnt[grp]  =  10;	//Number of Element-ID that will be cloned
	this.ie6            =  !!(document.all && navigator.appVersion.indexOf("MSIE 6.")!=-1);
}

cloner.prototype.create_clone =  function(grp, id, lastid) {
	var el, parent, nnode, clone, obj, cnt, radio, inp, inp_name, obj = this;
	this.clonecnt[grp] ++;			//increase index with step 1
	num ++;							//increase counter var with step 1
	el              =  document.getElementById(id);	//node that will copied
	parent          =  el.parentNode;//parentnode
	clone           =  el.cloneNode(true);	//true means copy subnodes
	clone.id        =  grp + "_" + this.clonecnt[grp]; // new node ID
	parent.appendChild(clone);		//insert copied node with new node ID

	nnode = clone.childNodes(0);	//first childnode of clone object with number of question
	nnode.innerHTML = num;			//modefy the number of question with counter var
	
	nnode = clone.childNodes(lastid-1);	//childnode of clone object (link to add answers)
	var ersatz = nnode.innerHTML.replace(/(hide_answer\()\d+/, "hide_answer("+num); //Replace the ID var with regular expressions
	nnode.innerHTML = ersatz;		//modify the ID in the link

	nnode = clone.childNodes(lastid);	//last childnode of clone object (hidden area for answers)
	var ersatz = nnode.outerHTML.replace(/(hide)\d+/, "hide"+num); //Replace the ID var with regular expressions
	nnode.outerHTML = ersatz;
		
	// Fix IE6 Bug at Radio Control
	inp = clone.getElementsByTagName("input");
	for (var i = 0; i < inp.length; i++) {
		if (inp[i].type.toLowerCase() != "radio") continue;
		inp_name    =  /(.+\_)[0-9]{1,3}$/i.exec(inp[i].name);
		inp_name    =  inp_name[1] + this.clonecnt[grp];
		if (this.ie6) {
			inp_curr            =  document.createElement('<input type="radio" name="' + inp_name + '">');
			inp_curr.value      =  inp[i].value;
			inp_curr.className  =  inp[i].className;
			inp[i].parentNode.replaceChild(inp_curr, inp[i]);
		} else {
			inp[i].name         =   inp_name;
		}
	}
}

//Object
_question = new cloner('question');