/**
 * JavaScript WMDOM Library
 * Copyright 2005 by Mathias Karstädt
 **/

String.prototype.tags = "address applet area a base basefont big blockquote body br b caption center cite code dd dfn dir div dl dt em font form h1 h2 h3 h4 h5 h6 head hr html img input isindex i kbd link li map menu meta ol option param pre p samp script select small strike strong style sub sup table td textarea th title tr tt ul u var".split(" ");

/**
 * Erstellt ein HTMLDOMElement, setzt die vorhandenen Attribute und bindet
 * automatisch Kinderelemente ein, sofern welche übergeben wurden.
 * Wenn ein String übergeben wird, wird dies als TextNode eingebunden.
 *
 * Bsp: "p".t("Ich bin ein Absatz");
 * Bsp: "div".t("p".t("Ich bin ein Absatz"));
 **/
String.prototype.t = function(children) 
{
	var tag = document.createElement(this);
	if (this.attribs != null) 
	{
		for(var i = 0; i < this.attribs.length; i++) 
		{
			var attr = this.attribs[i];
			if (attr.name == "class") {
				tag.className = attr.value;
			}else{
				tag.setAttribute(attr.name, attr.value);
			}
		}
	}
	return appendChildren(tag, children);
}

/**
 * Setzt ein oder mehrere Attribute.
 * wenn der erste Parameter ein Array ist, dann wird dieses verwendet.
 *
 * Bsp: "img".a("src","test.jpg");
 **/
String.prototype.a = function(n, v) 
{
	if (this.attribs == undefined || this.attribs == null) this.attribs = new Array();
	if (arguments.length > 1) 
	{
		this.attribs.push({name : n, value : v});
	} 
	else if (arguments.length == 1)
	{
		if (n.length != undefined) 
		{
			for (var i = 0; i < n.length; i++) 
			{
				this.attribs.push({name : n[i][0], value : n[i][1]});
			}
		}
	}
	return this;
}

/**
 * Sucht nach einem HTML Element mit der ID.
 *
 * Bsp: "test".id();
 * Bsp: "test".id("h1".t("Header"));
 **/
String.prototype.id = function(children) 
{
	return appendChildren(document.getElementById(this), children);
}

/**
 * Sucht nach einem HTML Element mit dem übergebenen NAME Attribut.
 *
 * Bsp: "test".name();
 * Bsp: "test".name(1);
 * Bsp: "test".name(2,"h1".t("Header"));
 **/
String.prototype.name = function(nr, children) 
{
	var elements = document.getElementsByName(this);
	if (nr != null && typeof(nr) == "number" && children != null)
	{
		return appendChildren(elements[nr], children);
	}
	else if (nr != null && typeof(nr) == "number" && children == null)
	{
		return elements[nr];
	}
	else
	{
		return elements;
	}
}

/**
 * Hilfsfunktion um einem Element ChildElemente hinzuzufügen.
 **/
appendChildren = function(tag, children) {
	if (children != null) 
	{
		if (typeof(children) == "string" || typeof(children) == "number") 
		{
			var text = document.createTextNode(children);
			tag.appendChild(text);
			return tag;
		}
		else if (children.length != undefined && children.nodeName == undefined) 
		{
			for (var i = 0; i < children.length; i++)
			{
				var child = children[i];
				if (typeof(child) == "string" || typeof(children) == "number") 
				{
					var text = document.createTextNode(child);
					tag.appendChild(text);
				}
				else
				{
					tag.appendChild(child);
				}
			}
			return tag;
		}
		else 
		{
			tag.appendChild(children);
		}

	}
	return tag;
}

/**
 * Ermöglicht es die Funktion t() auch auf Arrays anzuwenden.
 *
 * Bsp: ["td","td","td"].t();
 **/
Array.prototype.t = function(children) 
{
	var tmp = new Array();
	for (var i = 0; i < this.length; i++) 
	{
		tmp[i] = this[i].t(children);
	}
	return tmp;
}

/**
 * Ermöglicht es die Funktion a() auch auf Arrays anzuwenden.
 *
 * Bsp: ["td","td"].a("style","color:blue");
 **/
Array.prototype.a = function(name, value) 
{
	for (var i = 0; i < this.length; i++) 
	{
		var t = this[i];
		this[i] = t.a(name, value);
	}
	return this;
}

/**
 * Umschließt die Inhalte des Arrays mit dem angegebenen Tag.
 * Wird ein Array als Parameter übergeben, versucht die Funktion
 * jedes Element aus dem ersten Array mit den Elementen aus
 * dem übergebenen Array zu umschließen.
 *
 * Bsp: ["id","name","address"].s("th");
 * Bsp: ["id","name","address"].s(["a","b","div".a("id","1")]);
 **/
Array.prototype.s = function(tag) 
{
		if (typeof(tag) == "string" || (tag.length == undefined && tag.nodeName == undefined))
		{
			//Wenn kein Array
			for (var i = 0; i < this.length; i++) 
			{
					if ("".tags.contains(this[i])) 
					{
						this[i] = tag.t(this[i].t());
					}
					else
					{
						this[i] = tag.t(this[i]);
					}
			}
		}
		else
		{
			//Wenn ein Array
			for (var i = 0; i < this.length; i++) 
			{
				for (var j = 0; j < tag.length; j++)
				{
					this[i] = tag[j].t(this[i]);
				}
			}
		}
	return this;
}

/**
 * Durchsucht das Array nach dem übergebenen Objekt und liefert true
 * zurück, wenn es gefunden wurde.
 **/
Array.prototype.contains = function(obj)
{
	for (var i = 0; i < this.length; i++)
	{
		var o = this[i];
		if (o == obj)
		{
			return true;
		}
	}
	return false;
}

/**
 * alle ChildNodes einer Node löschen
 **/
deleteChildNodes = function(element)
{
	var childrenLength = element.childNodes.length;
	if (childrenLength > 0)
	{
		for (var i = childrenLength; i > 0; i--)
		{
			var childNode = element.childNodes[i-1];
			element.removeChild(childNode);
		}
	}
}




// JavaScript Document
function remove_children(node)
{
	while (node.hasChildNodes())
		node.removeChild(node.firstChild);
}


