function getPostings($sType, $iNewerThan, $iPage, $sNickname, $bWithFriends, $bOnlyLast) {
  // Plappadu.log($sType +"|"+ $iNewerThan +"|"+ $iPage+"|"+ $sNickname+"|"+ $bWithFriends+"|"+$bOnlyLast);
  var $response = "";

  // clear autoload interval
  if (typeof $getNewPostings != "undefined") {
    clearInterval($getNewPostings);
    delete $getNewPostings;
  }

  if ($sType == "all") {
    if ($iNewerThan == null) {
      $response = ResourceLoader.getJsonObject('/json/ajax_getPostings.php?channelId='+Plappadu.Environment.Channel.oChannel.channelId);
      // set interval needs to be called with parameters
      $getNewPostings = setInterval("getPostings('all',Plappadu.Global.newestPosting,null,null,null,null)", Plappadu.Global.getNewPostingsInterval);
      return($response);

    } else if ($iNewerThan != null) {
      // Plappadu.log(Plappadu.Global.doRefresh);
      if (Plappadu.Global.doRefresh === true) {
        $response = ResourceLoader.getJsonObject('/json/ajax_getPostings.php?newerthan='+$iNewerThan+'&channelId='+Plappadu.Environment.Channel.oChannel.channelId);
        // set interval needs to be called with parameters
        $getNewPostings = setInterval("getPostings('all',Plappadu.Global.newestPosting,null,null,null,null)", Plappadu.Global.getNewPostingsInterval);
        insertNewPostings($response);
      } else if (Plappadu.Global.doRefresh === false) {
        // clear autoload interval
        if (typeof $getNewPostings != "undefined") {
          clearInterval($getNewPostings);
          delete $getNewPostings;
        }
      }
    }
  } else if ($sType == "mine") {
    if ($iNewerThan == null) {
      if ($bWithFriends == null || $bWithFriends == false) {
        // show top postings of me and my friends
        $response = ResourceLoader.getJsonObject('/json/ajax_getPrivatePostings.php');
        return($response);
      } else {
        // show my and my friend's postings
        $response = ResourceLoader.getJsonObject('/json/ajax_getPrivatePostingsArchive.php?page='+$iPage);
        return($response);
      }
    } else {

    }

  } else if ($sType == "alien") {
    if ($iNewerThan == null) {
      if ($iPage == null) {
        $iPage = 0;
      }
      if ($bWithFriends === true) {
        $response = ResourceLoader.getJsonObject('/json/ajax_getAlienPostingsWithFriends.php?nickname='+$sNickname+'&page='+$iPage);
      } else {
        $response = ResourceLoader.getJsonObject('/json/ajax_getAlienPostings.php?nickname='+$sNickname);
      }
      return($response);
    } else {

    }
  } else {
    return false;
  }
}

function createPostings($oPostings) {
  var $aPostingsDivs = document.getElementById("postings");
  if($aPostingsDivs != null) {
    $aPostingsDivs.className = "";
    cleanNode($aPostingsDivs);
    for (var $i = 0; $i < $oPostings.postings.length; $i++) {
      if($oPostings.postings[$i] != null) {
        var $aPosting = createPosting($oPostings.postings[$i]);
        $aPostingsDivs.appendChild($aPosting[0]);
        $aPosting[0].className = "postingElement";
        $aPosting[0].innerHTML = $aPosting[1];

      }
      // set Plappadu.Global.newestPosting
      if ($oPostings.postings[$i].created > Plappadu.Global.newestPosting) {
        Plappadu.Global.newestPosting = $oPostings.postings[$i].created;
      }
    }
  }
}

