//loadfileset 8, 8/button_hilfe.png
//htdocs/fusion/libs/json2.js\n//jsfileid:c7e6cdbbf349641dcc3f799c2654906d-htdocs/fusion/libs/json2.js
//lastchange:2023-02-28 16:21:30
/*
    json2.js
    2008-01-17

    Public Domain

    No warranty expressed or implied. Use at your own risk.

    See http://www.JSON.org/js.html

    This file creates a global JSON object containing two methods:

        JSON.stringify(value, whitelist)
            value       any JavaScript value, usually an object or array.

            whitelist   an optional array prameter that determines how object
                        values are stringified.

            This method produces a JSON text from a JavaScript value.
            There are three possible ways to stringify an object, depending
            on the optional whitelist parameter.

            If an object has a toJSON method, then the toJSON() method will be
            called. The value returned from the toJSON method will be
            stringified.

            Otherwise, if the optional whitelist parameter is an array, then
            the elements of the array will be used to select members of the
            object for stringification.

            Otherwise, if there is no whitelist parameter, then all of the
            members of the object will be stringified.

            Values that do not have JSON representaions, such as undefined or
            functions, will not be serialized. Such values in objects will be
            dropped; in arrays will be replaced with null.
            JSON.stringify(undefined) returns undefined. Dates will be
            stringified as quoted ISO dates.

            Example:

            var text = JSON.stringify(['e', {pluribus: 'unum'}]);
            // text is '["e",{"pluribus":"unum"}]'

        JSON.parse(text, filter)
            This method parses a JSON text to produce an object or
            array. It can throw a SyntaxError exception.

            The optional filter parameter is a function that can filter and
            transform the results. It receives each of the keys and values, and
            its return value is used instead of the original value. If it
            returns what it received, then structure is not modified. If it
            returns undefined then the member is deleted.

            Example:

            // Parse the text. If a key contains the string 'date' then
            // convert the value to a date.

            myData = JSON.parse(text, function (key, value) {
                return key.indexOf('date') >= 0 ? new Date(value) : value;
            });

    This is a reference implementation. You are free to copy, modify, or
    redistribute.

    Use your own copy. It is extremely unwise to load third party
    code into your pages.
*/

/*jslint evil: true */

/*global JSON */

/*members "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
    charCodeAt, floor, getUTCDate, getUTCFullYear, getUTCHours,
    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, length,
    parse, propertyIsEnumerable, prototype, push, replace, stringify, test,
    toJSON, toString
*/

if (!this.JSON) {

    JSON = function () {

        function f(n) {    // Format integers to have at least two digits.
            return n < 10 ? '0' + n : n;
        }

        Date.prototype.toJSON = function () {

// Eventually, this method will be based on the date.toISOString method.

            return this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z';
        };


        var m = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        };

        function stringify(value, whitelist) {
            var a,          // The array holding the partial texts.
                i,          // The loop counter.
                k,          // The member key.
                l,          // Length.
                r = /["\\\x00-\x1f\x7f-\x9f]/g,
                v;          // The member value.

            switch (typeof value) {
            case 'string':

// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe sequences.

                return r.test(value) ?
                    '"' + value.replace(r, function (a) {
                        var c = m[a];
                        if (c) {
                            return c;
                        }
                        c = a.charCodeAt();
                        return '\\u00' + Math.floor(c / 16).toString(16) +
                                                   (c % 16).toString(16);
                    }) + '"' :
                    '"' + value + '"';

            case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

                return isFinite(value) ? String(value) : 'null';

            case 'boolean':
            case 'null':
                return String(value);

            case 'object':

// Due to a specification blunder in ECMAScript,
// typeof null is 'object', so watch out for that case.

                if (!value) {
                    return 'null';
                }

// If the object has a toJSON method, call it, and stringify the result.

                if (typeof value.toJSON === 'function') {
                    return stringify(value.toJSON());
                }
                a = [];
                if (typeof value.length === 'number' &&
                        !(value.propertyIsEnumerable('length'))) {

// The object is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                    l = value.length;
                    for (i = 0; i < l; i += 1) {
                        a.push(stringify(value[i], whitelist) || 'null');
                    }

// Join all of the elements together and wrap them in brackets.

                    return '[' + a.join(',') + ']';
                }
                if (whitelist) {

// If a whitelist (array of keys) is provided, use it to select the components
// of the object.

                    l = whitelist.length;
                    for (i = 0; i < l; i += 1) {
                        k = whitelist[i];
                        if (typeof k === 'string') {
                            v = stringify(value[k], whitelist);
                            if (v) {
                                a.push(stringify(k) + ':' + v);
                            }
                        }
                    }
                } else {

// Otherwise, iterate through all of the keys in the object.

                    for (k in value) {
                        if (typeof k === 'string') {
                            v = stringify(value[k], whitelist);
                            if (v) {
                                a.push(stringify(k) + ':' + v);
                            }
                        }
                    }
                }

// Join all of the member texts together and wrap them in braces.

                return '{' + a.join(',') + '}';
            }
        }

        return {
            stringify: stringify,
            parse: function (text, filter) {
                var j;

                function walk(k, v) {
                    var i, n;
                    if (v && typeof v === 'object') {
                        for (i in v) {
                            if (Object.prototype.hasOwnProperty.apply(v, [i])) {
                                n = walk(i, v[i]);
                                if (n !== undefined) {
                                    v[i] = n;
                                }
                            }
                        }
                    }
                    return filter(k, v);
                }


// Parsing happens in three stages. In the first stage, we run the text against
// regular expressions that look for non-JSON patterns. We are especially
// concerned with '()' and 'new' because they can cause invocation, and '='
// because it can cause mutation. But just to be safe, we want to reject all
// unexpected forms.

// We split the first stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace all backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

                if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the second stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.

                    j = eval('(' + text + ')');

// In the optional third stage, we recursively walk the new structure, passing
// each name/value pair to a filter function for possible transformation.

                    return typeof filter === 'function' ? walk('', j) : j;
                }

// If the text is not JSON parseable, then a SyntaxError is thrown.

                throw new SyntaxError('parseJSON');
            }
        };
    }();
}
;
//htdocs/fusion/pga/pga.js\n//jsfileid:6498ebfce7f18219ac1a1429f0abbdaf-htdocs/fusion/pga/pga.js
//lastchange:2023-02-28 16:21:30
//SETUP
var PGAInterfaceURL = '/common/fusion/ajax/fusionproxy.php?SCRIPTNAME=pga';
var PGAImageURL = '/common/fusion/pga/images/';

//CLASSES

