ie = document.all?1:0


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openWindow(theURL) {
  window.open(theURL,'zoom','scrollbars=no,width=500,height=540');
}


function chkFormular()
{
    if(document.formular.text.value == "")
    {
     alert("Bitte einen Text eingeben !");
     document.formular.text.focus();
     return false;
    }
}

function chkKAFormular()
{
    if(document.formular.rubrik.value == "0")
    {
     alert("Bitte Rubrik auswählen!");
     document.formular.rubrik.focus();
     return false;
    }

    if(document.formular.titel.value == "")
    {
     alert("Bitte einen Titel eingeben !");
     document.formular.titel.focus();
     return false;
    }

    if(document.formular.text.value == "")
    {
     alert("Bitte einen Text eingeben !");
     document.formular.text.focus();
     return false;
    }
}

// definition der farben
var textnormal     = "#0066CC";
var textaktiv      = "#FFFFFF";
var hinternormal   = "#d3d7c5";
var hinteraktiv    = "#FF9933";

// mouseover-effekt
function tabelle_drueber(quelle) {
        quelle.style.cursor = 'hand';
        quelle.bgColor = hinteraktiv;
        quelle.children.tags('A')[0].style.color = textaktiv;
}

// mouseout-effekt
function tabelle_raus(quelle) {
        quelle.style.cursor = 'hand';
        quelle.bgColor = hinternormal;
        quelle.children.tags('A')[0].style.color = textnormal;
}

// link-simulation
function tabelle_klick(quelle) {
        quelle.children.tags('A')[0].click();
}

function farbwechsel(quelle)
{
    if (quelle.checked)
        hL(quelle);
    else
        dL(quelle);
}

function hL(E)
{
    if (ie)
    {
        while (E.tagName!="TR")
        {
            E=E.parentElement;
        }
    }
    else
    {
        while (E.tagName!="TR")
        {
            E=E.parentNode;
        }
    }
    E.className = "auswahl";
}

function dL(E)
{
    if (ie)
    {
        while (E.tagName!="TR")
        {
            E=E.parentElement;
        }
    }
    else
    {
        while (E.tagName!="TR")
        {
            E=E.parentNode;
        }
    }
    E.className = "";
}

function alleauswaehlen ()
{
    var frm = document.harzflirt;
    for (var i=0;i<frm.elements.length;i++)
    {
        var e = frm.elements[i];
        if ((e.name != 'allbox') && (e.type=='checkbox'))
        {
            e.checked = frm.allbox.checked;
            if (frm.allbox.checked)
                hL(e);
            else
                dL(e);
        }
    }
}

function View(id)
{
	if (document.getElementById(id).style.display == "none")
		document.getElementById(id).style.display = "block";
	else
		document.getElementById(id).style.display = "none";
}

function dazu(id,value)
{
    Neu = new Option(value);
    document.data.wohnort.options[document.data.wohnort.length] = Neu;
    Neu.value = id;
}

function remove()
{
    while(document.data.wohnort.selectedIndex!=-1) {
        index = document.data.wohnort.selectedIndex;
        document.data.wohnort.options[index] = null;
    }
}

function createRequestObject()
{
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer")
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    else
        ro = new XMLHttpRequest();
    return ro;
}

var http = createRequestObject();

function sndReq(action)
{
    remove();
    http.open('get', 'plz.php?plz='+action);
    http.onreadystatechange = handleResponsePLZ;
    http.send(null);
}


function handleResponsePLZ()
{
    if(http.readyState == 4)
	{
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1))
            update = response.split('|');

		for(i=0;i<update.length-1;i++) {
			nun=update[i];
			detail = nun.split(';');
			dazu(detail[0],detail[1]);
		}
    }
}

function wohn(plz) {
    if (plz.length==5)
	{
	    document.data.wohnort.focus();
	    sndReq(plz);
    }
}
// Favoriten - Funktionen

var favid, favzeile, favstatus;

function eingabezeile_on(notiz)
{
	var input = '<input type="text" style="width:300px" maxlength="70" name="' + favzeile + '" value="' + notiz + '"><input type="image" src="navigation/speichern.gif" style="margin-left:10px" onClick="speichern(' + favid + ', \'' + favzeile + '\');"><a href="javascript:fav_notiz(' + favid + ', \'' + favzeile + '\', \'off\');"><image src="navigation/abbrechen.gif" style="margin-left:10px" border="0"></a>';
	if(!notiz)
		notiz = 'keine';
	if(favstatus == 'on')
		document.getElementById(favzeile).innerHTML = input;
	if(favstatus == 'off')
		document.getElementById(favzeile).innerHTML = notiz;
}

function fav_notiz(id, zeile, status)
{
	favid = id;
	favzeile = zeile;
	favstatus = status;
	var tan = 10000 * Math.round(Math.random());
    http.open('get', 'favoriten.notiz.php?aktion=r&id=' + id + '&tan=' + tan);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse()
{
    if(http.readyState == 4)
	{
        var response = http.responseText;
		if(response || favstatus)
			eingabezeile_on(response);
	}	
}

function speichern(id, zeile)
{
	var text = document.favoriten.elements[zeile].value;
    http.open('get', 'favoriten.notiz.php?aktion=w&id=' + id + '&notiz=' + text);
	favstatus = '';
	http.send(null);
	if(!text)
		text = 'keine';
	document.getElementById(zeile).innerHTML = text;
}

function fotobeschreibung(id)
{
	document.getElementById('fotobeschreibung').innerHTML = '';
	var tan = 10000 * Math.round(Math.random());
    http.open('get', 'profil.fotos.notiz.php?id=' + id + '&tan=' + tan);
    http.onreadystatechange = handleResponseFotos;
    http.send(null);
}

function handleResponseFotos()
{
    if(http.readyState == 4)
        var response = http.responseText;
	if(response)
		document.getElementById('fotobeschreibung').innerHTML = response;
}