function createPosting($oPosting) {
  // Plappadu.log($oPosting);
  var $aReturn = new Array();
  var $div = document.createElement("div");
  var $html = '';
  $html     += '<div class="avatar"><a href="/' + $oPosting.nickname + '"><img src="' + $oPosting.avatarPath + '" onabort="this.src=\'' + $oPosting.avatarPath + '\';"/></a></div>';
  $html     += '<div class="dataBlock">';
  $html     += '  <div class="top">&nbsp;</div>';
  $html     += '  <div class="middle">';

  if ($oPosting.emotionId != 0) {
    $html     += '    <div class="emotionIcon"><img src="/img/emoticons/' + $oPosting.emotionId + (Plappadu.Utils.Browser.isIE6 ? '.gif' : '.png') + '" width="24" height="24" alt="" border="0"></div>';
  }

  $html     += '    <div class="data">';
  $html     += '      <span class="nick"><a href="/' + $oPosting.nickname + '">' + $oPosting.nickname + ':</a></span><br/>';

  var $cont = $oPosting.content.replace(/(http:\/\/\S*)/g, '<a href="$1" onclick="window.open(this.href); return false;">$1</a>');

  $html     += '      <span class="content">' + $cont + '</span><br/>';
  $html     += '      <span class="created" id="posting' + $oPosting.postingId + '">' + getDelay($oPosting.created) + ' via ' + $oPosting.createdVia;
  if($oPosting.channelId == "") { $oPosting.channelId = "0"; }
  if($oPosting.channelId != Plappadu.Environment.Channel.oChannel.channelId) {
    $html     += ' in: <a href="http://'+Plappadu.Environment.Channel.getChannelShortcut($oPosting.channelId)+'.plappadu.com">'+Plappadu.Environment.Channel.getChannelName($oPosting.channelId)+'</a>';
  }
  $html     += '</span>';
  $html     += '      <input type="hidden" id="created' + $oPosting.postingId + '" value="' + $oPosting.created + '"/>';
  $html     += '      <input type="hidden" id="createdVia' + $oPosting.postingId + '" value=" via ' + $oPosting.createdVia;
  if($oPosting.channelId != Plappadu.Environment.Channel.oChannel.channelId) {
    $html   += ' in: <a href=\'http://'+Plappadu.Environment.Channel.getChannelShortcut($oPosting.channelId)+'.plappadu.com\'>'+Plappadu.Environment.Channel.getChannelName($oPosting.channelId)+'</a>';
  }
  $html     += '"/>';
  $html     += '      <span class="postingActions">';

  if (Plappadu.Environment.User.isLoggedIn === true) {
    if (inArray($oPosting.postingId, Plappadu.Environment.User.Favorites, true) === true) {
      $html   += '        <img title="Aus meinen Favoriten entfernen." src="/img/actions/bookmark_delete.png" onclick="unsetFavorite(' + $oPosting.postingId + ')"/>';
    } else {
      $html   += '        <img title="Zu meinen Favoriten hinzufügen." src="/img/actions/bookmark_add.png" onclick="setFavorite(' + $oPosting.postingId + ')"/>';
    }
  }
  if ($oPosting.deletable == "1") {
    $html   += '        <img title="Unwiederbringlich überall komplett löschen." src="/img/actions/delete2.gif" onclick="deletePosting(\'' + $oPosting.postingId + '\');"/>';
  }
  $html     += '      </span>';
  $html     += '    </div>';
  $html     += '  </div>';
  $html     += '  <div class="bottom">&nbsp;</div>';
  $html     += '</div>';
  $aReturn[0] = $div;
  $aReturn[1] = $html;
  return($aReturn);
}

function insertNewPostings($oJsonObjText) {
  var $oPostings = $oJsonObjText;
  if ($oPostings == null) {
    $oPostings = {"postings" : [] };
  }
  var $serverTime = new Date().getTime();
  if ($oJsonObjText != null) {
    if ($oJsonObjText.servertime != null) {
      $serverTime = $oJsonObjText.servertime;
    }
  }
  var $aPostingsDivs = document.getElementById("postings");

  for (var $i = 0, $count = $oPostings.postings.length; $i < $count; $i++) {
    if($oPostings.postings[$i] != null) {
      var $aPosting = createPosting($oPostings.postings[$i]);
      $aPostingsDivs.insertBefore($aPosting[0],$aPostingsDivs.firstChild);
      $aPosting[0].className = "postingElement";
      $aPosting[0].innerHTML = $aPosting[1];

      // set newest posting
      if($i==($oPostings.postings.length-1)) {
        Plappadu.Global.newestPosting = $oPostings.postings[$i].created;
      }
    }
  }
  // new delays setzen
  setNewDelays();
}

function setNewDelays() {
  var $aSpans = document.getElementById("postings").getElementsByTagName("span");
  var $aFilteredSpans = new Array;
  for (var $i = 0; $i < $aSpans.length; $i++) {
   if ($aSpans[$i].id != null && $aSpans[$i].id != "") {
      // ermittle id
      var $tmpId = $aSpans[$i].id.replace(/posting/, "");
      // setzt Zeit neu
      document.getElementById($aSpans[$i].id).innerHTML = getDelay(document.getElementById("created" + $tmpId).value) + document.getElementById("createdVia" + $tmpId).value;
    }
  }
}

function logout() {
  var $actURL  = "/json/ajax_logout.php";
  var $response = ResourceLoader.getJsonObject($actURL);
}

// helper

