// *-----------------------------------------------------------------------*
// | This file is part of the actSite, interacive Pages project.           |
// | Copyright (c) 2004-2009 Nemint (see authors). All rights reserved     |
// |                                                                       |
// | http://www.actSite.de, http://www.acsite.de/LICENCE.txt               |
// |                                                                       |
// | Änderungen sind erlaubt, solange wie dieser Copyright Hinweis         |
// | unverändert erhalten bleibt und die Lizenzbestimmungen beachtet       |
// | werden.                                                               |
// |                                                                       |
// | You may freely modify the source code under the terms of the License. |
// | Don`t edit, delete or modify this copyright header                    |
// |                                                                       |
// | $Id: actsite.js 48 2009-07-15 18:57:51Z nemint $                                                                 |
// *-----------------------------------------------------------------------*

/**
 *
 *
 * @copyright      (c) the authors
 * @author         Mesut Cftci <mc AT nemint DOT de>
 * @license        http://www.acsite.de/LICENCE.txt
 * @package        base_functions
 * @version        $Rev: 48 $, $Date:: 2009-07-15 20:57:51 #$
 * @todo
 */

var js = document.getElementsByTagName("html")[0].getElementsByTagName("script");
var my_URI_Path = js[js.length-1].src.replace("/extra/actsite.js","");
var myJS_URI_Path = my_URI_Path + "/extra";
document.write('<script language="JavaScript" type="text/JavaScript" src="' + myJS_URI_Path + '/mootools.js"></script>');
document.write('<script language="JavaScript" type="text/JavaScript" src="' + myJS_URI_Path + '/actsiteextra.js"></script>');
var my_actSiteMediaURL= my_URI_Path + '/media';
var actSiteCharset = 'utf-8';
var SmiliesA = new Array();
var DictionaryA = new Array();

//*********************************************************************************************
//***                     multiple calls to window.onload and window.unload                 ***
//*********************************************************************************************
window.onloadFunctions = new Array();
window.onunloadFunctions = new Array();

window.onloadAdd = function(func)
{
	if(typeof(func) == 'function')
	{
		window.onloadFunctions[window.onloadFunctions.length] = func;
	}
}
window.onunloadAdd = function(func)
{
	if(typeof(func) == 'function')
	{
		window.onunloadFunctions[window.onunloadFunctions.length] = func;
	}
}
if(typeof(window.onload) == 'function')
{
	window.onloadFunctions[window.onloadFunctions.length] = window.onload;
}
if(typeof(window.onunload) == 'function')
{
	window.onunloadFunctions[window.onunloadFunctions.length] = window.onload;
}
window.onload = function()
{
		for (var wj = 0; wj < window.onloadFunctions.length; wj++)
		{
			if(typeof(window.onloadFunctions[wj]) == 'function')
			{
				window.onloadFunctions[wj]();
			}
		}
}

window.onunload = function() {
	for (var wj = 0; wj <= window.onunloadFunctions.length; wj++)	{
		if(typeof(window.onunloadFunctions[wj]) == 'function') window.onunloadFunctions[wj]();
	}
}
//*********************************************************************************************
//***                                        Toggle Box                                     ***
//*********************************************************************************************
	function toggle_Box(box,thisID) {
		boxID = document.getElementById(box);
		if(boxID && boxID.style.display != 'none') {
			boxID.style.display = 'none';
			thisID.className = 'boxopenpic';
		}
		else if(boxID) {
			boxID.style.display = '';
			thisID.className = 'boxclosepic';
		}
	}
//*********************************************************************************************
//***                                        Body Onload                                    ***
//*********************************************************************************************
	function _body_onload(parse)  {
		try {
			LoadingOff();
			if(parse) {
				_parse_links();
			}
		}
		catch (e) {
			return false;
		}
	}
//*********************************************************************************************
//***                                      Body Onunload                                    ***
//*********************************************************************************************
	function _body_onunload()  {
		try {
			LoadingOn();
		}
		catch (e) {
			return false;
		}
	}
//*********************************************************************************************
//***                                        Links Parseing                                 ***
//*********************************************************************************************
	function _parse_links()  {
		if(document.getElementsByTagName && typeof(LoadingOn)=="function") {
			for(i=0;i<document.getElementsByTagName("a").length;i++) {
				node = document.getElementsByTagName("a")[i];
				link = node.getAttribute('href');
				onclick = node.getAttribute('onclick');
				target = node.getAttribute('target');
				if((onclick == null || onclick == '') && link.indexOf('#') == -1 && link.indexOf('javascript:') == -1) {
					node.onclick = function() {LoadingOnP();};
				}
			}
			for(i=0;i<document.getElementsByTagName("form").length;i++) {
				node = document.getElementsByTagName("form")[i];
				etarget = node.getAttribute('target');
				eonsubmit = node.getAttribute('onsubmit');
				if((etarget == null || etarget == '') && (eonsubmit == null || eonsubmit == '')) {
					node.onsubmit = function() {LoadingOnP(); node.submit();};
				}
			}
		}
	}
//*********************************************************************************************
//***                                     Unloading On                                     ***
//*********************************************************************************************
	function LoadingOnP()  {
		window.setTimeout('LoadingOff',9000);
		LoadingOn(); return;
	}
//*********************************************************************************************
//***                                     Unloading On                                     ***
//*********************************************************************************************
	function LoadingOn(target)
	{
		try
		{
			if(!target && document.getElementById("loaderDiv"))
			{
				document.getElementById("loaderDiv").style.display = "";
			}
			else if(target.document.getElementById("loaderDiv"))
			{
				target.document.getElementById("loaderDiv").style.display = "";
			}
			return;
		}
		catch (e)
		{
			return;
		}
	}
//*********************************************************************************************
//***                                     Unloading Off                                     ***
//*********************************************************************************************
	function LoadingOff(target)
	{
		try
		{
			if(!target && document.getElementById("loaderDiv"))
			{
				document.getElementById("loaderDiv").style.display = "none";
			}
			else if(target.document.getElementById("loaderDiv"))
			{
				target.document.getElementById("loaderDiv").style.display = "none";
			}
		}
		catch (e)
		{
			return;
		}
	}
//*********************************************************************************************
//***                                     Popup Window User                                     ***
//*********************************************************************************************
	function goUser(url,user,height,width,popup,name) {
		if(typeof(name) != 'string') {
			name = 'userpop';
		}
		if(typeof(popup) != 'string' && typeof(popup) != 'number') {
			popup = 0;
		}
		else {
			popup = parseInt(popup);
		}
		if(popup == 1) {
			Popup(url + user,height,width,name,1);
			return false;
		}
		else {
			return true;
		}
	}
//*********************************************************************************************
//***                                     Popup Window                                      ***
//*********************************************************************************************
	function Popup(url,height,width,name,popup,re,noscroll)  {
		Pop = false;
		if(typeof(noscroll) == 'number' && parseInt(noscroll) == 1) {
			noscroll = 'no';
		}
		else {
			noscroll = 'yes';
		}
		if(typeof(url) != 'string') {
			url = "";
		}
		if(typeof(re) != 'string' && typeof(re) != 'number') {
			re = 0;
		}
		else {
			re = parseInt(re);
		}
		if(!popup) {
			popup = null;
		}
		else if(typeof(popup) != 'string' && typeof(popup) != 'number') {
			popup = 0;
		}
		else {
			popup = parseInt(popup);
		}
		if(typeof(name) != 'string') {
			name = "Pop";
		}
		if(typeof(height) != 'string' && typeof(height) != 'number') {
			height = 500;
		}
		else {
			height = parseInt(height);
			if(height < 50) {
				height = 500;
			}
		}
		if(typeof(width) != 'string' && typeof(width) != 'number') {
			width = 550;
		}
		else {
			width = parseInt(width);
			if(width < 200) {
				width = 550;
			}
		}
		try {
			if(popup == 0) {
				location.href = url;
				return;
			}
			else if(popup == 1) {
				if(Pop = window.open(url, name, "height=" + height +",width=" + width + ",location=no,scrollbars=" + noscroll + ",menubars=no,toolbars=no,resizable=" + noscroll )) {
					Pop.resizeTo(width,height);
					var nwl = (screen.width - width) / 2;
					var nwh = (screen.height - height) / 2;
					Pop.moveTo(nwl,nwh);
					Pop.focus();
					Pop.focus();
				}
			}
			else if(Pop = window.open(url, name)) {
				Pop.focus();
				Pop.focus();
			}
		}
		catch (e) {
		}
		if(re == 1) {
			return Pop;
		}
	}