function getSubCat() {  
  
		var id = $('selectmaincategory').value;
		if(id != ""){
			//10.0.2.2
			new Ajax.Request("fileadmin/php-scripts/mathemagie/include/ajax/getSubCat.php?subid=" + escape(id), { 

					method:'get',
					
					onSuccess: function(transport) {
					
						theSubcategories = $('divsubcategories');

						var json = transport.responseText;					
						
						if(json == ""){
							remove_children(theSubcategories);
						} else {					
						
						var result = eval ("(" + json + ")");
					
							remove_children(theSubcategories);
						
							theSelect = document.createElement("select");
							theSubcategories.appendChild(theSelect);
							
							theSelect.name = "tbl_category_subid";
							//newSelect in theSubcategories platzieren
							
							//neues Optionfeld machen und es dem Selectfeld hinzufügen
							theOption = new Option("", "");
							theSelect.appendChild(theOption);
							
							for(i = 0; i < result.subcategories.length; i++){
								//Option Feld erzeugen, Value setzen, Text setzen
								theOptioni = new Option("", "");
								theSelect.appendChild(theOptioni)
								
								theOptioni.value = result.subcategories[i].id;						
								theOptioni.text = result.subcategories[i].subcategory;
								
							}
						}
					}		
					
			});
		}
}