var HorizontalNaviCtrl = Class.create();
HorizontalNaviCtrl.prototype = {
	parentWnd:			null,
	currentLevel:		0,
	cssclass:			"",
	name:				"",
	scrollupbutton:		null,
	scrolldownbutton:	null,
	scrollcontainer:	null,
	scrollcontent:		null,
	scrolloffset:		null,
	numitems:			null,
	currentHeight:		0,

	// Konstruktor
	initialize: function(parent, name, cssclass, scrollY) {
		if($(parent) == null) return null;

		this.scrolloffset = new Array();
		this.numitems = new Array();
		this.parentWnd = $(parent);
		this.cssclass = cssclass;
		if (typeof scrollY == 'undefined') {
			this.scrollY = 43;
		} else {
			this.scrollY = scrollY;
		}
		this.name = name;
		this.currentLevel = 0;

		this.createWnd();
	},

	registerScrollDownButton: function(button) {
		var self = this;
		this.scrolldownbutton = $(button);
		this.scrolldownbutton.onclick = function() {self.scrollDown();};
	},

	registerScrollUpButton: function(button) {
		var self = this;
		this.scrollupbutton = $(button);
		this.scrollupbutton.onclick = function() {self.scrollUp();};
	},

	findScrollContent: function() {
		var objlevel = $(this.name + 'Container_Level_' + this.currentLevel);
		if (objlevel)
		{
			var scrollcontent = objlevel.select('.PGAScrollContent');
			if (scrollcontent)
			{
				this.scrollcontent = scrollcontent[0];
			}
		}
	},

	findScrollContainer: function()	{
		var objlevel = $(this.name + 'Container_Level_' + this.currentLevel);
		if (objlevel)
		{
			var scrollcontainer = objlevel.select('.PGAScrollContainer');
			if (scrollcontainer)
			{
				this.scrollcontainer = scrollcontainer[0];
			}
		}
	},

	scrollDown: function() {
		this.scrolloffset[this.currentLevel]  += this.scrollY;
		this.doScroll();
		this.updateScrollButtons();
	},

	scrollUp: function() {
		this.scrolloffset[this.currentLevel]  -= this.scrollY;
		this.doScroll();
		this.updateScrollButtons();
	},

	doScroll: function() {
		if (this.scrollcontent != null && this.scrollcontainer != null)
		{
			new Effect.Move (this.scrollcontent,{ x: 0, y: -this.scrolloffset[this.currentLevel] , mode: 'absolute', duration: 0.25});
		}
	},

	createWnd: function() {
		var html = "";
		html += "<div class='" + this.cssclass + "' id='" + this.name + "'></div>";
		this.parentWnd.innerHTML = html;
		this.container = $(this.name);
	},

	replaceContent: function(html,numitems,modifylevel)	{
		if (typeof(modifylevel) == "undefined")
		{
			var modifylevel = this.currentLevel;
		}

		var objlevel = $(this.name + "Container_Level_" + modifylevel);
		if (!objlevel)
		{
			objlevel = document.createElement("div");
			objlevel.className = this.cssclass;
			objlevel.style["position"] = "absolute";
			objlevel.style["top"] = "0px";
			objlevel.style["left"] = (this.currentLevel * 224) + "px";
			objlevel.style["width"] = "224px";
			objlevel.id = this.name + "Container_Level_" + modifylevel;

			this.scrolloffset.push(0);
			this.numitems.push(0);

			this.container.appendChild(objlevel);
		}

		objlevel.innerHTML = html;
		this.scrolloffset[modifylevel] = 0;
		this.numitems[modifylevel] = numitems;
		this.updateScrollStructures();
	},

	nextLevel: function(html,numitems) {
		this.currentLevel++;
		this.replaceContent(html,numitems);
		this.onLevelChanged();
	},

	prevLevel: function() {
		if (this.currentLevel <= 0) return;
		this.currentLevel--;
		this.onLevelChanged();
	},

	updateScrollButtons: function()	{
		if (this.scrolldownbutton != null) {
			if (-this.scrolloffset[this.currentLevel] + this.scrollcontent.getHeight()-5 > this.scrollcontainer.getHeight()) {
				this.scrolldownbutton.show();
			} else {
				this.scrolldownbutton.hide();
			}
		}

		if (this.scrollupbutton != null) {
			if (this.scrolloffset[this.currentLevel] > 0) {
				this.scrollupbutton.show();
			} else {
				this.scrollupbutton.hide();
			}
		}
	},

	updateScrollStructures: function() {
		this.findScrollContainer();
		this.findScrollContent();

		if (this.scrollcontainer != null && this.scrollcontent != null)
		{
			this.updateScrollButtons();
		} else {
			// Wenn nix zu scrollen da, eventuelle Scrollbuttons vom Vorlevel
			// verstecken.
			if (typeof this.scrollupbutton != 'undefined' && this.scrollupbutton != null) {
				this.scrollupbutton.hide();
			}
			if (typeof this.scrolldownbutton != 'undefined' && this.scrollupbutton != null) {
				this.scrolldownbutton.hide();
			}
		}
	},

	onLevelChanged: function () {
		new Effect.Move ($(this.name),{ x: -(this.currentLevel*224), y: 0, mode: 'absolute', duration: 0.5});
		this.updateScrollStructures();
		if (this.name == 'PGAMessagesClientWnd') {
			var showToolbar = (this.currentLevel > 0) ? true : false;
			pga.lockMessageWnd = false;
			pga.adaptMessageWndSize(this.numitems[this.currentLevel], showToolbar);
			pga.lockMessageWnd = (this.currentLevel > 0) ? true : false;
		}
	},

	getNumItemsShown: function() {
		return this.numitems[this.currentLevel];
	},

	onItemRemoved: function() {
		this.numitems[this.currentLevel]--;
	},

	setHeight: function(height)	{
		if (this.currentHeight == 0) {
			this.currentHeight = this.parentWnd.getHeight();
		}
		var percent = (height/this.currentHeight)*100;
		if (this.currentHeight == 0) {
			percent = 100*height;
			this.currentHeight = 1;
		}
		new Effect.Scale(this.parentWnd, percent, {
			scaleContent: false,
			scaleX: false,
			duration: 0.5,
			scaleMode: {originalHeight: this.currentHeight}
		});
		this.currentHeight = height;
	}
}