function getDelay($timestamp) {
  var $date = new Date(parseInt($timestamp));
  var $now = new Date().getTime();
  var $postingDate1 = Plappadu.Utils.Date.formatDate($date,"dd.MM.yyyy");
  var $postingDate2 = Plappadu.Utils.Date.formatDate($date,"HH:mm:ss");
  var $secsAgo     = parseInt(($now - $timestamp + $iServerClientDelay) / 1000);
  if ($secsAgo < 1) {
    $secsAgo = 1;
  }
  var $minsAgo     = parseInt($secsAgo / 60);
  var $hoursAgo    = parseInt($minsAgo / 60);
  var $daysAgo     = parseInt($hoursAgo / 24);
  if ($secsAgo > 60) {
    if ($minsAgo > 60) {
      if ($hoursAgo > 24) {
        // return " vor mehr als " + parseInt($daysAgo) + ((parseInt($daysAgo) > 1) ? " Tagen" : " Tag");
        return " am " + $postingDate1 + " um " + $postingDate2 + " Uhr";
      }
      return " vor mehr als " + $hoursAgo + (($hoursAgo > 1) ? " Stunden" : " Stunde");
    }
    return " vor mehr als " + $minsAgo + (($minsAgo > 1) ? " Minuten" : " Minute");
  }
  return " vor " + $secsAgo + (($secsAgo) > 1 ? " Sekunden" : " Sekunde");
}

function pause($iMillis) {
  var $date = new Date();
  var $curDate = null;
  do {
    $curDate = new Date();
  } while ($curDate - $date < $iMillis);
}

function removeNode($node) {
  if(typeof $node == "string") { $node = document.getElementById(node); }
  if(document.getElementById($node) != null) {
    document.getElementById($node).parentNode.removeChild(document.getElementById($node));
  }
}

function cleanNode($node) {
  if(typeof $node == "string") { $node = document.getElementById(node); }
  if($node != null) {
    while($node.hasChildNodes()) {
      $node.removeChild($node.firstChild);
    }
    return true;
  } else {
    return false;
  }
}

function hideNode($node) {
  if(typeof $node == "string") { $node = document.getElementById(node); }
  document.getElementById($node).style.display = "none";
}

function showNode($node) {
  if(typeof $node == "string") { $node = document.getElementById(node); }
  document.getElementById($node).style.display = "block";
}

function toggleNode($node) {
  if(typeof $node == "string") { $node = document.getElementById($node); }
  if ($node.style.display == "none") {
    $node.style.display = "block";
  } else {
    $node.style.display = "none";
  }
}

function proofPostSigns() {
  var ptest = document.getElementById("text2post").value;
  var len = ptest.length;
  if(len <= 130) {
    document.getElementById("signNumber").innerHTML = len;
  } else {
    ptest = ptest.substr(0, 130);
    document.getElementById("text2post").value = ptest;
    document.getElementById("signNumber").innerHTML = "130";
  }
}

function sendPosting() {
  var $form2post = document.getElementById("form2post");
  var $postURL   = "/json/ajax_insertPosting.php";
  var $response  = ResourceLoader.getJsonObject($postURL, $form2post);
  if($response != null) {
    if(($response.error != null) && ($response.error != "0")) {
      alert($response.error);
    }
  }
  document.getElementById("text2post").value = "";
  try { document.getElementById("text2post").focus(); } catch(oe) {}
  show("postings");
  show("teaser");
  show("userData");
}

function deletePosting($postingId) {
  var $lo = ResourceLoader.getJsonObject("json/ajax_delPosting.php?elemId="+$postingId);
  if($lo != null) {
    if(($lo.error != null) && ($lo.error != "0")) {
      alert($lo.error);
    } else {
      alert("Dein Posting wurde erfolgreich gelöscht.");
      show("postings");
      show("userData");
    }
  }
}



// up all good
///////////////////////////////////////

function showMainNavi($url) {
  Plappadu.Global.doRefresh = false;
  var $oCont = document.getElementById("postings_content");
  cleanNode($oCont);

  var $cont = ResourceLoader.getContent($url);
  $oCont.innerHTML = $cont;
}