function getQandTorSubCat(uid, cid) {  
		var id = $('selectmaincategory').value;
		if(id != ""){
			//10.0.2.2
			var url = "fileadmin/php-scripts/mathemagie/include/ajax/getQandTorSubCat.php?cid=" + escape(cid) + "&subid=" + escape(id) + "&uid=" + escape(uid);
			
			
			new Ajax.Request(url, { 

					method:'get',
					
					onSuccess: function(transport) {
					
						json = transport.responseText;	
						
						
						if(json.indexOf("subcategories") != -1 ){ // keine subcats
								
								theResults = $('divresults');
								theSubcategories = $('divsubcategories');
								
								// anzeigen der Results
								var result = eval ("(" + json + ")");
								
								
								remove_children(theSubcategories);
								remove_children(theResults);
							
								//theSelect = document.createElement("select") ;
								theSelect = "select".a("name", "tbl_category_subid").a("id", "selectSubcategories").t();
								////alert(theSelect);
								
										
								Event.observe(theSelect,'change',new Function('fx', 'getQandT("' + escape(uid) + '","' + escape(cid) + '")'));
								
								//a("onchange", "getQandT(" + escape(uid) + "," + escape(cid) + ");")
								
								theSubcategories.appendChild(theSelect);
								
								//theSelect.name = "tbl_category_subid";
								//theSelect.
								//newSelect in theSubcategories platzieren
								
								//neues Optionfeld machen und es dem Selectfeld hinzufügen
								theOption = new Option("", "");
								theSelect.appendChild(theOption);
								
								for(i = 0; i < result.subcategories.length; i++){
									//Option Feld erzeugen, Value setzen, Text setzen
									theOptioni = new Option("", "");
									theSelect.appendChild(theOptioni)
									
									theOptioni.value = result.subcategories[i].id;						
									theOptioni.text = result.subcategories[i].subcategory;
								}				
								
							
							
						}; // end if(json.indexOf("subcategories") != -1 )
						
						
						if(json.indexOf("date") != -1){ // es hat keine subcats
							
							theResults = $('divresults');
							theSubcategories = $('divsubcategories');
							
							var result = eval ("(" + json + ")");
															
							remove_children(theSubcategories);
							remove_children(theResults);
							
							
					
							for(i = 0; i < result.QandT.length; i++){
							
						
							if (result.QandT[i].userQuestions && result.QandT[i].userQuestions.length > 0){

									var theH2i = "h2".t("Von Ihnen erfasste Aufgaben in der Kategorie " + result.QandT[i].userQuestions[0].category);
									theResults.appendChild(theH2i);
									
									var theTablei     	= "table".t();
									var theTableBodyi 	= "tbody".t();
									
									var theTRi			= "tr".t(); 
									var theTD1i 		= "td".t(); 
									var theTD2i 		= "td".t();
									var theTD3i			= "td".t();
									var theTD4i 		= "td".t(); 
									
									var theP1i 			= "p".t("Kategorie");
									var theP2i 			= "p".t("Datum");
									var theP3i 			= "p".t("Aufgabe");
									var theP4i 			= "p".t("Funktion");
									
									theTD1i.appendChild(theP1i);
									theTD2i.appendChild(theP2i);
									theTD3i.appendChild(theP3i);
									theTD4i.appendChild(theP4i);							
									
									theTRi.appendChild(theTD1i);
									theTRi.appendChild(theTD2i);
									theTRi.appendChild(theTD3i);
									theTRi.appendChild(theTD4i);
									
									theTableBodyi.appendChild(theTRi);
									
									for(j = 0; j < result.QandT[i].userQuestions.length; j++){
										
										var theTRij			= "tr".t();
										var theTD1ij 		= "td".t(); 
										var theTD2ij 		= "td".t();
										var theTD3ij		= "td".t();
										var theTD4ij 		= "td".t(); 
										
										var theP1ij 		= "p".t(result.QandT[i].userQuestions[j].category);
										var theP2ij			= "p".t(result.QandT[i].userQuestions[j].date);
										
										var theLightboxLinkij	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + result.QandT[i].userQuestions[j].cid + "&qid=" + result.QandT[i].userQuestions[j].qid + "&category=" + result.QandT[i].userQuestions[j].category + "").a("class", "lbOn").t(result.QandT[i].userQuestions[j].text);
										
										
										var theP3ij 		= "p".t();
										
										var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("title", "Frage hinzufügen").t();
										
										Event.observe(theImgij,'click',new Function('fx', 'addEntryToPdf("'+result.QandT[i].userQuestions[j].qid+'","'+result.QandT[i].userQuestions[j].cid+'","'+0+'")'));

										
										/*var theImgij = document.createElement('img');
										theImgij.src = "fileadmin/templates/img/add.gif"; 
										theImgij.title = "Frage hinzufügen";
										theImgij.addEventListener("click", addEntryToPdf( result.QandT[i].userQuestions[j].qid + "," + result.QandT[i].userQuestions[j].cid + ",0", true));
										
										*/
										
										//theImgij.
										
										theP3ij.appendChild(theLightboxLinkij);
										
										theTD1ij.appendChild(theP1ij);
										theTD2ij.appendChild(theP2ij);
										theTD3ij.appendChild(theP3ij);
										
										theTD4ij.appendChild(theImgij);
										
										theTRij.appendChild(theTD1ij);
										theTRij.appendChild(theTD2ij);
										theTRij.appendChild(theTD3ij);
										theTRij.appendChild(theTD4ij);
									
										theTableBodyi	.appendChild(theTRij);
										
										theImgij.style.cursor = "pointer";
										
										//checkbox erstellen*/
										
									} // end for
							

									// put the <tbody> in the <table>
									theTablei.appendChild(theTableBodyi);
									// appends <table> into <body>
									theResults.appendChild(theTablei);
									// sets the border attribute of tbl to 2;
									theTablei.style.width = "100%";	
									theTablei.style.margin = "15px 0 15px 0";
									theTablei.cellSpacing = "0";
									
									theP1i.style.fontWeight = "bold";
									theP2i.style.fontWeight = "bold";
									theP3i.style.fontWeight = "bold";
									theP4i.style.fontWeight = "bold";
									
									theTD1i.style.width = "28%";
									theTD2i.style.width = "15%";
									theTD3i.style.width = "35%";
									
								
									
								}// ende if (result.QandT[i].userQuestions.length > 0){
							
							if (result.QandT[i].userTheory && result.QandT[i].userTheory.length > 0){
			var theH2i = "h2".t("Von Ihnen erfasste Theory in der Kategorie " + result.QandT[i].userTheory[0].category);
									theResults.appendChild(theH2i);
									
									var theTablei     	= "table".t();
									var theTableBodyi 	= "tbody".t();
									
									var theTRi			= "tr".t(); 
									var theTD1i 		= "td".t(); 
									var theTD2i 		= "td".t();
									var theTD3i			= "td".t();
									var theTD4i 		= "td".t(); 
									
									var theP1i 			= "p".t("Kategorie");
									var theP2i 			= "p".t("Datum");
									var theP3i 			= "p".t("Aufgabe");
									var theP4i 			= "p".t("Funktion");
									
									theTD1i.appendChild(theP1i);
									theTD2i.appendChild(theP2i);
									theTD3i.appendChild(theP3i);
									theTD4i.appendChild(theP4i);							
									
									theTRi.appendChild(theTD1i);
									theTRi.appendChild(theTD2i);
									theTRi.appendChild(theTD3i);
									theTRi.appendChild(theTD4i);
									
									theTableBodyi.appendChild(theTRi);
									
									for(j = 0; j < result.QandT[i].userTheory.length; j++){
										
										var theTRij			= "tr".t();
										var theTD1ij 		= "td".t(); 
										var theTD2ij 		= "td".t();
										var theTD3ij			= "td".t();
										var theTD4ij 		= "td".t(); 
										
										var theP1ij 		= "p".t(result.QandT[i].userTheory[j].category);
										var theP2ij			= "p".t(result.QandT[i].userTheory[j].date);
										
										var theLightboxLinkij	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + result.QandT[i].userTheory[j].cid + "&tid=" + result.QandT[i].userTheory[j].tid + "&category=" + result.QandT[i].userTheory[j].category + "").a("class", "lbOn").t(result.QandT[i].userTheory[j].text);
										
										
										var theP3ij 		= "p".t();
										
										/*var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("onclick", "addEntryToPdf(" + result.QandT[i].userTheory[j].tid + "," + result.QandT[i].userTheory[j].cid + ",1);").a("title", "Theory hinzufügen").t();*/
										
										var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("title", "Theorie hinzufügen").t();
										
										Event.observe(theImgij,'click',new Function('fx', 'addEntryToPdf("'+result.QandT[i].userTheory[j].tid+'","'+result.QandT[i].userTheory[j].cid+'","'+1+'")'));

										
										theP3ij.appendChild(theLightboxLinkij);
										
										
										theTD1ij.appendChild(theP1ij);
										theTD2ij.appendChild(theP2ij);
										theTD3ij.appendChild(theP3ij);
										
										theTD4ij.appendChild(theImgij);
										
										theTRij.appendChild(theTD1ij);
										theTRij.appendChild(theTD2ij);
										theTRij.appendChild(theTD3ij);
										theTRij.appendChild(theTD4ij);
									
										theTableBodyi	.appendChild(theTRij);
										
										theImgij.style.cursor = "pointer";
										
										//checkbox erstellen*/
										
									} // end for
							

									// put the <tbody> in the <table>
									theTablei.appendChild(theTableBodyi);
									// appends <table> into <body>
									theResults.appendChild(theTablei);
									// sets the border attribute of tbl to 2;
									theTablei.style.width = "100%";	
									theTablei.style.margin = "15px 0 15px 0";
									theTablei.cellSpacing = "0";
									
									theP1i.style.fontWeight = "bold";
									theP2i.style.fontWeight = "bold";
									theP3i.style.fontWeight = "bold";
									theP4i.style.fontWeight = "bold";
									theTD1i.style.width = "28%";
									theTD2i.style.width = "15%";
									theTD3i.style.width = "35%";

								
							}
							
							
							if (result.QandT[i].otherQuestions && result.QandT[i].otherQuestions.length > 0){
			var theH2i = "h2".t("Von anderen erfasste Aufgaben in der Kategorie " + result.QandT[i].otherQuestions[0].category);
									theResults.appendChild(theH2i);
									
									var theTablei     	= "table".t();
									var theTableBodyi 	= "tbody".t();
									
									var theTRi			= "tr".t(); 
									var theTD1i 		= "td".t(); 
									var theTD2i 		= "td".t();
									var theTD3i			= "td".t();
									var theTD4i 		= "td".t(); 
									
									var theP1i 			= "p".t("Kategorie");
									var theP2i 			= "p".t("Datum");
									var theP3i 			= "p".t("Aufgabe");
									var theP4i 			= "p".t("Funktion");
									
									theTD1i.appendChild(theP1i);
									theTD2i.appendChild(theP2i);
									theTD3i.appendChild(theP3i);
									theTD4i.appendChild(theP4i);							
									
									theTRi.appendChild(theTD1i);
									theTRi.appendChild(theTD2i);
									theTRi.appendChild(theTD3i);
									theTRi.appendChild(theTD4i);
									
									theTableBodyi.appendChild(theTRi);
									
									for(j = 0; j < result.QandT[i].otherQuestions.length; j++){
										
										var theTRij			= "tr".t();
										var theTD1ij 		= "td".t(); 
										var theTD2ij 		= "td".t();
										var theTD3ij		= "td".t();
										var theTD4ij 		= "td".t(); 
										
										var theP1ij 		=  "p".t(result.QandT[i].otherQuestions[j].category);
										var theP2ij			= "p".t(result.QandT[i].otherQuestions[j].date);
										
										var theLightboxLinkij	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + result.QandT[i].otherQuestions[j].cid + "&qid=" + result.QandT[i].otherQuestions[j].qid + "&category=" + result.QandT[i].otherQuestions[j].category + "").a("class", "lbOn").t(result.QandT[i].otherQuestions[j].text);
										
										
										var theP3ij 		= "p".t();
										
										/*var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("onclick", "addEntryToPdf(" + result.QandT[i].otherQuestions[j].qid + "," + result.QandT[i].otherQuestions[j].cid + ",0);").a("title", "Frage hinzufügen").t();*/
										
										var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("title", "Frage hinzufügen").t();
										
										Event.observe(theImgij,'click',new Function('fx', 'addEntryToPdf("'+result.QandT[i].otherQuestions[j].qid+'","'+result.QandT[i].otherQuestions[j].cid+'","'+0+'")'));

										
										theP3ij.appendChild(theLightboxLinkij);
										theTD1ij.appendChild(theP1ij);
										theTD2ij.appendChild(theP2ij);
										theTD3ij.appendChild(theP3ij);
										
										theTD4ij.appendChild(theImgij);
										
										theTRij.appendChild(theTD1ij);
										theTRij.appendChild(theTD2ij);
										theTRij.appendChild(theTD3ij);
										theTRij.appendChild(theTD4ij);
									
										theTableBodyi.appendChild(theTRij);
										
										theImgij.style.cursor = "pointer";
										
										//checkbox erstellen*/
										
									} // end for
							

									// put the <tbody> in the <table>
									theTablei.appendChild(theTableBodyi);
									// appends <table> into <body>
									theResults.appendChild(theTablei);
									// sets the border attribute of tbl to 2;
									theTablei.style.width = "100%";	
									theTablei.style.margin = "15px 0 15px 0";
									theTablei.cellSpacing = "0";
									
									theP1i.style.fontWeight = "bold";
									theP2i.style.fontWeight = "bold";
									theP3i.style.fontWeight = "bold";
									theP4i.style.fontWeight = "bold";
									theTD1i.style.width = "28%";
									theTD2i.style.width = "15%";
									theTD3i.style.width = "35%";

								
							}
							
							
							if (result.QandT[i].otherTheory && result.QandT[i].otherTheory.length > 0){
								var theH2i = "h2".t("Von anderen erfasste Theoriebeiträge in der Kategorie " + result.QandT[i].otherTheory[0].category);
									theResults.appendChild(theH2i);
									
									var theTablei     	= "table".t();
									var theTableBodyi 	= "tbody".t();
									
									var theTRi			= "tr".t(); 
									var theTD1i 		= "td".t(); 
									var theTD2i 		= "td".t();
									var theTD3i			= "td".t();
									var theTD4i 		= "td".t(); 
									
									var theP1i 			= "p".t("Kategorie");
									var theP2i 			= "p".t("Datum");
									var theP3i 			= "p".t("Aufgabe");
									var theP4i 			= "p".t("Funktion");
									
									theTD1i.appendChild(theP1i);
									theTD2i.appendChild(theP2i);
									theTD3i.appendChild(theP3i);
									theTD4i.appendChild(theP4i);							
									
									theTRi.appendChild(theTD1i);
									theTRi.appendChild(theTD2i);
									theTRi.appendChild(theTD3i);
									theTRi.appendChild(theTD4i);
									
									theTableBodyi.appendChild(theTRi);
									
									var PDF 				= $('pdfid').value;

									
									for(j = 0; j < result.QandT[i].otherTheory.length; j++){
										
										var theTRij			= "tr".t();
										var theTD1ij 		= "td".t(); 
										var theTD2ij 		= "td".t();
										var theTD3ij		= "td".t();
										var theTD4ij 		= "td".t(); 
										
										
									
										var theP1ij 		= "p".t(result.QandT[i].otherTheory[j].category);
										var theP2ij			= "p".t(result.QandT[i].otherTheory[j].date);
										
										
										var theLightboxLinkij	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + result.QandT[i].otherTheory[j].cid + "&tid=" + result.QandT[i].otherTheory[j].tid + "&category=" + result.QandT[i].otherTheory[j].category + "").a("class", "lbOn").t(result.QandT[i].otherTheory[j].text);
										
										var theP3ij 		= "p".t();
										/*
										var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("onclick", "addEntryToPdf(" + result.QandT[i].otherTheory[j].tid + "," + result.QandT[i].otherTheory[j].cid + ",1);").a("title", "Theory hinzufügen").t();*/
										
										var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("title", "Theorie hinzufügen").t();
										
										Event.observe(theImgij,'click',new Function('fx', 'addEntryToPdf("'+result.QandT[i].otherTheory[j].tid+'","'+result.QandT[i].otherTheory[j].cid+'","'+1+'")'));

										
										theP3ij.appendChild(theLightboxLinkij);
										
										theTD1ij.appendChild(theP1ij);
										theTD2ij.appendChild(theP2ij);
										theTD3ij.appendChild(theP3ij);
										theTD4ij.appendChild(theImgij);
										
										theTRij.appendChild(theTD1ij);
										theTRij.appendChild(theTD2ij);
										theTRij.appendChild(theTD3ij);
										theTRij.appendChild(theTD4ij);
									
										theTableBodyi	.appendChild(theTRij);
										
										theImgij.style.cursor = "pointer";
										
										//checkbox erstellen*/
										
									} // end for
							

									// put the <tbody> in the <table>
									theTablei.appendChild(theTableBodyi);
									// appends <table> into <body>
									theResults.appendChild(theTablei);
									// sets the border attribute of tbl to 2;
									theTablei.style.width = "100%";	
									theTablei.style.margin = "15px 0 15px 0";
									theTablei.cellSpacing = "0";
									
									theP1i.style.fontWeight = "bold";
									theP2i.style.fontWeight = "bold";
									theP3i.style.fontWeight = "bold";
									theP4i.style.fontWeight = "bold";
									theTD1i.style.width = "28%";
									theTD2i.style.width = "15%";
									theTD3i.style.width = "35%";

								
							}
								
							} // ende for
							
							getEntryFromCurrentPdf();
	
						}; // 	if(json.indexOf("date") != -1){ // es hat subcats

					}// onSuccess:
				
			}); // end new Ajax.Request
		} // end 		if(id != ""){
} // end functin