var PersonalGamerAssistent = Class.create();
PersonalGamerAssistent.prototype = {
	visible:		false,
	showMessages:	4,
	messagewnd:		null,
	friendsWnd:		null,
	teaserWnd:		null,
	hilfeShown:		false,
	numMessages:	0,
	numItems:		0,
	lockMessageWnd:	false,

	initialize: function(container)
	{
        if($(container) == null) return null;

		this.createWnd(container);

		//Messages-Wnd erstellen und Scrollbuttons registrieren
		this.messagewnd = new HorizontalNaviCtrl('PGAMessagesClient', 'PGAMessagesClientWnd', 'PGAMessagesWnd');
		this.messagewnd.registerScrollDownButton('PGAMessagesButtonDown');
		this.messagewnd.registerScrollUpButton('PGAMessagesButtonUp');
	},

	createItem: function(itemdata,ingroup)
	{
		var html = '';
		var icon = '';
		var idcode = '';

		idcode = itemdata['message_id'];
		if (itemdata['numelements'] > 1) {
			idcode = itemdata['sendercode'];
		}

		if ( (itemdata['type_id'] == 1) | (itemdata['type_id'] == 3)  | (itemdata['type_id'] == 8) ) {
			icon = '<div class="PGAIcon" id="PGAIcon_' + idcode + '" imageurl="' + itemdata['imageurl'] + '"><a href="https://login.4players.de/profile.php/de/4players/' + itemdata['from_id'] + '/profile/" title="Profil von ' + itemdata['sender'] + '" onclick="void(0);"><img src="' + itemdata['imageurl'] + '"></a></div>';
		} else if (itemdata['type_id'] == 2) {
			if (itemdata['imageurl'] != null && itemdata['imageurl'] != '') {
				itemdata['imageurl'] = itemdata['imageurl'].replace(/http:\/\/static\.login\.4players\.de/, 'https://login.4players.de');
				icon = "<div class='PGAIcon' id='PGAIcon_" + idcode + "' imageurl='" + itemdata["imageurl"] + "'><img src='" + itemdata["imageurl"] + "'></div>";
			}
		} else {
			if (itemdata['imageurl'] != null && itemdata['imageurl'] != '') {
				icon = "<div class='PGAIcon' id='PGAIcon_" + idcode + "' imageurl='" + itemdata["imageurl"] + "'><img src='" + itemdata["imageurl"] + "'></div>";
			}
		}

		var targeturl = '';
		if (itemdata['type_id'] == 2) {
			targeturl = itemdata['text'].match(/id=\"WatchlistLink\" href=\"(http\:\/\/www.4players.de\/4players.php\/spielinfo\/Allgemein\/\d+\/)/);
			targeturl = targeturl[1];
		}

		if (itemdata["numelements"] > 1)
		{
			html = "<div class='PGAMessageGroup' id='PGAMessageGroup_" + itemdata["sendercode"] + "' onclick='pga.showGroupMessages(\"" + itemdata["sender"] + "\",\"" + itemdata["sendercode"] + "\");'>" + icon + "<div class='PGACaption'>" + itemdata["sender"] + "</div><div class='PGAVorschau'>Gruppe: <span id='PGAMessageGroupNumElements_" + itemdata["sendercode"] + "'>" + itemdata["numelements"] + "</span> Elemente</div><div class='PGAMessageButtons'><div class='PGAMessageButtonClose'></div><div class='PGAMessageButtonExpand'></div></div></div>";
		}
		else
		{
			html = "<div class='PGAMessage' sendercode='" + itemdata["sendercode"] + "' ingroup='" + ingroup + "' from_id='" + itemdata["from_id"] + "' to_id='" + itemdata["to_id"] + "' type_id='" + itemdata["type_id"] + "' targeturl='" + targeturl + "' id='PGAMessage_" + itemdata["message_id"] + "' onclick='pga.onMessageClicked(" + itemdata["message_id"] + ")'>" + icon + "<div class='PGACaption'>" + itemdata["sender"] + "</div><div class='PGAVorschau'>" + itemdata["subject"] + "</div><div class='PGAMessageButtons'><div class='PGAMessageButtonClose' onclick='pga.markMessageAsRead(" + itemdata["message_id"] + ");Event.stop(event);'></div></div></div>";
		}

		return html;
	},

	loadMessages: function(type_id)
	{
		var self = this;
		var now = new Date();
		var time = now.getTime();
		new Ajax.Request(PGAInterfaceURL, {
			method: 'get',
			evalJSON: 'force',
			parameters: {
				TYPE:	 'loadmessages',
				GROUPED: 'true',
				time: time
			},
		  	onSuccess: function(transport) {
		  		var json = transport.responseJSON;
		  		var i;
		  		var html = "";
				html += "<div class='PGAScrollContainer'>";
				html += "	<div id='PGAMessagesLevel0Content' class='PGAScrollContent'>";
				var nummessages = 0;
		  		for (i=0; i < json.length; i++) {
		  			nummessages += parseInt(json[i]['numelements']);
		  			html += self.createItem(json[i], 0);
		  		}
				html += "	<div class='PGATopShadow'></div>";
				html += "	</div>";
				html += "</div>";

				self.messagewnd.replaceContent(html, json.length, 0);
				self.onNumMessagesChanged(nummessages, json.length);
		  	}
		});

		setTimeout(function(){self.loadMessages()},30000);
	},

	callFunction: function(funcname,params,callfunc)
	{
		var url = PGAInterfaceURL + "&TYPE=" + funcname;
		if (params != "")
		{
			url += "&" + params;
		}

		var self = this;

		var now = new Date();
		var time = now.getTime();
		new Ajax.Request(url, {
			method: 'get',
			evalJSON: 'force',
			parameters: {
				time: time
			},
		  	onSuccess: function(transport) {
		  		var json = transport.responseJSON;
		  		callfunc(json);
		  	}
		});
	},

	onMessageRead: function(message_id)	{
		var ingroup = $('PGAMessage_' + message_id).getAttribute('ingroup');
		var sendercode = $('PGAMessage_' + message_id).getAttribute('sendercode');

		this.messagewnd.onItemRemoved();
		if (ingroup == 1) {
			if (this.messagewnd.getNumItemsShown() <= 0) {
				//Diese Nachricht war die letzte in der Gruppe, also zurück zur Hauptliste und Gruppe schlieï¿½en
				this.numItems -= 1;
				this.hideGroupMessages();
				new Effect.SwitchOff($('PGAMessageGroup_' + sendercode));
			} else {
				//Die Gruppe in der Hauptliste aktualisieren (Anzahl Elemente)
				$('PGAMessageGroupNumElements_' + sendercode).innerHTML = this.messagewnd.getNumItemsShown();
			}
		} else {
			this.numItems -= 1;
		}
		this.onNumMessagesChanged(this.numMessages - 1, this.numItems);
		this.messagewnd.updateScrollButtons();
	},

	// Verwaltet Änderungen an der Nachrichten-Anzahl
	onNumMessagesChanged: function(numMessages, numItems) {
		this.adaptMessageWndSize(numItems);

		if (fusionLoginBox != null) {
			 fusionLoginBox.onNumMessagesChanged(numMessages);
		}
		this.numMessages = numMessages;
		this.numItems = numItems;
	},

	// passt die Grï¿½ï¿½e des Message-Windows an Anzahl der übergebenen Objekte an
	adaptMessageWndSize: function(num, showToolbar) {
		if (typeof showToolbar == 'undefined') {
			showToolbar = false;
		}
		if (typeof num == 'undefined') {
			num = this.showMessages;
		}
		if (num > this.showMessages) {
			num = this.showMessages;
		}
		if (!this.lockMessageWnd) {
			if (showToolbar) {
				this.messagewnd.setHeight(num * 43 + 23);
			} else {
				this.messagewnd.setHeight(num * 43);
			}
		}
	},

	markMessageAsRead: function(message_id)
	{
		var self = this;
		this.callFunction("markmessageasread",
						  "MESSAGEID=" + message_id,
						  function(result) {
						      if (result == true)
						  	  {
						  		  new Effect.SwitchOff($('PGAMessage_' + message_id));
								  //self.onMessageRead(message_id);
						  	  }
						  });
	},

	addFriend: function(friendpid, message_id)
	{
		var self = this;

		this.callFunction("addfriend",
						  "FRIENDPID=" + friendpid,
						  function(result) {
						      if (result == true)
						  	  {
						  		  self.friendsWnd.update();
								  self.markMessageAsRead(message_id);
								  self.messagewnd.prevLevel();
						  	  }
						  });
	},

	denyFriend: function(friendpid, message_id)
	{
		var self = this;
	  	self.markMessageAsRead(message_id);
		self.messagewnd.prevLevel();
	},

	resetMessageIcon: function(idcode)
	{
		var icon = $('PGAIcon_' + idcode);
		if (icon)
		{
			icon.innerHTML = "<img src='" + icon.getAttribute('imageurl') + "'>";
		}
	},

	showLoadIcon: function(idcode)
	{
		var icon = $('PGAIcon_' + idcode);
		if (icon)
		{
			icon.innerHTML = "<img class='PGALoader' src='" + PGAImageURL + "ajaxloader_msg.gif'>";
		}
	},

	showMessageText: function(message_id)
	{
		this.showLoadIcon(message_id);

		var self = this;
		this.callFunction("getmessagetext",
						  "MESSAGEID=" + message_id,
						  function(result)
						  {
						  	  //Load Icon verstecken
						  	  self.markMessageAsRead(message_id);

						      var html = "";
							  html += "<div class='PGAToolbar'><div class='PGAToolbarButtonBack' onclick='pga.messagewnd.prevLevel();pga.onMessageRead(" + message_id + ");'></div><div class='PGACaption'>" + result["subject"] + "</div></div>";
							  html += "<div class='PGAScrollContainer'>";
							  html += "  <div class='PGAScrollContent PGAMessagesText'><pre>" + result["text"] + "</pre></div>";
							  html += "</div>";
							  html += "<div class='PGAMessagesProminentButtons'><div class='PGAMessageButtonAntworten' onclick=\"document.location.href='https://login.4players.de/messages.php/de/4players/send/reply/" + message_id + "/inbox/'\"></div><div class='PGAMessageButtonWeiterleiten' onclick=\"document.location.href='https://login.4players.de/messages.php/de/4players/send/forward/" + message_id + "/inbox/'\"></div></div>"
							  self.messagewnd.nextLevel(html);
							  self.messagewnd.setHeight(192);
						  });
	},

	acceptGameInvitation: function(invokeurl)
	{
		document.location.href = invokeurl;
	},

	showSpielEinladung: function(message_id)
	{
		this.showLoadIcon(message_id);

		var self = this;
		this.callFunction("getspieleinladung",
						  "MESSAGEID=" + message_id,
						  function(result)
						  {
						  	  //Load Icon verstecken
						  	  self.markMessageAsRead(message_id);

						      var html = "";
							  html += "<div class='PGAToolbar'><div class='PGAToolbarButtonBack' onclick='pga.messagewnd.prevLevel();pga.onMessageRead(" + message_id + ");'></div><div class='PGACaption'>" + result["subject"] + "</div></div>";
							  html += "<div class='PGAScrollContainer'>";
							  html += "  <div class='PGAScrollContent PGAMessagesText'><pre>" + result["text"] + "</pre></div>";
							  html += "</div>";
							  html += "<div class='PGAMessagesProminentButtons'><div class='PGAMessageButtonAnnehmen' onclick=\"pga.acceptGameInvitation('" + result["invokeurl"] + "');\"></div><div class='PGAMessageButtonAblehnen' onclick='pga.messagewnd.prevLevel();pga.onMessageRead(" + message_id + ");'></div></div>"
							  self.messagewnd.nextLevel(html);
							  self.messagewnd.setHeight(192);
						  });
	},

	toggleHilfe: function()
	{
		if (this.hilfeShown)
		{
			this.hideHilfe();
			this.hilfeShown = false;
		}
		else
		{
			this.showHilfe();
			this.hilfeShown = true;
		}
	},

	showHilfe: function()
	{
		$('PGAHilfe').show();
		$('PGAHilfeButton').src = PGAImageURL + "button_hilfe_on.png";
		new Effect.Appear('PGAHilfeContent',{duration:0.45});
		new Effect.Move('PGAHilfe',{y:70,x:433,mode:'absolute',duration:0.35});
	},

	hideHilfe: function()
	{
		$('PGAHilfeButton').src = PGAImageURL + "button_hilfe.png";
		new Effect.Fade('PGAHilfeContent',{duration:0.15});
		new Effect.Move('PGAHilfe',{y:70,x:225,mode:'absolute',duration:0.35});
	},

	onMessageClicked: function(message_id)
	{
		var type_id = $('PGAMessage_' + message_id).getAttribute('type_id');
		var from_id = $('PGAMessage_' + message_id).getAttribute('from_id');

		if (type_id == 2)
		{
			var targeturl = $('PGAMessage_' + message_id).getAttribute('targeturl');
			if (targeturl != "")
			{
				var self = this;
				this.markMessageAsRead(message_id);
				setTimeout(function(){self.jump(targeturl)},1000);
			}
		}
		else if (type_id == 3)
		{
			//Freundeseinladung
			var html = "";
			html += "<div class='PGAToolbar'><div class='PGAToolbarButtonBack' onclick='pga.messagewnd.prevLevel()'></div><div class='PGACaption'>Freundeseinladung annehmen?</div></div>";
			html += "<div class='PGAScrollContainer'>";
			html += "<div class='PGAMessagesText'>Wenn Du die Einladung annimmst, kannst Du fortan sehen, ob Dein Freund online ist, aber auch umgekehrt! Ihr könnt schnell und einfach Messages austauschen.</div>";
			html += "<div class='PGAMessagesProminentButtons'><div class='PGAMessageButtonAnnehmen' onclick='pga.addFriend(" + from_id + "," + message_id + ");'></div><div class='PGAMessageButtonAblehnen' onclick='pga.denyFriend(" + from_id + "," + message_id + ");'></div><!--<div class='PGAMessageButtonBlockieren'></div>--></div>"
			html += "</div>";
			this.messagewnd.nextLevel(html);
		}
		else if (type_id == 6)
		{
			//Spieleinladung
			this.showSpielEinladung(message_id);
		}
		else
		{
			this.showMessageText(message_id);
		}
	},

	makeShortMiddle: function(name,maxlength)
	{
		if (name.length>maxlength)
		{
			return name.substring(0,(maxlength/2)-1) + " ... " + name.substring(name.length-(maxlength/2)-1,name.length);
		}

		return name;
	},

	makeShort: function(name,maxlength)
	{
		if (name.length > maxlength)
		{
			return name.substring(0,maxlength-2) + '...';
		}

		return name;
	},

	jump: function(url)
	{
		document.location.href = url;
	},

	hideGroupMessages: function()
	{
		this.messagewnd.prevLevel();
	},

	showGroupMessages: function(sender, sendercode)
	{
		this.showLoadIcon(sendercode);

		var self = this;
		var now = new Date();
		var time = now.getTime();
		new Ajax.Request(PGAInterfaceURL, {
			method: 'get',
			evalJSON: 'force',
			parameters: {
				TYPE:	 "loadmessages",
				GROUPED: "false",
				SENDER:	 sender,
				time: time
			},
		  	onSuccess: function(transport) {
		  		self.resetMessageIcon(sendercode);
				var json = transport.responseJSON;
		  		var i;
		  		var html = "";
				html += "<div class='PGAToolbar'><div class='PGAToolbarButtonBack' onclick='pga.hideGroupMessages()'></div><div class='PGACaption'>" + sender + "</div></div>";
				html += "<div class='PGAScrollContainer'>";
				html += "	<div id='PGAMessagesLevel1Content' class='PGAScrollContent'>";

		  		for (i = 0; i < json.length; i++) {
	  				html += self.createItem(json[i], 1);
		  		}
				html += "	<div class='PGATopShadow'></div>";
				html += "	</div>";
				html += "</div>";

				self.messagewnd.nextLevel(html, json.length);
		  	}
		});
	},

	createWnd: function(container)
	{
        if (document.getElementById(container) == null) {
        	return null;
        }

		var html = '';
		html += '<div id="PGAModule_Messages">';
//		html += '	<div class="PGAHeadline"><div class="PGACaption">Persönliche Nachrichten</div><div class="PGAHeadlineButtons"><img id="PGAHilfeButton" onclick=\'pga.toggleHilfe()\' src="' + PGAImageURL + 'button_hilfe.png"></div></div>';
		html += '	<div class="PGAHeadline"><div class="PGACaption">Persönliche Nachrichten</div><div class="PGAHeadlineButtons"><div class="PGAMessageButtonClose" onclick="pga.hidePGA();"></div></div></div>';
		html += '	<div id="PGAMessagesClient"';
		html += '	</div>';
		html += '</div>';
		html += '<div id="PGAMessagesToolbar" class="PGAToolbar">';
		html += '	<div id="PGAMessagesGoTo" class="PGAButtonGoTo" onclick=\'$("PGAMessagesPopupGoTo").show()\'></div>';
		html += '	<div id="PGAMessagesPopupGoTo" style="display:none" onmouseover=\'$("PGAMessagesPopupGoTo").show()\' onmouseout=\'$("PGAMessagesPopupGoTo").hide();\'>';
		html += '		<ul class="PGAPopUp">';
		html += '			<li><a href="https://login.4players.de/messages.php/de/4players/inbox/0/">Posteingang</a></li>';
		html += '			<li><a href="https://login.4players.de/messages.php/de/4players/outbox/0/">Postausgang</a></li>';
		html += '			<li><a href="https://login.4players.de/messages.php/de/4players/archive/0/">Archiv</a></li>';
		html += '			<li><a href="https://login.4players.de/messages.php/de/4players/trash/0/">Mülleimer</a></li>';
		html += '			<li><a href="https://login.4players.de/messages.php/de/4players/send/">Neue&nbsp;Nachr.</a></li>';
		html += '		</ul>';
		html += '	</div>';
		html += '	<div id="PGAMessagesButtonUp" onclick="pga.scrollMessagesUp()" class="PGAButtonUp"></div>';
		html += '	<div id="PGAMessagesButtonDown" onclick="pga.scrollMessagesDown()" class="PGAButtonDown"></div>';
		html += '</div>';
		html += '<div id="PGAModule_Gadgets"></div>';
		html += '<div id="PGATeaserToolbar" class="PGAToolbar">';
//		html += '	<div id="PGATeaserGadgets" class="PGAButtonGadgets" onclick=\'$("PGATeaserPopupGadgets").show()\'></div>';
//		html += '	<div id="PGATeaserPopupGadgets" style="display:none" onmouseover=\'$("PGATeaserPopupGadgets").show()\' onmouseout=\'$("PGATeaserPopupGadgets").hide()\'>';
//		html += '		<ul class="PGAPopUp">';
//		html += '			<li onclick="pga.teaserWnd.type=\'teaser\';pga.teaserWnd.update();$(\'PGATeaserPopupGadgets\').hide()">4P-Tests</li>';
//		html += '			<li onclick="pga.teaserWnd.type=\'charts\';pga.teaserWnd.update();$(\'PGATeaserPopupGadgets\').hide()">Charts</li>';
//		html += '			<li>Meine Stats</li>';
//		html += '		</ul>';
//		html += '	</div>';
//		html += '	<div class="PGAButton" onclick="pga.teaserWnd.showMediaControlCharts();">Charts</div>';
		html += '	<div class="PGAButton" onclick="pga.teaserWnd.type=\'watchlist\';pga.teaserWnd.update();">Watchlist</div>';
		html += '	<div class="PGAButton" onclick="pga.teaserWnd.type=\'teaser\';pga.teaserWnd.update();">Tests</div>';
		html += '</div>';
		html += '<div id="PGAModule_Friends"></div>';

        if (document.getElementById(container) == null) {
            var div = document.createElement('div');
            div.setAttribute('id',container);
            document.body.appendChild(div);
        }

		$(container).innerHTML = html;


		//Vom User eingestellte Plugins
		this.teaserWnd = new PGATeaser();
		this.teaserWnd.createWnd("PGAModule_Gadgets");

		this.friendsWnd = new PGAFriends();
		this.friendsWnd.createWnd("PGAModule_Friends");
	},

	showPGA: function()
	{
		new Effect.SlideDown('PGARollDown', {duration: 0.5});
		this.visible = true;
		//Daten aktualisieren
		this.loadMessages(0);
		this.friendsWnd.update();
		this.teaserWnd.update();
	},

	hidePGA: function()
	{
		if ($('PGAHilfe')) {$('PGAHilfe').hide();}
		new Effect.Fade('PGARollDown');
		this.visible = false;
	}
}

Effect.ScaleTo = function(element, toWidth, toHeight) {
var ScaleToWidthPercent = new Number();
var ScaleToHeightPercent = new Number();
if (isNaN(toWidth) != true && toWidth != false) {
ScaleToWidthPercent = (100 * toWidth / ($(element).style.width).split("px")[0]);
} else { ScaleToWidthPercent = 100;}
if (isNaN(toHeight) != true && toHeight != false) {
ScaleToHeightPercent = (100 * toHeight / ($(element).style.height).split("px")[0]);
} else { ScaleToHeightPercent = 100;}
return (new Effect.Scale(element, ScaleToWidthPercent, {scaleY:false}),
new Effect.Scale(element, ScaleToHeightPercent, {scaleX:false}));
};


function initPGA()
{
	pga = new PersonalGamerAssistent("PGAMainWnd");
}
var pga = null;
Event.observe(window, 'load', initPGA);
;
//htdocs/fusion/pga/pgateaser.js\n//jsfileid:9a1a06ba340d3fbe9df01ceb549c3a5a-htdocs/fusion/pga/pgateaser.js
//lastchange:2023-02-28 16:21:30
var PGATeaser = Class.create();
PGATeaser.prototype = {
	container:  null,
	type:		'teaser',
	clientWnd:  null,
	currentSystem: 'PC-CDROM',

	initialize: function()
	{
		//not default anymore
		//this.type = 'charts';
	},

	updateTeaserItems: function(data)
	{
		var html = "";
		for (var i=0;i<data.length;i++)
		{
			var spielname = data[i]["spielname"];
			var spielnamekurz = '';
			if (spielname.length > 18)
			{
				spielnamekurz = spielname.substring(0,9) + " &hellip; " + spielname.substring(spielname.length-9,spielname.length);
			} else {
				spielnamekurz = spielname;
			}
			html += '		<div class="PGATeaserImage">';
			//html += '			<div class="PGATeaserImageContainer" onmouseover=\'new Effect.Scale(this,150,{scaleFromCenter:true, duration: 0.15});\' onmouseout=\'new Effect.Scale(this,66.6,{scaleFromCenter:true, duration: 0.15, scaleMode: {orginalHeight:80, originalWidth:60}});\'>';
			html += '			<div class="PGATeaserImageContainer">';
			html += '			<a href="' + data[i]['url'] + '" title="' + spielname +'"><img id="PGATeaserImage_' + data[i]['spielid'] + '" src="' + data[i]['imageurl'] + '" alt="' + spielname + '"><br>';
			html += '			<div class="PGATeaserText">' + spielnamekurz + '</div></a>';
			html += '			</div>';
			html += '		</div>';
		}

//		pga.teaserWnd.clientWnd.replaceContent(html);
		pga.teaserWnd.clientWnd.container.innerHTML = '';
		pga.teaserWnd.clientWnd.nextLevel(html);
	},

	showKonsolenCharts: function()
	{
		pga.teaserWnd.clientWnd.setHeight(130);
		var html = "";
		html += "<div class='PGAToolbar'><div class='PGAToolbarButtonBack' onclick='pga.teaserWnd.clientWnd.prevLevel()'></div><div class='PGACaption'>Konsolen-Verkaufscharts</div></div>";
		html += "<div class='PGACharts'><img src='" + PGAImageURL + "charts.png'></div>";
		pga.teaserWnd.clientWnd.nextLevel(html);
	},

	hideMediaControlCharts: function()
	{
		//new Effect.Scale('PGATeaserClient',100,{scaleFrom: 140, scaleContent: false, scaleX: false, duration: 0.5, scaleMode: {originalHeight: 130}});
		pga.teaserWnd.clientWnd.setHeight(130);
		pga.teaserWnd.clientWnd.prevLevel();
	},

	loadCharts: function(system)
	{
		if ($('PGAChartSelectButton_' + system).hasClassName('PGAActive'))
		{
			//Bereits aktiv;
			return;
		}

		$('PGAChartSelectButton_' + this.currentSystem).removeClassName('PGAActive');
		this.currentSystem = system;

		//Loader anzeigen
		var oldcontent = $('PGAChartSelectButton_' + this.currentSystem).innerHTML;
		$('PGAChartSelectButton_' + this.currentSystem).innerHTML = "<img class='PGALoader' src='" + PGAImageURL + "ajaxloader_msg.gif'>";

		var self = this;
		//pga.callFunction("loadcharts",
		//				 "SYSTEM=" + system,
		//				 function(result)
		//				 {
		//				 	var html = "<ol>";
		//				 	for (var i=0;i<result.length;i++)
		//				 	{
		//					 	html += '<li>(' + result[i]['lwpos'] + ') <a href="' + result[i]['url'] + '" title="' + result[i]['name'] + '">' + pga.makeShort(result[i]['name'],20) + '</a></li>';
		//				 	}
		//				 	html += "</ol>";
        //
		//				 	$('PGAChartsCharts').update(html);
		//				 	$('PGAChartSelectButton_' + self.currentSystem).update(oldcontent);
		//				 }
		//				 );

		$('PGAChartSelectButton_' + this.currentSystem).addClassName('PGAActive');
	},

	showMediaControlCharts: function() {
		if (Prototype.Browser.IE || Prototype.Browser.Opera) {
			pga.teaserWnd.clientWnd.setHeight(166);
		} else {
			pga.teaserWnd.clientWnd.setHeight(160);
		}

		var html = '';
//		html += '<div class="PGAToolbar"><div class="PGAToolbarButtonBack" onclick="pga.teaserWnd.hideMediaControlCharts()"></div><div class="PGACaption">4P-Store Charts</div></div>';
		html += '<div id="PGAChartsPlattformList">';
		html += '	<div class="PGAListItem" onclick="pga.teaserWnd.loadCharts(\'PC-CDROM\')" id="PGAChartSelectButton_PC-CDROM">PC</div>';
		html += '	<div class="PGAListItem" onclick="pga.teaserWnd.loadCharts(\'PlayStation2\')" id="PGAChartSelectButton_PlayStation2">PS2</div>';
		html += '	<div class="PGAListItem" onclick="pga.teaserWnd.loadCharts(\'PlayStation3\')" id="PGAChartSelectButton_PlayStation3">PS3</div>';
		html += '	<div class="PGAListItem" onclick="pga.teaserWnd.loadCharts(\'360\')" id="PGAChartSelectButton_360">360</div>';
		html += '	<div class="PGAListItem" onclick="pga.teaserWnd.loadCharts(\'Wii\')" id="PGAChartSelectButton_Wii">Wii</div>';
		html += '	<div class="PGAListItem" onclick="pga.teaserWnd.loadCharts(\'PSP\')" id="PGAChartSelectButton_PSP">PSP</div>';
		html += '	<div class="PGAListItem" onclick="pga.teaserWnd.loadCharts(\'NDS\')" id="PGAChartSelectButton_NDS">NDS</div>';
		html += '</div>';
		html += '<div id="PGAChartsCharts">';
		html += '</div>';

		pga.teaserWnd.clientWnd.container.innerHTML = '';
		pga.teaserWnd.clientWnd.nextLevel(html);

		$('PGATeaserHeadline').update('4P-Store Charts');
		this.loadCharts(this.currentSystem);
	},

	updateCharts: function() {
		var html = "";
		html += "<div id='PGAChartsList'>";
//		html += "	<div class='PGAListItem' onclick='pga.teaserWnd.showKonsolenCharts();'>Konsolen-Charts</div>";
		html += "	<div class='PGAListItem' onclick='pga.teaserWnd.showMediaControlCharts();'>4P-Store Charts</div>";
		html += "	<div style='clear:both'></div>";
		html += "</div>";
		this.clientWnd.replaceContent(html);
		$('PGATeaserHeadline').innerHTML = "Charts";
	},

	showWatchlist: function(data) {
		var html = '';
		var gameName = 'Diesen Namen gibt es nicht!!!';
		var height = 0;
		for (i = 0, j = data.length; i < j; i++) {
			if ((gameName != data[i]['nameshort']) && (gameName != data[i]['name'])) {
				gameName = data[i]['nameshort'] ? data[i]['nameshort'] : data[i]['name'];
				html += '<div class="WatchlistGame">' +
						'	<a href="//www.4players.de/4players.php/spielinfo/Allgemein/' + data[i]['spielid'] + '/' + gameName + '.html">' + gameName + '</a>' +
						'</div>';
				height += 20;
			}
			var headline = data[i]['teaser'] ? data[i]['teaser'] : data[i]['headline'];
			var href = (data[i]['weiterlesen'] != '') ? data[i]['weiterlesen'] : '//www.4players.de/4players.php/spielinfonews/Allgemein/' + data[i]['spielid'] + '/' + data[i]['newsid'] + '/' + gameName + '.html';
			html += '<div id="WatchlistItem' + data[i]['newsid'] + '" class="WatchlistItem">' +
					'	<a href="' + href + '" title="' + headline + '">' +	headline.truncate(30, '...') + '</a>' +
					'	<div id="WatchListClose' + data[i]['newsid'] + '" class="PGAWatchlistButtonClose WatchlistSpielid' + data[i]['spielid'] + '"></div>' +
					'</div>';
			height += 18;
		}
		if (data.length == 0) {
			html += '<div class="WatchlistNoItem">Es gibt keine Neuigkeiten auf deiner Watchlist.</div>';
			height += 36;
		}
		html += '<div class="WatchlistManage">( <a href="https://login.4players.de/go/watchlist.php">Watchlist verwalten</a> )</div>';
		//this.clientWnd.replaceContent(html);
		pga.teaserWnd.clientWnd.setHeight(height + 20);
		pga.teaserWnd.clientWnd.nextLevel(html);
		$$('.PGAWatchlistButtonClose').each(function(e) {
			var newsid = e.id.replace(/WatchListClose/, '');
			var spielid = e.className.replace(/PGAWatchlistButtonClose WatchlistSpielid/, '');
			e.observe('click', function() {
				Effect.SwitchOff('WatchlistItem' + newsid);
				new Ajax.Request('/common/fusion/ajax/fusionproxy.php', {
					method: 'post',
		            parameters: {
		                COMMAND: 'getstatus',
		                SPIELID: spielid,
		                NEWSID: newsid,
						SCRIPTNAME: 'watchlistinfo'
		            }
				});
			});
		});
	},

	update: function() {
		if (this.type == 'teaser') {
			$('PGATeaserHeadline').update('Die aktuellen 4Players-Tests');
			this.showLoader();
			if (pga.teaserWnd.clientWnd.currentLevel > 1) {
				pga.teaserWnd.clientWnd.setHeight(130);
			}
			pga.callFunction('loadcontentteaser', '', this.updateTeaserItems);
		} else if (this.type == 'watchlist') {
			$('PGATeaserHeadline').update('Neues auf der Watchlist');
			this.showLoader();
			pga.callFunction('loadwatchlist', '', this.showWatchlist);
		} else if (this.type == 'charts') {
			this.showMediaControlCharts();
		}
	},

	showLoader: function() {
		pga.teaserWnd.clientWnd.replaceContent('<img style="margin:10px;" class="PGALoader" src="' + PGAImageURL + 'ajaxloader_msg.gif">', 0);
	},

	createWnd: function(container)
	{
        if($(container) == null) return null;

		this.container = $(container);

        this.container.innerHTML = this.createHTML();

		this.clientWnd = new HorizontalNaviCtrl('PGATeaserClient','PGATeaserClientWnd','');
	},

	createHTML: function()
	{
		var html = "";

		html += "	<div class='PGAHeadline'><div class='PGACaption' id='PGATeaserHeadline'>Heute im 4Players-Magazin</div><div class='PGAHeadlineButtons'></div></div>";
		html += "	<div id='PGATeaserClient' class='PGAScrollContainer'>";
		html += "	</div>";

		return html;
	}
};
//htdocs/fusion/pga/pgafriends.js\n//jsfileid:5daac2971ae7d1393f34509b0a9da638-htdocs/fusion/pga/pgafriends.js
//lastchange:2023-02-28 16:21:30
var PGAFriends = Class.create();
PGAFriends.prototype = {
	container:	null,
	clientWnd: null,

	initialize: function()
	{
	},

	createWnd: function(container)
	{
		if($(container) == null) return null;
		this.container = $(container);
		this.container.innerHTML = this.createHTML();

		this.clientWnd = new HorizontalNaviCtrl('PGAFriendsClient', 'PGAFriendsClientWnd', '', 46);
		this.clientWnd.registerScrollDownButton('PGAFriendsButtonDown');
		this.clientWnd.registerScrollUpButton('PGAFriendsButtonUp');
	},

	onFriendClicked: function(friendpid)
	{
		var self = this;
		var now = new Date();
		var time = now.getTime();
		new Ajax.Request(PGAInterfaceURL, {
			method: 'get',
			parameters: {
				TYPE:	   "loadprofile",
				FRIENDPID: friendpid,
				time: time
			},
		  	onSuccess: function(transport,json) {
		  		if (json == null) json = JSON.parse(transport.responseText);
		  		var html = "";
				html += "<div class='PGAToolbar'><div class='PGAToolbarButtonBack' onclick='pga.friendsWnd.clientWnd.prevLevel()'></div><div class='PGACaption'>Details zu " + json["nickname"] + "</div></div>";
				html += "<div id='PGAFriendsInfo'>";
				html += "	<img src='" + json["photo_url"] + "' class='PGAFriendsPhoto'>";
				html += "	<div class='PGAListItem' onclick='pga.friendsWnd.onSendMessage(" + friendpid + ");'>Nachricht schicken</div>";
				html += "	<div class='PGAListItem' onclick='pga.friendsWnd.onShowProfile(" + friendpid + ");'>Profil ansehen</div>";
				html += "	<div class='PGAListItem' onclick='pga.friendsWnd.onShowGuestBook(" + friendpid + ");'>Zum Gästebuch</div>";
				html += "	<div style='clear:both'></div>";
				html += "</div>";
				self.clientWnd.nextLevel(html);
		  	}
		});
	},

	onShowProfile: function(friendpid)
	{
		document.location.href = "https://login.4players.de/profile.php/de/4players/" + friendpid + "/profile/";
	},

	onShowGuestBook: function(friendpid)
	{
		document.location.href = "https://login.4players.de/guestbook.php/de/4players/" + friendpid + "/";
	},

	onSendMessage: function(friendpid)
	{
		var self = this;
		var now = new Date();
		var time = now.getTime();
		new Ajax.Request(PGAInterfaceURL, {
			method: 'get',
			parameters: {
				TYPE:	   "loadprofile",
				FRIENDPID: friendpid,
				time: time
			},
		  	onSuccess: function(transport,json) {
		  		if (json == null) json = JSON.parse(transport.responseText);
		  		var html = "";
				html += "<div class='PGAToolbar'><div class='PGAToolbarButtonBack' onclick='pga.friendsWnd.clientWnd.prevLevel()'></div><div class='PGACaption'>Nachricht an " + json["nickname"] + "</div></div>";
				html += "<div id='PGAFriendsSendMessage'>";
				html += "	<div id='PGAFriendsSendMessageTextContainer'><textarea id='PGAFriendsSendMessageText'></textarea></div>";
				html += "	<div class='PGAFriendsProminentButtons'><div class='PGAMessageButtonSenden' onclick='pga.friendsWnd.sendMessage(" + friendpid + ");'></div><div class='PGAMessageButtonAbbrechen' onclick='pga.friendsWnd.clientWnd.prevLevel()'></div></div>";
				html += "</div>";
				self.clientWnd.nextLevel(html);
		  	}
		});
	},

	sendMessage: function(friendpid)
	{
		var messageText = $('PGAFriendsSendMessageText').value;
		$('PGAFriendsSendMessageTextContainer').innerHTML = "<img src='" + PGAImageURL + "ajax-loader-big-white.gif'>";
		var self = this;
		var now = new Date();
		var time = now.getTime();
		new Ajax.Request(PGAInterfaceURL, {
			method: 'post',
			parameters: {
				TYPE:	 	"sendmessage",
				FRIENDPID:	friendpid,
				message: 	messageText,
				time: time
			},
		  	onSuccess: function(transport,json) {
		  		if (json == null) json = JSON.parse(transport.responseText);
				if (json == true)
				{
					self.clientWnd.prevLevel();
				}
				else
				{
					$('PGAFriendsSendMessageTextContainer').innerHTML = "Die Nachricht konnte aufgrund eines technischen Fehlers nicht verschickt werden. Das Entwickler-Team wurde informiert. Bitte versuche es später erneut!";
				}
		  	}
		});
	},

	update: function()
	{
		var self = this;
		var now = new Date();
		var time = now.getTime();
		new Ajax.Request(PGAInterfaceURL, {
			method: 'get',
			parameters: {
				TYPE:	 "loadfriends",
				GROUPED: "false",
				time: time
			},
		  	onSuccess: function(transport,json) {
		  		if (json == null) json = eval(transport.responseText);
		  		var i;
		  		var html = '';
				html += '<div class="PGAScrollContainer">';
				html += '	<div id="PGAFriendsList" class="PGAScrollContent">';
		  		for (i = 0; i < json.length; i++) {
					var status = 'Online';
					if (!json[i]['online']) status = 'Offline';
					html += '<div class="PGAListItem" onclick="pga.friendsWnd.onFriendClicked(' + json[i]['pid']+ ')"><div class="PGALed' + status + '"></div>' + json[i]['nickname'].truncate(12) + '</div>';
				}
				html += '		<div style="clear:both"></div>';
				html += '	</div>';
				html += '</div>';
				html += '<div style="clear:both"></div>';

				//$('PGAFriendsList').innerHTML = html;
				self.clientWnd.replaceContent(html);
		  	}
		});
	},

	createHTML: function()
	{
		var html = "";

		html += '<div class="PGAHeadline"><div class="PGACaption">Meine Freunde</div><div class="PGAHeadlineButtons"></div></div>';
		html += '	<div id="PGAFriendsClient">';
		html += '		<div class="PGAScrollContainer">';
		html += '			<div id="PGAFriendsList" class="PGAScrollContent"></div>';
		html += '		</div>';
		html += '		<div style="clear:both"></div>';
		html += '	</div>';
		html += '	<div id="PGAFriendsToolbar" class="PGAToolbar"><div class="PGAButtonMeinProfil" onclick="document.location.href=\'https://login.4players.de/go/myprofile.php\'"></div>'
		html += '	<div id="PGAFriendsButtonUp" class="PGAButtonUp"></div>'
		html += '	<div id="PGAFriendsButtonDown" class="PGAButtonDown"></div>'
		html += '</div>'

		return html;
	}
};