function showRegister($sessionCode) {
  Plappadu.Global.doRefresh = false;
  var $capURL = "/json/ajax_getCaptcha.php";
  if($sessionCode != null) { $capURL += "?session_code="+$sessionCode; }
  var $captchaO = ResourceLoader.getJsonObject($capURL);
  var $captchaURL = "";
  var $capSession = "";
  if($captchaO != null) {
    if($captchaO.url != "none") {
      $captchaURL     = $captchaO.url;
      $capSession = $captchaO.sessionId;
    }
  }
  var $cont = document.getElementById("postings_content");
  cleanNode($cont);
  var $htmli = "<div class=\"teaser\" id=\"teaser\">";
  $htmli    += "  <h1>Melde Dich kostenlos an!</h1>";
  $htmli    += "  <div class=\"teasertext_full\">";
  $htmli    += "    ...damit die Welt weiss, was Du gerade tust.";
  $htmli    += "  </div>";
  $htmli    += "</div>";
  $htmli    += "<div id=\"postNavi\" class=\"postNavi\"/></div>";
  $htmli    += "<div id=\"postings\">";
  $htmli    += "  <iframe name=\"ireg\" id=\"ireg\" style=\"width:1px;height:1px;display:none\"></iframe>";
  $htmli    += "  <div class=\"nonPostings\">";
  $htmli    += "  <form id=\"registerForm\" action=\"/json/ajax_register.php?channel="+$actChannel+"\" target=\"ireg\" enctype=\"multipart/form-data\" method=\"post\">";
  $htmli    += "  <input type=\"hidden\" name=\"reg_captchaSession\" id=\"reg_captchaSession\" value=\""+$capSession+"\" />";
  $htmli    += "  <label for=\"reg_firstName\">Vorname</label>";
  $htmli    += "  <input type=\"text\" name=\"reg_firstName\" id=\"reg_firstName\" class=\"s50\" />";
  $htmli    += "  <label for=\"reg_lastName\">Nachname</label>";
  $htmli    += "  <input type=\"text\" name=\"reg_lastName\" id=\"reg_lastName\" class=\"s50\" />";
  $htmli    += "  <label for=\"reg_nickName\">Nickname <span class=\"mandatory\">*</span></label>";
  $htmli    += "  <input type=\"text\" name=\"reg_nickName\" id=\"reg_nickName\" class=\"s50\" />";
  $htmli    += "  <label for=\"reg_email\">E-Mail-Adresse <span class=\"mandatory\">*</span></label>";
  $htmli    += "  <input type=\"text\" name=\"reg_email\" id=\"reg_email\" class=\"s50\" />";
  $htmli    += "  <label for=\"reg_password\">Passwort (6-12 Zeichen) <span class=\"mandatory\">*</span></label>";
  $htmli    += "  <input type=\"password\" name=\"reg_password\" id=\"reg_password\" class=\"s50\" />";
  $htmli    += "  <label for=\"reg_password2\">Passwort-Wiederholung <span class=\"mandatory\">*</span></label>";
  $htmli    += "  <input type=\"password\" name=\"reg_password2\" id=\"reg_password2\" class=\"s50\" />";
  $htmli    += "  <label for=\"reg_timeZone\">Zeitzone</label>";
  $htmli    += "  <select class= \"s60\" size=\"1\" name=\"reg_timeZone\" id=\"reg_timeZone\">";
  $htmli    += "    <option value=\"DE,+1\">Deutschland / GMT +01:00</option>";
  $htmli    += "    <option value=\"DK,+1\">Dänemark (Danmark) / GMT +01:00</option>";
  $htmli    += "    <option value=\"FI,+2\">Finnland (Suomi) / GMT +02:00</option>";
  $htmli    += "    <option value=\"FR,+1\">Frankreich (France) / GMT +01:00</option>";
  $htmli    += "    <option value=\"GR,+2\">Griechenland ('Eλλας) / GMT +02:00</option>";
  $htmli    += "    <option value=\"EN,0\">Großbritannien (United Kingdom) / GMT +00:00</option>";
  $htmli    += "    <option value=\"IE,0\">Irland (Ireland) / GMT +00:00</option>";
  $htmli    += "    <option value=\"IS,0\">Island (Ísland) / GMT +00:00</option>";
  $htmli    += "    <option value=\"IT,+1\">Italien (Italia) / GMT +01:00</option>";
  $htmli    += "    <option value=\"LI,+1\">Liechtenstein / GMT +01:00</option>";
  $htmli    += "    <option value=\"LU,+1\">Luxemburg (Lëtzebuerg) / GMT +01:00</option>";
  $htmli    += "    <option value=\"NL,+1\">Niederlande (Nederland) / GMT +01:00</option>";
  $htmli    += "    <option value=\"NO,+1\">Norwegen (Norge) / GMT +01:00</option>";
  $htmli    += "    <option value=\"AT,+1\">Österreich / GMT +01:00</option>";
  $htmli    += "    <option value=\"SE,+1\">Schweden (Sverige) / GMT +01:00</option>";
  $htmli    += "    <option value=\"CH,+1\">Schweiz / GMT +01:00</option>";
  $htmli    += "    <option value=\"ES,+1\">Spanien (España) / GMT +01:00</option>";
  $htmli    += "    <option value=\"TR,+2\">Türkei (Türkiye) / GMT +02:00</option>";
  $htmli    += "    <option value=\",-11\">Sonstige / GMT -11:00</option>";
  $htmli    += "    <option value=\",-10\">Sonstige / GMT -10:00</option>";
  $htmli    += "    <option value=\",-9\">Sonstige / GMT -09:00</option>";
  $htmli    += "    <option value=\",-8\">Sonstige / GMT -08:00</option>";
  $htmli    += "    <option value=\",-7\">Sonstige / GMT -07:00</option>";
  $htmli    += "    <option value=\",-6\">Sonstige / GMT -06:00</option>";
  $htmli    += "    <option value=\",-5\">Sonstige / GMT -05:00</option>";
  $htmli    += "    <option value=\",-4\">Sonstige / GMT -04:00</option>";
  $htmli    += "    <option value=\",-3\">Sonstige / GMT -03:00</option>";
  $htmli    += "    <option value=\",-2\">Sonstige / GMT -02:00</option>";
  $htmli    += "    <option value=\",-1\">Sonstige / GMT -01:00</option>";
  $htmli    += "    <option value=\",0\">Sonstige / GMT -00:00</option>";
  $htmli    += "    <option value=\",+1\">Sonstige / GMT +01:00</option>";
  $htmli    += "    <option value=\",+2\">Sonstige / GMT +02:00</option>";
  $htmli    += "    <option value=\",+3\">Sonstige / GMT +03:00</option>";
  $htmli    += "    <option value=\",+4\">Sonstige / GMT +04:00</option>";
  $htmli    += "    <option value=\",+5\">Sonstige / GMT +05:00</option>";
  $htmli    += "    <option value=\",+6\">Sonstige / GMT +06:00</option>";
  $htmli    += "    <option value=\",+7\">Sonstige / GMT +07:00</option>";
  $htmli    += "    <option value=\",+8\">Sonstige / GMT +08:00</option>";
  $htmli    += "    <option value=\",+9\">Sonstige / GMT +09:00</option>";
  $htmli    += "    <option value=\",+10\">Sonstige / GMT +10:00</option>";
  $htmli    += "    <option value=\",+11\">Sonstige / GMT +11:00</option>";
  $htmli    += "    <option value=\",+12\">Sonstige / GMT +12:00</option>";
  $htmli    += "    <option value=\",+13\">Sonstige / GMT +13:00</option>";
  $htmli    += "    <option value=\",+14\">Sonstige / GMT +14:00</option>";
  $htmli    += "  </select>";
  $htmli    += "  <label for=\"reg_avatar\">Bild hochladen (Größe: 48x48 Pixel, Format: jpg, gif, png)</label>";
  $htmli    += "  <input type=\"file\" name=\"reg_avatar\" id=\"reg_avatar\" class=\"s50\" />";
  $htmli    += "  <img src=\"/captcha/images/cap_"+$captchaURL+".jpg\" id=\"reg_captcha\" class=\"captcha\" />";
  $htmli    += "  <label for=\"reg_captchaField\">Sicherheitscode <span class=\"mandatory\">*</span></label>";
  $htmli    += "  <input type=\"input\" name=\"reg_captchaField\" id=\"reg_captchaField\" class=\"s50\" /><br />";
  $htmli    += "  <input type=\"checkbox\" name=\"reg_agb\" id=\"reg_agb\" class=\"cb\" value=\"yes\" />";
  $htmli    += "  <label for=\"reg_agb\" class=\"cbLabel1\">Ich habe die AGB und Nutzungsbedingungen gelesen und akzeptiere sie. <span class=\"mandatory\">*</span></label>";
  $htmli    += "  <input type=\"checkbox\" name=\"reg_news\" id=\"reg_news\" value=\"yes\" class=\"cb\" checked=\"checked\" />";
  $htmli    += "  <label for=\"reg_news\" class=\"cbLabel2\">Ja, ich möchte per Newsletter über Neuigkeiten informiert werden.</label>";
  $htmli    += "  <br style=\"clear:both\" />";
  $htmli    += "  <span class=\"button submit\">";
  $htmli    += "    <input type=\"submit\" value=\"Registrieren\" />";
  $htmli    += "  </span>";
  $htmli    += "  <span class=\"advise\">Die mit <span class=\"mandatory\">*</span> markierten Felder sind Pflichtfelder</span>";
  $htmli    += "  </form>";
  $htmli    += "</div>";
  $htmli    += "</div>";
  $cont.innerHTML = $htmli;
}