//*********************************************************************************************
//***                                      Get_Cookie                                       ***
//*********************************************************************************************
	function Get_Cookie( name ) {
		var start = document.cookie.indexOf( name + "=" );
		var len = start + name.length + 1;
		if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
			return null;
		}
		if ( start == -1 ) return null;
		var end = document.cookie.indexOf( ";", len );
		if ( end == -1 ) end = document.cookie.length;
		return unescape( document.cookie.substring( len, end ) );
	}
//*********************************************************************************************
//***                                       Element move                                       ***
//*********************************************************************************************
	function elementmove(el,xPos,yPos) {
		last = 0;
		if(document.getElementById(el)) {
			var x,y;
			if (self.pageYOffset) { // all except Explorer
				x = self.pageXOffset;
				y = self.pageYOffset;
			}
			else if (document.documentElement && document.documentElement.scrollTop) {// Explorer 6 Strict
				x = document.documentElement.scrollLeft;
				y = document.documentElement.scrollTop;
			}
			else if (document.body) {// all other Explorers
				x = document.body.scrollLeft;
				y = document.body.scrollTop;
			}
			document.getElementById(el).style.position = "absolute";
			if(y > last) {
				for(i=last;last+i<y;i++) {
					i2 = i + last;
					document.getElementById(el).style.top = i2 + 'px';
				}
				last = y;
			}
			else if (last > y) {
				for(i=last;last-i>=y;i--) {
					i2 = last - i;
					document.getElementById(el).style.top = i2 + 'px';
				}
				last = y;
			}
			document.getElementById(el).style.left = x + 'px';
			document.getElementById(el).style.top = y + 'px';
		}
	}
//*********************************************************************************************
//***                                        Sound Player                                    ***
//*********************************************************************************************
function playsound(file) {
	if(!document.getElementById("flashsoundplayer")) {
		var newLine = document.createElement("div");
		newLine.innerHTML = '';
		newLine.id = 'flashsoundplayer';
		document.body.appendChild(newLine);
	}
	document.getElementById("flashsoundplayer").innerHTML = '<object data="' + myJS_URI_Path + '/soundplayer.swf" type="application/x-shockwave-flash" width="0" height="0"><param name="movie" value="' + myJS_URI_Path + '/soundplayer.swf" /><param name="FlashVars" value="sound=' + myJS_URI_Path + "/" + file + '" /></object>';
}
function stopsound(typ) {
	if(!document.getElementById("flashsoundplayer")) {
		document.getElementById("flashsoundplayer").innerHTML = '';
	}
}
//*********************************************************************************************
//***                          Nemint Text-Scroller v1.1                                    ***
//***                 2004 Nemint, New Media Interactiv www.nemint.de                       ***
//***       Für private Nutzung kostenlos einsetzbar, solange dieser Kopfbereich            ***
//***                           unverändert erhalten bleibt                                 ***
//***     Für eine gewerbliche Nutzung setzen Sie sich bitte mit uns in Verbindung          ***
//*********************************************************************************************
var nemintScroller_objects = new Array();
//window.onresize = nemintScrollerGetPosition;
window.onloadAdd(nemintScrollerStart);

function nemintScrollerStart() {
	for (i=0;i<nemintScroller_objects.length;i++) {
		if(nemintScroller_objects[i]) {
			obj = nemintScroller_objects[i]['name'];
			if(obj) {
				obj.beginn();
				obj.update();
			}
		}
	}
}

function nemintScrollerGetPosition() {
	for (i=0;i<nemintScroller_objects.length;i++) {
		if(nemintScroller_objects[i]) {
			obj = nemintScroller_objects[i]['name'];
			if(obj) {
				obj.index = 0;
				obj.getPosition();
			}
		}
	}
}

function nemintScroller() {
	this.scrollLeft		= 1;
	this.scrollingText	= '';
	this.scrollingSpeed	= 10;
	this.scrollingSpeedUp	= 2;
	this.scrollerObjName	= '';
	this.stopScrollingOnMouseover = 1;
	this.heightTicker	= 20;
	this.widthTicker		= 400;
	this.marginTop		= 0;
	this.marginLeft		= 0;
	this.stopScrollingOnMouseover = 1;

	this.finetuningLeft	= 0;
	this.finetuningTop	= 0;

	this.bgcolor		= '';
	this.border		= '';
	this.bordercolor		= '';
	this.borderstyle		= 'solid';

	this.tmp		= '';
	this.i			= 0;
	this.i2			= 0;
	this.i3			= 0;
	this.index		= 0;
	this.positionTop	= 0;
	this.positionLeft	= 0;
	this.positionTopTicker	= 0;
	this.positionLeftTicker	= 0;

	this.realTickerText		= '';

	this.scrolling		= 1;
	this.heightRealTicker	= 20;
	this.widthRealTicker	= 400;
	this.widthAuto	= 0;
	this.endMarkerTop	= -50000;
	this.endMarkerLeft	= -50000;
	var zeit = new Date();
	var ms = Date.parse(zeit);
	this.info			= "infobereich";
	this.info2			= "infobereich2";
	this.elTicker			= "ticker" + Math.random();
	this.elTickerID			= "tickerID" + Math.random();
	this.elTickerInnen		= "tickerInnen" + Math.random();
	this.elTickerInnenText		= "tickerInnenText" + Math.random();
	this.elTickerInnenEnde		= "tickerInnenEnde" + Math.random();
	this.elTickerInnenAnfang	= "tickerInnenAnfang" + Math.random();
	this.elTicker			= this.elTicker.replace(/\W/ig,'');
	this.elTickerInnen		= this.elTickerInnen.replace(/\W/ig,'');
	this.elTickerInnenText		= this.elTickerInnenText.replace(/\W/ig,'');
	this.elTickerInnenEnde		= this.elTickerInnenEnde.replace(/\W/ig,'');
	this.elTickerInnenAnfang	= this.elTickerInnenAnfang.replace(/\W/ig,'');
	return this;
}

nemintScroller.prototype.Start = function(name) {
	if(document.getElementById) {
		document.write('<div id="' + this.elTicker + '">&nbsp;</div>');
		document.getElementById(this.elTicker).style.height = this.heightTicker + 'px';
		this.scrollerObjName	= name;
		objCount = nemintScroller_objects.length;
		nemintScroller_objects[objCount] = new Array();
		nemintScroller_objects[objCount]['name'] = this;
		nemintScroller_objects[objCount]['realname'] = name;
		nemintScroller_objects[objCount]['speed'] = this.scrollingSpeed;
		nemintScroller_objects[objCount]['last'] = 0;
	}
}

