

  function HandleSubmitButton( idPosting)
   {
      var aft = document.getElementById( "afl" + idPosting);
		  
      if( aft)
      {
         if( aft.previousSibling)
	   if( aft.previousSibling.innerHTML)
	     {
		var oButtonContainer = document.getElementById("submitButtonsContainer");
		if( oButtonContainer)
		{
		/*
		   var zitatButton = "<INPUT style=\"float:right; margin-right:0px;\" onclick=\"InsertSelectionAsCiteInto5( \'msg\')\" value=\"Zitat\" type=button>";		   

		   oButtonContainer.innerHTML = zitatButton + "<div class=\"antworten2\" tabindex=\"1\" onclick=\"theForm.submit();\">" + aft.previousSibling.innerHTML + "</div>";
                  */ 																    
		   var zitatButton = "<INPUT style=\"float:right; margin-right:0px;\" onclick=\"InsertSelectionAsCiteInto5( \'msg\')\" value=\"Zitat\" type=button>";		   

		   oButtonContainer.style.minHeight = '20px';
		   oButtonContainer.style.paddingTop = '7px';		   
		   oButtonContainer.innerHTML = "<div class=\"antworten2\" style=\"float:left;\" tabindex=\"1\" onclick=\"theForm.submit();\">" + aft.previousSibling.innerHTML + "</div>" + zitatButton;
		  
	        }
	   }
      }
   }

   function HandleAnswerFormDiskussion( idPosting, idAnswerForm)
   {
      var af = document.getElementById( idAnswerForm);
      var aft = document.getElementById( "afl" + idPosting);
      
      HandleSubmitButton( idPosting);

      // if not a child already, move it
      if( af.parentNode.id != aft.id)
      {
	 af.parentNode.removeChild( af);
	 aft.appendChild( af);
	 af.style.display = "block";
	 
	 var irp = document.getElementById("id_parent");
	 if( irp)
	 {
	    irp.value = idPosting;
	 }
      }
      else
      {
	 ToogleAnswerFormDiskussion( idAnswerForm);	   
      }
   }


   function ToogleAnswerFormDiskussion( id)
   {
      var oForm = document.getElementById( id);
      
      if( oForm)
      {
	 if( oForm.style.display == "none") 
	   oForm.style.display = "block";
	 else 
	   oForm.style.display = "none";
      }
   }

   function SetStyleDisplayFor( id, display)
   {
      var obj = document.getElementById(id);
      if( obj)
	obj.style.display = display;
   }

function InsertSelectionAsCiteInto( id)
{
   var sel = getSel();
   if( sel != '')
   { 
      var ta = document.getElementById( id);
      if( ta)
      {
	 ta.innerHTML = ta.innerHTML + "<cite>" + sel + "</cite>";
      }
   }
   else
   {
      alert( 'Bitte zuerst einen Text mit dem Mauszeiger auswählen!');
   }
}

function getSel() 
{
   
   if (window.getSelection) 
     {
	
	return window.getSelection();
     }
    else if (document.selection) 
     {
	
	return document.selection.createRange();
     }
   
}


   function ShowDisskussionsForumlar()
   {		
      // falls javascript an ist, dann mitredenLink einblenden
      SetStyleDisplayFor( "mitredenLink", "block");
		
      // falls cookies an sind den rest einblenden bzw. ausblenden
      // falls cookies aus sind, dann kommt nur das antwort form mit
      // der direkten login moeglichkeit
      // 
      //if( MyCookieEnabled())
      // ein paar user haben die datei /v3/script/adcookie17.js im filter 
      // darin ist die function MyCookieEnabled() definiert
      // 

      // ein cookie setzen
      document.cookie = "arecookiesenabled=1";
      // nachsehn ob cookies an sind
      if( document.cookie.indexOf( "arecookiesenabled") >= 0)
      {
	 SetStyleDisplayFor( "formContainer", "none");

	 var refererField = document.getElementById("referer_login");
	 if( refererField)
	   refererField.value = window.location;	

	 var refererField = document.getElementById("referer_diskussion");
	 if( refererField)
	   refererField.value = window.location;	

	 var account = new Account();
	 //falls eingeloggt      
	 if( account.IsLoggedIn())
	 {
	    SetStyleDisplayFor( "answerContainer", "block");
	    SetStyleDisplayFor( "loginMiniForm", "none");	 
	    SetStyleDisplayFor( "userNamePassword", "none");
	    SetStyleDisplayFor( "pwVergessenLink", "none");
	    SetStyleDisplayFor( "mitgliedWerdenLink", "none");
	    
	    // passwort und username aus dem cookie ins form einfügen
	    var u = document.getElementById('username_diskussion');
	    if(u) { u.value = account.GetUsernameRaw(); }
	    var p = document.getElementById('password_diskussion');
	    if(p) { p.value = account.GetPasswordRaw(); }	 
	 }
	 // falls nicht eingeloggt	
	 else
	 {
	    SetStyleDisplayFor( "answerContainer", "none");
	    SetStyleDisplayFor( "loginMiniForm", "block");	 
	 }
      }  // !     if( MyCookieEnabled())
      // javascript ist an und cookies sind aus
      else
      {
	 // form einmal zuklappen
	 ToogleAnswerFormDiskussion('formContainer');
      }
   }
