<!--
               var prefix ="";
               var resultName = "exist:result";
               var isInRole = false;
               var isModRole = false;
               var url = document.URL;
               var lang = null; 
               var languageFull = null;
               var textfrom ="from";
              
               //alert("parent="+parent.document.URL);
               window.onload = function(){
               	   //alert("tracking_code="+tracking_code);   
               	  
                       //Index page or article page
                   var discText = document.getElementById("discussionText");  
                   if (discText != null)   {                     
                         lang = document.getElementById("languageOfArticle").value;
                          
                         languageFull = document.getElementById("languageFull").value;
                          //if this article is in german,then change the UI all in german
                          var discText = document.getElementById("discussionText");              	 
                         if (lang=="de" && discText != null){
                         	  textfrom = "von";
               	  	  //alert(document.getElementById("discussionLogIn").lang);
               	  	 // document.getElementById("divDiscLogin").innerHTML ="<iframe src ='"+prefix+"/discussion/LoggedIn.jsp'  lang='de' id ='discussionLogIn' class='discussLogInFalse' frameborder='0'></iframe>";
               	  	  var backLink = document.getElementById("backToIndex");
               	  	  backLink.innerHTML ="Inhaltsverzeichnis";
               	  	  
               	  	  discText.innerHTML ="Diskussion";
               	  	   var comText = document.getElementById("commentsText");
               	  	  // alert(comText.childNodes.length);
               	  	  comText.childNodes[1].nodeValue =" Kommentare:";
               	  	  var intro1 = document.getElementById("disc_intro1");
               	  	   intro1.innerHTML ="Sie k&ouml;nnen diesen Absatz mit ihren Kollegen diskutieren, indem sie die folgenden Icons anklicken:";
               	  	  var intro2 = document.getElementById("disc_intro2");
               	  	   intro2.innerHTML ="<img src='"+prefix+"/discussion/icons/discuss.gif'/>.&#160;  Diskussionen zu diesem Absatz/Artikel <strong>anzeigen</strong>&#160; (falls vorhanden).<br/> Die Zahlen zeigen an, wie viele Beitr&auml;ge zu diesem Absatz/Artikel existieren.";
               	  	    var intro3 = document.getElementById("disc_intro3");
               	  	   intro3.innerHTML ="<img src='"+prefix+"/discussion/icons/newTopic.gif'/> &#160; Einen neuen Beitrag <strong>verfassen</strong>&#160;(Sie m&uuml;ssen sich zuerst registrieren).";
               	  	  //  var registerarea = document.getElementById("disc_register");
               	  	  // registerarea.innerHTML ="Bitte <a href='"+prefix+"/discussion/registration_form.html' target='_blank'><strong>registrieren</strong></a> sie sich zuerst, um an dieser Diskussion teilzunehmen.";
               	      }else if (discText != null){
               	 	
               	 	//  document.getElementById("divDiscLogin").innerHTML ="<iframe src ='"+prefix+"/discussion/LoggedIn.jsp'  lang='en' id ='discussionLogIn' class='discussLogInFalse' frameborder='0'></iframe>";
               	      } 
               	  
               	  
                 var becomment = document.getElementById("discussion_1");
                 var abstractbecomment =document.getElementById("discussion_-1")
             //    var becomment = document.getElementsByName("commentarea").length;
           //   if it is volltext/abstract, then check the message of each paragraph
               if (becomment != null || abstractbecomment !=null) {
               	 
               	   // Check if the user is registered or not
               	     SowiportDiscussionFunctions.isInSWPRole(tracking_code,function(role){
                          //     alert(role);               
                         if (role!="offline" && role !="blocked_user" ){
                         	  isInRole=true; 
                         //alert("ist in Role!"); 
                        //decide the newTopic icon color
                         var ntopic = document.getElementsByName("newTopic");
                         var len = ntopic.length;                         
                         for (var i = 0; i<len; i++){
                            ntopic[i].setAttribute("src",prefix+"/discussion/icons/newTopic.gif"); 
                             ntopic[i].setAttribute("title","Kommentar verfassen / Write a comment");   
                            var parentID =  ntopic[i].parentNode.id;                       
                            var pid = parentID.substr(11);                      
                            //ntopic[i].setAttribute("onclick","createNewTopic("+pid+")");
                              ntopic[i].onclick = function(){createNewTopic(this.pid);}; 
                             ntopic[i].pid= pid;                                   
                         }
                         
                        var loginframe=  document.getElementById("discussionLogIn");
                        if (loginframe!= null)  
                         loginframe.className= "discussLogInTrue";
                         //check if the user is in moderator role, if so, set the branchout icon active
                             if (role=="moderator"){
                        	    isModRole= true;
                        	      //set the moderator view in the left spane                     
                        var mdiv=document.getElementById("disc_moderatorview");
                        mdiv.innerHTML = "<a href='/index.php?id=360' target='_blank' style='text-decoration: none; background-color: #ECEFF4;'><img alt='moderatorview' border='0' src='/discussion/icons/moderator.gif'/>  Moderator View </a>";
                           }  
                          }  //end if
                        });
                  }  
                  //check the messages      
                 //  var url = document.URL;               
                     var callbackProxy = function(data){
                                 callbackFunc1(data,becomment);
                       }
                      var processResponse = { callback: callbackProxy };
                      SowiportDiscussionFunctions. checkMessages(url,  processResponse);  
              
               }else{ //if it is not the article page or abstract, then it must be the index page
               
                 //alert(typo3_lang);
                   //  var indexlan = url.substr(31, 2);
                     //alert("index language="+indexlan);
                     
                     var comdisplay="comment";
                     var comsdisplay="comments";
                     if (typo3_lang=="de"){
                     	  comdisplay="Kommentar";
                          comsdisplay="Kommentare";
                     }
                     var discdisplay =   getElementsByName_iefix("P", "discussioninfo_display");
                  var discdisplaylen =discdisplay.length;
                 // alert(discdisplaylen);
                  if (discdisplaylen != 0){ 
                        for (var j = 0; j<discdisplaylen; j++){
                    //         for (var j = 0; j<3; j++){
                              var recordid = discdisplay[j].getAttribute("id");
                              	 var record =document.getElementById(recordid);                                   	 
                                  record.innerHTML="<img src='"+prefix+"/discussion/icons/discuss.gif'/>&#160;&#160; 0 &#160;"+comdisplay; 
                                   SowiportDiscussionFunctions.getTotalNumber(recordid,function(data){                         
                                   if (data!=null){
                                        var record =document.getElementById(data[0]); 
                                        if (data[1]==1){
                                         record.innerHTML="<img src='"+prefix+"/discussion/icons/discuss.gif'/>&#160;&#160;"+data[1]+ "&#160;"+comdisplay; 
                                        }else{
                                          record.innerHTML="<img src='"+prefix+"/discussion/icons/discuss.gif'/>&#160;&#160;"+data[1]+ "&#160;"+comsdisplay; 
                                        }
                                    }
                              });
                              
                          }   //end for
                   }//end if 
               }
                            
               }

                 function getElementsByName_iefix(tag, name) {
     
                var elem = document.getElementsByTagName(tag);
                var arr = new Array();
                for(i = 0,iarr = 0; i < elem.length; i++) {
                     att = elem[i].getAttribute("name");
                      if(att == name) {
                          arr[iarr] = elem[i];
                                  iarr++;
                      }
                  }
                 return arr;   
               } 

               function fly(str, seq,pid){
                       var el = null;
               	   str= unescape(str);
               	   if (pid== null){
               	       el = document.getElementById("flyover_"+seq);
               	   }else{
               	   	   el = document.getElementById("flyover_"+seq+"_"+pid);
               	   }
               	el.innerHTML = str;
                     el.style.visibility = 'visible';
               }
               function hide(seq,pid){
                       var el = null;
               	   if (pid== null){
               	       el = document.getElementById("flyover_"+seq);
               	   }else{
               	   	   el = document.getElementById("flyover_"+seq+"_"+pid);
               	   }
               	   el.style.visibility ='hidden';
               } 
                            
               function callbackFunc1 (data,becomment) {
               	  
                   var resdoc = data;            
                   var anks = resdoc.getElementsByTagName("Anchor");
                   var len = resdoc.getElementsByTagName("Anchor").length;
                   var totalPostings = 0;
                  // alert("len="+len);
                
                   for (var i = 0; i<len; i++){
                   	
                       var postingNum = anks[i].getAttribute("PublishedPostings");
                       if (postingNum >0) {
                       	   totalPostings= totalPostings+ Number(postingNum);
                       	   //alert ("NewesPosting1"+ anks[i].getElementsByTagName("NewestPosting")[0].firstChild.nodeName);´
                      	   
                         	var time = anks[i].getElementsByTagName("NewestPosting")[0].getElementsByTagName("Date")[0].firstChild.nodeValue;    
                            var seq = anks[i].getAttribute("sequence-number") ;
                            // alert(seq);                       
                            text =  postingNum  ;
                            var context =null; 
                         if (becomment != null){               
                           //var img = "<img src='/discussion/icons/p1_lo_plus.gif' class='overviewCategory' alt=\"open_the_display\" onclick=\"displayOverview("+seq+")\"/>";                     
                            if (text =="1") {        	
                       	    context =  postingNum + " comment on "+time;
                            }else {
                              context  =  postingNum + " comments (newest one on "+time+")";  
                            }
                            if (seq=="-1") {
                       	       context =context +"about the whole article ";
                            }else {
                       	       context =  context+"about this paragraph ";
                            }
                            var overview = document.getElementById("overviewimage_"+seq);
                     /*     
                      overview.onclick = function(){ 
                              displayOverview(seq); 
                      }                   
                     */  
                       //overview.innerHTML = "<img src='/discussion/icons/discuss.gif'  class='imgLink' alt='Show comments' title='Kommentare anzeigen /Show comments'  />  <a name='overview' title='"+context+"'>"+text+"</a>";
                      overview.innerHTML = "<span id='flyover_"+seq+"'class='flyover'></span><img src='"+prefix+"/discussion/icons/discuss.gif'  class='imgLink' alt='Show comments' title='Kommentare anzeigen /Show comments'  />  <a name='overview' onmouseover='fly(\""+context+"\","+seq+")' onmouseout='hide("+seq+")'>"+text+"</a>";
                        }else if(becomment == null && seq=="-1"){ //if it is only an abstract, then find only the comments about the whole text
                        	 if (text =="1") {        	
                       	    context =  postingNum + " comment on "+time;
                            }else {
                              context  =  postingNum + " comments (newest one on "+time+")";  
                            }
                             context =context +"about the whole article ";
                              var overview = document.getElementById("overviewimage_-1");
                                overview.innerHTML = "<img src='"+prefix+"/discussion/icons/discuss.gif'  class='imgLink' alt='Show comments' title='Kommentare anzeigen /Show comments'  />  <a name='overview' title='"+context+"'>"+text+"</a>";
                        }
                      }
                 }
                  // alert(totalPostings);
                 var totalnumber = document.getElementById("disc_totalnumber");
                  if ( totalnumber != null)
                   totalnumber.innerHTML = totalPostings;
                   
             } 
             
            
               
	function createNewTopic(id){
	
	  var contentview = document.getElementById("discContent_"+id);
	  if ( contentview.getAttribute("class")!="discContentSelectedOpen"){
	  	  //open the display
	  	  var discview = document.getElementById("discussion_"+id);
	  	  discview.className ="commentOpen";
          contentview.className="discContentSelectedOpen";
           var bordertopview = document.getElementById("discBorder_top_"+id);
           bordertopview.innerHTML =  "<img src='"+prefix+"/discussion/icons/cross.png' class='cross' title='Schliessen / Close' alt ='close' onclick ='closeOverview("+id+")'>"; 
           bordertopview.className="discBorderTopVisible";
           var borderbottomview = document.getElementById("discBorder_bottom_"+id); 
           borderbottomview.innerHTML = "<img src='"+prefix+"/discussion/icons/transparent.gif'heigth='1' width='1'>";           
           borderbottomview.className="discBorderBottomVisible";
      } 
      if (lang=="de"){
          var docname="newMessage_de.php";
      }else {
      	 var docname="newMessage_en.php"; 
      } 
          var formular =  " <iframe src ='"+prefix+"/php/discussion_templates/"+docname+"?seqid="+id+"&tracking="+tracking_code+"' name ='ifr'  id= 'ifr_"+id+"' frameborder='0' height ='265' width='100%'  ></iframe>";      
           var discformular = document.getElementById("discformular_"+id);
           discformular.className="disciframeOpen";
           discformular.innerHTML= formular;        
    	}
	
	 
            
         
            function displayOverview(id){
            //	 var overview = document.getElementById("overviewimage_"+id);      
            //	 overview.innerHTML = "<img class='cross'src='/discussion/icons/cross.png' alt ='close' onclick =' closeOverview("+id+")>";
          
         
            var url = document.URL;
            var callbackProxy = function(data){
            callbackFunc(data,id);
            }
             var processResponse = { callback: callbackProxy };
             SowiportDiscussionFunctions.displayThreadOverview(url, id,processResponse);
        
            }
            
              function callbackFunc(data,id){
           
               if (data!= null) {
               	    var anchors = data.getElementsByTagName("Anchor");
               	   // alert(anchors.length);
               	   if (anchors.length>0){
               	   	  var published = anchors[0].getAttribute("PublishedPostings");
               	   	  if (published>0){
               	   	  	var discview = document.getElementById("discussion_"+id);
               	   	  	if ( discview.getAttribute("class")!="commentOpen"){
	  	                discview.className ="commentOpen" 
                        var contentview = document.getElementById("discContent_"+id);
                        contentview.className="discContentSelectedOpen";
                        var bordertopview = document.getElementById("discBorder_top_"+id); 
                        bordertopview.innerHTML =  "<img src='"+prefix+"/discussion/icons/cross.png' class='cross' alt ='close'title='Schliessen / Close' onclick ='closeOverview("+id+")'>";    
                        //bordertopview.innerHTML = "<img src='/discussion/icons/transparent.gif'heigth='1' width='3'>";
                        bordertopview.className="discBorderTopVisible";
                        var borderbottomview = document.getElementById("discBorder_bottom_"+id); 
                        borderbottomview.innerHTML = "<img src='"+prefix+"/discussion/icons/transparent.gif'heigth='1' width='1'>";
                        borderbottomview.className="discBorderBottomVisible";
                        }
                        var threadsinf = getThreads(data,id);
                        var threadslen = threadsinf[0];
                        // var time = threadsinf[1];
                       var list =  threadsinf[1];
            
                      var displayview = document.getElementById("display_"+id);
                      displayview.className="discDisplayOpen"; 
          
                     displayview.innerHTML = list;
                	}else{
            		alert ("The comments are not found!");
            	}
              }else{
              	   alert ("The comments are not found!");
            		}
              }else {
              alert ("The comments are not found!");
              }
              }
              
           function getThreads(xmldoc,id)  {
              var postings = null;
              var anchor = xmldoc.getElementsByTagName("Anchor")[0];
            
             postings = anchor.childNodes; 
             
            // alert ("firstChild"+xmldoc.firstChild.nodeName);
              if (postings.length>0) {
              var len = postings.length;
             // alert ("returned document id is :"+ id +"and length :" + len);
               //var list = "<ul class =\"list\">";
               var list = "<ul class=\"none\">";
              for ( i=0; i<len; i++) {            
              var postingKnoten = postings[i];
            
              var postingid = postingKnoten.getAttribute("id");
         //   alert("postingid"+postingid);  
              var subKnoten=postingKnoten.getElementsByTagName("Subject")[0];
              var  subject = subKnoten.firstChild.nodeValue;    
              var conKnoten=postingKnoten.getElementsByTagName("Content")[0];
              var  content = conKnoten.firstChild.nodeValue;                       
              var authorKnoten = postingKnoten.getElementsByTagName("Author")[0].getElementsByTagName("Name")[0];
              var  author = authorKnoten.firstChild.nodeValue;
               var dateKnoten=postingKnoten.getElementsByTagName("Date")[0];
              var  date= dateKnoten.firstChild.nodeValue;     
              if(lang=="de"){
                    var clongtime = dateKnoten.getAttribute("id");
                    var date = new Date(Number(clongtime));
                    date= date.toLocaleString();
                 }    
         //  alert("subject: "+ subject +" date: "+ date + " content: "+ content);
             childPostings =  postingKnoten.getElementsByTagName("Posting");
             var replyamount = postingKnoten.getElementsByTagName("Posting").length;
            
             var haschilds = false;
             if ( replyamount>0){           
              
               for (j=0; j<replyamount; j++){
               	   var child = childPostings[j];
               	   var cstate = child.getElementsByTagName("State")[0].firstChild.nodeValue;
               	  //  alert("child state: "+child.getAttribute("id")+";"+cstate);
             	   if (cstate =="accepted"){
             	 	 haschilds = true;
             	   }            	 
               }
             }
             
             if (replyamount>0 && haschilds){
           list =  list + "<li id =\"topic_"+id+"_"+postingid+"\"><div id =\"topicview_"+id+"_"+postingid+"\"><table><tr><td><img name='check' title='Antworten anzeigen / Show replies'src='"+prefix+"/discussion/icons/plus.gif'  class ='thread' alt='open' onclick ='openThread("+id+","+ postingid+")'></td>";
          //  list =  list + "<li id =\"topic_"+id+"_"+postingid+"\"  class=\"threadItemUnselectedClose\" > <a id ='link' onClick ='showContent("+id+","+postingid+"); openThread("+id+","+ postingid+")'";
             }else{
             list = list +"<li id =\"topic_"+id+"_"+postingid+"\"><div id =\"topicview_"+id+"_"+postingid+"\"><table><tr><td><img name='check' title='No Reply / Noch keine Antwort' src='"+prefix+"/discussion/icons/dot.gif' alt='dot' class ='thread' ></td>";
          // list = list +"<li id =\"topic_"+id+"_"+postingid+"\" class=\"threadItemUnselected\" ><a id ='link' onClick ='showContent("+id+","+postingid+")'";
             }
         
          //check if the user has the right to reply
           var repsrc = prefix+"/discussion/icons/ico_reply.gif";
           var reptitle ="Antworten / Reply";
           var repEvent = "onclick ='answerPosting("+id+","+postingid+")'";
           if (!isInRole) {
               repsrc =prefix+"/discussion/icons/sp_reply_grey.gif";  
           	   //reptitle ="Please log in before you reply to the comment!";
           	  reptitle = "Bitte einloggen bevor Sie antworten! / Pls log in before you write a comment! "; 
           	   repEvent = "";     
           }
             
          list = list + "<td><span id='flyover_"+id+"_"+postingid+"'class='flyover'></span><a name='link' class='link' onmouseover='fly(\""+escape(content)+"\","+id+","+postingid+")' onmouseout='hide("+id+","+postingid+")' onclick ='showContent("+id+","+postingid+")'>"+subject +"</a> ("+ date +" "+textfrom+": "+author
          	  +")&#160;<img id ='reply_"+id+"_"+postingid+"'name='reply' title='"+reptitle+"' src='"+repsrc+"' class ='thread' alt='reply'"+repEvent+" ></td></tr></table></div>"
              +"<div id ='content_"+id+"_"+postingid+"' class='divClose'></div><div id = 'answerframe_"+id+"_"+postingid+"' class='divClose'></div><div id = 'threadview_"+id+"_"+postingid+"' class='divClose'></div></li>";
         
              }             
             // alert ("list:" + list);
             var threadslen = anchor.getAttribute("PublishedPostings");
             //alert ("xmldoc length:" + threadslen);
            // var newesttime =anchor.getElementsByTagName("NewestPosting")[0].getElementsByTagName("Date")[0].firstChild.nodeValue;
            // var newesttime ="";
             list = list+"</ul>";
             resultarray = new Array(threadslen,list);
             return resultarray;
             }else{
               alert ("The postings are not found!");
               return null;
              }
            
         }
              
        function closeOverview(id) {
         var discview = document.getElementById("discussion_"+id);
	  	  discview.className ="commentClose" 
        	var contentview = document.getElementById("discContent_"+id);
        	 contentview.className="discContentSelectedClose";
        //	contentview.className ="threadItemUnselectedClose ";
          /*   contentview.style.backgroundImage = "url(/discussion/icons/p1_lo_plus.gif)";
           contentview.onclick = function(){ 
                    displayOverview(id);      
               }  */
              //  document.getElementById("display_"+id).style.display= "none"; 
             // document.getElementById("display_"+id).style.visibility= "hidden"; 
             var display = document.getElementById("display_"+id);
             display.className="discDisplayClose";
            var ifrform = document.getElementById("discformular_"+id);
             // ifrform.style.display= "none";
             ifrform.className="disciframeClose";
                document.getElementById("discBorder_top_"+id).className="discBorderTopInvisible";
                document.getElementById("discBorder_bottom_"+id).className="discBorderBottomInvisible";    
           
             
         }
         
         
         function openThread(seqid, postingid) {
               var url = document.URL;
               var callbackProxy = function(data){
                                 callbackFunc3(data,seqid,postingid);
                       }
                      var processResponse = { callback: callbackProxy };
                      SowiportDiscussionFunctions.openThread(url,seqid,postingid,  processResponse);
         }
         
         function callbackFunc3(data,seqid,postingid){
            
             var li = document.getElementById("topicview_"+seqid+"_"+postingid);
          //    li.className="threadItemSelectedOpen";
             var imgs = li.getElementsByTagName("img");                      
              for (var i = 0; i<imgs.length; i++){
              	  if (imgs[i].name == "check"){
              	  	   imgs[i].setAttribute("src",prefix+"/discussion/icons/minus.gif");  
              	  	    //    imgs[i].removeAttribute("class");
              	  	        imgs[i].setAttribute("title","Antworten ausblenden / Hide replies");  
              	  	        imgs[i].setAttribute("alt","close");         	  	 
              	  	   imgs[i].onclick = function(){ closeThread(seqid, postingid); }; 
              	  	// imgs[i].onclick =  "javascript:alert('test!')";
                  }   
              }
         
             
             var  postings =  data.getElementsByTagName("Posting");     
              var text = retrievePostings(postings,seqid,postingid);               
              var threadview= document.getElementById("threadview_"+seqid+"_"+postingid);
               // threadview.style.display ="block";
                threadview.className ="divOpen"; 
                 threadview.innerHTML = text;
                 
         }
         
         function retrievePostings(postingNodes,seqid,postingid) {
              var len = postingNodes.length;
            // alert ("postinglength:  " +len);
              var resultList = "<ul class=\"none\">";
              
             for (var i = 0; i<len; i++){
                  var parent = postingNodes[i].getElementsByTagName("Parent")[0].firstChild.nodeValue;
              
                  if(parent ==postingid) {
                    var parentpostingid =postingNodes[i].getAttribute("id");
                    var subject = postingNodes[i].getElementsByTagName("Subject")[0].firstChild.nodeValue;
                   var  content =  postingNodes[i].getElementsByTagName("Content")[0].firstChild.nodeValue;
                    var author =  postingNodes[i].getElementsByTagName("Author")[0].getElementsByTagName("Name")[0].firstChild.nodeValue;
                    var date = postingNodes[i].getElementsByTagName("Date")[0].firstChild.nodeValue;
                      if(lang=="de"){
                    var clongtime =  postingNodes[i].getElementsByTagName("Date")[0].getAttribute("id");
                     var date = new Date(Number(clongtime));
                     date= date.toLocaleString();
                    }       
                    var subpostings = postingNodes[i].getElementsByTagName("Posting");
                    var state = postingNodes[i].getElementsByTagName("State")[0].firstChild.nodeValue;
                    //var branchoutNode = postingNodes[i].getAttributeNode("branchout");
                    var branchout = postingNodes[i].getAttribute("branchout");
                   // alert("brauchout="+postingNodes[i].getAttribute("branchout"));
                   
                    var sublen = subpostings.length;
                   if (state=="accepted") {
                  //if the node has children, the sate of its children must also be proved.
                         var hasAcceptedKids = false;
                         var counter =0;
                         while (!hasAcceptedKids && sublen>0 && counter<sublen){                    
                              if (subpostings[counter].getElementsByTagName("State")[0].firstChild.nodeValue=="accepted") {
                                      hasAcceptedKids = true;
                                      break;
                               }    
                           counter++;
                          }
                    if (sublen >0 && hasAcceptedKids ){                                  
                          resultList =resultList +"<li id =\"topic_"+seqid+"_"+parentpostingid+"\"><div id =\"topicview_"+seqid+"_"+parentpostingid+
                          "\"><table><tr><td><img name='check' title='Antworten anzeigen / Show replies'src='"+prefix+"/discussion/icons/plus.gif'  class ='thread' alt='open' onclick ='openThread("+seqid+","+parentpostingid+")'></td> ";
                         /*   var subList = retrievePostings(subpostings,seqid, parentpostingid);
                            resultList =resultList + "<li> <a onClick ='showContent("+seqid+","+parentpostingid+")' >"+subject +
                                           "</a>  ("+date +" by "+author+")<div id = 'content_"+seqid+"_"+parentpostingid+"'  class='postingContent'></div><div id = 'answerframe_"+seqid+"_"+parentpostingid+"'></div>"+subList +"</li>";  
                      
                           */           
                    }else{
                   resultList = resultList +"<li id =\"topic_"+seqid+"_"+parentpostingid+"\"><div id =\"topicview_"+seqid+"_"+parentpostingid+"\"><table><tr><td><img name='check' title='Noch keine Antwort / No reply' src='"+prefix+"/discussion/icons/dot.gif' alt='dot' class ='thread' ></td>";
                    	/*
                    resultList = resultList + "<li> <a onClick ='showContent("+seqid+","+parentpostingid+")'>"+subject +
                                           "</a>  ("+ date +" by "+author+")<div id = 'content_"+seqid+"_"+parentpostingid+"'  class='postingContent'></div><div id = 'answerframe_"+seqid+"_"+parentpostingid+"'></div></li>";        
                                          */
                      }
                    //check if the user has the right to reply or branchout 
                    var repsrc = prefix+"/discussion/icons/ico_reply.gif";
                    var reptitle ="Antworten / Reply";
                    var repEvent = "onclick ='answerPosting("+seqid+","+parentpostingid+")'";                    
                    if (!isInRole) {
                    repsrc =prefix+"/discussion/icons/sp_reply_grey.gif";  
           	        reptitle ="Bitte einloggen bevor Sie antworten! / Please log in before you reply to the comment! "; 
           	        repEvent = "";     
                    }
                    var branchsrc =prefix+"/discussion/icons/branch.gif";
                    var branchtitle="Zu neuem Kommentar verzweigen / Branch to a new comment";
                    var branchEvent ="onclick='branchoutAsNew("+seqid+","+parentpostingid+")'";
                    if (!isModRole){
                    	branchsrc=prefix+"/discussion/icons/sp_branch_grey.gif";
                    	branchtitle ="Bitte einloggen als Moderator bevor Sie die Antwort zu neuem Kommentar verzweigen! / Please log in as Moderator before you branch this Reply to a new comment! ";
                    	branchEvent = "";
                    }
                    
                      if (branchout=="true" ){                     	  
                      	    resultList = resultList  + "<td><span id='flyover_"+seqid+"_"+parentpostingid+"'class='flyover'></span><a name ='link' class='link' onmouseover='fly(\""+escape(content)+"\","+seqid+","+parentpostingid+")' onmouseout='hide("+seqid+","+parentpostingid+")'  onclick ='showContent("+seqid+","+parentpostingid+")'>"+subject +"</a> ("+ date +" "+textfrom+": "
                     	  +author+")</td></tr></table></div>"
                          +"<div id ='content_"+seqid+"_"+parentpostingid+"' class='divClose'></div><div id = 'answerframe_"+seqid+"_"+parentpostingid+"'></div><div id = 'threadview_"+seqid+"_"+parentpostingid+"'></div></li>"; 
                      }else{
                     resultList = resultList  + "<td><span id='flyover_"+seqid+"_"+parentpostingid+"'class='flyover'></span> <a name ='link' class='link' onmouseover='fly(\""+escape(content)+"\","+seqid+","+parentpostingid+")' onmouseout='hide("+seqid+","+parentpostingid+")' onclick ='showContent("+seqid+","+parentpostingid+")'>"+subject +"</a> ("+ date +" "+textfrom+": "
                     	  +author+")&#160;<img id ='reply_"+seqid+"_"+parentpostingid+"'name='reply'title='"+reptitle+"' src='"+repsrc+"' class ='thread' "+repEvent+">&#160;<img id ='branch_"+seqid+"_"+parentpostingid+"'name='branchout' class ='thread' title='"+branchtitle+"'src='"+branchsrc+"'"
                     	  +" alt='branch out as a new topic' "+branchEvent+"></td></tr></table></div>"
                          +"<div id ='content_"+seqid+"_"+parentpostingid+"' class='divClose'></div><div id = 'answerframe_"+seqid+"_"+parentpostingid+"' class='divClose'></div><div id = 'threadview_"+seqid+"_"+parentpostingid+"'class='divClose'></div></li>"; 
                      }
                   }             
                    }
                }
                
                resultList = resultList + "</ul>";
              // alert ("ergebnis: resultList = "  + resultList);   
                return resultList;
         }
         
        
         
         function closeThread(seqid, postingid) {
               var topview =  document.getElementById("topicview_"+seqid+"_"+postingid);
           // li.className = "threadItemUnselectedClose";
                
            
              var imgs = topview.getElementsByTagName("img");    
                    
              for (var i = 0; i<imgs.length; i++){
              	  if (imgs[i].name == "check"){
              	  	   if (imgs[i].getAttribute("alt")== "close"){
              	  	   imgs[i].setAttribute("src",prefix+"/discussion/icons/plus.gif");              	  	    
              	  	   imgs[i].setAttribute("title","Antworten anzeigen / Show replies"); 
              	  	   imgs[i].setAttribute("alt","open");
              	  	    imgs[i].onclick = function(){ 
                        openThread(seqid, postingid);    
                        } ; 
              	  	  }else if (imgs[i].getAttribute("alt")== "close_dot"){
              	  	   imgs[i].setAttribute("src",prefix+"/discussion/icons/dot.gif");
              	  	   imgs[i].setAttribute("title","No Reply / Noch keine Antwort"); 
              	  	  }  
              	  	     	  	 
              	  	  
                  } else if (imgs[i].name == "branchout" ||imgs[i].name == "reply"){
                      imgs[i].style.display ="inline";
                  	  
                   }   
              }
              //var newcontent = topview.innerHTML+"";
              
 
              var tw =  document.getElementById("threadview_"+seqid+"_"+postingid);
              tw.className ="divClose";
              //tw.style.display= "none";;
               var co =  document.getElementById("content_"+seqid+"_"+postingid);
               /*
               var icoimgs = co.getElementsByTagName("img");
               for (var j = 0; j<icoimgs.length; j++){
               	   var imgcopy = document.createElement("img");
               	   imgcopy= icoimgs[j].cloneNode(true);
               	   topview.appendChild(imgcopy);
               } 
             */ 
               co.className ="divClose"; 
              //co.style.display = "none";
                var an =  document.getElementById("answerframe_"+seqid+"_"+postingid);
                  an.className ="divClose";
             // an.style.display = "none";
         }
         
            
          function showContent(seqid, postingid) {
               var url = document.URL;
               
              var callbackProxy = function(data){
                                 callbackFunc2(data,seqid,postingid);
                       }
                      var processResponse = { callback: callbackProxy };
                      SowiportDiscussionFunctions. postingView(url,seqid,postingid,  processResponse);
       
           
          }
          
          function callbackFunc2(data,seqid,postingid){
          	  var havechildren = false;
                   var postingKnoten = data;            
                 //  alert ("seqid: "+seqid+"postingid: "+postingid );
                     var subKnoten=postingKnoten.getElementsByTagName("Subject")[0];
              var  subject = subKnoten.firstChild.nodeValue;    
              var conKnoten=postingKnoten.getElementsByTagName("Content")[0];
              var  content = conKnoten.firstChild.nodeValue;                       
              var authorKnoten = postingKnoten.getElementsByTagName("Author")[0].getElementsByTagName("Name")[0];
              var  author = authorKnoten.firstChild.nodeValue;
               var dateKnoten=postingKnoten.getElementsByTagName("Date")[0];
              var  date= dateKnoten.firstChild.nodeValue;
               if(lang=="de"){
                    var clongtime =  dateKnoten.getAttribute("id");
                     var date = new Date(Number(clongtime));
                     date= date.toLocaleString();
                    }       
               var paKnoten=postingKnoten.getElementsByTagName("Parent")[0];
              var  parent= paKnoten.firstChild.nodeValue;
             var posting = postingKnoten.getElementsByTagName("Posting")[0];
            var branchout = posting.getAttribute("branchout");
            //   alert("branchout:"+branchout+"parent:"+parent);
               var viewdiv = document.getElementById("content_"+seqid+"_"+postingid);
               var tvdiv = document.getElementById("topicview_"+seqid+"_"+postingid);
                var imgs = tvdiv.getElementsByTagName("img");
                if (viewdiv.style.display=="none")
                      	  viewdiv.style.display="";
                 if (viewdiv.className != "postingContent")                
                      viewdiv.className ="postingContent";
                      
                
                if (imgs.length>0 && branchout != "true")        {   
                
                   for (var i = 0; i<imgs.length; i++){          	 
              	      
      
                      if(imgs[i].name == "check" ){
                     	if (imgs[i].getAttribute("alt")== "dot"){
                     		 imgs[i].setAttribute("alt","close_dot");
                     	}else if(imgs[i].getAttribute("alt")== "open"){
                     	 havechildren = true;
                     	  imgs[i].setAttribute("alt","close");
                     	}
                     
                  	  imgs[i].setAttribute("src",prefix+"/discussion/icons/minus.gif");
                  	   imgs[i].setAttribute("title","Antworten ausblenden / Hide replies");
                              // imgs[i].removeAttribute("class");
                  	   imgs[i].onclick = function(){ 
                        closeThread(seqid, postingid);    
                       }  
                    }else  if (imgs[i].name == "branchout" ||imgs[i].name == "reply"){
                      imgs[i].style.display ="none";
                  	}
                    
                  } 
              
                }
            //  alert ("parent of vewdiv: " +topicdiv);
            //check the userrole
              var repsrc = prefix+"/discussion/icons/ico_reply.gif";
              var reptitle ="Antworten / reply";
              var repEvent = "onclick ='answerPosting("+seqid+","+postingid+")'";
               if (!isInRole) {
               repsrc =prefix+"/discussion/icons/sp_reply_grey.gif";  
           	   reptitle ="Please log in before you reply to the comment! / Bitte einloggen bevor Sie antworten!"; 
           	   repEvent = "";     
              }
              
               var branchsrc =prefix+"/discussion/icons/branch.gif";
                    var branchtitle="Zu neuem Kommentar verzweigen / Branch to a new comment";
                    var branchEvent ="onclick='branchoutAsNew("+seqid+","+postingid+")'";
                    if (!isModRole){
                    	branchsrc=prefix+"/discussion/icons/sp_branch_grey.gif";
                    	branchtitle ="Please log in as Moderator before you branch this Reply to a new comment! / Bitte einloggen als Moderator bevor Sie den Kommentar zu neuem Kommentar verzweigen!";
                    	branchEvent = "";
                    }
            
                if (parent !="null"&& parent!=null) {
                  if ( branchout == "" || branchout == null ) {
                   viewdiv.innerHTML = content+"&#160;<img id ='reply_"+seqid+"_"+postingid+"'name='reply'src='"+repsrc+"' title='"+reptitle+"'alt ='reply' class ='thread' "+repEvent+"'>"+"&#160;<img id ='branch_"+seqid+"_"+postingid+"'name='branchout' title='"+branchtitle+"' class ='thread' src='"+branchsrc+"'"
                     	  +" alt='branch out as a new topic' "+branchEvent+">";
               
              	  }else if (branchout=="true"){
                /*  viewdiv.innerHTML ="<div >"+ author +" wrote on "+ date + ":</br>"+content+"</br><button type=\"button\" value = \"anworten\"onClick=\"answerPosting("+seqid+","+postingid+") \">Reply</button>"+
             "     <button type=\"button\" value = \"verzweigen\"onClick=\" branchout("+seqid+","+postingid+") \">Branch out the reply as a new topic </button><button type=\"button\" value = \"close\"onClick=\"closeContent("+seqid+","+postingid+") \">Close the content</button></br></div>";
                */
               // alert("this topic is branched out! You can only see the content of the message.");
                  viewdiv.innerHTML =content;
                
                 }
                 }else {
              
               
               viewdiv.innerHTML = content+"&#160;<img id ='reply_"+seqid+"_"+postingid+"'name='reply' title='"+reptitle+"'src='"+repsrc+"' alt ='reply' class ='thread' "+repEvent+">";
              
              }
             // viewdiv.className ="postingContent";
              // viewdiv.style.display ="block";
              //open the childthreads
              if (havechildren){
              	 
               var  postings =  data.getElementsByTagName("Posting");     
               var text = retrievePostings(postings,seqid,postingid);               
               var threadview= document.getElementById("threadview_"+seqid+"_"+postingid);
               //alert("open the replies!")
                  threadview.className ="divOpen";
                //threadview.style.display ="block";
                threadview.innerHTML = text; 
              }
          }
          
           function closeContent(seqid,postingid) {
                 var contentview = parent.document.getElementById("content_"+seqid+"_"+postingid);
                   contentview.className ="divClose";
                 // contentview.style.display= "none";
                //   var topicview = parent.document.getElementById("topic_"+seqid+"_"+postingid);
                 //topicview.className ="threadItemUnselected";
          }
          
          
          function answerPosting(seqid,postingid) {
          	  if (lang=="de"){
                 var docname="replyMessage_de.php";
              }else {
      	          var docname="replyMessage_en.php"; 
              } 
             var formular =  " <iframe src ='"+prefix+"/php/discussion_templates/"+docname+"?seqid="+seqid +"&postingid="+postingid+"&tracking="+tracking_code+ "' id ='answeriframe_ "+seqid+"_"+postingid +"'  frameborder='0' height ='265' width='600'><seqid>"
                                      +seqid + "</seqid></iframe>";              
                var answerform = document.getElementById("answerframe_"+seqid+"_"+ postingid);
                 answerform.className ="divOpen";
               // answerform.style.display = "block";
                answerform.innerHTML= formular;
          }
          
        function branchoutAsNew(seqid,postingid) {
              if (lang=="de"){
                     var docname="branchoutMessage_de.php";
              }else {
                     var docname="branchoutMessage_en.php"; 
              } 
             var formular =  " <iframe src ='"+prefix+"/php/discussion_templates/"+docname+"?seqid="+seqid +"&postingid="+postingid +"&tracking="+tracking_code+"' id ='answeriframe_ "+seqid+"_"+postingid +"'  frameborder='0' height ='265' width='600'></iframe>";
             var answerform = document.getElementById("answerframe_"+seqid+"_"+ postingid);
            answerform.className ="divOpen";
            // answerform.style.display = "block";
             answerform.innerHTML= formular;
            
          }         
          
    function article_senden(){
                   var recommendDIV = document.getElementById("send_article");
                   recommendDIV.className= "recommendArticle";
                   var title =     document.getElementById("titleOfArticle").value;
                   var language =     document.getElementById("languageOfArticle").value;  
                   var authors =document.getElementById("authorsOfArticle").value;
                   var volume =document.getElementById("volumeOfArticle").value; 
                   var publisher = document.getElementById("publisherOfArticle").value;
                   var pubdate = document.getElementById("dateOfArticle").value;      
                   recommendDIV.style.display ="block";
                   if (language=="de"){
                         /*     recommendDIV.innerHTML = "<p>Versenden Sie diesen Artikel an Ihren Freund oder Kollege. F&uuml;llen Sie das folgende Formular aus und dann clicken Sie auf  \"Abschicken\". Mehrfache Adressen im Empf&auml;ngerfeld soll mit das Semikolon getrennt werden.</p><span id='rec_errormessage' class='rec_errormessage'></span><br><div> <label for='rec_emailTo' class='mailaddressText1'>E-Mail-Adresse des Empf&auml;ngers</label>"+
                            "<label for='rec_emailFrom' class='mailaddressText2'>Ihre eingene E-Mail-Adresse </label><div class='clear'/></div><div><div class='mailaddressInput1'><input type='text' name='emailTo' id='rec_emailTo'> </input></div><div class='mailaddressInput2'><input type='text' name='emailFrom' id='rec_emailFrom'> </input></div><div class='clear'/></div><br>"+
                            "<label for='rec_subject'>Betreff:</label><div><input type='text' name='subject' id='rec_subject' size='65' value='"+title+" '> </input></div><br><label for='rec_message'>Mitteilungen an den Empf&auml;nger:</label><div><textarea rows='3' cols='34' name='message' id='rec_message'></textarea></div><br>"+
                           " <div><a  href='javascript:recommendmail_senden_check();' >Abschicken</a></div>";   */
                             recommendDIV.innerHTML = "<p>Versenden Sie diesen Artikel an Ihren Freund oder Kollege. F&uuml;llen Sie das folgende Formular aus und dann clicken Sie auf  \"Abschicken\".</p><span id='rec_errormessage' class='rec_errormessage'></span><br><div><label for='rec_emailFrom' class='mailaddressText2'>Von:</label></div>"+
                            "<div class='mailaddressInput2'><input type='text' name='emailFrom' id='rec_emailFrom'> </input><span>(Ihre E-Mail-Adresse)</span></div><br><div><label for='rec_emailTo' class='mailaddressText1'>An: </label></div><div class='mailaddressInput1'><input type='text' name='emailTo' id='rec_emailTo'> </input><span>(E-Mail-Adresse des Empf&auml;ngers; mehrfache Adressen im Empf&auml;ngerfeld sollen mit das Semikolon getrennt werden)</span></div><br>"+
                            "<label for='rec_subject'>Betreff:</label><div><input type='text' name='subject' id='rec_subject' size='65' value='Link to article from FQS Journal'> </input></div><br><label for='rec_message'>Message:</label><p>Folgende  Zitierung wird auch an die Emf&auml;nger gesendet : </p><p>"+authors+title+"."+publisher+","+volume+"."+"Available at: <a>"+url+"</a></p><div><textarea rows='3' cols='34' name='message' id='rec_message'></textarea></div><br>"+
                           " <div><a  href='javascript:recommendmail_senden_check();' >Submit</a> <a  href='javascript:recommendmail_cancel();' >Cancel</a></div>";
                     }else{
                           /*    recommendDIV.innerHTML = "<p>Send this article to a friend or colleague. Fill out the form below, and then click \"Submit\". Multiple addresses in recipients field must be sparated by a semicolon.</p><span id='rec_errormessage' class='rec_errormessage'></span><br><div> <label for='rec_emailTo' class='mailaddressText1'>To: Enter e-mail address of recipients</label>"+
                            "<label for='rec_emailFrom' class='mailaddressText2'>Enter your e-mail address</label><div class='clear'/></div><div><div class='mailaddressInput1'><input type='text' name='emailTo' id='rec_emailTo'> </input></div><div class='mailaddressInput2'><input type='text' name='emailFrom' id='rec_emailFrom'> </input></div><div class='clear'/></div><br>"+
                            "<label for='rec_subject'>Subject:</label><div><input type='text' name='subject' id='rec_subject' size='65' value='"+title+" '> </input></div><br><label for='rec_message'>Message:</label><div><textarea rows='3' cols='34' name='message' id='rec_message'></textarea></div><br>"+
                           " <div><a  href='javascript:recommendmail_senden_check();' >Submit</a></div>";  */
                            recommendDIV.innerHTML = "<p>Send this article to a friend or colleague. Fill out the form below, and then click \"Submit\". </p><span id='rec_errormessage' class='rec_errormessage'></span><br><div><label for='rec_emailFrom' class='mailaddressText2'>From:</label></div>"+
                            "<div class='mailaddressInput2'><input type='text' name='emailFrom' id='rec_emailFrom'> </input><span>(your e-mail address)</span></div><br><div><label for='rec_emailTo' class='mailaddressText1'>To: </label></div><div class='mailaddressInput1'><input type='text' name='emailTo' id='rec_emailTo'> </input><span>(recipient's address; separate multiple addresses with colons)</span></div><br>"+
                            "<label for='rec_subject'>Subject:</label><div><input type='text' name='subject' id='rec_subject' size='65' value='Link to article from FQS Journal'> </input></div><br><label for='rec_message'>Message:</label><p>The following citation will also been sent to the recipient: </p><p>"+authors+title+"."+publisher+","+volume+"."+"Available at: <a>"+url+"</a></p><div><textarea rows='3' cols='34' name='message' id='rec_message'></textarea></div><br>"+
                           " <div><a  href='javascript:recommendmail_senden_check();' >Submit</a> <a  href='javascript:recommendmail_close();' >Cancel</a></div>";
                           }
                   
          }
          
          function recommendmail_senden_check() {
          var emailTo = document.getElementById("rec_emailTo").value;
          var emailFrom =document.getElementById("rec_emailFrom").value;
          var subject =document.getElementById("rec_subject").value;
          var message = document.getElementById("rec_message").value;
          var mailexp =/[a-zA-Z0-9_-]+@([a-zA-Z0-9_-]+[.])+[a-zA-Z0-9_-]+/;
            //TODO check the maillists of  emailTo  mit loop
           var formatcheck1=emailTo.search(mailexp);
           var formatcheck2=emailFrom.search(mailexp);
              if (emailTo == "" || emailFrom =="" ||formatcheck1== -1 ||formatcheck2== -1   ) {
                 var eMessage =document.getElementById("rec_errormessage");
                 eMessage.innerHTML = "please enter valid To and From email addresses.";
              }else if( subject ==""){
               var eMessage =document.getElementById("rec_errormessage");
               eMessage.innerHTML= "please enter the subject of this email.";
              }else {
                   var artikelTitle =document.getElementById("titleOfArticle").value;
                   var authors =document.getElementById("authorsOfArticle").value;
                   var volume =document.getElementById("volumeOfArticle").value;
                   var language = document.getElementById("languageOfArticle").value;
                   var publisher = document.getElementById("publisherOfArticle").value;
                   var pubdate = document.getElementById("dateOfArticle").value;
                     DiscussionFunctions.recommendMail(emailTo,emailFrom,language,subject,message,url, artikelTitle,volume,authors,pubdate,publisher, function(data){
                         var recommendDIV = document.getElementById("send_article");
                        if(new Boolean(data))  {                  
                          recommendDIV.innerHTML ="<div>Your e-Mail has been sent.<div/>";
                          // set the "email has been sent" Info only for 10 sec, then made the div hidden.
                         // window.setTimeout("closeDiv()",10000);
                            window.setTimeout("recommendmail_close()",10000);
                          
                     }else {
                             //ask the user to send the mail again.
                              var notice = document.getElementById("rec_errormessage");
                              notice.innerHTML ="An Error was occured during email sending. Please send the message again. ";
                     }
                     
                     });
              }  //end else
          
          }
          
          
            function recommendmail_close(){
              var toClose = document.getElementById("send_article");
              toClose.style.display ="none";
    
          }
          
        
         /* 
          var browserName = navigator.appName;
          var browserVer = parseInt(navigator.appVersion);
          var version = "";
          var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
          if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
           
           // Blurring links:
         function blurLink(theObject) {
         //  alert("hi!msie4="+msie4); //
          if (msie4) {theObject.blur();}
          
         }  */
         
/*
Abstract Display in index page of online publication 
*/
function showAbstractFull(abShortSpan){
	
	abShortSpan.className="abstractShortClose";
	var abFullSpan=abShortSpan.nextSibling;
	abFullSpan.className="abstractFullOpen";
	
}
function showAbstractShort(abFullSpan){
	abFullSpan.className="abstractFullClose";
	var abShortSpan  = abFullSpan.previousSibling;
	abShortSpan.className ="abstractShortOpen";
}


	  
//-->
