/* original by http://qlib.quazzle.com/ */
function make_hash(str) 
{
    var h = 0;
    if (str) 
    {
        ANTABLE    = "w5Q2KkFts3deLIPg8Nynu_JAUBZ9YxmH1XW47oDpa6lcjMRfi0CrhbGSOTvqzEV";
        for (var j=str.length-1; j>=0; j--) 
        {
            h ^= ANTABLE.indexOf(str.charAt(j)) + 1;
            for (var i=0; i<3; i++) 
            {
                var m = (h = h<<7 | h>>>25) & 150994944;
                h ^= m?(m==150994944?1:0):1;
            }
        }
    }
    return h;
}

function NewWindow(mypage, myname, w, h, scroll, res, winl, wint)
{
    if (typeof winl == 'undefined') winl = (screen.width-w)/2;
    if (typeof wint == 'undefined') wint = (screen.height-h)/2;
    winprops = 'menubar=no,status=no,height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+res;
    win = window.open(mypage, myname, winprops)
    if (!win)
    {
        alert('Du hast anscheinend einen Popupblocker installiert!!!\nBitte deaktiviere diesen zumindest für unsere Seite, da ansonsten viele Funktionen nur eingeschränkt nutzbar sind!\nWenn Du Hilfe benötigt, such am besten in den Foren oder schreibe eine Nachricht an den Support.');
        return true;
    }
    win.focus();
    return false;
}
function gallery(id)
{
    width = 800;
    height = 600;
    NewWindow("/photo.php?pic_id="+id, 'picture'+Math.abs(make_hash(id)), width, height, 'yes','yes');
    return false;
}
function profil(id, mode)
{
    width = 860;
    height = 680;
    NewWindow("/profile.php?id="+id+"&mode="+mode, 'profil'+Math.abs(make_hash(id)), width, height, 'yes','yes');
    return false;
}
function privatealbum(id, albumid)
{
    width = 800;
    height = 680;
    NewWindow("/profile.php?id="+id+"&mode=album&first_click=true&album_id="+albumid, 'profil'+Math.abs(make_hash(id)), width, height, 'yes','yes');
    return false;
}
function profilExt(id, mode, subject)
{
    width = 800;
    height = 680;
    NewWindow("/profile.php?id="+id+"&mode="+mode+"&subject="+subject, 'profil'+Math.abs(make_hash(id)), width, height, 'yes','yes');
    return false;
}

function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    } else {
        countfield.value = maxlimit - field.value.length;
    }
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  var newwindow = window.open(theURL,winName,features);
}

function changeFormTarget() { // AF
 if(document.formular.pass.value != "")
  document.formular.action = "user.php";
 else
  window.location.href = "chatlogin.php";
}
function open_entfernen_lassen() {
  window.open('','entfernen','toolbar=no,scrollbars=yes,resizable=yes,width=400,height=350');
}
function open_event_details(url) {
  window.open(url,'eventdetails','toolbar=no,scrollbars=yes,resizable=yes,width=590,height=350');
}
function open_agb() {
  myWindow = window.open("/agb.php", "AGBs", "height=550, width=540, scrollbars=yes, location=no, menubar=no, status=no, toolbar=no, dependent=yes, left=50, top=50");
}
function activate_all(mark) {
  if (mark == true) {
    for (i=0; i<=document.list.elements.length; i++) {
        document.list.elements[i].checked = true;
    }
  }
  else {
    for (i=0; i<=document.list.elements.length; i++) {
        document.list.elements[i].checked = false;
    }
  }
}
function show(divid) {
    $("cat1").hide();
    $("cat2").hide();
    $(divid).show();
}
function show_report_form() {
    $('report_text').value = "";
    $('report_message').innerHTML = "";
    if ($('report_milky_layer').getStyle("display") == "block") {
        $('report_milky_layer').hide();
    } else {
        $('report_content').show();
        $('report_milky_layer').show();
    }
}
function dispatch_report() {
      if($F("report_text") == "") {
          alert("Du musst eine Aussage machen bzw. deine Anschuldigungen kurz begründen!");
          return false;
      } else {
        if(window.document.report.report_select.value=="0") {
                  alert("Du musst einen Grund auswählen damit unsere Supporter wissen worum es geht!");
                  return false;
              } else {
                $('report_content').hide();
                $('report_message').show();
                var myAjax = new Ajax.Request( "/lib/report.php", {
                    method: 'post',
                    parameters: $('report').serialize(),
                    onComplete: showReport
                });
            }
    }
}
function showReport(response) {
    $('report_message').show();
    $('report_message').update('<strong>Deine Meldung war:</strong><br />' + $F('report_text'));
    window.setTimeout("$('report_milky_layer').hide();", 4000);
}
function bugButtonClick(event) {
    //var width = screen.availWidth;
    //var height = screen.availHeight;
    if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
        var width = window.innerWidth;
        var height = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        var width = document.documentElement.clientWidth;
        var height = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        var width = document.body.clientWidth;
        var height = document.body.clientHeight;
    }
    
    var left = (width-$('bug_reporting').getWidth())/2;
    var top = (height-$('bug_reporting').getHeight())/2;
    $('bug_reporting').style.left = left+'px';
    $('bug_reporting').style.top = top+'px';
    $('bug_reporting').setStyle({
      left: left+'px',
      top: top+'px'
    });
    Effect.Appear('bug_reporting');
}
function bugButtonMover(event) {
    $('bug_button_img').src = "/images/grafik/beta_bug_hover.gif";
}
function bugButtonMout(event) {
    $('bug_button_img').src = "/images/grafik/beta_bug.gif";
}
function removeBugReport() {
    Effect.Fade('bug_reporting');
}
function submitBugReport() {
    var pars = $('bug_reporting_form').serialize(true);
    new Ajax.Request('/lib/bugs.php', {
        method: 'get',
        parameters: pars,
        onSuccess: submitSuccess,
        onError: submitError
    });
}
function submitError(response) {
    $('bug_reporting_content').innerHTML = '<small><strong>Der Server konnte nicht erreicht werden<\/strong><\/small>';
    setTimeout('Effect.Fade("bug_reporting")', 2000);
}
function submitSuccess(response) {
    $('bug_reporting_content').innerHTML = '<small><strong>'+response.responseText+'<\/strong><\/small>';
    setTimeout('Effect.Fade("bug_reporting")', 2000);
}