function sendMail() {  
  
		var emailAuthor = $('emailAuthor').value;
		var emailUser = $('emailUser').value;
		var nachricht = $('nachricht').value;
		var art = $('art').value;

			new Ajax.Request("fileadmin/php-scripts/mathemagie/include/ajax/sendMail.php?emailAuthor=" + escape(emailAuthor) + "&emailUser=" + escape(emailUser) + "&nachricht=" + escape(nachricht) + "&art=" + escape(art), { 

					method:'get',
					
					onSuccess: function(transport) {
			
						theDiv = $('formular');
						h1 = $('h1');
						h2 = $('h2');

						theTextH1 = document.createTextNode("Email verschickt.");
						theTextH2 = document.createTextNode("Das Email wurde erfolgreich an " + emailAuthor + " verschickt.\n\nDanke dass Sie sich um die Quailität von Aufgaben und Theoriebeträgen auf MatheMagie bemühen.");

												
						remove_children(theDiv)
						remove_children(h1)
						remove_children(h2)
						
						h1.appendChild(theTextH1);
						h2.appendChild(theTextH2);
						
					}
					
			});
		
}


function addEntryToPdf(entryid, cid, type){
	
		var uid = $('uid').value;
		var pdfid = $('pdfid').value;
		
	
		if(type == 0){
		
			var url = "fileadmin/php-scripts/mathemagie/include/ajax/addEntryToPdf.php?tid=false&qid=" + escape(entryid) + "&cid=" + escape(cid) + "&uid=" + escape(uid) + "&pdfid=" + escape(pdfid);
	
		} else if (type == 1){
			var url = "fileadmin/php-scripts/mathemagie/include/ajax/addEntryToPdf.php?qid=false&tid=" + escape(entryid) + "&cid=" + escape(cid) + "&uid=" + escape(uid) + "&pdfid=" + escape(pdfid);
				
		}
		
		new Ajax.Request(url, { 

				method:'get',
					
				onSuccess: function(transport) {
					
					var success = transport.responseText;	
					//alert("addentrytopdf:" + success);		
					if(success != ""){
				
						getEntryFromCurrentPdf();					
					}			
				},
				
				onFailure: function(){
					alert("addentrytopdf: Fehler");
				}
					
		});
		
		
}

