$(document).ready(function() {
    
    //tg info
    $("#tginfo").hide();
    $("#tginfo_icon").mouseover(
		function() {
	        $("#tginfo").show();
			
		}
	);
	$("#tginfo").mouseout(
		function() {
	        $("#tginfo").hide();
		   
		}
	);
	
	//dateien_ info
    $("#dateien_info").hide();
    $("#dateien_info_icon").mouseover(
		function() {
	        $("#dateien_info").show();
			
		}
	);
	$("#dateien_info").mouseout(
		function() {
	        $("#dateien_info").hide();
		   
		}
	);
	//members
	$("#ws_member_header").click(function(){
		
		var picsrc=$("#category_pic_0").attr("src");
		if(picsrc.indexOf("down")>0)
			$("#category_pic_0").attr({src: SYSTEMPATH+"html/img/icons/category.gif"})
		else
			$("#category_pic_0").attr({src: SYSTEMPATH+"html/img/icons/category_down.gif"})

			$("#ws_members").slideToggle(330);
		
	});
	
	//links
	$("#ws_Links_header").click(function(){
		
		var picsrc=$("#category_pic_1").attr("src");
		if(picsrc.indexOf("down")>0)
			$("#category_pic_1").attr({src: SYSTEMPATH+"html/img/icons/category.gif"})
		else
			$("#category_pic_1").attr({src: SYSTEMPATH+"html/img/icons/category_down.gif"})

			$("#ws_links").slideToggle(330);
		
	});
	//material
	$("#ws_material_header").click(function(){
		
		var picsrc=$("#category_pic_2").attr("src");
		if(picsrc.indexOf("down")>0)
			$("#category_pic_2").attr({src: SYSTEMPATH+"html/img/icons/category.gif"})
		else
			$("#category_pic_2").attr({src: SYSTEMPATH+"html/img/icons/category_down.gif"})

			$("#ws_material").slideToggle(330);
		
	});
	//zuschauer
	$("#ws_zuschauer_header").click(function(){
		
		var picsrc=$("#category_pic_3").attr("src");
		if(picsrc.indexOf("down")>0)
			$("#category_pic_3").attr({src: SYSTEMPATH+"html/img/icons/category.gif"})
		else
			$("#category_pic_3").attr({src: SYSTEMPATH+"html/img/icons/category_down.gif"})

			$("#ws_zuschauer").slideToggle(330);
		
	});
	
	//message send
	
	//	$("#message_eingabe").hide();
	//	if(ac =="send"){
	//			$("#message_eingabe").show();
	//			$("#message_eingabe").html("Your message has been send!");
	//	}


	
});






function sort(filter){
	document.location.href=SYSTEMPATH+'tg-'+filter; 
}

function abbrechen(){
	document.location.href=SYSTEMPATH+'tg'; 
}


function checkTitel()
{
	
	if(document.editform.titel.value!="")
		document.editform.submit();
	else
		alert("Ihr Workspace braucht einen Titel!");
}


function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength);
}




/*********************************************************************/
function check_upload_media(url){
		str=document.editform.picfile.value;
		str2=str.split(".");
		end=str2[str2.length-1];
		end=end.toLowerCase();
		
	if(end == "mov" || end == "dcr" || end == "jar" || end == "swf" || end == "avi" || end == ".rm"){	
		
		if(document.editform.m_width.value =="" && document.editform.m_height.value==""){
			document.getElementById('size').style.visibility="visible";
			alert("Dieser Dateityp benötigt Größenangaben!");
		}
		else
			document.editform.submit();
	}
// 	else if(end == "gif"){
// 			alert("Bilder vom Dateityp Gif können von PHP  nicht skaliert werden\n und sollten in der Breite 500 Pixel \n und in der Höhe 300 Pixel nicht überschreiten!");
// 		}
	else{
		
		document.editform.submit();
	}

}
/*********************************************************************/

function show(who){
		
			document.getElementById(who).style.visibility="visible";
		
}


/*********************************************************************/

