//Javascript
//setzt die links
//erzeugt ein pop up
function popup(name,einstellungen) {
         window.open('',name,einstellungen);
}
//&ouml;ffnet ein popup bei neuen nachrichten
function popup_newpn() {
    var breite=260;
    var hoehe=140;
    var positionX=((screen.availWidth / 2) - breite / 2);
    var positionY=((screen.availHeight / 2) - hoehe / 2);
    var url='inhalte/popup_new_pn.php';
    pop=window.open('','popup_newpn','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=0,left=0');
    pop.resizeTo(breite,hoehe);
    pop.moveTo(positionX,positionY);
    pop.location=url;
}
//&ouml;ffnet ein popup fuer den kalendereintrag der user
function popup_kalender_hinzufuegen() {
    var breite=300;
    var hoehe=200;
    var positionX=((screen.availWidth / 2) - breite / 2);
    var positionY=((screen.availHeight / 2) - hoehe / 2);
    var url='inhalte/new_kalendereintrag.php';
    pop=window.open('','','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=0,left=0');
    pop.resizeTo(breite,hoehe);
    pop.moveTo(positionX,positionY);
    pop.location=url;
}
//&ouml;ffnet ein popup bei f&uuml;r den chat
function popup_chat() {
    var breite=640;
    var hoehe=500;
    var positionX=((screen.availWidth / 2) - breite / 2);
    var positionY=((screen.availHeight / 2) - hoehe / 2);
    var url='chat/index.php';
    pop=window.open('','chat','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=0,left=0');
    pop.resizeTo(breite,hoehe);
    pop.moveTo(positionX,positionY);
    pop.location=url;
}
function prfNumber(MyElement,MyDocument) {
    if(isNaN(MyElement)) {
        alert("Bitte trage hier nur Zahlen ein!");
        document.getElementById(MyDocument).value = "18";
    }
}
function check(checkbox, senden) {
         if(checkbox.checked==true){
             senden.disabled = false;
         }
         else {
              senden.disabled = true;
         }
}
// prüft Textarea auf Inhalt und gibt Checkbox frei
function check_textarea(textarea, checkbox) {

         if(textarea.value!=false){
             checkbox.disabled = false;
         }
         else {
              checkbox.disabled = true;
         }
}

//&ouml;ffnet ein popup f&uuml;r die agb
function popup_agb() {
    var breite=640;
    var hoehe=500;
    var positionX=((screen.availWidth / 2) - breite / 2);
    var positionY=((screen.availHeight / 2) - hoehe / 2);
    var url='inhalte/agb_popup.php';
    pop=window.open('','chat','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=0,left=0');
    pop.resizeTo(breite,hoehe);
    pop.moveTo(positionX,positionY);
    pop.location=url;
}
//&auml;ndert den cursor &uuml;ber ein bils
function image_itsme(type) {
    //document.getElementById("image_form").onSubmit = "return true";
    //alert(document.getElementById("image_form").onSubmit);
    //alert(document.forms['image_form']['image_cords_activated'].value);
    if(document.forms['image_form']['image_cords_activated'].value == '0') {
        document.forms['image_form']['image_cords_activated'].value = ''+type;
        document.getElementById('image_cords').style.cursor = 'crosshair';
        //document.forms['image_form']['image_cords_activated'].value == '1'
        document.forms['image_form'].action = 'index.php';
    } else  {
        document.forms['image_form']['image_cords_activated'].value = '0';
        document.getElementById('image_cords').style.cursor = 'hand';
        document.forms['image_form'].action = image_form_url_save;
    }
}
//ThatsMe ein/ausblenden
var marks_display_status = true;

function marks_display() {
    if(marks_display_status == true) {
        marks_display_status = false;
        var i=1;
        while(true)  {
            var el = document.getElementById('thatsme_label_'+i);
            if(el) el.style.display = 'none';
            else break;
            ++i;
        }
        var i=1;
        while(true)  {
            var el = document.getElementById('iwantyou_label_'+i);
            if(el) el.style.display = 'none';
            else break;
            ++i;
        }
    } else {
        marks_display_status = true;
        var i=1;
        while(true)  {
            var el = document.getElementById('thatsme_label_'+i);
            if(el) el.style.display = 'block';
            else break;
            ++i;
        }
        var i=1;
        while(true)  {
            var el = document.getElementById('iwantyou_label_'+i);
            if(el) el.style.display = 'block';
            else break;
            ++i;
        }
    }
}

