// Notizkalender - javascript.js


// Jahreskalender - Feiertage markieren
function feiertage() {
 tag = new Array();
 monat = new Array();
 tag[1] = "1"; monat[1] = "1"; // Neujahr
 tag[2] = "1"; monat[2] = "5"; // Maifeiertag
 tag[3] = "3"; monat[3] = "10"; // Tag der deu. Einheit
 tag[4] = "31"; monat[4] = "10"; // Halloween
 tag[5] = "25"; monat[5] = "12"; // Weihnachten
 tag[6] = "26"; monat[6] = "12"; // Weihnachten
 /* Hier weitere Feiertage/Geburtstage etc. einfügen! */

 for (zaehler = 1; zaehler < monat.length; zaehler++) {
  var id = "m" + monat[zaehler] + "t" + tag[zaehler];
  document.getElementById(id).style.border="solid 1px #CC0000";
  document.getElementById(id).style.fontWeight="bold";
 }
}


// Monatskalender - Aktuelles Datum markieren
function akt_datum_monatscal(jahr,monat) {
 heute = new Date();
 if (jahr == heute.getFullYear() && monat == (heute.getMonth()+1)) {
  var id = "m" + (heute.getMonth()+1) + "t" + heute.getDate();
  document.getElementById(id).style.backgroundColor="#DADADA";
  document.getElementById(id).style.fontWeight="bold";
 }
}


// Jahreskalender - Aktuelles Datum markieren
function akt_datum_jahrescal(datum) {
 heute = new Date();
 if (datum == heute.getFullYear()) {
  var id = "m" + (heute.getMonth()+1) + "t" + heute.getDate();
  document.getElementById(id).style.backgroundColor="#DADADA";
  document.getElementById(id).style.fontWeight="bold";
 }
}


// Notiz Vorschau
function vorschau() {
 var f = window.open("","f","scrollbars=1,width=680,height=370");
 f.document.writeln("<div style=\"white-space: Pre;\">"+document.Form.text.value+"<\/div>");
 f.document.close();
 f.document.focus();
}


// Kalender/Suche - Eingabe der Jahreszahl
function jahreszahl(seite) {
  heute = new Date();
 var datum = prompt("Jahreszahl eingeben:",heute.getFullYear());
 if (datum.length == 4) {
  window.location.href=seite+".php?das_jahr="+datum+"";
 }
}


// JavaScript-Sicherheitsabfrage bevor die Notiz gelöscht werden soll
function kontrolle(datum) {
 if (document.Form.option.options[3].selected == true) {
  var frage = confirm("Möchten Sie die Notiz vom "+datum+" wirklich löschen?"); // Umlaute nicht ersetzen!
  if (frage == true) {
   return true;
  } 
  else {
   return false;
  }
 } 
 else {
  return true;
 }
}


// Tastatur-Funktion
function taste(ein) {
 a = "";
 if (ein == "link") {
  a = ' <a href="http://www." target="_blank"></a>';
 }
 if (ein == "bild") {
  a = ' <img src="upload/">';
 }
 if (ein == "einteilung") {
  a = '\nUhr - Termin\n1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n';
 }
 if (ein == "ul") {
  a = ' <u></u>';
 }
 if (ein == "fett") {
  a = ' <b></b>';
 }
 if (ein == "kursiv") {
  a = ' <i></i>';
 }
 if (ein == "gestrichen") {
  a = ' <s></s>';
 }
 if (ein == "hr") {
  a = '\n<hr>\n';
 }
 if (ein == ":)") {
  a = ' :)';
 }
 if (ein == ":(") {
  a = ' :(';
 }
 if (ein == ";)") {
  a = ' ;)';
 }
 if (ein == ":D") {
  a = ' :D';
 }
 if (ein == ":o") {
  a = ' :o';
 }
 if (ein == ":x") {
  a = ' :x';
 }
document.Form.text.value = document.Form.text.value+a;
aenderung();
}


// Textfeldgröße ändern
function groesser() {
 if (document.getElementById("Kommentar").rows < 45){
  document.getElementById("Kommentar").rows += 5;
 }
}
function kleiner() {
 if (document.getElementById("Kommentar").rows > 10){
  document.getElementById("Kommentar").rows -= 5;
 }
}


// Textfeld leeren
function leeren() {
 document.Form.text.value = "";
 aenderung();
}


// Bei einer Änderung Button markieren
function aenderung() {
 if (document.Form.text.value.length != document.Form.laenge.value) {
  document.getElementById("speichern").style.backgroundColor = "#C9C9C9";
 }
else {
  document.getElementById("speichern").style.backgroundColor = "#E2E2E2";
 }
}


// Upload-Datei löschen
function del(url, datei) {
 if (confirm("Soll \"" + unescape(datei) + "\" wirklich gelöscht werden?") ) {
  window.location = url;
 }
}