function regSuccess($nick, $mail) {
  var $cont = document.getElementById("postings_content");
  cleanNode($cont);
  var $htmli = "<div class=\"teaser\" id=\"teaser\">";
  $htmli    += "  <h1>Vielen Dank für Dein Interesse!</h1>";
  $htmli    += "</div>";
  $htmli    += "<div id=\"postNavi\" class=\"postNavi\"/></div>";
  $htmli    += "<div id=\"postings\">";
  $htmli    += "  <div class=\"nonPostings\">";
  $htmli    += "    <h2>Hallo "+$nick+",</h2>";
  $htmli    += "    eine E-Mail mit Deinen Zugangsdaten wurde an Deine Adresse:<br />";
  $htmli    += "    <div class=\"highlight\">"+$mail+"</div>";
  $htmli    += "    geschickt.<br />";
  $htmli    += "  </div>";
  $htmli    += "</div>";
  $cont.innerHTML = $htmli;
}

function testFileField() {
  var f = document.getElementById("file_1").value;
  var btn = document.getElementById("sett_file_btn");
  var bbtn = btn.getElementsByTagName("input")[0];
  if(f == "") {
    btn.className = "button disabled";
    bbtn.setAttribute("disabled", "disabled", false);
  } else {
    btn.className = "button submit";
    bbtn.removeAttribute("disabled", false);
  }
}

