/*  2008-12-28  RS1Lib.js JavaScript functions

    Dr. Rolf Schröder
    Möörkenweg 37
    21029 Hamburg, Deutschland
    http://rschr.de
*/
//------------------------------------------------------------------------------------------
//------------------------------------- General functions ----------------------------------
//------------------------------------------------------------------------------------------

if(top!=self) top.location=self.location; // Don't squeeze page into a frame!

function NewWindow(url,name,features)
//       #########
{
   MyWindow = window.open( url, name, features);
   MyWindow.focus();
}

function langQuery()  // If <meta name="language" content="lang"> is found in
//       #########    // the page, the return value is "lang", else "". 
{
  var s = document.getElementsByTagName("meta"); // read all meta-tags
  for( i=0; i < s.length; i++)  // search the meta-tags for name="language"
  { if(s[i].name.toLowerCase() == "language")
    { return s[i].content.toLowerCase();         //  return content as string
    }
  }
  return "";                                     // return "" if no language given
}

//------------------------------------------------------------------------------------------
//-------------------------------------- E-Mail-Functions ----------------------------------
//------------------------------------------------------------------------------------------

function obscure( Name, Domain, Text)
//       #######
//
// The three parameters Name, Domain, and Text are of type string,
// the third parameter 'Text' is optional. Its content replaces
// the otherwise displayed e-mail-address. 
//
{  
   function Rint(n)                   // Random integer r: 1 <= r <= n 
   { return Math.floor( n*Math.random() + 1 );  
   }      
   function s2h(str)                  // Replaces chars randomly by three 
   { var s = "", i, z1 = 0, z2, cod;  // different HTML character notations,
     for( i = 0; i < str.length; i++) // namely direct notation,    
     { cod = str.charCodeAt(i);       // decimal notation, and
       z2 = Rint(3);                  // hexadecimal notation.
       while( z2 == z1 ) { z2 = Rint(3); } // Avoids repetitions.
       z1 = z2;
       switch( z1 )
       { case 1: s += "&#"  + cod.toString(10) + ";"; break;
         case 2: s += "&#x" + cod.toString(16) + ";"; break;
         case 3: s += String.fromCharCode(cod); break;
       } 
     }
     return s;
   }
   Name = s2h(Name);
   Domain = s2h(Domain);
   if( arguments.length < 3 )
   { Text = Name + "&#x24D0;" + Domain;
   }
   document.write("<a href=\""
               + s2h(decodeURIComponent("%6D%61%69%6C%74%6F%3A"))
               + Name + '&#x40;' + Domain + "\">"
               + Text + "</a>");
}

function obscure_test( Name, Domain) // Only for testing!!!
//       ############
{
   document.write("<a href=\"" + decodeURIComponent("%6D%61%69%6C%74%6F%3A")
               + Name + decodeURIComponent("%40") + Domain + "\">"
               + Name + decodeURIComponent("%40") + Domain + "</a>");
}

//------------------------------------------------------------------------------------------
//----------------------------------- Date-Time-functions ----------------------------------
//------------------------------------------------------------------------------------------

function iso_date_format(t)
//       ###############
{
    var Year    = t.getUTCFullYear();
    var Month   = t.getUTCMonth() + 1;
    var Day     = t.getUTCDate();
    var Hours   = t.getUTCHours();
    var Minutes = t.getUTCMinutes();
    var Seconds = t.getUTCSeconds();

    if (Month   < 10  ) Month   =  "0" + Month;
    if (Day     < 10  ) Day     =  "0" + Day;
    if (Hours   < 10  ) Hours   =  "0" + Hours;
    if (Minutes < 10  ) Minutes =  "0" + Minutes;
    if (Seconds < 10  ) Seconds =  "0" + Seconds;

    return Year+"-"+Month+"-"+Day+"&nbsp;"+Hours+":"+Minutes+":"+Seconds+"&nbsp;UTC";
}

function last_modified_UTC()
//       #################
{
    d = new Date(document.lastModified);  // Date obj. of document
    document.write(iso_date_format(d));
}

function now_UTC()
//       #######
{
    d = new Date();
    document.write(iso_date_format(d));
}

//------------------------------------------------------------------------------------------
//----------------------------------- Several Bottom Features ------------------------------
//------------------------------------------------------------------------------------------

