
// --------------------------------------------------------------------------------------------

// Cookie speichern

   function SetCookie (name, value)
   { 
     if (value == "undefined")
	   value = "" ;

     var ExpDate = new Date () ;
     ExpDate.setTime (ExpDate.getTime() + 30 * 24 * 60 * 60 * 1000) ;

     document.cookie = name + "=" + escape (value) + "; expires=" + ExpDate.toGMTString() ;
   }

// --------------------------------------------------------------------------------------------

// Cookie einlesen

   function GetCookie (name, defaultvalue)
   { 
     var arg = name + "=" ;
     var alen = arg.length ;

     var clen = document.cookie.length ;

     var i = 0 ;
     while (i < clen)
       { 
         var j = i + alen ;

         if (document.cookie.substring (i, j) == arg)
           { 
             var endstr = document.cookie.indexOf (";", j) ;

             if (endstr == -1)
               endstr = document.cookie.length ;
  
             value = unescape (document.cookie.substring (j, endstr)) ;
        
             if (value == "" || value == "undefined")
               value = defaultvalue;
        
             return value ;          
           }
      
         i = document.cookie.indexOf (" ", i) + 1 ;

         if (i == 0)
           break ;
       }
  
     return defaultvalue ;
   }

// --------------------------------------------------------------------------------------------

// Sonderzeichen in Texten umsetzen

  function EscapeText (Text)
  {
    while (Text.search (" ") != -1)  Text = Text.replace (" ", "&sp;") ;
    while (Text.search ("\n") != -1) Text = Text.replace ("\n", "&lf;") ;
    while (Text.search ("\r") != -1) Text = Text.replace ("\r", "&cr;") ;
    while (Text.search ("=") != -1)  Text = Text.replace ("=", "&eq;") ;
    while (Text.search ("<") != -1)  Text = Text.replace ("<", "&_lt;") ;
    while (Text.search (">") != -1)  Text = Text.replace (">", "&_gt;") ;
    while (Text.search ("#") != -1)  Text = Text.replace ("#", "&fis;") ;
    while (Text.search ("\\|") != -1)  Text = Text.replace ("\|", "&_or;") ;
    while (Text.search ("\\+") != -1)  Text = Text.replace ("\+", "&plus;") ;
    while (Text.search ("\"") != -1)  Text = Text.replace ("\"", "&_quot;") ;
    while (Text.search ("%") != -1)  Text = Text.replace ("%", "&perc;") ;
    while (Text.search ("\\?") != -1)  Text = Text.replace ("\?", "&!") ;
    
    return Text ;
  }
  
// --------------------------------------------------------------------------------------------