function proofComing(object) {
  if(object != null) {
    if((object.error != null) && (object.error != "0") && (object.error != "1")) {
      alert(object.error);
    } else {
      if(object.error == "1") {
        alert("Du hast die Daten des Bildes nicht korrekt eingegeben.");
        $reg_captchaSession = document.getElementById("reg_captchaSession").value;
        var $capURL = "/json/ajax_getCaptcha.php";
        if(($reg_captchaSession != null) && ($reg_captchaSession != "")) { $capURL += "?session_code="+$reg_captchaSession; }
        var $captchaO = ResourceLoader.getJsonObject($capURL);
        var $captchaURL = "";
        var $capSession = "";
        if($captchaO != null) {
          if($captchaO.url != "none") {
            $captchaURL     = $captchaO.url;
            $capSession = $captchaO.sessionId;
          }
        }
        var img = document.getElementById("reg_captcha");
        img.src = "/captcha/images/cap_"+$captchaURL+".jpg";
      } else {
        var $nick = document.getElementById("reg_nickName").value;
        var $mail = document.getElementById("reg_email").value;
        regSuccess($nick, $mail);
      }
    }
  }
}

function formProofChange(oForm) {
  if((typeof oForm) != "object") {
    oForm = document.getElementById(oForm);
  }
  if((typeof oForm) != "object") {
    return true;
  } else {
    var inputs  = oForm.getElementsByTagName("input");
    var selects = oForm.getElementsByTagName("select");
    var areas   = oForm.getElementsByTagName("textarea");
    var change = false;
    for(var i = 0; i < inputs.length; i++) {
      var id = inputs[i].getAttribute("id")+"H";
      var orig = document.getElementById(id);
      if(orig != null) {
        if((inputs[i].getAttribute("type").toLowerCase() == "text") || (inputs[i].getAttribute("type") == "") || (inputs[i].getAttribute("type").toLowerCase() == "radio")) {
          if(orig != null) {
            if(inputs[i].value != orig.value) { return true; }
          }
        }
        if((inputs[i].getAttribute("type").toLowerCase() == "checkbox")) {
          if(orig != null) {
            if((inputs[i].checked) && ((orig.value == "") || (orig.value == "false") || (orig.value == "0"))) { return true; }
          }
        }
        if((inputs[i].getAttribute("type").toLowerCase() == "file")) {
          if(orig != null) {
            if((inputs[i].value != "") && (orig.value == "")) { return true; }
          }
        }
      }
    }
    for(var i = 0; i < selects.length; i++) {
      var id = selects[i].getAttribute("id")+"H";
      var orig = document.getElementById(id);
      if(orig != null) {
        if(orig.value != selects[i].value) { return true; }
      }
    }
    for(var i = 0; i < areas.length; i++) {
      var id = areas[i].getAttribute("id")+"H";
      var orig = document.getElementById(id);
      if(orig != null) {
        if(orig.value != areas[i].value) { return true; }
      }
    }
  }
  return false;
}

function settings() {
  proof_settings('/public/settings.php');
}

function sendSettings_account() {
  var $lo = ResourceLoader.getJsonObject("json/ajax_settingsAccount.php", document.getElementById("settings_konto"));
  if($lo != null) {
    if(($lo.error != null) && ($lo.error != "0")) {
      alert($lo.error);
    } else {
      alert("Deine Änderungen wurden erfolgreich gespeichert.");
    }
  } else {
    alert("Deine Änderungen wurden erfolgreich gespeichert.");
  }
}