function bottom()
//       ######
{
    var c;
	switch( langQuery() )
	{ case "de": c = "Seit ";
	  break;
	  case "en":
	  case ""  : c = "Since ";
	  break;
	  case "ru": c = "C ";
	  break;
	}
    document.write(c + "2000-11-29:&nbsp;");
    switch("1&1+Hoppe")
    { case "1&1":
        document.write("<a href=\"http://login.1und1.de/\" target=\"_blank\"><img src=\"http://rschr.de/Bilder/Dragon.gif\" border=\"0\" width=\"114\" height=\"35\" title=\"Dragon\" alt=\"Dragon\"><\/a>");
        document.write("<a href=\"http://login.1und1.de/\" target=\"_blank\"><img src=\"http://rschr.de/tinc?key=p5rywepE\" border=\"0\" width=\"48\" height=\"16\" title=\"1&amp;1-Z&auml;hler\" alt=\"1&amp;1-Z&auml;hler\"><\/a>");
        break;
      case "Dra+1&1":
        document.write("<a href=\"http://boingdragon.com/cgi-bin/account/rschr=stats\" target=\"_blank\"><img src=\"http://cgi.boingdragon.com/count/rschr/1.gif\" border=\"0\" width=\"114\" height=\"35\" title=\"Dragon-Counter\" alt=\"Dragon-Counter\"><\/a>");
        document.write("&nbsp;");
        document.write("<a href=\"http://login.1und1.de/\" target=\"_blank\"><img src=\"http://rschr.de/tinc?key=p5rywepE\" border=\"0\" width=\"48\" height=\"16\" title=\"1&amp;1-Z&auml;hler\" alt=\"1&amp;1-Z&auml;hler\"><\/a>");
        break;
      case "Dragon":
        document.write("<a href=\"http://boingdragon.com/cgi-bin/account/rschr=stats\" target=\"_blank\"><img src=\"http://cgi.boingdragon.com/count/rschr/1.gif\" border=\"0\" width=\"114\" height=\"35\" title=\"Dragon-Counter\" alt=\"Dragon-Counterer\"><\/a>");
        break;
      case "1&1+Hoppe":
        document.write("<a href=\"http://login.1und1.de/\" target=\"_blank\"><img src=\"http://rschr.de/Bilder/Dragon.gif\" border=\"0\" width=\"114\" height=\"35\" title=\"Dragon\" alt=\"Dragon\"><\/a>");
        document.write("<a href=\"http://login.1und1.de/\" target=\"_blank\"><img src=\"http://rschr.de/tinc?key=p5rywepE\" border=\"0\" width=\"48\" height=\"16\" title=\"1&amp;1-Z&auml;hler\" alt=\"1&amp;1-Z&auml;hler\"><\/a>");
        document.write("&nbsp;");
        document.write("<a href=\"http://www.andyhoppe.com/\" target=\"_blank\"><img src=\"http://www.andyhoppe.com/count/?id=1236605075\" border=\"0\" width=\"80\" height=\"31\" style=\"border:none\" title=\"Hoppe-Z&auml;hler\" alt=\"Hoppe-Z&auml;hler\"><\/a>");
        break;
      case "all":
        document.write("<a href=\"http://boingdragon.com/cgi-bin/account/rschr=stats\" target=\"_blank\"><img src=\"http://cgi.boingdragon.com/count/rschr/1.gif\" border=\"0\" width=\"114\" height=\"35\" title=\"Dragon-Counter\" alt=\"Dragon-Counter\"><\/a>");
        document.write("&nbsp;");
        document.write("<a href=\"http://login.1und1.de/\" target=\"_blank\"><img src=\"http://rschr.de/tinc?key=p5rywepE\" border=\"0\" width=\"48\" height=\"16\" title=\"1&amp;1-Z&auml;hler\" alt=\"1&amp;1-Z&auml;hler\"><\/a>");
        document.write("&nbsp;");
        document.write("<a href=\"http://www.andyhoppe.com/\" target=\"_blank\"><img src=\"http://www.andyhoppe.com/count/?id=1236605075\" border=\"0\" width=\"80\" height=\"31\" style=\"border:none\" title=\"Hoppe-Z&auml;hler\" alt=\"Hoppe-Z&auml;hler\"><\/a>");
        break;
    }
    document.write("&nbsp;&nbsp;&nbsp;");
    document.write("<a href=\"http://validator.w3.org/check?uri=referer\" target=\"_blank\"><img src=\"http://rschr.de/Bilder/valid-html401.gif\" title=\"Valid HTML 4.01!\" alt=\"Valid HTML 4.01!\" height=\"31\" width=\"88\" border=\"0\"><\/a>");
    document.write("&nbsp;&nbsp;&nbsp;");
    document.write("<a href=\"http://jigsaw.w3.org/css-validator/check/referer\" target=\"_blank\"><img src=\"http://rschr.de/Bilder/vcss.gif\" title=\"Valid CSS!\" alt=\"Valid CSS!\" height=\"31\" width=\"88\" border=\"0\"></a>");
    document.write("&nbsp;&nbsp;&nbsp;");
    document.write("<a href=\"http://tool.motoricerca.info/robots-checker.phtml?checkreferer=1\" target=\"_blank\"><img src=\"http://rschr.de/Bilder/valid-robots.png\" title=\"ValidRobots\" alt=\"ValidRobots\" width=\"88\" height=\"31\" border=\"0\"></a>");
    document.write("&nbsp;&nbsp;&nbsp;");
    document.write("<a href=\"http://geourl.org/near?p=http://rschr.de/\" target=\"_blank\"><img src=\"http://rschr.de/Bilder/geourl.png\" title=\"GeoURL\" alt=\"GeoURL\" width=\"52\" height=\"14\" border=\"0\"></a>");
}