// disabled die felder im warenkorb
function disable(checked) {
    var ges_fotos = document.getElementById("ges_fotos").value;
     if(document.getElementById("herunterladen").checked==true){
         for (var i=0;i < ges_fotos;i++) {
            //document.getElementById("anzahl_" + i).disabled = true;
            //document.getElementById("groesse_" + i).disabled = true;
            document.getElementById("preis_" + i).value = "0.59";
         }
         document.getElementById("ges_anzahl").value = ges_fotos;
         document.getElementById("ges_preis").value = ges_fotos * 0.59;
         document.getElementById("versand").value = "0";
         document.getElementById("ges_preis_versand").value = ges_fotos * 0.59;
         document.getElementById("aendern").disabled = true;
     }
     else {
         for (var i=0;i < ges_fotos;i++) {
            //document.getElementById("anzahl_" + i).disabled = false;
            //document.getElementById("groesse_" + i).disabled = false;
            document.getElementById("preis_" + i).value = document.getElementById("preis_h_" + i).value;
         }
         document.getElementById("ges_anzahl").value = document.getElementById("ges_anzahl_h").value;
         document.getElementById("ges_preis").value = document.getElementById("ges_preis_h").value;
         document.getElementById("versand").value = document.getElementById("versand_h").value;
         document.getElementById("ges_preis_versand").value = document.getElementById("ges_preis_versand_h").value;
         document.getElementById("aendern").disabled = false;
     }
}
//&ouml;ffnet ein messenger popup f&uuml;r den ajaxchat
function popup_messenger(MyHash) {
    var breite=240;
    var hoehe=600;
    var positionX=(screen.availWidth - breite);
    var positionY=0;
    var url="http://h1313646.stratoserver.net/messenger/messenger.php?n=" + MyHash;
    pop=window.open('','messenger','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=0,left=0');
    pop.resizeTo(breite,hoehe);
    pop.moveTo(positionX,positionY);
    pop.location=url;
}
//&ouml;ffnet ein popup f&uuml;r den ajaxchat
function popup_ajaxchat(MyName) {
    var breite=480;
    var hoehe=390;
    var positionX=((screen.availWidth / 2) - breite / 2);
    var positionY=((screen.availHeight / 2) - hoehe / 2);
    var url="http://h1313646.stratoserver.net/popup_chat.php?an_name=" + MyName;
    pop=window.open('',MyName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=0,left=0');
    pop.resizeTo(breite,hoehe);
    pop.moveTo(positionX,positionY);
    pop.location=url;
}
// speichert klicks etc zu einem foto
function saveData_Pics(MyFotoId) {
    // globale Instanz von XMLHttpRequest
    var xmlHttp = false;
    
    // XMLHttpRequest-Instanz erstellen
    // ... f&uuml;r Internet Explorer
    try {
        xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
        try {
            xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
        } catch(e) {
            xmlHttp  = false;
        }
    }
    // ... f&uuml;r Mozilla, Opera und Safari
    if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
        xmlHttp = new XMLHttpRequest();
    }
    if (xmlHttp) {
        xmlHttp.open('POST', 'config/setdata_pics.php');
        xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xmlHttp.send('foto_id=' + MyFotoId);
    }
}




// These variables are for saving the original background colors
var savedStates=new Array();
var savedStateCount=0;

/////////////////////////////////////////////////////
// This function takes an element as a parameter and
//   returns an object which contain the saved state
//   of the element's background color.
/////////////////////////////////////////////////////
function saveBackgroundStyle(myElement)
{
  saved=new Object();
  saved.element=myElement;
  saved.className=myElement.className;
  saved.backgroundColor=myElement.style["backgroundColor"];
  return saved;
}

/////////////////////////////////////////////////////
// This function takes an element as a parameter and
//   returns an object which contain the saved state
//   of the element's background color.
/////////////////////////////////////////////////////
function restoreBackgroundStyle(savedState)
{
  savedState.element.style["backgroundColor"]=savedState.backgroundColor;
  if (savedState.className)
  {
    savedState.element.className=savedState.className;
  }
}

/////////////////////////////////////////////////////
// This function is used by highlightTableRow() to find table cells (TD) node
/////////////////////////////////////////////////////
function findNode(startingNode, tagName)
{
  // on Firefox, the TD node might not be the firstChild node of the TR node
  myElement=startingNode;
  var i=0;
  while (myElement && (!myElement.tagName || (myElement.tagName && myElement.tagName!=tagName)))
  {
    myElement=startingNode.childNodes[i];
    i++;
  }
  if (myElement && myElement.tagName && myElement.tagName==tagName)
  {
    return myElement;
  }
  // on IE, the TD node might be the firstChild node of the TR node
  else if (startingNode.firstChild)
    return findNode(startingNode.firstChild, tagName);
  return 0;
}