function sendSettings_password() {
  var $lo = ResourceLoader.getJsonObject("/json/ajax_settingsPassword.php", document.getElementById("settings_password"));
  if($lo != null) {
    if(($lo.error != null) && ($lo.error != "0")) {
      alert($lo.error);
    } else {
      alert("Deine Änderungen wurden erfolgreich gespeichert.");
      document.getElementById("settings_password").reset();
    }
  } else {
    alert("Deine Änderungen wurden erfolgreich gespeichert.");
    document.getElementById("settings_password").reset();
  }
}

function sendSettings_notifications() {
  var $lo = ResourceLoader.getJsonObject("json/ajax_settingsNotifications.php", document.getElementById("settings_notifications"));
  if($lo != null) {
    if(($lo.error != null) && ($lo.error != "0")) {
      alert($lo.error);
    } else {
      alert("Deine Änderungen wurden erfolgreich gespeichert.");
    }
  } else {
    alert("Deine Änderungen wurden erfolgreich gespeichert.");
  }
}


function setImageDone($object) {
  if($object != null) {
    if(($object.error != null) && ($object.error != "0")) {
      alert($object.error);
    } else {
      alert("Dein Avatar wurde erfolgreich geändert.");
      Plappadu.Environment.User.avatarPath = ResourceLoader.getContent("/json/ajax_getAvatarPath.php?userId=" + Plappadu.Environment.User.userId);
      var img = document.getElementById("settings_avatar").getElementsByTagName("img")[0];
      img.src = Plappadu.Environment.User.avatarPath;
    }
  } else {
    alert("Deine Änderungen wurden erfolgreich gespeichert.");
  }
}

function proof_settings(nextPage) {
  var f = document.getElementById("kindOfSetting");
  if((f != null) && (f.value != "")) {
    if(formProofChange(f.value)) {
      showMainNavi(nextPage);
    } else {
      showMainNavi(nextPage);
    }
  } else {
    showMainNavi(nextPage);
  }
}

function settings_password() {
  proof_settings('/public/settings_password.php');
}

function settings_fon_im() {
  proof_settings('/public/settings_fon_im.php');
}

function newActivation() {
  showMainNavi('/public/settings_fon_im.php?renew=true');
}

function settings_notifications() {
  proof_settings('/public/settings_notifications.php');
}

function settings_image() {
  proof_settings('/public/settings_image.php');
}

function forgottenPass() {
  var $nick = document.getElementById("login_user").value;
  if(($nick != null) && ($nick != "")) {
    var $lo = ResourceLoader.getJsonObject("json/ajax_sendPass.php?nick="+$nick);
    var $cont = document.getElementById("postings_content");
    cleanNode($cont);
    var $htmli = "<div class=\"teaser\" id=\"teaser\">";
    $htmli    += "  <h1>Das kann jedem mal passieren...</h1>";
    $htmli    += "</div>";
    $htmli    += "<div id=\"postNavi\" class=\"postNavi\"/></div>";
    $htmli    += "<div id=\"postings\">";
    $htmli    += "  <div class=\"nonPostings\">";
    $htmli    += "    <h2>Hallo "+$nick+",</h2>";
    $htmli    += "    eine E-Mail mit Deinen Zugangsdaten wurde an Deine angegebene E-Mail-Adresse";
    $htmli    += "    versendet.<br />";
    $htmli    += "  </div>";
    $htmli    += "</div>";
    $cont.innerHTML = $htmli;
  } else {
    alert("Du musst Deinen Nicknamen eingeben.");
  }
}



function sendRecommandation() {
  var $lo = ResourceLoader.getJsonObject("json/ajax_recommend.php", document.getElementById("recommendForm"));
  if($lo != null) {
    if(($lo.error != null) && ($lo.error != "0")) {
      alert($lo.error);
    } else {
      alert("Deine Empfehlung wurde erfolgreich versandt.");
      showMainNavi('/public/empfehlen.php');
    }
  }
}

function followUser(userId) {
  var $lo = ResourceLoader.getJsonObject("json/ajax_followUser.php?userId="+userId);
  if($lo != null) {
    if(($lo.error != null) && ($lo.error != "0")) {
      alert($lo.error);
    } else {
      alert("Dieser Nutzer ist jetzt Dein Freund.");
      Plappadu.Environment.Alien.numberOfFollowers++;
      Plappadu.Environment.User.numberOfFriends++;
      xshow("alienProfile");
    }
  }
}

function stopFollow(userId) {
  var $lo = ResourceLoader.getJsonObject("json/ajax_stopFollow.php?userId="+userId);
  if($lo != null) {
    if(($lo.error != null) && ($lo.error != "0")) {
      alert($lo.error);
    } else {
      alert("Die Freundschaft mit diesem Nutzer wurde erfolgreich beendet.");
      Plappadu.Environment.Alien.numberOfFollowers--;
      Plappadu.Environment.User.numberOfFriends--;
      xshow("alienProfile");
    }
  }
}