nemintScroller.prototype.beginn = function(name) {
	if(document.getElementById) {
		if(this.widthTicker == 'auto')
		{
			this.widthTicker = document.getElementById(this.elTicker).offsetWidth;
		}
		this.heightRealTicker = parseInt(this.heightTicker - (this.marginTop * 2));
		this.widthRealTicker  = parseInt(this.widthTicker - (this.marginLeft * 2));

		if(this.border != '')
		{
			document.getElementById(this.elTicker).style.border = this.border;
		}
		if(this.bgcolor != '')
		{
			document.getElementById(this.elTicker).style.background = this.bgcolor;
		}
		document.getElementById(this.elTicker).style.height = this.heightTicker + 'px';
		document.getElementById(this.elTicker).style.width = this.widthTicker + 'px';
		var n = document.createElement("div");
		n.style.height = this.heightTicker + 'px';
		n.style.width = this.widthTicker + 'px';
		document.getElementById(this.elTicker).parentNode.insertBefore(n, document.getElementById(this.elTicker));
		document.getElementById(this.elTicker).style.position = "absolute";
		document.getElementById(this.elTicker).style.overflow = "hidden";

		var tickerout = '';

		if(this.scrollLeft == 1)
		{
			tickerout = '\n<div id="' + this.elTickerInnen + '" style="height:' + this.heightRealTicker + 'px; display: inline; white-space: nowrap;">' + this.scrollingText + '</div>';
			this.index = this.widthTicker;
	    document.getElementById(this.elTicker).innerHTML = tickerout;
			this.widthRealTicker = document.getElementById(this.elTickerInnen).offsetWidth;
		}
		else
		{
			tickerout = '\n<div id="' + this.elTickerInnen + '" style="height:' + this.heightRealTicker + 'px; display: inline;">' + this.scrollingText + '</div>';
			this.index = this.heightTicker;
	    document.getElementById(this.elTicker).innerHTML = tickerout;
			this.widthRealTicker = document.getElementById(this.elTickerInnen).offsetWidth;
			this.heightRealTicker = document.getElementById(this.elTickerInnen).offsetHeight;
		}

		this.positionTopTicker =  this.absTop(n);
		this.positionLeftTicker = this.absLeft(n);
		document.getElementById(this.elTicker).style.top = this.positionTopTicker + "px";
		document.getElementById(this.elTicker).style.left = this.positionLeftTicker + "px";

		document.getElementById(this.elTickerInnen).style.position = "absolute";
		document.getElementById(this.elTickerInnen).style.top = this.marginTop + "px";
		document.getElementById(this.elTickerInnen).style.left = this.marginLeft + "px";

		var obj = this;
		if(this.stopScrollingOnMouseover == 1) {
			document.getElementById(this.elTickerInnen).onmouseover = function() {
										obj.scrolling = 0;
										return false;
										};
			document.getElementById(this.elTickerInnen).onmouseout = function() {
										obj.scrolling = 1;
										return false;
										};
		}
	}
	else {
		//todo for old browsers, perhaps ???
	}
}

nemintScroller.prototype.update = function(newticker) {
	if(this.scrollLeft != 0 && this.scrolling == 1) {
		this.scrollLeftFunc();
	}
	else if(this.scrolling == 1 && this.scrolling == 1) {
		this.scrollTopFunc();
	}
	window.setTimeout(this.scrollerObjName + ".update()", this.scrollingSpeed);
}

nemintScroller.prototype.scrollLeftFunc = function() {
	if(this.index + this.widthRealTicker < 0 )
	{
		this.index = this.widthTicker;
		//this.getPosition();
	}
	var i = 1 * this.scrollingSpeedUp;
	this.index = parseInt(this.index - i);
 	document.getElementById(this.elTickerInnen).style.left = this.index + "px";
}

nemintScroller.prototype.scrollTopFunc = function() {
	if(this.index + this.heightRealTicker < 0 )
	{
		this.index = this.heightTicker;
		//this.getPosition();
	}
	var i = 1 * this.scrollingSpeedUp;
	this.index = parseInt(this.index - i);
 	document.getElementById(this.elTickerInnen).style.top = this.index + "px";
}

nemintScroller.prototype.getPosition = function()
{
	this.positionTopTicker =  parseInt(this.absTop(document.getElementById(this.elTicker)));
	this.positionLeftTicker = parseInt(this.absLeft(document.getElementById(this.elTicker)));
}

nemintScroller.prototype.absLeft = function(el) {
	if(el) {
		return (el.offsetParent)?
		el.offsetLeft+this.absLeft(el.offsetParent) : el.offsetLeft;
	}
	else return 0;
}