function showMedia(whichfile,suffix,w,h){
		url="show_media.php?mfile="+whichfile+"&suffix="+suffix+"&w="+w+"&h="+h;
		if(suffix=="mov")
			plus=25;
		else
			plus=20;
	
		breite=parseInt(w)+plus;
		hoehe=parseInt(h)+plus;
		
		var m_Fenster = window.open( url, "m_Fenster", "status=yes,  width="+breite+",height="+hoehe+",resizable=yes,scrollbars=yes" );
		
}
/*********************************************************************/

function getFileInfo(){
	str=document.editform.picfile.value;
		str2=str.split(".");
		end=str2[str2.length-1];
		end=end.toLowerCase();
		
	if(end == "mov" || end == "dcr" || end == "jar" || end == "swf" || end == "avi" || end == ".rm"){	
		if(end == "mov" && document.getElementById("quick_scale").style.visibility=="hidden"){
			document.getElementById("quick_scale").style.visibility="visible";
			
		}
		if(document.editform.m_width.value =="" && document.editform.m_height.value==""){
			document.getElementById('size').style.visibility="visible";
			alert("Dieser Dateityp benötigt Größenangaben!");
		}
	}
	
		document.getElementById('size').style.visibility="visible";
		
}

/*********************************************************************/

var help_flag=false;
function showHelp(){
	
	starttxt="<a href='javascript:showHelp();'><img src='"+SYSTEMPATH+"html/img/icons/help.gif' class='wiki_img' border='0'>Information zu den Formatierungsoptionen der Wiki-Syntax</a>";
	

	txt="<img src='"+SYSTEMPATH+"html/img/icons/help.gif' border='0' class='wiki_img'>Information zu den Formatierungsoptionen der Wiki-Syntax ";
	txt+="<div class='dimmed_txt'><table class='wikitable'><tr><td class='wikitable_td_links'>";
	txt+="Textuelle Einbindung von Hyperlinks:&nbsp;</td><td class='wikitable_td_rechts'>[[Name|http://www.beispiel.com]]</td></tr>";
	txt+="<tr><td class='wikitable_td_links'>Link mit Icon  <img src='"+SYSTEMPATH+"html/img/icons/link.gif'> einbinden :</td><td class='wikitable_td_rechts'>[[http://www.beispiel.com]]</td></tr>";
//	txt+="<tr><td class='wikitable_td_links'>Archivbeitrag verlinken:</td><td class='wikitable_td_rechts'>[[[Beitragstitel]]]</td></tr>";
//	txt+="<tr><td class='wikitable_td_links'>besser:</td><td class='wikitable_td_rechts'>[[[Beitragstitel|Workspacetitel]]]</td></tr>";

	
	txt+="<tr><td class='wikitable_td_links'>Textformatierung :</td><td class='wikitable_td_rechts'>[i]<i>Kursiv</i>[/i]</td></tr>";
	txt+="<tr><td></td><td class='wikitable_td_rechts'>[b]<b>fett</b>[/b]</td></tr></table>";
	
	txt+="<a href='javascript:showHelp();'><img src='"+SYSTEMPATH+"html/img/icons/close.gif' border='2' style='margin-top:-68px; ; float:right;'></a>";
	txt+="</div>";
	if(!help_flag){
		document.getElementById('wiki_help').innerHTML=txt;
		help_flag=true;
	}
	else{
		document.getElementById('wiki_help').innerHTML=starttxt;
		help_flag=false;
	}
}




