// Copyright (C) 2008 Ursula Zehlius - Kosmopeia - Astrologie 
//
// Inanspruchnahme von Urheberrechtschutz unter Registernummer 624-080821-176404547 bei http://www.notatus.de
//
// Version 1.0 vom 02.05.2008
// Einbindecode:
// <table style='border-color:#f0b050;border-width:10px;border-style:ridge;font-size:11pt;color:#f0b050;' bgcolor='#461626' onclick='newwindow()'>
// <SCRIPT LANGUAGE="javascript" TYPE="text/javascript" SRC="http://www.kosmopeia.de/html/mondkalender_zmn.js">
// </SCRIPT>
// <NOSCRIPT>
// <a href="http://www.kosmopeia.de/html/mondkalender.html">zum Mondkalender hier klicken</a> 
// </NOSCRIPT>
// </table>
function atn2 (y, x) {
  a = Math.atan(y / x);
  if (x < 0) a = a + Math.PI;
  if ((y < 0) && (x > 0))	a = a + 2*Math.PI;
  return a;
}
function range (x) {
  return  x - Math.floor(x / (2*Math.PI)) * 2*Math.PI;
}
function GetDateFromJD(jd){
  a = Math.floor(jd+0.5);
  if (a < 2299161){
  	b=0;
  	c=a+1524;
  }
  else {
  	b=Math.floor((a-1867216.25)/36524.25);
  	c=a+b-Math.floor(b/4)+1525.0;
  }
  d=Math.floor((c-122.1)/365.25);
  e=Math.floor(365.25*d);
  f=Math.floor((c-e)/30.6001);
  t=c-e-Math.floor(30.6001*f);
  m=f-1.0-12.0*Math.floor(f/14.0);
  j=d-4715.0-Math.floor((7.0+m)/10.0);
  tt = jd-Math.floor(jd)-0.5;
  if (tt < 0)tt++;
  s = tt * 86400.0;
  h = Math.floor(s / 3600);
  min = Math.floor(s / 60)-h*60;
  s -= min * 60.0 + h * 3600.0;
  return Date.UTC(j, m-1, t, h, min, s, 0);
}
function GetJulianDay(j, m, t, h, min, s){
  tt = h/24.0+min/1440.0+s/86400.0;
  if (m<3){j--;m+=12;}
  b= Math.floor(j/400.0)-Math.floor(j/100.0);
  return Math.floor(365.25*j)+Math.floor(30.6001*(m+1))+b+1720996.5+t+tt;
}
function GetDMS(x){
  sign = sgn(x);
  x = Math.abs(x);
  d = Math.floor(x);
  m = (x - d);
  s = m * 60;
  m = Math.floor(s);
  s = s - m;
  return (d*sign)+"&deg; "+m+"' "+Math.floor(s * 60)+"\"";
}
function sgn(x){
  return(x<0)?-1:((x>0)?1:0);
}
function CalcMond2R(jd) {
  d = jd-2451543.5;
  Nm = range((125.1228 - .0529538083 * d) * Math.PI/180.0);
  im = 5.1454 * Math.PI/180.0;
  wm = range((318.0634 + .1643573223 * d) * Math.PI/180.0);
  am = 60.2666;
  ecm = .0549;
  Mm = range((115.3654 + 13.0649929509 * d) * Math.PI/180.0);
  Ms = range((356.047 + .9856002585 * d) * Math.PI/180.0);
  ws = range((282.9404 + 4.70935E-05 * d) * Math.PI/180.0);
  Em = Mm + ecm * Math.sin(Mm) * (1 + ecm * Math.cos(Mm));
  e1 = Em-(Em-ecm*Math.sin(Em)-Mm)/(1-ecm*Math.cos(Em));
  Em = e1;
  xv = am * (Math.cos(Em) - ecm);
  yv = am * (Math.sqrt(1 - ecm * ecm) * Math.sin(Em));
  vm = atn2(yv, xv);
  rm = Math.sqrt(xv * xv + yv * yv);
  xh = rm * (Math.cos(Nm) * Math.cos(vm + wm) - Math.sin(Nm) * Math.sin(vm + wm) * Math.cos(im));
  yh = rm * (Math.sin(Nm) * Math.cos(vm + wm) + Math.cos(Nm) * Math.sin(vm + wm) * Math.cos(im));
  zh = rm * (Math.sin(vm + wm) * Math.sin(im));
  lon = atn2(yh, xh);
  lat = atn2(zh, Math.sqrt(xh * xh + yh * yh));
  Ls = Ms + ws;
  Lm = Mm + wm + Nm;
  dm = Lm - Ls;
  F = Lm - Nm;
  dlon = -1.274 * Math.sin(Mm - 2 * dm);
  dlon += .658 * Math.sin(2 * dm);
  dlon -= .186 * Math.sin(Ms);
  dlon -= .059 * Math.sin(2 * Mm - 2 * dm);
  dlon -= .057 * Math.sin(Mm - 2 * dm + Ms);
  dlon += .053 * Math.sin(Mm + 2 * dm);
  dlon += .046 * Math.sin(2 * dm - Ms);
  dlon += .041 * Math.sin(Mm - Ms);
  dlon -= .035 * Math.sin(dm);
  dlon -= .031 * Math.sin(Mm + Ms);
  dlon -= .015 * Math.sin(2 * F - 2 * dm);
  dlon += .011 * Math.sin(Mm - 4 * dm);
  return range(dlon * Math.PI/180 + lon);
}
function GibZeichen() {
  var sz=new Array(12);
  sz[0]="Widder"; sz[1]="Stier"; sz[2]="Zwilling"; sz[3]="Krebs"; sz[4]="L&ouml;we"; sz[5]="Jungfrau";
  sz[6]="Waage"; sz[7]="Skorpion"; sz[8]="Sch&uuml;tze"; sz[9]="Steinbock"; sz[10]="Wassermann"; sz[11]="Fische";
  var jetzt = new Date();
  var t = jetzt.getUTCDate();
  var m = jetzt.getUTCMonth() + 1;
  var j = jetzt.getUTCFullYear();
  var s = jetzt.getUTCHours();
  var min = jetzt.getUTCMinutes();
  var sec = jetzt.getUTCSeconds();
  var jd = GetJulianDay(j, m, t, s, min, sec);
  var lon = CalcMond2R(jd);
  var dms = GetDMS(lon*180/Math.PI-Math.floor((lon*180/Math.PI)/30)*30);
  return sz[Math.floor((lon*180/Math.PI)/30)]+" "+dms;
}
function newwindow()
{
}

var jetzt = new Date();
document.write("<th><center>Aktueller Mondkalender</center></th>");
document.write("<tr><td>");
document.write("<center>"+jetzt.toLocaleString()+"<br>Der Mond steht jetzt im Zeichen:<br>>>> <font color=#ffffff>"+GibZeichen()+"</font> <<<");
document.write("<br><a style='color:#f0b050; font-size:10px;' href='http://www.kosmopeia.de/html/mondkalender.html' target='_blank'>mehr zum Mondkalender</a></center>");
document.write("</td></tr>");