nemintScroller.prototype.absTop = function(el) {
	if(el) {
		return (el.offsetParent)?
		el.offsetTop+this.absTop(el.offsetParent) : el.offsetTop;
	}
	else return 0;
}
//*********************************************************************************************
//***                                 Server Kommunikation                                  ***
//***                                  Nemint Ajax v1.0                                     ***
//***                 2006 Nemint, New Media Interactiv www.nemint.de                       ***
//*********************************************************************************************
function NemintAjax() {
	var req = new Object();

	// -------------------
	// Instance properties
	// -------------------

	/**
	 * Timeout period (in ms) until an async request will be aborted, and
	 * the onTimeout function will be called
	 */
	req.timeout = null;

	/**
	 *	Since some browsers cache GET requests via XMLHttpRequest, an
	 * additional parameter called NemintAjaxUniqueId will be added to
	 * the request URI with a unique numeric value appended so that the requested
	 * URL will not be cached.
	 */
	req.generateUniqueUrl = true;

	/**
	 * The url that the request will be made to, which defaults to the current
	 * url of the window
	 */
	req.url = window.location.href;

	/**
	 * The method of the request, either GET (default), POST, or HEAD
	 */
	req.method = "GET";

	/**
	 * Whether or not the request will be asynchronous. In general, synchronous
	 * requests should not be used so this should rarely be changed from true
	 */
	req.async = true;

	/**
	 * The username used to access the URL
	 */
	req.username = null;

	/**
	 * The password used to access the URL
	 */
	req.password = null;

	/**
	 * The parameters is an object holding name/value pairs which will be
	 * added to the url for a GET request or the request content for a POST request
	 */
	req.parameters = new Object();

	/**
	 * The sequential index number of this request, updated internally
	 */
	req.requestIndex = NemintAjax.numNemintAjaxs++;

	/**
	 * Indicates whether a response has been received yet from the server
	 */
	req.responseReceived = false;

	/**
	 * The name of the group that this request belongs to, for activity
	 * monitoring purposes
	 */
	req.groupName = null;

	/**
	 * The query string to be added to the end of a GET request, in proper
	 * URIEncoded format
	 */
	req.queryString = "";

	/**
	 * After a response has been received, this will hold the text contents of
	 * the response - even in case of error
	 */
	req.responseText = null;
	req.responseTextNew = '';
	req.responseTextNewBegin = 0;

	/**
	 * After a response has been received, this will hold the XML content
	 */
	req.responseXML = null;

	/**
	 * After a response has been received, this will hold the status code of
	 * the response as returned by the server.
	 */
	req.status = null;

	/**
	 * After a response has been received, this will hold the text description
	 * of the response code
	 */
	req.statusText = null;

	/**
	 * An internal flag to indicate whether the request has been aborted
	 */
	req.aborted = false;

	/**
	 * The XMLHttpRequest object used internally
	 */
	req.xmlHttpRequest = null;

	// --------------
	// Event handlers
	// --------------

	/**
	 * If a timeout period is set, and it is reached before a response is
	 * received, a function reference assigned to onTimeout will be called
	 */
	req.onTimeout = null;

	/**
	 * A function reference assigned will be called when readyState=1
	 */
	req.onLoading = null;

	/**
	 * A function reference assigned will be called when readyState=2
	 */
	req.onLoaded = null;

	/**
	 * A function reference assigned will be called when readyState=3
	 */
	req.onInteractive = null;

	/**
	 * A function reference assigned will be called when readyState=4
	 */
	req.onComplete = null;

	/**
	 * A function reference assigned will be called after onComplete, if
	 * the statusCode=200
	 */
	req.onSuccess = null;

	/**
	 * A function reference assigned will be called after onComplete, if
	 * the statusCode != 200
	 */
	req.onError = null;

	/**
	 * If this request has a group name, this function reference will be called
	 * and passed the group name if this is the first request in the group to
	 * become active
	 */
	req.onGroupBegin = null;

	/**
	 * If this request has a group name, and this request is the last request
	 * in the group to complete, this function reference will be called
	 */
	req.onGroupEnd = null;

	req.getXmlHttpRequest = function() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
			// Based on http://jibbering.com/2002/4/httprequest.html
			/*@cc_on @*/
			/*@if (@_jscript_version >= 5)
			try {
				return new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					return new ActiveXObject("Microsoft.XMLHTTP");
				} catch (E) {
					return null;
				}
			}
			@end @*/
		}
		else {
			return null;
		}
	};

	// Get the XMLHttpRequest object itself
	req.xmlHttpRequest = req.getXmlHttpRequest();

	req.importArraySearch  = new Array('\\&lt;','\\&gt;','\\&amp;');
	req.importArrayReplace = new Array('<','>','&');

	if (req.xmlHttpRequest==null) { return null; }

	req.get = function() {
		req.method = "GET";
		req.doRequest();
	};

	req.post = function(args) {
		req.method = "POST";
		req.handleArguments(args);
		req.doRequest();
	};

	req.submit = function(theform) {
		req.queryString = req.serializeForm(theform);
		req.method = theform.method.toUpperCase();
		req.url = theform.action;
		req.process();
		return true;
	};

	req.doRequest = function() {
		req.process();
	};

	req.parseXML = function(node) {
		if(node.nodeType != 1) {
			return false;
		}
		var tmp = new Array();
		var text = '';
		var attrib = new Array();
		tmp['nodeName'] = node.nodeName;
		tmp['nodeType'] = node.nodeType;
		tmp['nodeChilds'] = new Array();
		if(node.attributes.length > 0) {
			for(var i3 = 0; i3 < node.attributes.length ; i3++ ) {
				attrib[node.attributes[i3].nodeName] = node.attributes[i3].nodeValue;
			}
		}
		tmp['nodeAttribs'] = attrib;
		var i2 = 0;
		for(var i = 0; i < node.childNodes.length ; i++ ) {
			if(node.childNodes[i].nodeType == 1) {
				if(tmp['nodeChilds'][i2] = req.parseXML(node.childNodes[i])) {
					i2++;
				}
			}
			else if(node.childNodes[i].nodeType == 3) {
				text = text + node.childNodes[i].nodeValue;
			}
		}
		if(typeof(tmp['nodeAttribs']['encoding']) != 'undefined' && tmp['nodeAttribs']['encoding'] == 'htmlstrip') {
			tmp['nodeData'] = req.replaceInputXML(text);
		}
		else {
			tmp['nodeData'] = text;
		}
		return tmp;
	};

	req.parseData = function(node) {
		var tmp = new Array();
		if(req.responseXML!=null) {
			for(var i = 0; i < req.responseXML.getElementsByTagName(node).length ; i++ ) {
				tmp[i] = new Array();
				tmp[i] = req.parseXML(req.responseXML.getElementsByTagName(node)[i]);
			}
			return tmp;
		}
		else {
			tmp['plainText'] = req.responseText;
			return tmp;
		}
	};

	req.replaceInputXML = function(text) {
		for(var i = 0; i < req.importArraySearch.length; i++) {
			var s = '/' + req.importArraySearch[i] +'/ig';
			text = text.replace(s,req.importArrayReplace[i]);
		}
		return text;
	};

	// -------------------------------------------------------
	// Attach the event handlers for the XMLHttpRequest object
	// -------------------------------------------------------
	function DataArrived() {
	alert('jaa');
	}
	req.xmlHttpRequest.onreadystatechange =
	function() {
		if (req==null || req.xmlHttpRequest==null || !req.xmlHttpRequest) { return; }
		if (req.xmlHttpRequest.readyState==1) { req.onLoadingInternal(req); }
		if (req.xmlHttpRequest.readyState==2) { req.onLoadedInternal(req); }
		if (req.xmlHttpRequest.readyState==3) { req.onInteractiveInternal(req); }
		if (req.xmlHttpRequest.readyState==4) { req.onCompleteInternal(req); }
	};
	// ---------------------------------------------------------------------------
	// Internal event handlers that fire, and in turn fire the user event handlers
	// ---------------------------------------------------------------------------
	// Flags to keep track if each event has been handled, in case of
	// multiple calls (some browsers may call the onreadystatechange
	// multiple times for the same state)
	req.onLoadingInternalHandled = false;
	req.onLoadedInternalHandled = false;
	req.onInteractiveInternalHandled = false;
	req.onCompleteInternalHandled = false;
	req.onLoadingInternal =
		function() {
			if (req.onLoadingInternalHandled) { return; }
			NemintAjax.numActiveNemintAjaxs++;
			if (NemintAjax.numActiveNemintAjaxs==1 && typeof(window['NemintAjaxBegin'])=="function") {
				NemintAjaxBegin();
			}
			if (req.groupName!=null) {
				if (typeof(NemintAjax.numActiveAjaxGroupRequests[req.groupName])=="undefined") {
					NemintAjax.numActiveAjaxGroupRequests[req.groupName] = 0;
				}
				NemintAjax.numActiveAjaxGroupRequests[req.groupName]++;
				if (NemintAjax.numActiveAjaxGroupRequests[req.groupName]==1 && typeof(req.onGroupBegin)=="function") {
					req.onGroupBegin(req.groupName);
				}
			}
			if (typeof(req.onLoading)=="function") {
				req.onLoading(req);
			}
			req.onLoadingInternalHandled = true;
		};
	req.onLoadedInternal =
		function() {
			if (req.onLoadedInternalHandled) { return; }
			if (typeof(req.onLoaded)=="function") {
				req.onLoaded(req);
			}
			req.onLoadedInternalHandled = true;
		};
	req.onInteractiveInternal =
		function() {
			if (req.onInteractiveInternalHandled) { return; }
			if (typeof(req.onInteractive)=="function") {
				var text = req.xmlHttpRequest.responseText;
				req.responseTextNew = req.xmlHttpRequest.responseText;
				req.responseTextNewBegin = text.length;
				req.onInteractive(req);
			}
			//req.onInteractiveInternalHandled = true;
		};
	req.onCompleteInternal =
		function() {
			if (req.onCompleteInternalHandled || req.aborted) { return; }
			req.onCompleteInternalHandled = true;
			NemintAjax.numActiveNemintAjaxs--;
			if (NemintAjax.numActiveNemintAjaxs==0 && typeof(window['NemintAjaxEnd'])=="function") {
				NemintAjaxEnd(req.groupName);
			}
			if (req.groupName!=null) {
				NemintAjax.numActiveAjaxGroupRequests[req.groupName]--;
				if (NemintAjax.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
					req.onGroupEnd(req.groupName);
				}
			}
			req.responseReceived = true;
			req.status = req.xmlHttpRequest.status;
			req.statusText = req.xmlHttpRequest.statusText;
			req.responseText = req.xmlHttpRequest.responseText;
			if(req.responseTextNew == '') {
				req.responseTextNew = req.xmlHttpRequest.responseText;
			}
			req.responseXML = req.xmlHttpRequest.responseXML;
			if (typeof(req.onComplete)=="function") {
				req.onComplete(req);
			}
			if (req.xmlHttpRequest.status==200 && typeof(req.onSuccess)=="function") {
				req.onSuccess(req);
			}
			else if (typeof(req.onError)=="function") {
				req.onError(req);
			}

			// Clean up
			req.xmlHttpRequest = null;
		};
	req.onTimeoutInternal =
		function() {
			if (req!=null && req.xmlHttpRequest!=null && !req.onCompleteInternalHandled) {
				req.aborted = true;
				req.xmlHttpRequest.abort();
				NemintAjax.numActiveNemintAjaxs--;
				if (NemintAjax.numActiveNemintAjaxs==0 && typeof(window['NemintAjaxEnd'])=="function") {
					NemintAjaxEnd(req.groupName);
				}
				if (req.groupName!=null) {
					NemintAjax.numActiveAjaxGroupRequests[req.groupName]--;
					if (NemintAjax.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
						req.onGroupEnd(req.groupName);
					}
				}
				if (typeof(req.onTimeout)=="function") {
					req.onTimeout(req);
				}
				req.xmlHttpRequest = null;
			}
		};

	// ----------------
	// Instance methods
	// ----------------
	/**
	 * The process method is called to actually make the request. It builds the
	 * querystring for GET requests (the content for POST requests), sets the
	 * appropriate headers if necessary, and calls the
	 * XMLHttpRequest.send() method
	*/
	req.process =
		function() {
			if (req.xmlHttpRequest!=null) {
				// Some logic to get the real request URL
				if (req.generateUniqueUrl && req.method=="GET") {
					req.parameters["NemintAjaxUniqueId"] = new Date().getTime() + "" + req.requestIndex;
				}
				var content = null; // For POST requests, to hold query string
				for (var i in req.parameters) {
					if (req.queryString.length>0) { req.queryString += "&"; }
					req.queryString += encodeURIComponent(i) + "=" + encodeURIComponent(req.parameters[i]);
				}
				if (req.method=="GET") {
					if (req.queryString.length>0) {
						req.url += ((req.url.indexOf("?")>-1)?"&":"?") + req.queryString;
					}
				}
				req.xmlHttpRequest.open(req.method,req.url,req.async,req.username,req.password);
				if (req.method=="POST") {
					if (typeof(req.xmlHttpRequest.setRequestHeader)!="undefined") {
						req.xmlHttpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
					}
					content = req.queryString;
				}
				if (req.timeout>0) {
					setTimeout(req.onTimeoutInternal,req.timeout);
				}
				req.xmlHttpRequest.send(content);
			}
		};

	/**
	 * An internal function to handle an Object argument, which may contain
	 * either NemintAjax field values or parameter name/values
	 */
                                                                                                 	req.handleArguments =
		function(args) {
			for (var i in args) {
				// If the NemintAjax object doesn't have a property which was passed, treat it as a url parameter
				if (typeof(req[i])=="undefined") {
					req.parameters[i] = args[i];
				}
				else {
					req[i] = args[i];
				}
			}
		};

	/**
	 * Returns the results of XMLHttpRequest.getAllResponseHeaders().
	 * Only available after a response has been returned
	 */
	req.getAllResponseHeaders =
		function() {
			if (req.xmlHttpRequest!=null) {
				if (req.responseReceived) {
					return req.xmlHttpRequest.getAllResponseHeaders();
				}
				alert("Cannot getAllResponseHeaders because a response has not yet been received");
			}
		};

	/**
	 * Returns the the value of a response header as returned by
	 * XMLHttpRequest,getResponseHeader().
	 * Only available after a response has been returned
	 */
	req.getResponseHeader =
		function(headerName) {
			if (req.xmlHttpRequest!=null) {
				if (req.responseReceived) {
					return req.xmlHttpRequest.getResponseHeader(headerName);
				}
				alert("Cannot getResponseHeader because a response has not yet been received");
			}
		};

	req.serializeForm = function(theform) {
		var els = theform.elements;
		var len = els.length;
		var queryString = "";
		req.addField =
			function(name,value) {
				if (queryString.length>0) {
					queryString += "&";
				}
				queryString += encodeURIComponent(name) + "=" + encodeURIComponent(value);
			};
		for (var i=0; i<len; i++) {
			var el = els[i];
			if (!el.disabled) {
				switch(el.type) {
					case 'text': case 'password': case 'hidden': case 'textarea':
						req.addField(el.name,el.value);
						break;
					case 'select-one':
						if (el.selectedIndex>=0) {
							req.addField(el.name,el.options[el.selectedIndex].value);
						}
						break;
					case 'select-multiple':
						for (var j=0; j<el.options.length; j++) {
							if (el.options[j].selected) {
								req.addField(el.name,el.options[j].value);
							}
						}
						break;
					case 'checkbox': case 'radio':
						if (el.checked) {
							req.addField(el.name,el.value);
						}
						break;
				}
			}
		}
		return queryString;
	};
	return req;
};