/*********************************************************************/
function edit_ws(w_id){

	var titel=$("#edit_ws_titel").html();
	var beschreibung=$("#edit_ws_abstract_long").val();
	var secret=$("#edit_ws_secret").val();
console.log("secret::"+secret);	
   	$("#edit_ws_titel").html("<input type='text' name='ws_titel' id='ws_titel' value='"+titel+"'>");
	$("#edit_ws_abstract").html("<textarea name='ws_beschreibung' id='ws_beschreibung'>"+beschreibung+"</textarea>")
	if(RECHTE <=2){
		if(secret == "1")
			$("#ws_form").append("<input type='checkbox' id='ws_secret' name='ws_secret' checked='checked' /><span>Themengruppe verstecken&nbsp;<br/></span>");
		else
			$("#ws_form").append("<input type='checkbox' id='ws_secret' name='ws_secret' /><span>Themengruppe verstecken&nbsp;<br/></span>");
	}
	$("#ws_form").append("<div class='buttons'><input type='button' value='abbrechen' id='cancelButton'>&nbsp<input type='submit' value='sichern'></div><hr class='hrdotted'/>");
	$("#cancelButton").click(function(){
		var html="<div id='edit_ws_titel'>"+titel+"</div>";
			html+="<div id='edit_ws_abstract'>"+beschreibung+ "</div>";
			html+="<input id='edit_ws_secret' name='edit_ws_secret' type='hidden' value='"+secret+"' />";
			$("#ws_form").html(html);

	});
	//
}
/*********************************************************************/
function canceledit(idx,task){
	if(task == 8){//pattern_abschnitt
	
			$("#pattern_show_"+idx).show();
			$("#pattern_edit_"+idx).html("");
	
 	}
	if(task == 18){//titel
	
		$("#p_titel_show").show();
		$("#p_titel_edit").html("");

 	}
	if(task == 7){//ws
		
		$("#show_beitrag_"+idx).show();
		$("#edit_beitrag_"+idx).html("");

	}
	if(task == 10){	//comments 
	
		$("#ws_abschnitt_comments_edit_"+idx).html("");
		$("#ws_abschnitt_comments_show_"+idx).show();
		
	}
	if(task == 101){	//wsTitel 
		
		$("#edit_ws_titel").html($("#ws_titel").val());
		$("#edit_ws_abstract").html($("#ws_beschreibung").val());
		
	   
		
	}
	if(task == 222){	//Linklisten 
		
		$("#"+idx).html("");
	
		
	   
		
	}
}
/*********************************************************************/
function cancelDelete(idx,task){	
	if(task==9){
		$("#show_beitrag_"+idx).show();
		$("#ws_abschnitt_comments_"+idx).show();
		$("#edit_beitrag_"+idx).html('');
	}
	else if(task==12){
		$("#ws_abschnitt_comments_"+idx).show();
		$("#ws_abschnitt_comments_edit_"+idx).html('');
	}
	else if(task==13){
		
		$("#addLink").html('');
	}
	else if(task==14){
		
		$("#addDat").html('');
	}
	else if(task==5){	//ganzer WS
		
		$("#w_"+idx).show();
		$("#w_edit_"+idx).html('');
	}
	else if(task==22){	// WS Mitglied
		
		
		$("#message_eingabe_"+idx).html('');
	}
}
/*********************************************************************/
function delete_comment(w_id,post_id,idx){	
	

			var	url=SYSTEMPATH+"code/workspaces/delete_p_content.php?w_id="+w_id+"&idx="+idx+"&task=kommentar";
	
			$("#ws_abschnitt_comments_show_"+idx).hide();
			$("#ws_abschnitt_comments_edit_"+idx).load(
				SYSTEMPATH+"html/templates/really_delete.php",
				{}, 
				function() { 
	
			 		$("#delete_yes").click(function() {
						document.location.href=url;
						return false;
					});
				//	$("#delete_no").attr({ href: "javascript:cancelDelete("+post_id+",12);"});
						$("#delete_no").click(function() {
    						$("#ws_abschnitt_comments_show_"+idx).show();
    						$("#ws_abschnitt_comments_edit_"+idx).html("");
    						return false;
    					});
					$("#which").html(" diesen Kommentar ");
  					
			
				}
			);



}
/*********************************************************************/
function deletePic(p_id,idx,task){	//TODO!

		var url=SYSTEMPATH+"code/workspaces/delete_imgRef.php";
	  	var o={};
	  	o.w_id=p_id;
		o.idx=idx;

	  	$.getJSON(url,o,function (ok) {
			$("#deletePicLink").hide();
			$("#ws_old_file").val("");
		});

}
/*********************************************************************/
function delete_comment_Pic(idx){	//TODO!

		var url=SYSTEMPATH+"code/workspaces/delete_comment_imgRef.php";
	  	var o={};
	  //	o.w_id=p_id;
		o.idx=idx;

	  	$.getJSON(url,o,function (ok) {
			$("#comment_deletePicLink").hide();
			$("#comment_old_file").val("");
		});

}
/*********************************************************************/
function delete_ws(w_id){

		var	url=SYSTEMPATH+"code/workspaces/delete_workspace.php?w_id="+w_id;
		$("#w_"+w_id).hide();
	
		
		$("#w_edit_"+w_id).load(
			SYSTEMPATH+"html/templates/really_delete.php",
			{}, 
			function() { 
			

		 		$("#delete_yes").click(function() {
					document.location.href=url;
					return false;
				});
			//	$("#delete_no").attr({ href: "javascript:cancelDelete("+w_id+",5);"});
					$("#delete_no").click(function() {
						$("#w_"+w_id).show();
						$("#w_edit_"+w_id).html("");
						return false;
					});
				$("#which").html(" diese Themengruppe ");
		
			}
		);
}

