/*  JS for weserperlen.de */

function changeContent(newContent, newPicture) {
	if (document.getElementById("changeWindow"))
	{
		if(document.getElementById("changePicture").getAttribute("src") == newPicture) return;
	//	var content = document.createTextNode(newContent);
	//	document.getElementById("changeText").replaceChild('', document.getElementById("changeText").firstChild);
		document.getElementById("changeText").innerHTML = newContent;
		document.getElementById("changePicture").setAttribute("src", "misc/laden.gif");
		window.setTimeout("document.getElementById(\"changePicture\").setAttribute(\"src\", '" + newPicture + "')", 1);
	}
}

function changeContent2(newContent, newPicture, newID) {
	if(document.getElementById("selectImg").getAttribute("src") == newPicture) return;
	var content = document.createTextNode(newContent);
	document.getElementById("selectTxt").replaceChild(content, document.getElementById("selectTxt").firstChild);
//	document.getElementById("changeText").innerHTML = newContent;
	document.getElementById("selectImg").setAttribute("src", newPicture);
//	window.setTimeout("document.getElementById(\"changePicture\").setAttribute(\"src\", '" + newPicture + "')", 1);
	document.getElementById("changeID").setAttribute("value", newID);
}

function changePreview() {
	var pict;
	var selected = document.getElementById("changer").selectedIndex;
	if(document.getElementById("changer").options[selected].value != "")
		pict = document.getElementById("changer").options[selected].value;
	else
		pict = firstPict;
	document.getElementById("selectImg").setAttribute("src", "./misc/img/" + pict);
}

function deleteEntry() {
	if(confirm("Soll der Eintrag wirklich gel&ouml;scht werden?")) {
		document.getElementById("delete").setAttribute("value", "1");
		document.forms[0].submit();
	}
}
function checkEntries() {
	if (document.getElementById("checkbox").checked) {
		if (document.getElementById("upload").value == "") {
			if (!confirm("Achtung! Es wurde kein neues Bild hochgeladen! Sicher, dass ein *neuer Eintrag* erstellt werden soll?")) {
				return;
			}
		}
	}
	document.forms[0].submit();
}

// This script hereby is dedicated in the Public Domain
// as long as nobody else claims the copyright for it.
// origin: 2000-01-08 nospam@geht.net http://tools.geht.net/rot13.html
// Use at own risk.
var last="";
var rot13map;

// The problem is that JavaScript 1.0
// does not provide a Char to Numeric value conversion
// Thus we define a map.
// Because there are 64K UniCode characters, this map does not cover all characters.
function rot13init()
{
  var map = new Array();
  var s   = "abcdefghijklmnopqrstuvwxyz";
  
  for (i=0; i<s.length; i++)
    map[s.charAt(i)]			= s.charAt((i+13)%26);
  for (i=0; i<s.length; i++)
    map[s.charAt(i).toUpperCase()]	= s.charAt((i+13)%26).toUpperCase();
  return map;
}

function rot13(a)
{
  if (!rot13map)
    rot13map=rot13init();
  s = "";
  for (i=0; i<a.length; i++)
    {
      var b = a.charAt(i);

      s	+= (b>='A' && b<='Z' || b>='a' && b<='z' ? rot13map[b] : b);
    }
  document.contact.action = 'mailto:' + s;
  document.contact.submit();
//  return alert(s);
}