//*********************************************************************************************
//***                                  Nemint Ajax Static                                   ***
//*********************************************************************************************
//*********************************************************************************************
NemintAjax.numActiveNemintAjaxs = 0;
NemintAjax.numActiveAjaxGroupRequests = new Object();
NemintAjax.numNemintAjaxs = 0;

NemintAjax.isActive = function() {
	return (NemintAjax.numActiveNemintAjaxs>0);
};

//*********************************************************************************************
NemintAjax.sendServerData = function(url,nextjob,method,args,async) {
	var obj = new NemintAjax();
	if(typeof(obj.xmlHttpRequest) != 'object') {
		return false;
	}
	if(typeof async != 'undefined') {
		obj.async = false;
	}
	if(typeof(url)=="string") {
		obj.url = url;
	}
	obj.onSuccess = function() {NemintAjax.goServerInput(obj,nextjob,args); };
	obj.onError = function() {alert('ERROR on sending ajax request'); };
	if(typeof(url)!= "undefined" && typeof(url)!="string" || typeof(method)=="string" && method.toLowerCase() == 'submit') {
		obj.submit(url);
		return true;
	}
	else if(typeof(method)!="undefined" && typeof(args)!="undefined" && method.toLowerCase() == 'post') {
		obj.post(args);
		return true;
	}
	else if(typeof(url)!="undefined" && typeof(url)=="string") {
		obj.get();
		return true;
	}
	else {
		alert('error');
		return false;
	}
};