function deleteEntryFromPdf(entryid){
	
		
		var url = "fileadmin/php-scripts/mathemagie/include/ajax/deleteEntryFromPdf.php?id=" + escape(entryid);
	
		new Ajax.Request(url, { 

				method:'get',
					
				onSuccess: function(transport) {
						var success = transport.responseText;	
						
						if(success != ""){
							getEntryFromCurrentPdf();					
						}
				}
				
					
		});
		
		
}



function getEntryFromCurrentPdf(){
		//getEntryFromCurrentPdf();
					
		var cid = $('cid').value;
		var pdfid = $('pdfid').value;
		
		
		var url = "fileadmin/php-scripts/mathemagie/include/ajax/getEntryFromCurrentPdf.php?pdfid=" + escape(pdfid);
		
		
		new Ajax.Request(url, { 
	
				method:'get',
					
				onSuccess: function(transport) {
					//darstellen der Aufgaben & der Theory im Pdf
						
					var json = transport.responseText;	
					var result = eval ("(" + json + ")");
					
					
					var divCurrentPdf = $('divCurrentPdf');
					
					remove_children(divCurrentPdf);
					
					
					//if (result.QandT[i].userTheory && result.QandT[i].userTheory.length > 0){

					if (result.currentPdf && result.currentPdf.length > 0){
					
						var pdfH2 = "h2".t("Ihr momentanes PDF enthält folgende Einträge.");
	
						divCurrentPdf.appendChild(pdfH2);
										
						var theTable  	 	= "table".t();
						var theTableBody 	= "tbody".t();
										
						var theTR			= "tr".t(); 
						var theTD1 			= "td".t(); 
						var theTD2 			= "td".t();
						var theTD3			= "td".t();
						var theTD4 			= "td".t(); 
										
						var theP1 			= "p".t("Kategorie");
						var theP2 			= "p".t("Typ");
						var theP3 			= "p".t("Inhalt");
						var theP4 			= "p".t("Funktion");
										
						theTD1.appendChild(theP1);
						theTD2.appendChild(theP2);
						theTD3.appendChild(theP3);
						theTD4.appendChild(theP4);							
								
						theTR.appendChild(theTD1);
						theTR.appendChild(theTD2);
						theTR.appendChild(theTD3);
						theTR.appendChild(theTD4);
										
						theTableBody.appendChild(theTR);
										
						for(j = 0; j < result.currentPdf.length; j++){
											
							var theTRj			= "tr".t();
							var theTD1j 		= "td".t(); 
							var theTD2j 		= "td".t();
							var theTD3j			= "td".t();
							var theTD4j 		= "td".t(); 
										
							var theP1j 		= "p".t(result.currentPdf[j].category);
							
							
							if(result.currentPdf[j].type == "1"){
								var theP2j 		= "p".t("Theorie");
							} else {
								var theP2j 		= "p".t("Aufgabe");
							}
							
							var theP3j			= "p".t();
							
							if(result.currentPdf[j].type == "1"){
							var theLightboxLinkj	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + escape(cid) + "&tid=" + result.currentPdf[j].entryid + "&category=" + result.currentPdf[j].category + "").a("class", "lbOn").t(result.currentPdf[j].text);
							} else {
								
								var theLightboxLinkj	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + escape(cid) + "&qid=" + result.currentPdf[j].entryid + "&category=" + result.currentPdf[j].category + "").a("class", "lbOn").t(result.currentPdf[j].text);
								
							}
							
											
							var theImgj 	= "img".a("src","fileadmin/templates/img/remove.gif").a("title", "Entfernen").t();
							
							Event.observe(theImgj,'click',new Function('fx', 'deleteEntryFromPdf("'+result.currentPdf[j].id+'")'));

							
							theP3j.appendChild(theLightboxLinkj);
							
							theTD1j.appendChild(theP1j);
							theTD2j.appendChild(theP2j);
							theTD3j.appendChild(theP3j);
											
							theTD4j.appendChild(theImgj);
											
							theTRj.appendChild(theTD1j);
							theTRj.appendChild(theTD2j);
							theTRj.appendChild(theTD3j);
							theTRj.appendChild(theTD4j);
										
							theTableBody.appendChild(theTRj);
											
							theImgj.style.cursor = "pointer";
											
											//checkbox erstellen
										
						} // end for
								
	
										// put the <tbody> in the <table>
						theTable.appendChild(theTableBody);
										// appends <table> into <body>
						divCurrentPdf.appendChild(theTable);
										// sets the border attribute of tbl to 2;
						theTable.style.width = "100%";	
						theTable.style.margin = "15px 0 15px 0";
						theTable.cellSpacing = "0";
										
						theP1.style.fontWeight = "bold";
						theP2.style.fontWeight = "bold";
						theP3.style.fontWeight = "bold";
						theP4.style.fontWeight = "bold";
										
						theTD1.style.width = "28%";
						theTD2.style.width = "16%";
						theTD3.style.width = "35%";
										
						initialize();	
										
					}// ende if (result.currentPdf.length > 0){
						
					
					if (result.currentPdf.length < 1){
						
						var pdfH2 = "h2".t("Ihr momentanes PDF enthält noch keine Einträge.");
	
						divCurrentPdf.appendChild(pdfH2);
						initialize();
					}	
					
				} 			
				
				
		});
						
	
}



