/**
 * Square7 javascript file
 * (c) 2007-2010 miro/Square7, unless otherwise noted
**/

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload)
                oldonload();
        }
        func();
    }
}

addLoadEvent(function() { extern(); primary(); });

onerror = halt;

function halt() {
    return true;
}

function counterDE() {
    var count = document.getElementById('message').value;
    document.getElementById('textcount').innerHTML = 'Bisher ' +count.length+ ' von max. 800 Zeichen benutzt... ';
        if (count.length>=801) {
            document.getElementById('message').value = count.substr(0, 800);
            alert('Sry, mehr als 800 Zeichen sind nicht drin...');
            counterDE();
        }
}

function counterEN() {
    var count = document.getElementById('message').value;
    document.getElementById('textcount').innerHTML = count.length+ ' characters of max. 800 used so far... ';
        if (count.length>=801) {
            document.getElementById('message').value = count.substr(0, 800);
            alert('Sorry, more than 800 characters are not available...');
            counterEN();
        }
}

function extern() {
  var links, i, a;
  links = document.getElementsByTagName("a");
  for(i = 0; i < links.length; i++) {
    a = links[i];
    if(a.getAttribute("rel") == "extern") {
      a.onclick = function() {
        window.open(this.href);
        return false;
      }
    }
    if(a.getAttribute("rel") == "descr") {
      a.onclick = function() {
        window.open(this.href,'name','width=640,height=480,status=no,scrollbars=no,resizable=no,top=210,left=320');
        return false;
      }
    }
  }
}

function primary() {
    document.getElementById('focus').focus();
}