//*********************************************************************************************
NemintAjax.updateServerInput = function(obj) {
	var tmp2 = new Array();
	tmp2['script'] = obj.parseData('script');
	for(i=0; i < tmp2['script'].length; i++) {
		j = document.createElement('script');
		j.type = 'text/javascript';
		if(actSiteCharset != 'utf-8' && !document.all) {
			j.text = Base64.utf8_decode(tmp2['script'][i]['nodeData']);
		}
		else {
			j.text = tmp2['script'][i]['nodeData'];
		}
		document.body.appendChild(j);
	}
	for(i=tmp2['script'].length-1; i >= 0; i--) {
		delete tmp2['script'][i];
	}
	tmp2['data'] = obj.parseData('data');
	return tmp2;
};
//*********************************************************************************************
NemintAjax.goServerInput = function(obj,nextjob,args) {
	if(!obj) {
		alert("Server communication error!!!");
	}
	else if(!obj.responseXML || obj.responseXML == null) {
		if(typeof(nextjob)=="function") {
			nextjob(obj, null, args);
		}
		delete obj;
		return true;
	}
	else if(obj.responseXML) {
		var tmp = NemintAjax.updateServerInput(obj);
		if(typeof(nextjob)=="function") {
			nextjob(obj, tmp, args);
			delete obj;
		}
		else
		{
			for(i=0; i < tmp['data'].length; i++) {
				if(typeof(tmp['data'][i]['nodeAttribs']['name'])!='undefined' && document.getElementById(tmp['data'][i]['nodeAttribs']['name'])) {
					if(actSiteCharset != 'utf-8'&& !document.all) {
						document.getElementById(tmp['data'][i]['nodeAttribs']['name']).innerHTML = Base64.utf8_decode(tmp['data'][i]['nodeData']);
					}
					else if(typeof(tmp['data'][i]['nodeAttribs']['encoding']) == 'string' && tmp['data'][i]['nodeAttribs']['encoding'] == 'base64') {
						document.getElementById(tmp['data'][i]['nodeAttribs']['name']).innerHTML = Base64.decode(tmp['data'][i]['nodeData']);
					}
					else {
						document.getElementById(tmp['data'][i]['nodeAttribs']['name']).innerHTML = tmp['data'][i]['nodeData'];
					}
				}
			}
		}
		delete obj;
		return true;
	}
	if(obj) {
		delete obj;
	}
	return false;
};
//*********************************************************************************************
NemintAjax.sendServerJSON = function(args) {
	var obj = new NemintAjax();
	if(typeof(obj.xmlHttpRequest) != 'object')
	{
		return false;
	}

	if(typeof(args.nextjob)!="function")
	{
		args.nextjob = null;
	}

	obj.onSuccess = function() {NemintAjax.retrieveServerJSON(obj,args); };
	obj.onError = function() {alert('ERROR on sending JSON request'); };

	if(typeof(args.form)!="undefined")
	{
		if(typeof(args.form.action)=="undefined")
		{
			alert('error no form defined');
			return false;
		}
		obj.method = 'POST';
		obj.submit(args.form);
	}
	else if(typeof(args.variable)!="undefined")
	{
		if(typeof(args.url)=="undefined")
		{
			alert('error no url defined');
			return false;
		}
		if(typeof(args.variable)=="undefined")
		{
			alert('error no var defined');
			return false;
		}
		obj.method = 'POST';
		obj.url = args.url;
		var a = new Object();
		a.json_data_sended = JSON.encode(args.variable.clean());
		obj.post(a);
	}
	else if(typeof(args.url)!="undefined")
	{
		obj.url = args.url;
		obj.method = 'GET';
		obj.get();
	}
	else
	{
		alert('error');
		return false;
	}
	return false;
};
//*********************************************************************************************
NemintAjax.retrieveServerJSON = function(obj,args) {
	if(!obj)
	{
		alert("Server communication error!!!");
	}
	else if(obj.responseText && obj.responseText != null && obj.responseText != '')
	{
		var re = null;

		try
		{
			re = JSON.decode(obj.responseText);
		}
		catch(e)
		{
		}
			for(var i in re)
			{
				if(i == 'javascript' && typeof(re[i])!="string")
				{
					for(var i2 = 0; i2 < re[i].length; i2++)
					{
						var j = document.createElement('script');
						j.type = 'text/javascript';
						if(actSiteCharset != 'utf-8' && !document.all)
						{
							j.text = Base64.utf8_decode(re[i][i2]);
						}
						else
						{
							j.text = re[i][i2];
						}
						document.body.appendChild(j);
					}
				}
				else if(i == 'javascript')
				{
					var j = document.createElement('script');
					j.type = 'text/javascript';
					if(actSiteCharset != 'utf-8' && !document.all)
					{
						j.text = Base64.utf8_decode(re[i]);
					}
					else
					{
						j.text = re[i];
					}
					document.body.appendChild(j);
				}
			}
		if(typeof(args.nextjob)=="function")
		{
			args.nextjob(re, obj, args);
		}
		else
		{
			for(var i in re)
			{
				if(i != 'javascript' && document.getElementById(i))
				{
					if(actSiteCharset != 'utf-8' && !document.all && document.getElementById(i).value)
					{
						document.getElementById(i).value = Base64.utf8_decode(re[i]);
					}
					else if(actSiteCharset != 'utf-8' && !document.all)
					{
						document.getElementById(i).innerHTML = Base64.utf8_decode(re[i]);
					}
					else if(document.getElementById(i).value)
					{
						document.getElementById(i).value = re[i];
					}
					else
					{
						document.getElementById(i).innerHTML = re[i];
					}
				}
			}
		}
		delete obj;
		return true;
	}
	if(obj)
	{
		delete obj;
	}
	return false;
};
//*********************************************************************************************
//*********************************************************************************************
//***                             Base64 UTF-8 De-/Encoding                                 ***
//*********************************************************************************************
//*********************************************************************************************
	var Base64 = {

		_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

		utf8_base64_encode : function (input) {
				input = this.utf8_encode(input);
				return this.encode(input);
		},

		utf8_base64_decode : function (input) {
				input = this.decode(input);
				return this.utf8_decode(input);
		},

		encode : function (input) {
				var output = "";
				var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
				var i = 0;

				while (i < input.length) {
					chr1 = input.charCodeAt(i++);
					chr2 = input.charCodeAt(i++);
					chr3 = input.charCodeAt(i++);

					enc1 = chr1 >> 2;
					enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
					enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
					enc4 = chr3 & 63;

					if (isNaN(chr2)) {
						enc3 = enc4 = 64;
					}
					else if (isNaN(chr3)) {
						enc4 = 64;
					}

					output = output +
					this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
					this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
				}
				return output;
		},

		decode : function (input) {
				var output = "";
				var chr1, chr2, chr3;
				var enc1, enc2, enc3, enc4;
				var i = 0;

				input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

				while (i < input.length) {
					enc1 = this._keyStr.indexOf(input.charAt(i++));
					enc2 = this._keyStr.indexOf(input.charAt(i++));
					enc3 = this._keyStr.indexOf(input.charAt(i++));
					enc4 = this._keyStr.indexOf(input.charAt(i++));

					chr1 = (enc1 << 2) | (enc2 >> 4);
					chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
					chr3 = ((enc3 & 3) << 6) | enc4;

					output = output + String.fromCharCode(chr1);

					if (enc3 != 64) {
						output = output + String.fromCharCode(chr2);
					}
					if (enc4 != 64) {
						output = output + String.fromCharCode(chr3);
					}
				}
				return output;
		},

		utf8_encode : function (string) {
				string = string.replace(/\r\n/g,"\n");
				var utftext = "";

				for (var n = 0; n < string.length; n++) {
					var c = string.charCodeAt(n);

					if (c < 128) {
						utftext += String.fromCharCode(c);
					}
					else if((c > 127) && (c < 2048)) {
						utftext += String.fromCharCode((c >> 6) | 192);
						utftext += String.fromCharCode((c & 63) | 128);
					}
					else {
						utftext += String.fromCharCode((c >> 12) | 224);
						utftext += String.fromCharCode(((c >> 6) & 63) | 128);
						utftext += String.fromCharCode((c & 63) | 128);
					}
				}
				return utftext;
		},

		utf8_decode : function (utftext) {
				var string = "";
				var i = 0;
				var c = c1 = c2 = 0;

				while ( i < utftext.length ) {
					c = utftext.charCodeAt(i);

					if (c < 128) {
						string += String.fromCharCode(c);
						i++;
					}
					else if((c > 191) && (c < 224)) {
						c2 = utftext.charCodeAt(i+1);
						string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
						i += 2;
					}
					else {
						c2 = utftext.charCodeAt(i+1);
						c3 = utftext.charCodeAt(i+2);
						string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
						i += 3;
					}
				}
				return string;
		}
}

var xMousePos =  0;
var yMousePos =  0;
var AssignedMovedElement = new Array();
var MoveDivElementObj = null;
var MoveDivElementObjX = 0;
var MoveDivElementObjY = 0;
var isIE = false;

if(navigator.userAgent.indexOf("MSIE") != -1 && document.all) {
	isIE = true;
}

function MouseMoved(e) {
	if(!isIE) {
		yMousePos = e.pageY;
		xMousePos = e.pageX;
	}
	else {
      xMousePos = e.clientX;
      yMousePos = e.clientY;
			if(document.documentElement) {
        //IE 6 (in standards compliant mode)
				if(document.documentElement.scrollLeft) {
        	xMousePos += document.documentElement.scrollLeft;
        }
				if(document.documentElement.scrollTop) {
					yMousePos += document.documentElement.scrollTop;
        }
      }
      else  if( document.body) {
        //IE 4, 5 & 6 (in non-standards compliant mode)
				if(document.documentElement.scrollLeft) {
        	xMousePos += document.body.scrollLeft;
        }
				if(document.documentElement.scrollTop) {
					yMousePos += document.body.scrollTop;
        }
      }
	}
}

function MouseDownDivElement(node,e) {
	if(document.getElementById(node)) {
		MoveDivElementObj = node;
		e.style.cursor='move';
		MoveDivElementObjY = yMousePos - parseInt(document.getElementById(node).style.top);
		MoveDivElementObjX = xMousePos - parseInt(document.getElementById(node).style.left);
	}
}

function RegisterMoveDivElement(node,e) {
	if(document.getElementById(node)) {
		MoveDivElementObj = node;
		e.style.cursor='move';
		MoveDivElementObjY = yMousePos - parseInt(document.getElementById(node).style.top);
		MoveDivElementObjX = xMousePos - parseInt(document.getElementById(node).style.left);
		document.getElementById(node).onmouseup = function() {MouseUpDivElement(node,e)};
		document.getElementById(node).onmouseover = function() {e.style.cursor='pointer';};
	}
}

function MouseUpDivElement(node,e) {
	MoveDivElementObj = null;
	e.style.cursor='';
	MoveDivElementObjX = 0;
	MoveDivElementObjY = 0;
}

function MoveDivElement(e) {
	if(!isIE) {
		yMousePos = e.pageY;
		xMousePos = e.pageX;
	}
	else {
      xMousePos = e.clientX;
      yMousePos = e.clientY;
			if(document.documentElement) {
        //IE 6 (in standards compliant mode)
				if(document.documentElement.scrollLeft) {
        	xMousePos += document.documentElement.scrollLeft;
        }
				if(document.documentElement.scrollTop) {
					yMousePos += document.documentElement.scrollTop;
        }
      }
      else  if( document.body) {
        //IE 4, 5 & 6 (in non-standards compliant mode)
				if(document.documentElement.scrollLeft) {
        	xMousePos += document.body.scrollLeft;
        }
				if(document.documentElement.scrollTop) {
					yMousePos += document.body.scrollTop;
        }
      }
	}

	if(MoveDivElementObj != null && document.getElementById(MoveDivElementObj)) {
		y = yMousePos - MoveDivElementObjY;
		x = xMousePos - MoveDivElementObjX;
		if(y < 0) y = 0;
		if(x < 0) x = 0;

		if(typeof($) != 'undefined')
		{
			var myValues = $(MoveDivElementObj).getCoordinates();
			if(x + myValues.width > window.getWidth())
			{
			  x = window.getWidth() - myValues.width;
				document.getElementById(MoveDivElementObj).style.left = x + 'px';
			}
			if(y + myValues.height > window.getHeight())
			{
			  y = window.getHeight() - myValues.height;
				document.getElementById(MoveDivElementObj).style.top = y + 'px';
			}
		}
		document.getElementById(MoveDivElementObj).style.top = y + 'px';
		document.getElementById(MoveDivElementObj).style.left = x + 'px';
	}
}