/*********************************************************************/
function delete_post(w_id,idx){	
	

	
		//	var	url="../workspaces/delete_p_content.php?5,"+w_id+","+task+","+idx+","+mediaordner+","+sum;
			var	url=SYSTEMPATH+"code/workspaces/delete_p_content.php?w_id="+w_id+"&idx="+idx+"&task=beitrag";
			$("#show_beitrag_"+idx).hide();
			$("#ws_abschnitt_comments_"+idx).hide();
			
			$("#edit_beitrag_"+idx).load(
				SYSTEMPATH+"html/templates/really_delete.php",
				{}, 
				function() { 
				
	
			 		$("#delete_yes").click(function() {
						document.location.href=url;
						return false;
					});
				//	$("#delete_no").attr({ href: "javascript:cancelDelete("+idx+",9);"});
						$("#delete_no").click(function() {
    						$("#show_beitrag_"+idx).show();
    						$("#ws_abschnitt_comments_"+idx).html("");
    						return false;
    					});
  					$("#which").html(" diesen Beitrag ");
			
				}
			);
		

}
/*********************************************************************/
function edit_comment(w_id,idx,comment_id){
	//comment


			var url=SYSTEMPATH+"code/workspaces/get_comment.php";
		  	var o={};
		  	o.w_id=w_id;
		  	o.idx=idx;
			o.c_id=comment_id;


		  	    $.getJSON(url,o,function (comment) {
                    
    					$("#ws_abschnitt_comments_show_"+comment_id).hide();	
				
    					$("#ws_abschnitt_comments_edit_"+comment_id).load(
    						SYSTEMPATH+"html/templates/comment_edit_loop.php",
					
    						{}, 
    						function() { 
							
						
								
    									$("#comment_titel").html("Kommentar zu: "+comment.beitrag_titel);
    									$("#c_inhaltstr").val(comment.inhalt);
									 
									 $("#deletePic").hide();
									    if(comment.bild != "" && comment.bild != undefined){
									       
                                            $("#deletePic").show();
                                            $("#comment_old_file").val(comment.bild);
        		    					}
        		    					
        		    					
        		    					
    									var updateUrl=SYSTEMPATH+"code/workspaces/iw_comment_update.php?mid="+w_id+"&content_id="+idx+"&comment_id="+comment_id;
    								
    									$("#c_editform").attr({action: updateUrl});

    									$("#buttonUpload").click(function() {$("#c_editform").submit();});
    									$("#cancel").click(function() {	
    									
    										canceledit(comment_id,10);
    										return false;
    								    });
    								    $("#comment_deletePicLink").click(function() {
    		    						
    		    							delete_comment_Pic(idx);
    		    							return false;
    		    						});
									
								
    							}//func
    					);
    			});
    			
	
}
/**************************************************************///neu
/****************************************************************************************/