/////////////////////////////////////////////////////
// Highlight table row.
// newElement could be any element nested inside the table
// highlightColor is the color of the highlight
/////////////////////////////////////////////////////
function highlightTableRow(myElement, highlightColor)
{
  var i=0;
  // Restore color of the previously highlighted row
  for (i; i<savedStateCount; i++)
  {
    restoreBackgroundStyle(savedStates[i]);
  }
  savedStateCount=0;

  // To get the node to the row (ie: the <TR> element),
  // we need to traverse the parent nodes until we get a row element (TR)
  // Netscape has a weird node (if the mouse is over a text object, then there's no tagName
  while (myElement && ((myElement.tagName && myElement.tagName!="TR") || !myElement.tagName))
  {
    myElement=myElement.parentNode;
  }

  // If you don't want a particular row to be highlighted, set it's id to "header"
  // If you don't want a particular row to be highlighted, set it's id to "header"
  if (!myElement || (myElement && myElement.id && myElement.id=="header") )
    return;

  // Highlight every cell on the row
  if (myElement)
  {
    var tableRow=myElement;

    // Save the backgroundColor style OR the style class of the row (if defined)
    if (tableRow)
    {
      savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
      savedStateCount++;
    }

    // myElement is a <TR>, then find the first TD
    var tableCell=findNode(myElement, "TD");

    var i=0;
    // Loop through every sibling (a sibling of a cell should be a cell)
    // We then highlight every siblings
    while (tableCell)
    {
      // Make sure it's actually a cell (a TD)
      if (tableCell.tagName=="TD")
      {
        // If no style has been assigned, assign it, otherwise Netscape will
        // behave weird.
        if (!tableCell.style)
        {
          tableCell.style={};
        }
        else
        {
          savedStates[savedStateCount]=saveBackgroundStyle(tableCell);
          savedStateCount++;
        }
        // Assign the highlight color
        tableCell.style["backgroundColor"]=highlightColor;

        // Optional: alter cursor
        tableCell.style.cursor='default';
        i++;
      }
      // Go to the next cell in the row
      tableCell=tableCell.nextSibling;
    }
  }
}

/////////////////////////////////////////////////////
// This function is to be assigned to a <table> mouse event handler.
// If the element that fired the event is within a table row,
//   this function will highlight the row.
/////////////////////////////////////////////////////
function trackTableHighlight(mEvent, highlightColor)
{
  if (!mEvent)
    mEvent=window.event;

  // Internet Explorer
  if (mEvent.srcElement)
  {
    highlightTableRow( mEvent.srcElement, highlightColor);
  }
  // Netscape and Firefox
  else if (mEvent.target)
  {
    highlightTableRow( mEvent.target, highlightColor);
  }
}

/////////////////////////////////////////////////////
// Highlight table row.
// newElement could be any element nested inside the table
// highlightColor is the color of the highlight
/////////////////////////////////////////////////////
function highlightTableRowVersionA(myElement, highlightColor)
{
  var i=0;
  // Restore color of the previously highlighted row
  for (i; i<savedStateCount; i++)
  {
    restoreBackgroundStyle(savedStates[i]);
  }
  savedStateCount=0;

  // If you don't want a particular row to be highlighted, set it's id to "header"
  if (!myElement || (myElement && myElement.id && myElement.id=="header") )
    return;

  // Highlight every cell on the row
  if (myElement)
  {
    var tableRow=myElement;

    // Save the backgroundColor style OR the style class of the row (if defined)
    if (tableRow)
    {
      savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
      savedStateCount++;
    }

    // myElement is a <TR>, then find the first TD
    var tableCell=findNode(myElement, "TD");

    var i=0;
    // Loop through every sibling (a sibling of a cell should be a cell)
    // We then highlight every siblings
    while (tableCell)
    {
      // Make sure it's actually a cell (a TD)
      if (tableCell.tagName=="TD")
      {
        // If no style has been assigned, assign it, otherwise Netscape will
        // behave weird.
        if (!tableCell.style)
        {
          tableCell.style={};
        }
        else
        {
          savedStates[savedStateCount]=saveBackgroundStyle(tableCell);
          savedStateCount++;
        }
        // Assign the highlight color
        tableCell.style["backgroundColor"]=highlightColor;

        // Optional: alter cursor
        tableCell.style.cursor='default';
        i++;
      }
      // Go to the next cell in the row
      tableCell=tableCell.nextSibling;
    }
  }
}
function browser() {
    var navName = navigator.appName;
    var brVer = navigator.userAgent; var brNum; var reg = new RegExp('/');
    function verNumIE() {
       var brVerId = brVer.indexOf('MSIE');
       brNum = brVer.substr(brVerId,8);
    }
    function verNumOt() {
       var brVerId = brVer.search(reg);
       brNum = brVer.substring(brVerId+1);
    }
    if (navigator.appName == 'Microsoft Internet Explorer') {
      verNumIE() ;
    }
    else if (navigator.appName == 'Opera') {
      return 5;
    } else {
      verNumOt() ;
    }
    return brNum.substring(5,6);
}