function showuserpicinfo(uid,nick,pic,picupload,gender,age) {
	if(typeof(uid)!='string' && typeof(uid)!='number' || typeof(nick)!='string' || typeof(pic)!='string' || typeof(picupload)!='string' && typeof(picupload)!='number' || parseInt(picupload) != 1 || pic.length < 20) {
		return false;
	}
	uid = parseInt(uid);
	if(typeof(gender)!='string') {
		gender == '';
	}
	if(typeof(age)!='string' && typeof(age)!='number') {
		age == '';
	}
	if(!document.getElementById('showuserpicinfodiv')) {
		var newpicinfo = document.createElement("div");
		newpicinfo.id = 'showuserpicinfodiv';
		newpicinfo.style.cssText = 'position: absolute;';
		newpicinfo.innerHTML = '<img id="showuserpicinfopic" title="" alt="" border="0" src="" />';
		newpicinfo.style.width = '100px';
		newpicinfo.style.height = '100px';
		h = yMousePos - h;
		w = xMousePos - w;
		newpicinfo.style.top = '0px';
		newpicinfo.style.left = '0px';
		document.body.appendChild(newpicinfo);
	}

	var title = nick + '(' + gender + age + ')';
	document.getElementById('showuserpicinfopic').src = my_actSiteMediaURL + '/community/' + pic;
	document.getElementById('showuserpicinfopic').title = title;
	document.getElementById('showuserpicinfopic').alt = title;
	newpic = document.getElementById('showuserpicinfopic');

	var w = parseInt(newpic.width);
	var h = parseInt(newpic.height);

	document.getElementById('showuserpicinfodiv').style.width = w + 'px';
	document.getElementById('showuserpicinfodiv').style.height = h + 'px';
	h = yMousePos - h;
	w = xMousePos;// + w;
	document.getElementById('showuserpicinfodiv').style.top = h + 'px';
	document.getElementById('showuserpicinfodiv').style.left = w + 'px';
	document.getElementById('showuserpicinfodiv').style.display = '';
}

function clearshowuserpicinfo() {
	if(document.getElementById('showuserpicinfodiv')) {
		document.getElementById('showuserpicinfodiv').style.display = 'none';
	}
}

if(isIE) {
	document.attachEvent('onmousemove', MoveDivElement);
	document.attachEvent('onmouseup', MoveDivElement);
}
else {
	document.addEventListener('mousemove', MoveDivElement,false);
	document.addEventListener('mouseup', MoveDivElement,false);
}

function InlinePopup(args) {
	var popup = new Object();

	popup.url = '';
	popup.id = null;
	popup.interactivemove = true;
	popup.replace_id = null;
	popup.clone_id = null;
	popup.iframe = false;
	popup.top = false;
	popup.left = false;
	popup.width = 500;
	popup.height = 400;
	popup.title_height = 20;
	popup.content_height = 0;
	popup.fixed = false;
	popup.resize = false;
	popup.noscroll = false;
	popup.darkbody = false;
	popup.titlediv = '<div id="%%id%%_Title" class="Title" style="height: %%title_height%%px;"><div id="%%id%%_CloseButton" class="CloseButton"></div>%%title%%</div>\n';
	popup.innercontainerdiv = '<div id="%%id%%_Inner" class="Inner">%%titlediv%%%%contentdiv%%</div>\n';
	popup.contentdiv = '<div class="Content" id="%%id%%_Content" style="height: %%content_height%%px; overflow: auto;"></div>\n';
	popup.bottomdiv = '<div id="%%id%%_Bottom" class="Bottom">&nbsp;</div>\n';
	popup.title = '';
	popup.params = new Array();

	popup.parseArgs =	function(args) {
											for (var i in args) {
												if (typeof(popup[i])=="undefined") {
													popup.params[i] = args[i];
												}
												else {
													popup[i] = args[i];
												}
											}
										};

	popup.createPopup =	function() {
											if(typeof popup.id != 'string') {
												popup.id = 'r' + Math.random();
											}
											popup.width = parseInt(popup.width);
											if(popup.width < 20 || typeof popup.width != 'number') {
												popup.width = 20;
											}
											popup.height = parseInt(popup.height);
											if(popup.height < 40 || typeof popup.height != 'number') {
												popup.height = 40;
											}
											popup.title_height = parseInt(popup.title_height);
											if(popup.title_height < 8) {
												popup.title_height = 20;
											}
											popup.content_height = popup.height - 5;
											for(var i=0;i<InlinePopup.activePopups.length;i++) {
												if(InlinePopup.activePopups[i] == popup.id && document.getElementById(InlinePopup.activePopups[i])) {
													if(document.getElementById(InlinePopup.activePopups[i]).className.search(/InlinePopupDarkBody/) != -1 && document.getElementById('InlinePopupDarkBody')){
														document.getElementById('InlinePopupDarkBody').style.display='';
														document.getElementById('InlinePopupDarkBody').style.zIndex = InlinePopup.MaxZIndex;
														InlinePopup.MaxZIndex++;
													}
													document.getElementById(InlinePopup.activePopups[i]).style.display = '';
													document.getElementById(InlinePopup.activePopups[i]).style.zIndex = InlinePopup.MaxZIndex;
													InlinePopup.MaxZIndex++;
													return false;
												}
											}
											InlinePopup.activePopups[InlinePopup.activePopups.length] = popup.id;
											var title = '';
											if(typeof popup.title == 'string' && popup.title.length > 0) {
												title = popup.titlediv.replace(/%%id%%/g,popup.id);
												title = title.replace(/%%title%%/,popup.title);
												title = title.replace(/%%title_height%%/,popup.title_height);
												popup.content_height -= popup.title_height + 6;
											}
											var size = getInnerSize();
											if(typeof popup.top == 'string' && popup.top.toLowerCase() == 'center') {
												popup.top = parseInt(size['y']/2) - parseInt(popup.height/2);
											}
											else if(popup.top != false) {
												popup.top = parseInt(popup.top);
											}
											else {
												popup.top = yMousePos - parseInt(popup.width/2);
											}
											if(typeof popup.left == 'string' && popup.left.toLowerCase() == 'center') {
												popup.left = parseInt(size['x']/2) - parseInt(popup.width/2);
											}
											else if(popup.left != false) {
												popup.left = parseInt(popup.left);
											}
											else {
												popup.left = xMousePos - parseInt(popup.height/2);
											}
											if(popup.top < 0 || typeof popup.top != 'number' || popup.top == 'NaN') popup.top = 0;
											if(popup.left < 0 || typeof popup.left != 'number' || popup.left == 'NaN') popup.left = 0;
											if(popup.top > size['y'] - popup.height) popup.top = size['y'] - popup.height;
											if(popup.left > size['x'] - popup.width) popup.left = size['x'] - popup.width;
											if(!popup.top || popup.top < 0 || typeof popup.top != 'number' || popup.top == 'NaN') popup.top = 0;
											if(!popup.left || popup.left < 0 || typeof popup.left != 'number' || popup.left == 'NaN') popup.left = 0;

											var bottom = popup.bottomdiv.replace(/%%id%%/g,popup.id);
											var content = popup.contentdiv.replace(/%%id%%/g,popup.id);
											content = content.replace(/%%content_height%%/g,popup.content_height);
											var innercontainer = popup.innercontainerdiv.replace(/%%id%%/g,popup.id);
											innercontainer = innercontainer.replace(/%%titlediv%%/,title);
											innercontainer = innercontainer.replace(/%%contentdiv%%/,content);
											title = title.replace(/%%title%%/,popup.title);
											title = title.replace(/%%title_height%%/,popup.title_height);
											var popdiv = document.createElement("div");
											popdiv.id = popup.id;
											popdiv.style.cssText = 'top: 200px; left: 50px; position: absolute;';

											popdiv.className = 'InlinePopup';
											if(popup.darkbody == true && !document.getElementById('InlinePopupDarkBody')) {
												var darkbodyt = document.createElement("div");
												darkbodyt.className = 'InlinePopupDark';
												darkbodyt.style.display = '';
												darkbodyt.id = 'InlinePopupDarkBody';
												darkbodyt.style.zIndex = InlinePopup.MaxZIndex;
												InlinePopup.MaxZIndex++;
												document.body.appendChild(darkbodyt);
												popdiv.className = 'InlinePopup InlinePopupDarkBody';
											}
											else if(popup.darkbody == true && document.getElementById('InlinePopupDarkBody')) {
												document.getElementById('InlinePopupDarkBody').style.zIndex = InlinePopup.MaxZIndex;
												InlinePopup.MaxZIndex++;
												document.getElementById('InlinePopupDarkBody').style.display = '';
											}

											popdiv.style.zIndex = InlinePopup.MaxZIndex;
											InlinePopup.MaxZIndex++;
											popdiv.innerHTML = innercontainer + bottom;
											popdiv.style.width = parseInt(popup.width) + 'px';

											popdiv.style.top = popup.top + 'px';
											popdiv.style.left = popup.left + 'px';
											document.body.appendChild(popdiv);

											if(popup.fixed == false) {
												if(popup.iframe == false) {
													document.getElementById(popup.id + '_Content').onmouseup = function() {MouseUpDivElement(popup.id, this);};
													document.getElementById(popup.id + '_Content').onmousedown = function() {MouseDownDivElement(popup.id, this);};
												}
												if(document.getElementById(popup.id + '_Title')) {
													document.getElementById(popup.id + '_Title').onmouseup = function() {MouseUpDivElement(popup.id, this);};
													document.getElementById(popup.id + '_Title').onmousedown = function() {MouseDownDivElement(popup.id, this); InlinePopup.BringToFront(popup.id);};
													document.getElementById(popup.id + '_Title').onmouseover = function() {this.style.cursor='pointer';};
													if(document.getElementById(popup.id + '_CloseButton')) {
														document.getElementById(popup.id + '_CloseButton').onmouseover = function() {this.style.cursor='pointer';};
														document.getElementById(popup.id + '_CloseButton').onclick = function() {document.getElementById(popup.id).style.display='none'; if(document.getElementById('InlinePopupDarkBody')){document.getElementById('InlinePopupDarkBody').style.display='none';}};
													}
												}
											}
											if(document.getElementById(popup.id + '_CloseButton'))
											{
												document.getElementById(popup.id + '_CloseButton').onmouseover = function() {this.style.cursor='pointer';};
												document.getElementById(popup.id + '_CloseButton').onclick = function() {document.getElementById(popup.id).style.display='none'; if(document.getElementById('InlinePopupDarkBody')){document.getElementById('InlinePopupDarkBody').style.display='none';}};
											}
											if(popup.noscroll != false) {
												document.getElementById(popup.id + '_Content').style.overflow = 'hidden';
											}
											return true;
										};

	return popup;
}