function publish(w_id,idx){
	var url=SYSTEMPATH+"code/workspaces/publish.php";
	var o={};
  	o.w_id=w_id;
  	o.idx=idx;
	
  	$.getJSON(url,o,function (result) {
    	if(result.success){
			document.location.href=SYSTEMPATH+"tg/"+w_id;
		}
		else{
			
		}
    		
	});
}
/****************************************************************************************/

function publish_ws(w_id){
	var url=SYSTEMPATH+"code/workspaces/publish_ws.php";
	var o={};
  	o.w_id=w_id;
  
	
  	$.getJSON(url,o,function (result) {
    	if(result.success){
			document.location.href=SYSTEMPATH+"tg";
		}
		else{
			
		}
    		
	});
}
/*********************************************************************/
function newMember(w_id,users_id){
	var url=SYSTEMPATH+"code/workspaces/newWS_member.php";
	
  	var o={};
  	o.w_id=w_id;
  	o.users_id=users_id;

  	$.getJSON(url,o,function (result) {
		if(result.success)
			document.location.href=SYSTEMPATH+"tg/"+w_id;
	
	});
}
/*********************************************************************/
function newZaungast(w_id,users_id){
	var url=SYSTEMPATH+"code/workspaces/newWS_zaungast.php";
	
  	var o={};
  	o.w_id=w_id;
  	o.users_id=users_id;

  	$.getJSON(url,o,function (result) {
		if(result.success)
			document.location.href=SYSTEMPATH+"tg/"+w_id;
	
	});
}
/*********************************************************************/
function edit(w_id,idx){
	
	$("#edit_beitrag_"+idx).html("<div align='center' ><img src='"+SYSTEMPATH+"html/img/icons/working.gif' /></div>");
	
		if(idx!=0){
			var url=SYSTEMPATH+"code/workspaces/get_ws_abschnitt.php";
		
		  	var o={};
		  	o.w_id=w_id;
		  	o.idx=idx;

		  	$.getJSON(url,o,function (ws_abschnitt_content) {
		    	
		    		$("#show_beitrag_"+idx).hide();
		    		$("#edit_beitrag_"+idx).load(
		    			SYSTEMPATH+"html/templates/ws_edit_loop.php",
		    			{}, 
		    			function() { 
		    			
		    					$("#ws_beitrag_titel").val(ws_abschnitt_content.titel);
		    		  			$("#ws_inhaltstr").val(ws_abschnitt_content.inhalt);
		    					if(ws_abschnitt_content.bild != ""){
		    			
		    					}
		    					else{
		    						$("#ws_abschnitt_bild_edit").hide();
		    						$("#deletePic").hide();
		    					}
		    					$("#ws_old_file").val(ws_abschnitt_content.bild);
          
		    				   if(ws_abschnitt_content.bb == "1")	{
		    				   	$("#ws_editform").checkCheckboxes(".bbcheck", true);
		    				   }
		
							   if(ws_abschnitt_content.startseite == "1")	{
		    				   	$("#ws_editform").checkCheckboxes(".startcheck", true);
		    				   }
							  if(ws_abschnitt_content.published == "1")	{
							  	$(".publiz").attr("checked", true); 
							
			    			   }
							  else{
							  	$(".vorschau").attr("checked", true); 
							  }
		
		    					
		    					if(ws_abschnitt_content.rubrik_bb != "-1")	{
		    						$("#rubrik_bb").selectOptions(ws_abschnitt_content.rubriken, true);	
		    					}
		    					
									var updateUrl=SYSTEMPATH+"code/workspaces/iw_content_update.php?mid="+w_id+"&content_id="+idx;

		    				
		    						$("#ws_editform").attr({action: updateUrl});
          
		    						$("#buttonUpload").click(function() {$("#ws_editform").submit();});
		    						$("#cancel").click(function() {	
		    							canceledit(idx,7);
		    							return false;
		    						});
		    						$("#deletePicLink").click(function() {
		    							console.log("deletePicClicked");
		    							deletePic(w_id,idx,"ws");
		    							return false;
		    						});
		    				
		    				}
          
		    		);
		    });
			
		}//idx!=0
		else{
				$("#show_beitrag_"+idx).hide();
				
				$("#edit_beitrag_"+idx).load(
					SYSTEMPATH+"html/templates/ws_edit_loop.php",
					{}, 
					function() { 
						$("#ws_abschnitt_bild_edit").hide();
						$("#deletePic").hide();
						
							var updateUrl=SYSTEMPATH+"code/workspaces/iw_content_update.php?mid="+w_id+"&content_id=0";
					
							$("#ws_editform").attr({action: updateUrl});

							$("#buttonUpload").click(function() {$("#ws_editform").submit();});
						$("#cancel").click(function() {	
							canceledit(idx,7);
							return false;
						});
						$("#deletePicLink").click(function() {
							console.log("deletePicClicked");
							deletePic(w_id,idx,"ws");
							return false;
						});
					});
			
		}//else


}
/*********************************************************************/
function readCookie(name) {

	var cookiename = name + "=";

	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) {

		var c = ca[i];

		while (c.charAt(0)==' ') c = c.substring(1,c.length);

		if (c.indexOf(cookiename) == 0) return c.substring(cookiename.length,c.length);

	}

	return null;
}
/********************************************************************************************/