function getQandT(uid, cid) {  
  		var subid = $('selectSubcategories').value;
		
		var url = "fileadmin/php-scripts/mathemagie/include/ajax/getQandT.php?cid=" + escape(cid) + "&subid=" + escape(subid) + "&uid=" + escape(uid);
		
		
			//10.0.2.2
			new Ajax.Request(url, { 

					method:'get',
					
					onSuccess: function(transport) {
					
						var json = transport.responseText;	

						var result = eval ("(" + json + ")");
											
						if(result.QandT.length > 0){ // es hat subcats
							
							remove_children(theResults);
					
							for(i = 0; i < result.QandT.length; i++){
							
							if (result.QandT[i].userQuestions && result.QandT[i].userQuestions.length > 0){
									
									var theH2i = "h2".t("Von Ihnen erfasste Aufgaben in der Kategorie " + result.QandT[i].userQuestions[0].category);
									theResults.appendChild(theH2i);
									
									var theTablei     	= "table".t();
									var theTableBodyi 	= "tbody".t();
									
									var theTRi			= "tr".t(); 
									var theTD1i 		= "td".t(); 
									var theTD2i 		= "td".t();
									var theTD3i			= "td".t();
									var theTD4i 		= "td".t(); 
									
									var theP1i 			= "p".t("Kategorie");
									var theP2i 			= "p".t("Datum");
									var theP3i 			= "p".t("Aufgabe");
									var theP4i 			= "p".t("Funktion");
									
									theTD1i.appendChild(theP1i);
									theTD2i.appendChild(theP2i);
									theTD3i.appendChild(theP3i);
									theTD4i.appendChild(theP4i);							
									
									theTRi.appendChild(theTD1i);
									theTRi.appendChild(theTD2i);
									theTRi.appendChild(theTD3i);
									theTRi.appendChild(theTD4i);
									
									theTableBodyi.appendChild(theTRi);
									
									for(j = 0; j < result.QandT[i].userQuestions.length; j++){
										
										var theTRij			= "tr".t();
										var theTD1ij 		= "td".t(); 
										var theTD2ij 		= "td".t();
										var theTD3ij			= "td".t();
										var theTD4ij 		= "td".t(); 
										
										var theP1ij 		= "p".t(result.QandT[i].userQuestions[j].category);
										var theP2ij			= "p".t(result.QandT[i].userQuestions[j].date);
										
										var theLightboxLinkij	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + result.QandT[i].userQuestions[j].cid + "&qid=" + result.QandT[i].userQuestions[j].qid + "&category=" + result.QandT[i].userQuestions[j].category + "").a("class", "lbOn").t(result.QandT[i].userQuestions[j].text);
										
										
										var theP3ij 		= "p".t();
										
										var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("title", "Frage hinzufügen").t();
										
										Event.observe(theImgij,'click',new Function('fx', 'addEntryToPdf("'+result.QandT[i].userQuestions[j].qid+'","'+result.QandT[i].userQuestions[j].cid+'","'+0+'")'));

/*Event.observe(theImgij, 'click', new Function('fx', 'addEntryToPdf("' + result.QandT[i].userQuestions[j].qid + '","' + result.QandT[i].userQuestions[j].cid '",0));

	var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("onclick", ";").a("title", "Frage hinzufügen").t();
*/

	
										
										theP3ij.appendChild(theLightboxLinkij);
										
										theTD1ij.appendChild(theP1ij);
										theTD2ij.appendChild(theP2ij);
										theTD3ij.appendChild(theP3ij);
										
										theTD4ij.appendChild(theImgij);
										
										theTRij.appendChild(theTD1ij);
										theTRij.appendChild(theTD2ij);
										theTRij.appendChild(theTD3ij);
										theTRij.appendChild(theTD4ij);
									
										theTableBodyi	.appendChild(theTRij);
										
										theImgij.style.cursor = "pointer";
										theTD1ij.style.verticalAlign = "top";
										theTD2ij.style.verticalAlign = "top";
										theTD3ij.style.verticalAlign = "top";
										theTD4ij.style.verticalAlign = "top";
										//checkbox erstellen*/
										
									} // end for
							

									// put the <tbody> in the <table>
									theTablei.appendChild(theTableBodyi);
									// appends <table> into <body>
									theResults.appendChild(theTablei);
									// sets the border attribute of tbl to 2;
									theTablei.style.width = "100%";	
									theTablei.style.margin = "15px 0 15px 0";
									theTablei.cellSpacing = "0";
									
									theP1i.style.fontWeight = "bold";
									theP2i.style.fontWeight = "bold";
									theP3i.style.fontWeight = "bold";
									theP4i.style.fontWeight = "bold";
									
									theTD1i.style.width = "28%";
									theTD2i.style.width = "15%";
									theTD3i.style.width = "35%";
									theTD3i.style.width = "35%";
									
									
								
									
								}// ende if (result.QandT[i].userQuestions.length > 0){
							
							if (result.QandT[i].userTheory && result.QandT[i].userTheory.length > 0){

			var theH2i = "h2".t("Von Ihnen erfasste Theory in der Kategorie " + result.QandT[i].userTheory[0].category);
									theResults.appendChild(theH2i);
									
									var theTablei     	= "table".t();
									var theTableBodyi 	= "tbody".t();
									
									var theTRi			= "tr".t(); 
									var theTD1i 		= "td".t(); 
									var theTD2i 		= "td".t();
									var theTD3i			= "td".t();
									var theTD4i 		= "td".t(); 
									
									var theP1i 			= "p".t("Kategorie");
									var theP2i 			= "p".t("Datum");
									var theP3i 			= "p".t("Aufgabe");
									var theP4i 			= "p".t("Funktion");
									
									theTD1i.appendChild(theP1i);
									theTD2i.appendChild(theP2i);
									theTD3i.appendChild(theP3i);
									theTD4i.appendChild(theP4i);							
									
									theTRi.appendChild(theTD1i);
									theTRi.appendChild(theTD2i);
									theTRi.appendChild(theTD3i);
									theTRi.appendChild(theTD4i);
									
									theTableBodyi.appendChild(theTRi);
									
									for(j = 0; j < result.QandT[i].userTheory.length; j++){
										
										var theTRij			= "tr".t();
										var theTD1ij 		= "td".t(); 
										var theTD2ij 		= "td".t();
										var theTD3ij			= "td".t();
										var theTD4ij 		= "td".t(); 
										
										var theP1ij 		= "p".t(result.QandT[i].userTheory[j].category);
										var theP2ij			= "p".t(result.QandT[i].userTheory[j].date);
										
										var theLightboxLinkij	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + result.QandT[i].userTheory[j].cid + "&tid=" + result.QandT[i].userTheory[j].tid + "&category=" + result.QandT[i].userTheory[j].category + "").a("class", "lbOn").t(result.QandT[i].userTheory[j].text);
										
										
										var theP3ij 		= "p".t();
										
										/*var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("onclick", "addEntryToPdf(" + result.QandT[i].userTheory[j].tid + "," + result.QandT[i].userTheory[j].cid + ",1);").a("title", "Theory hinzufügen").t();*/
										
										var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("title", "Theorie hinzufügen").t();
										
										Event.observe(theImgij,'click',new Function('fx', 'addEntryToPdf("'+result.QandT[i].userTheory[j].tid+'","'+result.QandT[i].userTheory[j].cid+'","'+1+'")'));
										
										theP3ij.appendChild(theLightboxLinkij);
										
										
										theTD1ij.appendChild(theP1ij);
										theTD2ij.appendChild(theP2ij);
										theTD3ij.appendChild(theP3ij);
										
										theTD4ij.appendChild(theImgij);
										
										theTRij.appendChild(theTD1ij);
										theTRij.appendChild(theTD2ij);
										theTRij.appendChild(theTD3ij);
										theTRij.appendChild(theTD4ij);
									
										theTableBodyi.appendChild(theTRij);
										
										theImgij.style.cursor = "pointer";
										theTD1ij.style.verticalAlign = "top";
										theTD2ij.style.verticalAlign = "top";
										theTD3ij.style.verticalAlign = "top";
										theTD4ij.style.verticalAlign = "top";
										
										//checkbox erstellen*/
										
									} // end for
							

									// put the <tbody> in the <table>
									theTablei.appendChild(theTableBodyi);
									// appends <table> into <body>
									theResults.appendChild(theTablei);
									// sets the border attribute of tbl to 2;
									theTablei.style.width = "100%";	
									theTablei.style.margin = "15px 0 15px 0";
									theTablei.cellSpacing = "0";
									
									theP1i.style.fontWeight = "bold";
									theP2i.style.fontWeight = "bold";
									theP3i.style.fontWeight = "bold";
									theP4i.style.fontWeight = "bold";
									theTD1i.style.width = "28%";
									theTD2i.style.width = "15%";
									theTD3i.style.width = "35%";
									

								
							}
							
							
							if (result.QandT[i].otherQuestions && result.QandT[i].otherQuestions.length > 0){

			var theH2i = "h2".t("Von anderen erfasste Aufgaben in der Kategorie " + result.QandT[i].otherQuestions[0].category);
									theResults.appendChild(theH2i);
									
									var theTablei     	= "table".t();
									var theTableBodyi 	= "tbody".t();
									
									var theTRi			= "tr".t(); 
									var theTD1i 		= "td".t(); 
									var theTD2i 		= "td".t();
									var theTD3i			= "td".t();
									var theTD4i 		= "td".t(); 
									
									var theP1i 			= "p".t("Kategorie");
									var theP2i 			= "p".t("Datum");
									var theP3i 			= "p".t("Aufgabe");
									var theP4i 			= "p".t("Funktion");
									
									theTD1i.appendChild(theP1i);
									theTD2i.appendChild(theP2i);
									theTD3i.appendChild(theP3i);
									theTD4i.appendChild(theP4i);							
									
									theTRi.appendChild(theTD1i);
									theTRi.appendChild(theTD2i);
									theTRi.appendChild(theTD3i);
									theTRi.appendChild(theTD4i);
									
									theTableBodyi.appendChild(theTRi);
									
									for(j = 0; j < result.QandT[i].otherQuestions.length; j++){
										
										var theTRij			= "tr".t();
										var theTD1ij 		= "td".t(); 
										var theTD2ij 		= "td".t();
										var theTD3ij			= "td".t();
										var theTD4ij 		= "td".t(); 
										
										var theP1ij 		= "p".t(result.QandT[i].otherQuestions[j].category);
										var theP2ij			= "p".t(result.QandT[i].otherQuestions[j].date);
										
										var theLightboxLinkij	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + result.QandT[i].otherQuestions[j].cid + "&qid=" + result.QandT[i].otherQuestions[j].qid + "&category=" + result.QandT[i].otherQuestions[j].category + "").a("class", "lbOn").t(result.QandT[i].otherQuestions[j].text);
										
										
										var theP3ij 		= "p".t();
										
										/*var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("onclick", "addEntryToPdf(" + result.QandT[i].otherQuestions[j].qid + "," + result.QandT[i].otherQuestions[j].cid + ",0);").a("title", "Frage hinzufügen").t();*/
										
										var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("title", "Frage hinzufügen").t();
										
										Event.observe(theImgij,'click',new Function('fx', 'addEntryToPdf("'+result.QandT[i].otherQuestions[j].qid+'","'+result.QandT[i].otherQuestions[j].cid+'","'+0+'")'));
										
										theP3ij.appendChild(theLightboxLinkij);
										theTD1ij.appendChild(theP1ij);
										theTD2ij.appendChild(theP2ij);
										theTD3ij.appendChild(theP3ij);
										
										theTD4ij.appendChild(theImgij);
										
										theTRij.appendChild(theTD1ij);
										theTRij.appendChild(theTD2ij);
										theTRij.appendChild(theTD3ij);
										theTRij.appendChild(theTD4ij);
									
										theTableBodyi.appendChild(theTRij);
										
										theImgij.style.cursor = "pointer";
										theTD1ij.style.verticalAlign = "top";
										theTD2ij.style.verticalAlign = "top";
										theTD3ij.style.verticalAlign = "top";
										theTD4ij.style.verticalAlign = "top";
										//checkbox erstellen*/
										
									} // end for
							

									// put the <tbody> in the <table>
									theTablei.appendChild(theTableBodyi);
									// appends <table> into <body>
									theResults.appendChild(theTablei);
									// sets the border attribute of tbl to 2;
									theTablei.style.width = "100%";	
									theTablei.style.margin = "15px 0 15px 0";
									theTablei.cellSpacing = "0";
									
									theP1i.style.fontWeight = "bold";
									theP2i.style.fontWeight = "bold";
									theP3i.style.fontWeight = "bold";
									theP4i.style.fontWeight = "bold";
									theTD1i.style.width = "28%";
									theTD2i.style.width = "15%";
									theTD3i.style.width = "35%";
									

								
							}
							
							
							if (result.QandT[i].otherTheory && result.QandT[i].otherTheory.length > 0){

								var theH2i = "h2".t("Von anderen erfasste Theoriebeiträge in der Kategorie " + result.QandT[i].otherTheory[0].category);
									theResults.appendChild(theH2i);
									
									var theTablei     	= "table".t();
									var theTableBodyi 	= "tbody".t();
									
									var theTRi			= "tr".t(); 
									var theTD1i 		= "td".t(); 
									var theTD2i 		= "td".t();
									var theTD3i			= "td".t();
									var theTD4i 		= "td".t(); 
									
									var theP1i 			= "p".t("Kategorie");
									var theP2i 			= "p".t("Datum");
									var theP3i 			= "p".t("Aufgabe");
									var theP4i 			= "p".t("Funktion");
									
									theTD1i.appendChild(theP1i);
									theTD2i.appendChild(theP2i);
									theTD3i.appendChild(theP3i);
									theTD4i.appendChild(theP4i);							
									
									theTRi.appendChild(theTD1i);
									theTRi.appendChild(theTD2i);
									theTRi.appendChild(theTD3i);
									theTRi.appendChild(theTD4i);
									
									theTableBodyi.appendChild(theTRi);
									
									var PDF 			= $('pdfid').value;

									
									for(j = 0; j < result.QandT[i].otherTheory.length; j++){
										
										var theTRij			= "tr".t();
										var theTD1ij 		= "td".t(); 
										var theTD2ij 		= "td".t();
										var theTD3ij			= "td".t();
										var theTD4ij 		= "td".t(); 
										
										var theP1ij 		= "p".t(result.QandT[i].otherTheory[j].category);
										var theP2ij			= "p".t(result.QandT[i].otherTheory[j].date);
										
										
										var theLightboxLinkij	= "a".a("href", "fileadmin/php-scripts/mathemagie/include/lightbox/lightbox.php?cid=" + result.QandT[i].otherTheory[j].cid + "&tid=" + result.QandT[i].otherTheory[j].tid + "&category=" + result.QandT[i].otherTheory[j].category + "").a("class", "lbOn").t(result.QandT[i].otherTheory[j].text);
										
										
										var theP3ij 		= "p".t();
										
										/*var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("onclick", "addEntryToPdf(" + result.QandT[i].otherTheory[j].tid + "," + result.QandT[i].otherTheory[j].cid + ",1);").a("title", "Theory hinzufügen").t();*/
										
											
										var theImgij 		= "img".a("src","fileadmin/templates/img/add.gif").a("title", "Theorie hinzufügen").t();
										
										Event.observe(theImgij,'click',new Function('fx', 'addEntryToPdf("'+result.QandT[i].otherTheory[j].qid+'","'+result.QandT[i].otherTheory[j].cid+'","'+1+'")'));
										
										theP3ij.appendChild(theLightboxLinkij);
										theTD1ij.appendChild(theP1ij);
										theTD2ij.appendChild(theP2ij);
										theTD3ij.appendChild(theP3ij);
										
										theTD4ij.appendChild(theImgij);
										
										theTRij.appendChild(theTD1ij);
										theTRij.appendChild(theTD2ij);
										theTRij.appendChild(theTD3ij);
										theTRij.appendChild(theTD4ij);
									
										theTableBodyi.appendChild(theTRij);
										
										theImgij.style.cursor = "pointer";
										theTD1ij.style.verticalAlign = "top";
										theTD2ij.style.verticalAlign = "top";
										theTD3ij.style.verticalAlign = "top";
										theTD4ij.style.verticalAlign = "top";
										
										//checkbox erstellen*/
										
									} // end for
							

									// put the <tbody> in the <table>
									theTablei.appendChild(theTableBodyi);
									// appends <table> into <body>
									theResults.appendChild(theTablei);
									// sets the border attribute of tbl to 2;
									theTablei.style.width = "100%";	
									theTablei.style.margin = "15px 0 15px 0";
									theTablei.cellSpacing = "0";
									
									theP1i.style.fontWeight = "bold";
									theP2i.style.fontWeight = "bold";
									theP3i.style.fontWeight = "bold";
									theP4i.style.fontWeight = "bold";
									theTD1i.style.width = "28%";
									theTD2i.style.width = "15%";
									theTD3i.style.width = "35%";
									

								
							}
								
							} // ende for
							
							getEntryFromCurrentPdf()

						} else {
							
							// keine resultate
							remove_children(theResults);
							var theH2 = "h2".t("Diese Unterkategorie enthält weder Fragen noch Theoriebeiträge, die von Ihnen oder anderen Usern erfasst wurden.");
							theResults.appendChild(theH2);
							getEntryFromCurrentPdf();
				
						}

					}// onSuccess:
				
			}); // end new Ajax.Request
} // end functin