InlinePopup.activePopups = new Array();
InlinePopup.MaxZIndex = 100000;

InlinePopup.BringToFront = function(id) {
	for(var i=0;i<InlinePopup.activePopups.length;i++) {
		if(InlinePopup.activePopups[i] == id && document.getElementById(id)) {
			if(document.getElementById(id).className.search(/InlinePopupDarkBody/) != -1 && document.getElementById('InlinePopupDarkBody')){
				document.getElementById('InlinePopupDarkBody').style.display='';
				document.getElementById('InlinePopupDarkBody').style.zIndex = InlinePopup.MaxZIndex;
				InlinePopup.MaxZIndex++;
			}
			document.getElementById(id).style.zIndex = InlinePopup.MaxZIndex;
			InlinePopup.MaxZIndex++;
			break;
		}
	}
}

InlinePopup.update_div = function(ajax,tmp,arguments) {
	if(ajax.responseText.search(/<.*\/.*head.*?>/i) != -1) {
		var iframe = document.createElement("iframe");
		iframe.id = arguments['obj'].id + '_IFrame';
		iframe.src = "about:blank";
		iframe.style.border = "0px";
		iframe.style.height = "100%";
		iframe.style.margin = "0px";
		iframe.style.width = "100%";
		document.getElementById(arguments['obj'].id + '_Content').appendChild(iframe);
		document.getElementById(arguments['obj'].id + '_Content').onmouseup = '';
		document.getElementById(arguments['obj'].id + '_Content').onmousedown = '';
		var iframedoc = document.getElementById(arguments['obj'].id + '_IFrame').contentWindow.document
		iframedoc.open();
		iframedoc.write(ajax.responseText);
		iframedoc.close();
		document.getElementById(arguments['obj'].id + '_Content').style.overflow = 'hidden';
	}
	else {
		document.getElementById(arguments['obj'].id + '_Content').innerHTML = ajax.responseText;
	}
	delete arguments['obj'];
};

InlinePopup.external_url = function(obj) {
	if(obj.createPopup() == false) {
		delete obj;
		return;
	}
	if(obj.url != '' && obj.iframe) {
		var iframe = document.createElement("iframe");
		iframe.id = obj.id + '_IFrame';
		iframe.src = obj.url;
		iframe.style.height = "100%";
		iframe.style.border = "0px";
		iframe.style.margin = "0px";
		iframe.style.width = "100%";
		document.getElementById(obj.id + '_Content').appendChild(iframe);
		document.getElementById(obj.id + '_Content').onmouseup = '';
		document.getElementById(obj.id + '_Content').onmousedown = '';
		document.getElementById(obj.id + '_Content').style.overflow = 'hidden';
		delete obj;
	}
	else if(obj.url != '')
	{
		NemintAjax.sendServerData(obj.url, function(ajax,tmp,arguments) {InlinePopup.update_div(ajax,tmp,arguments);},'get',{"obj":obj});
	}
};

InlinePopup.replace_div = function(obj) {
	if(typeof obj.replace_id != 'string') {
		alert('replace_id fehlt');
		return;
	}
	if(!document.getElementById(obj.replace_id)) {
		alert('replace_id unbekanntes element');
		return;
	}
	if(obj.createPopup() == false) {
		delete obj;
		return;
	}
	var node = document.getElementById(obj.replace_id);
	var newnode = node.cloneNode(true);
	if(obj.interactivemove != true) {
		document.getElementById(obj.id + '_Content').onmouseup = '';
		document.getElementById(obj.id + '_Content').onmousedown = '';
	}
	node.parentNode.removeChild(node);
	document.getElementById(obj.id + '_Content').appendChild(newnode);
	delete obj;
};

InlinePopup.clone_div = function(obj) {
	if(typeof obj.clone_id != 'string') {
		alert('clone_id fehlt');
		return;
	}
	if(!document.getElementById(obj.clone_id)) {
		alert('clone_id unbekanntes element');
		return;
	}
	if(obj.createPopup() == false) {
		delete obj;
		return;
	}
	if(obj.interactivemove != true)
	{
		document.getElementById(obj.id + '_Content').onmouseup = '';
		document.getElementById(obj.id + '_Content').onmousedown = '';
	}
	document.getElementById(obj.id + '_Content').innerHTML = document.getElementById(obj.clone_id).innerHTML;
	delete obj;
};

InlinePopup.Open = function(args) {
	var obj = new InlinePopup();
	obj.parseArgs(args);
	if(typeof obj.replace_id == 'string' && obj.replace_id.length > 0) {
		InlinePopup.replace_div(obj);
		return;
	}
	if(typeof obj.clone_id == 'string' && obj.clone_id.length > 0) {
		InlinePopup.clone_div(obj);
		return;
	}
	else if(typeof obj.url != 'string' || obj.url.length > 0) {
		InlinePopup.external_url(obj);
		return;
	}
	else {
		alert('url bzw. replace_id Angabe fehlt');
		delete obj;
	}
};

function getInnerSize() {
	var size = new Array();
	if (self.innerHeight) {
		size['x'] = self.innerWidth;
		size['y'] = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		size['x'] = document.documentElement.clientWidth;
		size['y'] = document.documentElement.clientHeight;
	}
	else if (document.body) {
		size['x'] = document.body.clientWidth;
		size['y'] = document.body.clientHeight;
	}
	return size;
}

function var_dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];

  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
}