function write_message(w_id,uid){
	
	$("#message_eingabe_"+uid).show();
	user_id=readCookie('dgtf_userid');

	
	$("#message_eingabe_"+uid).html("<div align='center'><img src='"+SYSTEMPATH+"/html/img/icons/working.gif' /></div>");

	$("#message_eingabe_"+uid).load(
		SYSTEMPATH+"html/templates/write_message.php",
		{}, 
		function() { 

	 
			var updateUrl=SYSTEMPATH+"code/nachrichten/nachricht_senden.php?empfaenger="+uid;
			$("#message_form").attr({action: updateUrl});

			$("#buttonUpload").click(function() {$("#message_form").submit();});
			$("#cancel").click(function() {	
				$("#message_eingabe_"+uid).html("");
				$("#message_eingabe_"+uid).hide();
				return false;
		    });
	
		}
	);
	
	
}
/********************************************************************************************/
function remove_wsMember(w_id,uid){

	
	$("#message_eingabe_"+uid).html("<div align='center'><img src='"+SYSTEMPATH+"/html/img/icons/working.gif' /></div>");
	var	url=SYSTEMPATH+"code/workspaces/user_abmelden.php?w_id="+w_id+"&uid="+uid;
	
	$("#message_eingabe_"+uid).load(
		SYSTEMPATH+"html/templates/really_delete.php",
		{}, 
		
			function() { 

		 		$("#delete_yes").click(function() {
					document.location.href=url;
					return false;
				});
		
					$("#delete_no").click(function() {
					
						$("#message_eingabe_"+uid).html("");
						return false;
					});
				$("#which").html(" dieses Mitglied ");

			}
	);

}
/********************************************************************************************/
function remove_wsZaungast(w_id,uid){

	
	$("#message_eingabe_"+uid).html("<div align='center'><img src='"+SYSTEMPATH+"/html/img/icons/working.gif' /></div>");
	var	url=SYSTEMPATH+"code/workspaces/zaungast_abmelden.php?w_id="+w_id+"&uid="+uid;
	
	$("#message_eingabe_"+uid).load(
		SYSTEMPATH+"html/templates/really_delete.php",
		{}, 
		
			function() { 

		 		$("#delete_yes").click(function() {
					document.location.href=url;
					return false;
				});
		
					$("#delete_no").click(function() {
					
						$("#message_eingabe_"+uid).html("");
						return false;
					});
				$("#which").html(" diesen Zaungast ");

			}
	);

}
/********************************************************************************************/

