function Chat() {
    this.chatID;
    this.partner;
    this.partnerName;
    this.minimized;
    this.position;
    this.warte = 0;
}
Chat.prototype.setChatID = function (ID) {
    this.chatID = ID;
}
Chat.prototype.getChatID = function () {
    return this.chatID;
}
Chat.prototype.setPartner = function (partner) {
    this.partner = partner;
}
Chat.prototype.setPartnerName = function (partnerName) {
    this.partnerName = partnerName;
}
Chat.prototype.getPartner = function () {
    return this.partner;
}
Chat.prototype.getPartnerName = function () {
    return this.partnerName;
}
Chat.prototype.setWarte = function (warte) {
    this.partner = warte;
}
Chat.prototype.getWarte = function () {
    return this.warte;
}
Chat.prototype.setPosition = function (pos) {
    this.position = pos;
}
Chat.prototype.getPosition = function () {
    return this.position;
}

Chat.prototype.startChat = function() {
    this.createDiv(this.getChatID()+"Body", "", "20%", "30%", this.getPosition(), "5px", "#fcf0fa" );
    this.createDiv(this.getChatID()+"Head", "", "20%", "3%", this.getPosition(), "30.5%", "#c0c0c0");
}

Chat.prototype.refreshChat = function() {
    new Ajax.Updater(this.getChatID()+'Body', 'intern/chat/shoutboxClass.php?User='+this.getPartner()+'&ID='+this.getChatID());
    new Ajax.Updater(this.getChatID()+'Head', 'intern/chat/head.php?User='+this.getPartner()+'&Username='+this.getPartnerName());
    //new Ajax.Updater('anzeige'+this.getChatID(), 'intern/chat/shoutboxMsgClass.php?User='+this.getPartner()+'');
}

Chat.prototype.createDiv = function(id, html, width, height, right, top, bg) {
       var newdiv = document.createElement('div');
       newdiv.setAttribute('id', id);
       if (width) {
           newdiv.style.width = width;
       }
       if (height) {
           newdiv.style.height = height;
       }
       if ((right || top) || (right && top)) {
           newdiv.style.position = "absolute";
           if (right) {
               newdiv.style.right = right+'%';
           }
           if (top) {
               newdiv.style.bottom = top;
           }
       }
       newdiv.style.background = bg;
       newdiv.style.border = "1px solid gray";
       newdiv.style.zIndex = "10000000";
       if (html) {
           newdiv.innerHTML = html;
       } else {

       }
       document.body.appendChild(newdiv);

}

Chat.prototype.scrollDown = function() {
    alert("");
    var x = document.getElementById('anzeige'+this.getChatID());
    x.scrollTop = x.scrollHeight;
}
function isEnterShoutbox(e) {
   /* e= e || window.event || {};
        var charCode = e.charCode || e.keyCode || e.which;

        if (charCode == 13) {
            return true;
        }
        return false;*/
    e = e || window.event;
    var key = e.keyCode || e.which || e.charCode, Shift = Event.SHIFT_MASK || e.shiftKey, Alt = Event.ALT_MASK || e.altKey, Ctrl = Event.CONTROL_MASK || e.ctrlKey;
    if(key == 13 && !Shift){
        return true;
    }
    return false;
}

function loadPage(target, page){
    new Ajax.Updater(target, page, {
        method: 'get',
        evalScripts: true,
        onComplete: function() {
            return true;
        }
    });
}
