
function createCookie(fav_name,fav_value,fav_days){
	if (fav_days){
		var fav_date = new Date();
		fav_date.setTime(fav_date.getTime()+(fav_days*24*60*60*1000));
		var fav_expires = "; expires="+fav_date.toGMTString();
	}
	else var fav_expires = "";
	document.cookie = fav_name+"="+fav_value+"; "+fav_expires+";path=/";
}


function readCookie(fav_name){
	var nameEQ = fav_name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(fav_name){
	var Antwort = confirm("Wollen Sie wirklich alle Favoriten loeschen?");
	if(Antwort === true){
		createCookie(fav_name,"",-1);
		location.reload();
	}
}

function showcookie(){
	alert(document.cookie);
}



function Favorit(fav_url,fav_titel,fav_bemerkung){



	var schondrin = "0";


	if (readCookie('Favoriten') && fav_bemerkung !== null){		//Existiert das Cookie schon?
		var inhalt = readCookie('Favoriten').split('|');
		for (var i=0; i<inhalt.length; i++){
			var tmp = inhalt[i].split('+');
			var alte_fav_url = tmp[0];

			//Ueberpruefen, ob diese URL schon bei den Favoriten drin ist
			if (alte_fav_url == fav_url){
				schondrin = 1;
				alert("Diese Seite befindet sich schon bei Ihren Favoriten");
			}
		}
	}
	else var inhalt="";
	//Datum erstellen:
	var datum = new Date();
	var tag = datum.getDate();
	var monat = datum.getMonth() + 1;
	var jahr = datum.getFullYear();
	var fav_datum = tag+"."+monat+"."+jahr;

	if(!fav_bemerkung && schondrin != 1){
		var fav_bemerkung = prompt("Geben Sie Ihre Beschreibung fuer diese Seite ein", "");
	}

	//Neue Seite hinzufuegen:
	if (schondrin != 1 && fav_bemerkung !== null){
		var inhalt_neu = "";
		for (var i=0; i<inhalt.length; i++){
			if (inhalt[i] != ""){
				inhalt_neu += ""+inhalt[i]+"|";
			}
		}
	inhalt_neu += fav_url+"+"+fav_titel+"+"+fav_bemerkung+"+"+fav_datum;

		createCookie('Favoriten',inhalt_neu,'30');
		alert("Die Seite wurde gespeichert");
	}
}




function FavoritenHinzu(beschreibung){
var fav_titel = document.getElementsByTagName("title").item
(0).innerHTML;

// Leerzeichen am Anfang und am Ende des Titels entfernen
var fav_titel = fav_titel.replace(/\s+/,"");
var fav_titel = fav_titel.replace(/\s+$/,"");


fav_titel = fav_titel.replace(/\|/g,"-");
fav_titel = fav_titel.replace(/\+/g,"&");
if(!beschreibung){
         var fav_beschreibung = document.getElementById
("FavBemerkung").value;
         if (fav_beschreibung == "") fav_beschreibung = " ";
}
else{
         var fav_beschreibung = beschreibung;
}

fav_beschreibung = fav_beschreibung.replace(/\|/g,"-");
fav_beschreibung = fav_beschreibung.replace(/\+/g,"&");

fav_url = document.location.href;
fav_url = fav_url.replace(/\+/g,"%20");

if(beschreibung != 0){
         Favorit(fav_url,fav_titel,fav_beschreibung);
}
else{
         Favorit(fav_url,fav_titel);
}
}

function popup(adresse,breite,hoehe){
info2=window.open(adresse,"info3","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+breite+",height="+hoehe)
info2.focus();}

function fensterauf(adresse,breite,hoehe){
info=window.open(adresse,"info2","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+breite+",height="+hoehe)
info.focus();}


function redirect(location) {
        document.location.href=location+'.html';
}
function Go (select) {
  var wert = select.options[select.options.selectedIndex].value;
  if (wert == "leer") {
    select.form.reset();
    parent.frames["unten"].focus();
    return;
  } else {
    if (wert == "ende") {
      top.location.href = parent.frames[1].location.href;
    } else {
      document.location.href = wert;
      select.form.reset();
      parent.frames["unten"].focus();
    }
  }
}

// schaltet onfocus aus
function BlurLinks(){

// Text- u. Grafik-Links
lnks=document.getElementsByTagName('a');
for(i=0;i<lnks.length;i++){
lnks[i].onfocus=new Function("this.blur()");
}

// ImageMaps -optional-
lnks=document.getElementsByTagName('area');
for(i=0;i<lnks.length;i++){
lnks[i].onfocus=new Function("this.blur()");
}

// Klick-Buttons -optional-
lnks=document.getElementsByName('Verweis');
for(i=0;i<lnks.length;i++){
lnks[i].onfocus=new Function("this.blur()");
}

// Formular-Buttons -optional-
lnks=document.getElementsByName('form');
for(i=0;i<lnks.length;i++){
lnks[i].onfocus=new Function("this.blur()");
}
}

window.onload=BlurLinks;


//f?r Presse-Seite
var fehler = 0;

function chkFormular()
{

 if(document.Formular.pp2pr_user.value == "")  {
   alert("Bitte Ihren Usernamen eingeben!");
   document.Formular.vorname.focus();
   fehler = 1; return false;
  }
 if(document.Formular.pp2pr_pass.value == "")  {
   alert("Bitte Ihr Passwort eingeben!");
   document.Formular.nachname.focus();
   fehler = 1; return false;
  }
  if (fehler != 1){
	  if(window.open("","submitwindow","width=300,height=100")){
	   return true;
	  	}
  }
}

//f?r Newsletter

function clearForm() {

document.mailform.FIRSTNAME.value = "";
document.mailform.LASTNAME.value = "";
document.mailform.EMAIL.value = "";
}

function uebergabeHolen() {
  uebergabe = location.search;
  uebergabe = uebergabe.substring(1);
  document.forms[0].EMAIL.value = unescape(uebergabe);
}
function check() {

if (document.mailform.EMAIL.value.length<8 ||
    document.mailform.EMAIL.value.indexOf(".")==-1 ||
    document.mailform.EMAIL.value.indexOf("@")==-1 ||
    document.mailform.EMAIL.value.lastIndexOf(".")>document.mailform.EMAIL.value.length-3 ||
    document.mailform.EMAIL.value.indexOf("@")>document.mailform.EMAIL.value.length-6)
        {window.alert("Bitte geben Sie eine g\374ltige E-Mail-Adresse ein!");
        document.mailform.EMAIL.focus();
    document.mailform.EMAIL.select();
    return false;}


window.open("about:blank","Infofenster","scrollbars=no,height=500,width=590,left=50,top=100,");
return true;}


function abmeldung() {
window.open("about:blank","Infofenster","scrollbars=no,height=500,width=590,left=50,top=100,");
return true;}


function pbPopup(popupURL,popupWIDTH,popupHEIGHT,popupSCROLL,popupRESIZE) {

	if (popupSCROLL == null)
		var	popupSCROLL = 'no';

	if (popupWIDTH == null)
		var	popupWIDTH = '800';

	if (popupHEIGHT == null)
		var	popupHEIGHT = '600';

	if (popupSCROLL == null)
		var	popupSCROLL = 'no';

	if (popupRESIZE == null)
		var	popupRESIZE = false;

	var random = (Math.round(Math.random()*1000));
	var popupNAME = "pbpopup" + random;

	var popup = window.open(popupURL,popupNAME,"toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars="+popupSCROLL+",width="+popupWIDTH+",height="+popupHEIGHT);
	popup.focus();

	if(popupRESIZE == true) {
		popup.moveTo(0,0);
		popup.resizeTo(screen.availWidth,screen.availHeight);
	}
}


// fuer footer:
function load_content(url){
	if(aktiv == url){
	aktiv = "";
	document.getElementById("ajaxcontent").style.display="none";
}
else{
	aktiv = url;
	get_content(url);
}

}

function get_content(url) {
	document.getElementById("ajaxcontent").innerHTML = '<div style="text-align: center;"><img src="/files/html/imgpool/loading.gif" width="32" height="32" /></div>';
	document.getElementById("ajaxcontent").style.display="block";
	window.scrollBy(0, 160);

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
            return false;
        }
        http_request.onreadystatechange = alertInhalt;
        http_request.open('GET', url, true);
        http_request.send(null);
}



function alertInhalt() {

	if (http_request.readyState == 4) {
	    if (http_request.status == 200) {
		    // in Seite einfuegen
		    document.getElementById("ajaxcontent").innerHTML = http_request.responseText;


	} else {
                alert('Es trat ein Problem auf.');

            }
        }

    }

function check_s2f(){	// send2frien formular
	var ok = true;
	if(document.getElementById('s2f_AbsName').value == "") ok = false;
	if(document.getElementById('s2f_AbsEMail').value == "") ok = false;
	if(document.getElementById('s2f_EmpfName').value == "") ok = false;
	if(document.getElementById('s2f_EmpfEMail').value == "") ok = false;
	if(document.getElementById('s2f_EmpfEMail').value.indexOf('@') < 1) ok = false;
	if(document.getElementById('s2f_AbsEMail').value.indexOf('@') < 1) ok = false;
	if(!ok) alert("Bitte alle Felder vollst\xE4ndig ausf\xFCllen");
	return ok;
}

function check_lb(){	// leserbrief formular
	var ok = true;
	if(document.getElementById('lb_Name').value == "") ok = false;
	if(document.getElementById('lb_EMail').value.indexOf('@') < 1) ok = false;
	if(document.getElementById('lb_Nachricht').value == "") ok = false;
	if(!ok) alert("Bitte alle Felder vollst\xE4ndig ausf\xFCllen");
	return ok;
}