function write_all(w_id){
	
	$("#message_eingabe_alle").show();
	user_id=readCookie('dgtf_userid');

	
	$("#message_eingabe_alle").html("<div align='center'><img src='"+SYSTEMPATH+"/html/img/icons/working.gif' /></div>");

	$("#message_eingabe_alle").load(
		SYSTEMPATH+"html/templates/write_message.php",
		{}, 
		function() { 


			var updateUrl=SYSTEMPATH+"code/nachrichten/nachricht_senden_alle.php?w_id="+w_id;
		
			$("#message_form").attr({action: updateUrl});

			$("#buttonUpload").click(function() {$("#message_form").submit();});
			$("#cancel").click(function() {	
				$("#message_eingabe_alle").html("");
				$("#message_eingabe_alle").hide();
				return false;
		    });
	
		}
	);
	
	
}
/********************************************************************************************/

function neueLinkListe(w_id){

		
	$("#links_eingabe").load(
		SYSTEMPATH+"html/templates/form_1.php",
		{}, 
		function() { 
		
	 		var updateUrl=SYSTEMPATH+"code/workspaces/edit_links.php?w_id="+w_id+"&task=add_link";
		
			$("#form1").attr({action: updateUrl});
		
			$("#submit_yes").click(function() {$("#form1").submit();});			
			$("#submit_no").click(function() {	
				$("#links_eingabe").html("");
			
				return false;
		    });
			$("#which").html(" Neue Linkliste ");
	
		}
	);
}
/********************************************************************************************/

function editLinkListe(which,c_id){
	//linkliste_
	var this_titel=$("#linkliste_"+which).html();
	var element=$("#linkliste_"+which);
	$("#linkliste_"+which).load(
		SYSTEMPATH+"html/templates/form_1.php",
		{}, 
		function() { 
			$("#titel").val(this_titel);
	 		var updateUrl=SYSTEMPATH+"code/workspaces/edit_links.php?c_id="+c_id+"&task=rename_link";

			$("#form1").attr({action: updateUrl});
		
			$("#submit_yes").click(function() {$("#form1").submit();});			
			$("#submit_no").click(function() {
				$("#linkliste_"+which).html(this_titel);
			});
			$("#which").html(" Linkliste umbenennen ");
	
		}
	);
}
/********************************************************************************************/

function deleteLinkListe(which,c_id){
	//linkliste_
	var this_titel=$("#linkliste_"+which).html();
	var element=$("#linkliste_"+which);
	$("#linkliste_"+which).load(
		
		SYSTEMPATH+"html/templates/really_delete.php",
		{}, 
		
			function() { 
				var url=SYSTEMPATH+"code/workspaces/edit_links.php?c_id="+c_id+"&task=delete_link";
		 		$("#delete_yes").click(function() {
					document.location.href=url;
					return false;
				});
				$("#delete_no").click(function() {
					$("#linkliste_"+which).html(this_titel);
					return false;
				});
				$("#which").html(" diese Linkliste ");


			}
	
	
	);
}
/********************************************************************************************/

function neuerMaterialOrdner(w_id){

		
	$("#material_eingabe").load(
		SYSTEMPATH+"html/templates/form_1.php",
		{}, 
		function() { 
		
	 		var updateUrl=SYSTEMPATH+"code/workspaces/edit_material.php?w_id="+w_id+"&task=create_ordner";
		
			$("#form1").attr({action: updateUrl});
		
			$("#submit_yes").click(function() {$("#form1").submit();});			
			$("#submit_no").click(function() {
				$("#material_eingabe").html("");
		
			});
			$("#which").html(" Neuer Download Ordner ");
	
		}
	);
}
/********************************************************************************************/

function editMaterialordner(which,c_id,w_id){
	//linkliste_
	var this_titel=$("#materialorner_"+which).html();

	$("#materialorner_"+which).load(
		SYSTEMPATH+"html/templates/form_1.php",
		{}, 
		function() { 
			$("#titel").val(this_titel);
	 		var updateUrl=SYSTEMPATH+"code/workspaces/edit_material.php?c_id="+c_id+"&task=rename_ordner&w_id="+w_id+"&old="+this_titel;
	
			$("#form1").attr({action: updateUrl});
		
			$("#submit_yes").click(function() {$("#form1").submit();});			
			$("#submit_no").click(function() {
				
				$("#materialorner_"+which).html(this_titel);
			});
			$("#which").html(" Download Ordner umbenennen ");
	
		}
	);
}
/********************************************************************************************/