function blockUser(userId) {
  var $lo = ResourceLoader.getJsonObject("json/ajax_blockUser.php?userId="+userId);
  if($lo != null) {
    if(($lo.error != null) && ($lo.error != "0")) {
      alert($lo.error);
    } else {
      alert("Du blockst nun diesen Nutzer.");
      xshow("alienProfile");
    }
  }
}

function stopBlock(userId) {
  var $lo = ResourceLoader.getJsonObject("json/ajax_stopBlock.php?userId="+userId);
  if($lo != null) {
    if(($lo.error != null) && ($lo.error != "0")) {
      alert($lo.error);
    } else {
      alert("Das Blocken dieses Nutzers wurde erfolgreich beendet.");
      xshow("alienProfile");
    }
  }
}

// up is funzing but nessecary todos in struct
///////////////////////////////////////////////



function showAlienProfile(profileToShow) {
  var pc = document.getElementById("postings_content");
  cleanNode(pc);
  var html = "<div id=\"teaser\" class=\"teaser\">";
  html += "<h1>Was tut "+profileToShow+"? Und die Freunde?</h1>";
  html += "<div class=\"teasertext_full\">";
  var url = "/json/ajax_getAlienLastPosting.php?nickname="+profileToShow;
  html += "<strong>Aktuell:</strong> "+ResourceLoader.getContent(url);
  html += "</div></div>";
  html += "<div id=\"postNavi\" class=\"postNavi\">";
  html += "<span class=\"active\">";
  html += "<a onclick=\"getPostings('alien',null,0,'"+profileToShow+"',false);\" href=\"javascript:void(0);\">aktuell</a>";
  html += "</span> ";
  html += "<span class=\"inactive\">";
  html += "<a onclick=\"getPostings('alien',null,1,'"+profileToShow+"',true);\" href=\"javascript:void(0);\">mit Freunden</a>";
  html += "</span>";
  html += "</div>";
  html += "<div id=\"postings\" class=\"pNavi\"></div>";
  pc.innerHTML = html;
  var $oPostings = getPostings("alien",null,0,profileToShow,false);
  createPostings($oPostings);
}

// down all good

function setFavorite($iPostingId) {
  ResourceLoader.loadJsonObject("/json/ajax_addFavorite.php?postingId=" + $iPostingId, null, setFavoriteSuccess);
}

function setFavoriteSuccess($sJsonObject) {
  if ($sJsonObject != null) {
    if (($sJsonObject.error != null) && ($sJsonObject.error != 0)) {
      alert($sJsonObject.error);
    } else {
      alert("Das Posting wurde erfolgreich zu Deinen Favoriten hinzugefügt.");
      Plappadu.Environment.User.numberOfFavorites++;
      Plappadu.Environment.User.Favorites.unshift($sJsonObject.postingId);
      show("userData");
      show("postings");
    }
  }
}

function unsetFavorite($iPostingId) {
  ResourceLoader.loadJsonObject("/json/ajax_removeFavorite.php?postingId=" + $iPostingId, null, unsetFavoriteSuccess);
}

function unsetFavoriteSuccess($sJsonObject) {
  if ($sJsonObject != null) {
    if (($sJsonObject.error != null) && ($sJsonObject.error != 0)) {
      alert($sJsonObject.error);
    } else {
      alert("Das Posting wurde erfolgreich aus Deinen Favoriten entfernt.");
      Plappadu.Environment.User.numberOfFavorites--;
      var $aNewArray = removeValuesFromArray($sJsonObject.postingId, Plappadu.Environment.User.Favorites, true, null);
      if ($aNewArray instanceof Array) {
        Plappadu.Environment.User.Favorites = $aNewArray;
      }
      show("userData");
      show("postings");
    }
  }
}

function init() {
  Plappadu.Environment.Channel.getChannel($actChannel);
  if($skinToShow == "") {
    $skinToShow = Plappadu.Environment.Channel.oChannel.defSkinId;
  }
  Plappadu.Environment.Skin.applySkin();
  if ($profileToShow != "") {
    getAlienFromServer($profileToShow);
    Plappadu.Environment.showAlienProfile = true;
    Plappadu.Environment.showAlienProfileNick = $profileToShow;

  }
  if(($toactivateU != null) && ($toactivateA != null)) {
    Plappadu.Environment.activationRequest = true;
    Plappadu.Environment.activationRequestUserId = $toactivateU;
    Plappadu.Environment.activationRequestActivationKey = $toactivateA;
    getUserFromServer("activate", null);
  } else if ($loginToSession) {
    Plappadu.Environment.showPublicTimeline = false;
    getUserFromServer("session", null);
  } else {
    displayEnvironment();
  }
}