function deleteMaterialordner(which,c_id,w_id){
	//linkliste_
	var this_titel=$("#materialorner_"+which).html();

	$("#materialorner_"+which).load(
		
		SYSTEMPATH+"html/templates/really_delete.php",
		{}, 
		
			function() { 
				var url=SYSTEMPATH+"code/workspaces/edit_material.php?c_id="+c_id+"&task=delete_ordner&w_id="+w_id+"&titel="+this_titel;
		 		$("#delete_yes").click(function() {
					document.location.href=url;
					return false;
				});
				$("#delete_no").click(function() {
					$("#materialorner_"+which).html(this_titel);
					return false;
				});
				$("#which").html(" diesen Download Ordner ");


			}
	
	
	);
}
/*********************************************************************/
function pop_up_link(w_id,thema_id){
	

	
	$("#addLink_"+thema_id).html("<div align='center' ><img src='"+SYSTEMPATH+"html/img/icons/working.gif' /></div>");


	$("#addLink_"+thema_id).load(
		SYSTEMPATH+"html/templates/add_link.php",
		{}, 
		function() { 
			var updateUrl=SYSTEMPATH+"code/workspaces/save_link.php?w_id="+w_id+"&thema_id="+thema_id;
	
			$("#linkform").attr({action: updateUrl});
			$("#buttonUpload").click(function() {

				$("#linkform").submit();
	
			});
			//
			$("#cancel").click(function() {
					$("#addLink_"+thema_id).html("");
					return false;
			});
		});
	
}
/*********************************************************************/
function delete_link(idx){
	
	var	url=SYSTEMPATH+"code/workspaces/delete_link.php?idx="+idx;


	$("#dl_"+idx).load(
		SYSTEMPATH+"html/templates/really_delete.php",
		{}, 
		function() { 

	 		$("#delete_yes").click(function() {
				document.location.href=url;
				return false;
			});
			$("#delete_no").click(function() {
					$("#dl_"+idx).html("");
					return false;
			});
			$("#which").html(" diesen Link ");
			
	
		}
	);
}
/*********************************************************************/

function delete_material(idx,path,w_id){
	
	var	url=SYSTEMPATH+"code/workspaces/delete_file.php?idx="+idx+"&path="+path+"&w_id="+w_id;

	
	$("#dm_"+idx).load(
		SYSTEMPATH+"html/templates/really_delete.php",
		{}, 
		function() { 

	 		$("#delete_yes").click(function() {
				document.location.href=url;
				return false;
			});
			$("#delete_no").click(function() {
					$("#dm_"+idx).html("");
					return false;
			});
			$("#which").html(" diese Datei ");
			
	
		}
	);
}

/*********************************************************************/

function pop_up_material(ordner,w_id,ordner_id){
	

	
	$("#addDat_"+ordner_id).html("<div align='center' ><img src="+SYSTEMPATH+"html/img/icons/working.gif' /></div>");
	


	$("#addDat_"+ordner_id).load(
	   SYSTEMPATH+"html/templates/add_material.php",
		{}, 
		function() { 
			var updateUrl=SYSTEMPATH+"code/workspaces/save_material.php?w_id="+w_id+"&ordner="+ordner+"&ordner_id="+ordner_id;
	
			$("#datform").attr({action: updateUrl});
			$("#buttonUpload").click(function() {

				$("#datform").submit();
	
			});
			//
			$("#cancel").click(function() {
					$("#addDat_"+ordner_id).html("");
					return false;
			});
		});
	
}
/*********************************************************************/
function showFullView(path){

	
	
	$("<div id='picViewContainer'><div id='picView'><img src='"+path+"' /></div></div>").appendTo('body').fadeIn(100).center();
	
	$("#picViewContainer").click(function() {$("#picViewContainer").remove();});

}

/*********************************************************************/
function preloader(file) 

{

	img = new Image(); 

	img.src = file;

}