/*

	AJAX BASIC
	----------
	JavaScript Application Object Library

	Version:	0.5.0

	Copyright 2008 by AEYOL SOLUTIONS LTD.

*/



/* --- BASE FUNCTIONS --- */

$=function(ID)
{
	return document.getElementById(ID);
};
Show=function(ID)
{
	$(ID).style.display="";
};
Hide=function(ID)
{
	$(ID).style.display="none";
};
ShowHide=function(ID)
{
	if ($(ID).style.display=="none") {$(ID).style.display="";} else {$(ID).style.display="none";}
};
AbsLeft=function(Element,Container)
{
	if (Container)
	{
		return ((Element.offsetParent) ? ((Element.id==Container.id) ? 0 : Element.offsetLeft+AbsLeft(Element.offsetParent,Container)) : Element.offsetLeft);
	}
	else
	{
		return (Element.offsetParent) ? Element.offsetLeft+AbsLeft(Element.offsetParent) : Element.offsetLeft;
	}
};
AbsTop=function(Element,Container)
{
	if (Container)
	{
		return (Element.offsetParent) ? ((Element.id==Container.id) ? 0 : Element.offsetTop+AbsTop(Element.offsetParent,Container)) : Element.offsetTop;
	}
	else
	{
		return (Element.offsetParent) ? Element.offsetTop+AbsTop(Element.offsetParent) : Element.offsetTop;
	}
};
SetOpacity=function(Element,Value)
{
	Element.style.opacity=(Value/10);
	Element.style.filter='alpha(opacity='+(Value*10)+')';
};


/* --- AJAX OBJECT --- */

abAjax=function()
{
	try {this.Request = new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {try {this.Request = new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {this.Request=false;}} if (!this.Request && typeof XMLHttpRequest!='undefined') {this.Request = new XMLHttpRequest();} if (this.Request) {return true;}
};
abAjax.prototype=
{
	Request: false,
	GetData: function(Url,Sync)
	{
		if (this.Request)
		{
			var refRequest=this.Request;
			var Handler=this;

			refRequest.open('GET',Url,!Sync);
			refRequest.onreadystatechange = function()
			{
				if (refRequest.readyState==4 && refRequest.status==200) {Handler.onLoaded();}
				else if (refRequest.readyState==4 && refRequest.status!=200) {Handler.onError();}
				else if (refRequest.readyState==3) {Handler.onReceiving();}
				else if (refRequest.readyState==2) {Handler.onSent();}
				else if (refRequest.readyState==1) {Handler.onOpen();}
			};
			refRequest.send(null);
		}
	},
	PostData: function(Url,Data,Sync,NoResponse)
	{
		if (this.Request)
		{
			var refRequest=this.Request;
			var Handler=this;

			refRequest.open('POST',Url,!Sync);
			refRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			if (NoResponse!=true && !Sync)
			{
				refRequest.onreadystatechange = function()
				{
					if (refRequest.readyState==4 && refRequest.status==200) {Handler.onLoaded();}
					else if (refRequest.readyState==4 && refRequest.status!=200) {Handler.onError();}
					else if (refRequest.readyState==3) {Handler.onReceiving();}
					else if (refRequest.readyState==2) {Handler.onSent();}
					else if (refRequest.readyState==1) {Handler.onOpen();}
				};
			}
			refRequest.send(Data);
			if (NoResponse!=true && Sync)
			{
				this.onLoaded();
			}
		}
	},
    onError: function(){alert("An error occured");},
    onOpen: function(){},
    onSent: function(){},
    onReceiving: function(){},
    onLoaded: function(){alert("success");}
};

/* --- WINDOW OBJECT --- */

abWindow=function(Key,Title,Width,Height,Left,Top)
{
	this.Key=Key;
	this.Title=Title;
	if (!Width) {Width=700;}
	if (!Height) {Height=530;}

	var Wnd = document.createElement("div");
	Wnd.innerHTML=
	'<div class="Window" style="text-align: right;">'+
		'<div id="'+Key+'_in" class="WindowBody">'+
			'<div class="WindowHeader" id="'+Key+'_header">'+
				'<div class="RoundBorderTopLeft">'+
					'<div class="PixSeven"><div></div></div>'+
					'<div class="PixSix"><div></div></div>'+
					'<div class="PixFive"><div></div></div>'+
					'<div class="PixFour"><div></div></div>'+
					'<div class="PixThree"><div></div></div>'+
					'<div class="PixTwo"><div></div></div>'+
					'<div class="PixOne"><div></div></div>'+
					'<div class="PixNull"><div></div></div>'+
				'</div>'+
				'<div class="RoundBorderTopRight">'+
					'<div class="PixSeven"><div></div></div>'+
					'<div class="PixSix"><div></div></div>'+
					'<div class="PixFive"><div></div></div>'+
					'<div class="PixFour"><div></div></div>'+
					'<div class="PixThree"><div></div></div>'+
					'<div class="PixTwo"><div></div></div>'+
					'<div class="PixOne"><div></div></div>'+
					'<div class="PixNull"><div></div></div>'+
				'</div>'+
				'<div class="HeaderBody">'+
					'<span class="WindowTitleBgOpen">'+
						'<span id="'+Key+'_title" class="WindowTitle">'+Title+'</span>'+
					'</span>'+
					'<span class="WindowTitleBgClose">&nbsp;</span>'+
					'<span class="WindowActionBgClose">&nbsp;</span>'+
					'<span class="WindowActionBgOpen">'+
						'<div class="CloseButton" id="'+Key+'_close"></div>'+
					'</span>'+
				'</div>'+
			'</div>'+
			'<div class="InactiveLayer" id="'+Key+'_inactive"></div>'+
			'<div class="Content" id="'+Key+'_container" style="cursor: default; height: '+Height+'px;"></div>'+
			'<div class="RoundBorderBottom">'+
				'<div class="PixNull"><div></div></div>'+
				'<div class="PixOne"><div></div></div>'+
				'<div class="PixTwo"><div></div></div>'+
				'<div class="PixThree"><div></div></div>'+
				'<div class="PixFour"><div></div></div>'+
			'</div>'+
		'</div>'+
		'<span id="'+Key+'_resize" class="WindowResizeButton"></span>'+
	'</div>';

	var WindowArea = document.getElementById("windows");
	WindowArea.appendChild(Wnd);

	Wnd.id=this.Key;
	Wnd.className="WindowFrame";
	Wnd.style.width=(parseInt(Width,10)+16)+"px";
	if (Left) {Wnd.style.left=Left+"px";}
	else
	{
		var WndLeft=(document.all) ? (document.documentElement.scrollLeft+((document.documentElement.clientWidth/2)-($(Key).offsetWidth/2))) : (window.pageXOffset+((window.innerWidth/2)-($(Key).offsetWidth/2)));
		if (WndLeft<0) {WndLeft=0;}
		Wnd.style.left=WndLeft+"px";
	}
	if (Top) {Wnd.style.top=Top+"px";}
	else
	{
		var WndTop=(document.all) ? (document.documentElement.scrollTop+((document.documentElement.clientHeight/2)-($(Key).offsetHeight/2))) : (window.pageYOffset+((window.innerHeight/2)-($(Key).offsetHeight/2)));
		if (WndTop<0) {WndTop=0;}
		Wnd.style.top=WndTop+"px";
	}
	Wnd.style.visibility="hidden";
	Wnd.style.zIndex=(80+App.Windows.length);
};



/* --- TOOLTIP OBJECT --- */

abToolTip=function(Key,AnchorID,ContainerID,HAlign,VAlign,Content,TipType,Width,Height)
{
	this.Key=Key;
	this.Content=Content;
	this.AnchorID=AnchorID;
	this.ContainerID=ContainerID;
	this.HAlign=HAlign;
	this.VAlign=VAlign;

	var t = document.createElement("div");
	t.innerHTML=
	'<div class="ToolTipArrow"></div>'+
	'<div class="ToolTipSpace" onclick="App.HideToolTip(\''+this.Key+'\');">'+
		'<div class="ToolTipHeadFoot">'+
			'<div class="ToolTipBody1">'+
				'<div id="'+Key+'_container" class="ToolTipBody2">'+
					Content+
				'</div>'+
			'</div>'+
		'</div>'+
	'</div>';

	var wnda = document.getElementById(ContainerID);
	wnda.appendChild(t);

	var hs,vs;

	switch (HAlign)
	{
		case "left": hs="A1Left"; break;
		case "right": hs="A1Right"; break;
		case "top": hs="A1Top"; break;
		case "bottom": hs="A1Bottom"; break;
	}
	switch (VAlign)
	{
		case "top": vs="A2Top"; break;
		case "center": vs="A2Middle"; break;
		case "bottom": vs="A2Bottom"; break;
	}

	if (HAlign=="left" || HAlign=="right")
	{
		switch (VAlign)
		{
			case "top": vs="A2Top"; break;
			case "center": vs="A2Middle"; break;
			case "bottom": vs="A2Bottom"; break;
		}
	}
	else if (HAlign=="top" || HAlign=="bottom")
	{
		switch (VAlign)
		{
			case "left": vs="A2Left"; break;
			case "center": vs="A2Center"; break;
			case "right": vs="A2Right"; break;
		}
	}

	t.id=this.Key;
	t.className="ToolTip "+hs+" "+vs+((TipType) ? " "+TipType : "");

	if (Width>0) {t.style.width=Width+"px";}
	if (Height>0) {t.style.height=Height+"px";}

	t. style.visibility="hidden";
	t.style.zIndex=(100);
};




/* --- APPLICATION OBJECT --- */

abApp=function(AppName,AppURL)
{
	this.AppName=AppName;
	this.AppURL=AppURL;
	this.Windows = new Array();
	this.Messages = new Array();
	this.LastMessageID = 0;
	this.ToolTips = new Array();
	this.Vars = new Object();
	this.Referrer=document.referrer;
};
abApp.prototype=
{
	AppName: "",
	AppURL: "",
	Referrer: "",
	WindowsUseDisplayLock: true,

	ActiveMenu: "",
	ActiveMenuButton: "",
	ActiveMenuWindow: "",
	ActiveMenuWindowButton: "",
	ActiveMenuForm: "",
	DisplayIsLocked: false,
	SessionID: "",
	SessionName: "sess",
	EventCaptions: ['<div class="Loader"><img src="http://www.fahrexperte.de/system/themes/yellow/gfx/preload.gif" border="0" alt=""></div>','','','',"Fehler"],
	ActiveWindow: "",
	WindowDragging: false,
	WindowResizing: false,
	WindowResizingLeft: 0,
	WindowResizingTop: 0,
	WindowClickX: 0,
	WindowClickY: 0,
	WindowMotionIncrement: 0,
	ToolTipTimeout: false,

	//<img src="http://www.fahrexperte.de/system/themes/yellow/gfx/preload.gif" border="0" alt="">

	onWindowUnload: function(Key) {return true;},
	onWindowCreate: function(Key) {},
	onWindowActivate: function(Key) {},
	onWindowDeactivate: function(Key) {},

	GetCachePreventionHash: function()
	{
		var Hash=""+Math.random();
		return Hash.replace(/\./,"");
	},


	/* --- TOOLTIPS --- */

	CreateToolTip: function(Key,AnchorID,ContainerID,Align,Content,TipType,Width,Height)
	{
		if ($(Key)) {this.UnloadToolTip(Key);}

		var a=Align.toLowerCase();
		a=a.split(" ");
		var ha="left";
		var va="top";
		if (a[0]) {ha=a[0];}
		if (a[1]) {va=a[1];}

		if (ContainerID=="") {ContainerID="windows";}

		App.ToolTips.push(new abToolTip(Key,AnchorID,ContainerID,ha,va,Content,TipType,Width,Height));

		return true;
	},
	ShowToolTip: function(Key,Content,Sleep,Left,Top)
	{
		if ($(Key))
		{
			var p;

			if (Sleep>0)
			{
				p=App.GetToolTipIndex(Key);
				App.ToolTips[p].Timer=window.setTimeout("App.ShowToolTip('"+Key+"','"+Content+"')",Sleep);
			}
			else
			{
				p=App.GetToolTipIndex(Key);

				$(Key+'_container').innerHTML=Content;

				Width=$(Key).offsetWidth;
				Height=$(Key).offsetHeight;

				r=$(App.ToolTips[p].AnchorID);
				c=$(App.ToolTips[p].ContainerID);

				var RelatedLeft=AbsLeft(r,c);
				var RelatedTop=AbsTop(r,c);

				var ClientWidth=(document.all) ? (document.documentElement.scrollLeft+document.documentElement.clientWidth) : (window.pageXOffset+window.innerWidth);
				var ClientHeight=(document.all) ? (document.documentElement.scrollTop+document.documentElement.clientHeight) : (window.pageYOffset+window.innerHeight);

				switch (App.ToolTips[p].HAlign)
				{
					case "left": TipLeft=RelatedLeft-Width; break;
					case "top": TipTop=RelatedTop-Height; break;
					case "right": TipLeft=RelatedLeft+r.offsetWidth; break;
					case "bottom": TipTop=RelatedTop+r.offsetHeight; break;
				}
				if (App.ToolTips[p].HAlign=="left" ||  App.ToolTips[p].HAlign=="right")
				{
					switch (App.ToolTips[p].VAlign)
					{
						case "top": TipTop=RelatedTop+r.offsetHeight-Height; break;
						case "center": TipTop=RelatedTop+(r.offsetHeight/2)-(Height/2); break;
						case "bottom": TipTop=RelatedTop; break;
					}
				}
				else if (App.ToolTips[p].HAlign=="top" || App.ToolTips[p].HAlign=="bottom")
				{
					switch (App.ToolTips[p].VAlign)
					{
						case "left": TipLeft=RelatedLeft-Width+r.offsetWidth; break;
						case "center": TipLeft=RelatedLeft+(r.offsetWidth/2)-(Width/2); break;
						case "right": TipLeft=RelatedLeft; break;
					}
				}

				$(Key).style.left=((parseInt(TipLeft,10)+((Left) ? parseInt(Left,10) : 0)))+"px";
				$(Key).style.top=((parseInt(TipTop,10)+((Top) ? parseInt(Top,10) : 0)))+"px";

				$(Key).style.visibility="visible";
				return true;
			}
		}
	},
	HideToolTip: function(Key,Sleep)
	{
		if ($(Key))
		{
			var p=App.GetToolTipIndex(Key);
			if (Sleep)
			{
				App.ToolTips[p].Timer=window.setTimeout("App.HideToolTip('"+Key+"')",Sleep);
			}
			else
			{
				window.clearTimeout(App.ToolTips[p].Timer);
				$(Key).style.visibility="hidden";
			}
		}
	},
	UnloadToolTip: function(Key)
	{
		if (!$(Key)) {return false;}
		$(Key).parentNode.removeChild($(Key));
		App.ToolTips.splice(App.GetToolTipIndex(Key),1);
		return true;
	},
	GetToolTipIndex: function(Key)
	{
		if (App.ToolTips.length==0) {return -1;}
		var i=0;
		while (App.ToolTips[i].Key!=Key || i>App.ToolTips.length-1) {i++;}
		if (App.ToolTips[i].Key!=Key) {return -1;} else {return i;}
	},
	FlushToolTips: function()
	{
		for (var i=0;i<App.ToolTips.length;i++) {App.UnloadToolTip(App.ToolTips[i].Key);}
	},


	/* --- WINDOWS --- */

	CreateWindow: function(Key,Title,Width,Height,Left,Top)
	{
		if (!$(Key))
		{
			App.onWindowCreate(Key);
			App.Windows.push(new abWindow(Key,Title,Width,Height,Left,Top));
			$(Key+'_inactive').onmousedown=function() {App.ActivateWindow(Key);};
			$(Key+'_close').onclick=function() {App.UnloadWindow(Key);};
			$(Key+'_header').onmousedown=App.BeginDragWindow;
			$(Key+'_resize').onmousedown=App.BeginResizeWindow;
		}
	},
	ActivateWindow: function(Key)
	{
		if (!$(Key)) {return false;}
		if (App.ActiveWindow!=Key)
		{
			App.onWindowActivate(Key);
			if (App.ActiveWindow) {App.DeactivateWindow();}
			$(Key+'_inactive').style.display="none";
			var p=App.GetWindowIndex(Key);
			var tmp=App.Windows[p];
			App.Windows.splice(p,1);
			App.Windows.push(tmp);
			App.ReorderWindows();
			App.ActiveWindow=Key;

			if (App.WindowsUseDisplayLock) {App.LockDisplay();}

			App.ShowWindow(Key);
		}
		return true;
	},
	DeactivateWindow: function()
	{
		if (!App.ActiveWindow) {return false;}
		else
		{
			App.onWindowDeactivate(App.ActiveWindow);
			$(App.ActiveWindow+'_inactive').style.width=($(App.ActiveWindow).offsetWidth)+"px";
			$(App.ActiveWindow+'_inactive').style.height=($(App.ActiveWindow).offsetHeight-20)+"px";
			$(App.ActiveWindow+'_inactive').style.display="";
			App.ActiveWindow="";
			return true;
		}
	},
	UnloadWindow: function(Key)
	{
		if (!$(Key)) {return false;}
		App.FlushToolTips();
		if (!App.onWindowUnload(Key)) {return false;}
		if (Key==App.ActiveWindow) {App.DeactivateWindow();}
		App.Windows.splice(App.GetWindowIndex(Key),1);
		$('windows').removeChild($(Key));
		if (App.Windows.length>0) {App.ActivateWindow(App.Windows[App.Windows.length-1].Key);}
		else {App.UnlockDisplay();}
		return true;
	},
	ShowWindow: function(Key)
	{
		$(Key).style.visibility="visible";
	},
	HideWindow: function(Key)
	{
		$(Key).style.visibility="hidden";
	},
	GetWindowIndex: function(Key)
	{
		if (App.Windows.length==0) {return -1;}
		var i=0;
		while (App.Windows[i].Key!=Key || i>App.Windows.length-1) {i++;}
		if (App.Windows[i].Key!=Key) {return -1;} else {return i;}
	},
	ReorderWindows: function()
	{
		for (var i=0;i<App.Windows.length;i++) {$(App.Windows[i].Key).style.zIndex=100+i;}
	},
	BeginDragWindow: function(e)
	{
		if (!App.WindowDragging)
		{
			var WindowKey=this.id;
			WindowKey=WindowKey.substring(0,WindowKey.lastIndexOf('_'));
			if (WindowKey!=App.ActiveWindow) {App.ActivateWindow(WindowKey);}
			App.WindowClickX=((document.all) ? window.event.x : e.pageX)-parseInt($(App.ActiveWindow).style.left,10);
			App.WindowClickY=((document.all) ? window.event.y : e.pageY)-parseInt($(App.ActiveWindow).style.top,10);
			App.WindowMotionIncrement=0;
			App.WindowDragging=true;
			document.onmousemove=App.DragWindow;
			document.onmouseup=App.EndDragWindow;
		}
	},
	DragWindow: function(e)
	{
		if (App.WindowDragging)
		{
			App.WindowMotionIncrement++;
			if (((App.WindowMotionIncrement/2)-parseInt(App.WindowMotionIncrement/2,10))==0)
			{
				var ClickX=(document.all) ? window.event.x : e.pageX;
				var ClickY=(document.all) ? window.event.y : e.pageY;
				$(App.ActiveWindow).style.left=((ClickX-App.WindowClickX>0) ? ClickX-App.WindowClickX : 0)+"px";
				$(App.ActiveWindow).style.top=((ClickY-App.WindowClickY>0) ? ClickY-App.WindowClickY : 0)+"px";
			}
			App.ReleaseFocus();
		}
	},
	EndDragWindow: function(e)
	{
		App.WindowDragging=false;
		document.onmousemove=null;
		document.onmouseup=null;
	},
	BeginResizeWindow: function(e)
	{
		if (!App.WindowResizing)
		{
			var WindowKey=this.id;
			WindowKey=WindowKey.substring(0,WindowKey.lastIndexOf('_'));
			if (WindowKey!=App.ActiveWindow) {App.ActivateWindow(WindowKey);}
			App.WindowResizingLeft=parseInt($(App.ActiveWindow).style.left,10);
			App.WindowResizingTop=parseInt($(App.ActiveWindow).style.top,10);
			App.WindowClickX=((document.all) ? window.event.x-2 : e.pageX)-parseInt($(App.ActiveWindow).style.left,10)-$(App.ActiveWindow).offsetWidth+17;
			App.WindowClickY=((document.all) ? window.event.y-2 : e.pageY)-parseInt($(App.ActiveWindow).style.top,10)-$(App.ActiveWindow).offsetHeight+17;
			App.WindowMotionIncrement=0;
			App.WindowResizing=true;
			document.onmousemove=App.ResizeWindow;
			document.onmouseup=App.EndResizeWindow;
		}
	},
	ResizeWindow: function(e)
	{
		if (App.WindowResizing)
		{
			App.WindowMotionIncrement++;
			if (((App.WindowMotionIncrement/2)-parseInt(App.WindowMotionIncrement/2,10))==0)
			{
				var ClickX=(document.all) ? window.event.x : e.pageX;
				var ClickY=(document.all) ? window.event.y : e.pageY;
				if (ClickX-App.WindowResizingLeft>700) {$(App.ActiveWindow).style.width="700px";}
				else if (ClickX-App.WindowResizingLeft<=200) {$(App.ActiveWindow).style.width="200px";}
				else {$(App.ActiveWindow).style.width=(ClickX-App.WindowResizingLeft+17-App.WindowClickX)+"px";}
				if (ClickY-App.WindowResizingTop-37>530) {$(App.ActiveWindow+'_container').style.height="530px";}
				else if (ClickY-App.WindowResizingTop-37<=180) {$(App.ActiveWindow+'_container').style.height="180px";}
				else {$(App.ActiveWindow+'_container').style.height=(ClickY-App.WindowResizingTop-33+17-App.WindowClickY)+"px";}
			}
			App.ReleaseFocus();
		}
	},
	EndResizeWindow: function(e)
	{
		App.WindowResizing=false;
		document.onmousemove=null;
		document.onmouseup=null;
	},


	/* --- FORMS --- */

	DecodeForm: function(Data,Form)
	{
		return Data
		//.replace(/˙11/g,Form)
		.replace(/˙1/g,"</div></div></div>")
		.replace(/˙2/g,"</div></div>")
		.replace(/˙3/g,"<div></div>")
		.replace(/˙4/g,'href="#document"')
		.replace(/˙5/g,"DataFormEditTextBox('df")
		.replace(/˙6/g,'<a href="')
		.replace(/˙7/g,"</div></td>")
		.replace(/˙8/g,"CommandButton")
		.replace(/˙9/g,"TextBox")
		.replace(/˙A/g,'<div class="Value">')
		.replace(/˙B/g,'<span class="')
		.replace(/˙C/g,"<label for=")
		.replace(/˙D/g,'App.LoadForm(\'')
		.replace(/˙E/g,'<div id="')
		.replace(/˙F/g,'type="')
		.replace(/˙G/g,'class="Column"')
		.replace(/˙H/g,'<table class="')
		.replace(/˙I/g,'Cancel=true;')
		.replace(/˙J/g,"').focus();")
		.replace(/˙K/g,"<tr class=")
		.replace(/˙L/g,"<div ")
		.replace(/˙M/g,"text-align: left;")
		.replace(/˙N/g,'style="')
		.replace(/˙O/g,'class="')
		.replace(/˙P/g,'onclick="')
		.replace(/˙Q/g,'width: ')
		.replace(/˙R/g,'value="')
		.replace(/˙S/g,'</td><td')
		.replace(/˙T/g,'_container')
		.replace(/˙U/g,'<input')
		.replace(/˙V/g,'</a>')
		.replace(/˙W/g,'</td>')
		.replace(/˙X/g,'</tr>')
		.replace(/˙Y/g,'</table>')
		.replace(/˙Z/g,'><td')
		.replace(/˙a/g,'</label>')
		.replace(/˙b/g,"='+escape(\$('")
		.replace(/˙c/g,"').value)")
		.replace(/˙d/g,"VarStr+=((VarStr!='') ? '&' : '')+'")
		.replace(/˙e/g,"border")
		.replace(/˙f/g,"vertical-align:")
		.replace(/˙g/g,"text-align:")
		.replace(/˙h/g,"center;")
		.replace(/˙i/g,"middle;")
		.replace(/˙j/g,"order_column")
		.replace(/˙k/g,"order_direction");

	},
	LoadForm: function(Container,Form,Arguments,CallBack,StateHide)
	{
		var Ajax = new abAjax();
		Ajax.Parent=this;
		if (!StateHide)
		{
			if ($(Container))
			{
				Ajax.onOpen=function() {$(Container).innerHTML=Ajax.Parent.EventCaptions[0];};
				//Ajax.onSent=function() {$(Container).innerHTML=Ajax.Parent.EventCaptions[1];};
				//Ajax.onReceiving=function() {$(Container).innerHTML=Ajax.Parent.EventCaptions[2];};
				//Ajax.onError=function() {$(Container).innerHTML=Ajax.Parent.EventCaptions[4];};
			}
		}
		Ajax.onLoaded=function()
		{
			if ($(Container))
			{
				var xmlResponse=Ajax.Request.responseXML.documentElement;
				var Content=xmlResponse.getElementsByTagName("content")[0].firstChild.data;

				var HeaderArr = new Object();
				if (xmlResponse.getElementsByTagName("headers")[0])
				{
					var HeaderNodes=xmlResponse.getElementsByTagName("headers")[0].childNodes;
					for (var i=0;i<HeaderNodes.length;i++)
					{
						HeaderArr[HeaderNodes[i].getAttribute("key")]=HeaderNodes[i].firstChild.data;
					}
				}

				$(Container).innerHTML=App.DecodeForm(Content,Form);
			}
			if (CallBack) {CallBack(HeaderArr,Arguments);}
		};

		if (Arguments) {Arguments="&"+Arguments;} else {Arguments="";}
		Ajax.GetData(this.AppURL+"/load.form?form="+Form+Arguments
		+((this.SessionID) ? "&"+this.SessionName+"="+this.SessionID : ""),false);
	},
	PostData: function(Container,Form,Arguments,Data,CallBack,StateHide)
	{
		var Ajax = new abAjax();
		Ajax.Parent=this;

		if (!StateHide)
		{
			if ($(Container))
			{
				Ajax.onOpen=function() {$(Container).innerHTML=Ajax.Parent.EventCaptions[0];};
				Ajax.onSent=function() {$(Container).innerHTML=Ajax.Parent.EventCaptions[1];};
				Ajax.onReceiving=function() {$(Container).innerHTML=Ajax.Parent.EventCaptions[2];};
				Ajax.onError=function() {$(Container).innerHTML=Ajax.Parent.EventCaptions[4];};
			}
		}
		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var Content=xmlResponse.getElementsByTagName("content")[0].firstChild.data;

			var HeaderArr = new Object();
			if (xmlResponse.getElementsByTagName("headers")[0])
			{
				var HeaderNodes=xmlResponse.getElementsByTagName("headers")[0].childNodes;
				for (var i=0;i<HeaderNodes.length;i++)
				{
					HeaderArr[HeaderNodes[i].getAttribute("key")]=HeaderNodes[i].firstChild.data;
				}
			}

			$(Container).innerHTML=App.DecodeForm(Content);

			if (CallBack) {CallBack(HeaderArr,Arguments,Data);}
		};
		Ajax.onError=function()
		{
			alert('here error');
		};
		if (Arguments) {Arguments="&"+Arguments;} else {Arguments="";}
		Ajax.PostData(this.AppURL+"/load.form?form="+Form+Arguments
		+((this.SessionID) ? "&"+this.SessionName+"="+this.SessionID : ""),Data);
	},
	LoadMenuWindow: function(Menu,Button,Form,Arguments,CallBack,LoadOnce)
	{
		this.CloseMenuWindow();
		if (this.ActiveMenu!="")
		{
			$(this.ActiveMenu+"_"+this.ActiveMenuButton).className="Button";
		}
		$(Menu+"_"+Button).className="SelectedButton";
		Show(Menu+"_"+Button+"_window");
		this.LoadForm(Menu+"_"+Button+"_window_container",Form,Arguments,CallBack,false);
		this.ActiveMenuWindow=Menu;
		this.ActiveMenuWindowButton=Button;
	},
	CloseMenuWindow: function()
	{
		if (this.ActiveMenuWindow!="")
		{
			Hide(this.ActiveMenuWindow+"_"+this.ActiveMenuWindowButton+"_window");
			$(this.ActiveMenuWindow+"_"+this.ActiveMenuWindowButton).className="Button";
			this.ActiveMenuWindow="";
			this.ActiveMenuWindowButton="";
		}
	},
	LoadMenuForm: function(Menu,Button,Form,Arguments,CallBack,StateHide)
	{
		if (this.ActiveMenu!="")
		{
			$(this.ActiveMenu+"_"+this.ActiveMenuButton).className="Button";
		}
		$(Menu+"_"+Button).className="SelectedButton";
		this.ActiveMenu=Menu;
		this.ActiveMenuButton=Button;
		this.ActiveMenuForm=Form;
		this.CloseMenuWindow();
		this.LoadForm("display_container",Form,Arguments,CallBack,StateHide);
	},
	SwapWindow: function(Key,WithButton)
	{
		if ($(Key+"_container").style.display=="")
		{
			if (WithButton) {$(Key+"_swap").className="MaximizeButton";}
			Hide(Key+"_container");
		}
		else
		{
			if (WithButton) {$(Key+"_swap").className="MinimizeButton";}
			Show(Key+"_container");
		}
	},
	ShowPrintPopup: function(Form)
	{
		var Left=screen.availWidth/2-800/2;
        var Top=screen.availHeight/2-600/2;
        var Popup=window.open(App.AppURL+"/print.php?form="+Form,'','width=800,height=600,left='+Left+',top='+Top+',screenX='+Left+',screenY='+Top+",menubar,scrollbars,resizeable");
		return Popup;
	},
	UnlockDisplay: function()
	{
		$("inactive").style.display="none";
		this.DisplayIsLocked=false;
		//$("display_frame").style.overflow="auto";
		//$("display_frame").style.overflowY="scroll";
	},
	LockDisplay: function()
	{
		this.DisplayIsLocked=true;
		this.ArrangeDisplayLock();
		$("inactive").style.display="block";
		//$("display_frame").style.overflow="hidden";
		//$("display_frame").style.overflowY="hidden";
	},
	ArrangeDisplayLock: function()
	{
		if (App.DisplayIsLocked)
		{
			var ClientWidth=((document.all) ? document.documentElement.clientWidth : window.innerWidth);
			var ClientHeight=((document.all) ? document.documentElement.clientHeight : window.innerHeight);
			$("inactive").style.left="0px";
			$("inactive").style.top="0px";
			$("inactive").style.width=((ClientWidth>$("body_container").offsetWidth) ? ClientWidth : $("body_container").offsetWidth)+"px";
			$("inactive").style.height=((ClientHeight>$("body_container").offsetHeight) ? ClientHeight : $("body_container").offsetHeight)+"px";
		}
	},
	ReleaseFocus: function()
	{
		$('unfocus').focus();
	},
	SetOpacity: function(Element,Value)
	{
		$(Element).style.opacity=(Value/10);
		if (document.all) {$(Element).style.height="42px";}
		$(Element).style.filter='alpha(opacity='+(Value*10)+')';
	},
	CreateInlineMessage: function(Title,Content,Type)
	{
		this.LastMessageID++;
		App.Messages.push(new abInlineMessage(this.LastMessageID,Title,Content,Type));
		App.RemoveInlineMessage(this.LastMessageID,10000);
		return true;
	},
	RemoveInlineMessage: function(ID,Sleep,Fade)
	{
		if ($("message_"+ID))
		{
			var Index=App.GetMessageIndex(ID);
			if (Sleep)
			{
				App.Messages[Index].Timer=window.setTimeout("App.RemoveInlineMessage('"+ID+"',0,11)",Sleep);
			}
			else if (Fade>0)
			{
				App.SetOpacity("message_"+ID,Fade);
				Fade--;

				App.Messages[Index].FadeTimer=window.setTimeout("App.RemoveInlineMessage('"+ID+"',0,"+Fade+")",100);
			}
			else
			{
				window.clearTimeout(App.Messages[Index].Timer);

				App.Messages.splice(Index,1);
				$('messages').removeChild($("message_"+ID));
			}
		}
	},
	ActivateMessage: function(ID)
	{
		if (!$("message_"+ID)) {return false;}

		var Index=App.GetMessageIndex(ID);
		if (App.LastMessageID!=ID)
		{

			var Message=App.Messages[Index];
			App.Messages.splice(Index,1);
			App.Messages.push(Message);
			App.ReorderMessages();

			App.LastMessageID=ID;
		}
		//window.clearTimeout(App.Messages[Index].Timer);
		//window.clearTimeout(App.Messages[Index].FadeTimer);
		//App.RemoveInlineMessage(ID,10000);

		return true;
	},
	ReorderMessages: function()
	{
		for (var i=0;i<App.Messages.length;i++) {$("message_"+App.Messages[i].ID).style.zIndex=120+i;}
	},
	GetMessageIndex: function(ID)
	{
		if (App.Messages.length==0) {return -1;}
		var i=0;
		while (App.Messages[i].ID!=ID || i>App.Messages.length-1) {i++;}
		if (App.Messages[i].ID!=ID) {return -1;} else {return i;}
	}
};








/* --- INLINE MESSAGE OBJECT --- */

abInlineMessage=function(ID,Title,Content,Type)
{
	// Type = critical, exclamation, information, question

	this.ID=ID;
	this.Content=Content;
	this.Type=Type;

	var ViewWidth=((document.all) ? (((window.innerWidth) ? window.pageXOffset+window.innerWidth : ((document.documentElement) ? document.documentElement.scrollLeft+document.documentElement.clientWidth : document.body.scrollLeft+document.body.clientWidth))) : (window.pageXOffset+window.innerWidth));
	var m = document.createElement("div");

	m.innerHTML=
	'<div'+
	' onclick="App.ActivateMessage('+this.ID+');"'+
	' class="MessageBox_'+Type+'">'+
		'<div class="MessageBoxContent">'+
		'<a href="#document" title="Schlie&szlig;en" style="float: right; cursor: pointer;" class="MessageBoxCloser" onclick="App.RemoveInlineMessage('+this.ID+',0);"></a>'+
			/* '<span class="MessageBoxTitle">'+Title+':</span>'+ */
			'<span class="MessageBoxBody">'+Content+'</span>'+
		'</div>'+

	'</div>';

	var wnda = document.getElementById("messages");
	wnda.appendChild(m);

	m.style.visibility="hidden";
	m.id='message_'+this.ID;
	m.style.position="absolute";
	m.style.zIndex=120+this.ID;
	m.style.top="0px";
	m.style.width="360px";


	if (App.Messages.length>0)
	{
		m.style.left=((ViewWidth/2)-(m.offsetWidth/2))+(App.Messages.length*30)+'px';
	}
	else
	{
		m.style.left=((ViewWidth/2)-(m.offsetWidth/2))+'px';
	}
	m.style.visibility="visible";
};




/* --- USER OBJECT --- */

abUser=function(HandlerURL,SessionName)
{
	this.HandlerURL=HandlerURL;
	this.SessionName=SessionName;
};
abUser.prototype=
{
	HandlerURL: "",
	SessionName: "",
	UserID: "",
	Username: "",
	SessionID: "",

	onLogin: function(){},
	onLogout: function(){},
	onBeforeLogout: function(){},
	onPing: function(){},
	onPong: function(){},
	onLoginFailed: function(Reason){},
	onLogoutFailed: function(Reason){},
	onTerminate: function(Reason){},

	Login: function(Username,Password)
	{
		var Ajax = new abAjax(); Ajax.Parent=this;
		Ajax.onError=function() {Ajax.Parent.onLoginFailed(0);};
		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;
			if (ResponseCode=="200")
			{
				Ajax.Parent.SessionID=xmlResponse.getElementsByTagName("sessionid")[0].firstChild.data;
				Ajax.Parent.UserID=xmlResponse.getElementsByTagName("userid")[0].firstChild.data;
				Ajax.Parent.Username=xmlResponse.getElementsByTagName("username")[0].firstChild.data;
				Ajax.Parent.onLogin();
			}
			else
			{
				Ajax.Parent.onLoginFailed(ResponseCode);
			}
		};
		Ajax.PostData(this.HandlerURL,"username="+Username+"&password="+Password,false);
	},
	Logout: function(ForceLogout)
	{
		if (this.SessionID!="")
		{
			var Ajax = new abAjax(); Ajax.Parent=this;
			if (ForceLogout!=true)
			{
				Ajax.onError=function() {Ajax.Parent.onLogoutFailed(0);};
				Ajax.onLoaded=function()
				{
					var xmlResponse=Ajax.Request.responseXML.documentElement;
					var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;
					if (ResponseCode=="200")
					{
						Ajax.Parent.SessionID="";
						Ajax.Parent.UserID=0;
						Ajax.Parent.Username="";
						Ajax.Parent.onLogout();
					}
					else if (ForceLogout!=true)
					{
						Ajax.Parent.onLogoutFailed(ResponseCode);
					}
				};
			}
			this.onBeforeLogout();
			Ajax.PostData(this.HandlerURL,this.SessionName+"="+this.SessionID+"&logout=logout",false,ForceLogout);
		}
	},
	Ping: function()
	{
		var Ajax = new abAjax(); Ajax.Parent=this;
		Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;
			if (ResponseCode=="200")
			{
				Ajax.Parent.SessionID=xmlResponse.getElementsByTagName("sessionid")[0].firstChild.data;
				Ajax.Parent.onPong();
			}
			else
			{
				Ajax.Parent.SessionID="";
				Ajax.Parent.UserID="";
				Ajax.Parent.Username="";
				Ajax.Parent.onTerminate(ResponseCode);
			}
		};
		this.onPing();
		Ajax.PostData(this.HandlerURL,this.SessionName+"="+this.SessionID,false);
	}
};


/* --- MISC FUNCTIONS --- */

fixPNG=function()
{
	if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
		if (!(navigator.appVersion.indexOf("MSIE 7")>-1))
		{
			var png = /\.png$/i;
			var imgs = document.getElementsByTagName('img');



			(($('inactive').offsetWidth>0) ? $('inactive').style.width=$('inactive').offsetWidth : '');
			(($('inactive').offsetHeight>0) ? $('inactive').style.height=$('inactive').offsetHeight : '');

			$('inactive').style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+$('inactive').src+'\',sizingMethod=\'scale\')';
			$('inactive').src=App.AppURL+'/content/images/fixpng/blank.gif';

			for (var i=0,l=imgs.length;i<l;i++)
			{
				if (png.test(imgs[i].src))
				{
					((imgs[i].offsetWidth>0) ? imgs[i].style.width=imgs[i].offsetWidth : '');
					((imgs[i].offsetHeight>0) ? imgs[i].style.height=imgs[i].offsetHeight : '');
					if (imgs[i].src.indexOf("/fahrexperte_summer.png")==-1 && imgs[i].src.indexOf("/fahrexperte_community.png")==-1)
					{
						if (imgs[i].src.indexOf("/content/images")>-1)
						{
							imgs[i].style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+imgs[i].src+'\',sizingMethod=\'image\')';
						}
						else
						{
							imgs[i].style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+imgs[i].src+'\',sizingMethod=\'scale\')';
						}

						//imgs[i].src=App.AppURL+'/content/images/fixpng/blank.gif';
					}
				}


			}
		}
	}
};


DecodeXMLValue=function(Value)
{
	Value=Value.replace(/\[LT\]/g,'<');
	Value=Value.replace(/\[AMP\]/g,'&');
	return Value;
};

NewWindow=function(Name,Form,Arguments,Title,Width,Height)
{
	App.CreateWindow(Name,Title,Width,Height);
	App.ActivateWindow(Name);
	App.LoadForm(Name+'_container',Form,Arguments);
	return false;
};










/* --- EVENT HANDLER --- */

abEventHandler=function()
{

};
abEventHandler.prototype=
{
	AddEvent: function(obj,type,func)
	{
		if (type=="DOMMouseScroll" && document.all)
		{
			type="mousewheel";
		}

		if (obj.addEventListener)
		{
			obj.addEventListener(type,func,false);
		}
		else if (obj.attachEvent)
		{
			obj["e"+type+func]=func;
			obj[type+func]=function()
			{
				obj["e"+type+func](window.event);
			}
			obj.attachEvent("on"+type,obj[type+func]);
		}
		else
		{
			obj["on"+type]=obj["e"+type+func];
		}
	},
	RemoveEvent: function(obj,type,func)
	{
		if (obj.removeEventListener)
		{
			obj.removeEventListener(type,func,false);
		}
		else if (obj.detachEvent)
		{
			obj.detachEvent("on"+type,obj[type+func]);
			obj[type+func]=null;
			obj["e"+type+func]=null;
		}
		else
		{
			obj["on"+type]=null;
		}
	}
};




/* --- NEWS READER CONTROL --- */

abNewsReader=function()
{
	this.Key=""; // Container ID
	this.NC = {}; // News container
	this.NCount=0; // News count
	this.FdT=0; // Fade timer
	this.FdI=0; // Fade interval

	this.Scroll=true; // Scroll initiated
	this.ScrBrk=7500; // Scroll break
	this.ScrT=33; // Scroll interval timer
	this.ScrPos=0; // Scroll position
};
abNewsReader.prototype=
{
	StartScroll: function()
	{
		this.Scroll=true;
		this.ScrPos=0;
		this.FdT=window.setTimeout("NewsReader.ScrollNews()",this.ScrBrk);
	},
	StopScroll: function()
	{
		this.Scroll=false;
		window.clearInterval(this.FdI);
		this.ScrPos=-1;
	},
	NextNews: function()
	{
		NewsReader.ScrollNews();
	},
	ScrollNews: function()
	{
		this.NCount=this.NC.childNodes.length;

		if (this.NC.childNodes[0] && this.Scroll==true)
		{
			if (this.ScrPos==120)
			{
				var NCC = this.NC.childNodes[0].cloneNode(true);

				this.NC.removeChild(this.NC.firstChild);
				this.NC.appendChild(NCC);
				this.NC.lastChild.style.marginTop="0";

				this.StopScroll();
				this.StartScroll();
			}
			else if (this.ScrPos<120 && this.ScrPos>0)
			{
				this.NC.childNodes[0].style.marginTop="-"+(this.ScrPos/10)+"em";
				this.ScrPos++;
			}
			else if (this.ScrPos==0)
			{
				window.clearTimeout(this.FdT);
				this.FdI = window.setInterval("NewsReader.ScrollNews()",this.ScrT);
				this.ScrPos++;
			}
		}
	},
	ScrollInit: function(Key)
	{
		this.Key=Key;

		if (!$(this.Key)) {$("newsfeed_frame").style.display="none";}
		else if ($(this.Key).childNodes.length>1)
		{
			$(this.Key).style.height="12em";
			$(this.Key).style.paddingTop="0";
			$(this.Key).style.paddingBottom="0";
			$(this.Key).style.paddingLeft="0";
			$(this.Key).style.paddingRight="0";

			if (!$("news_next")) {}
			else
			{
				$("news_next").style.display="";
				EventHandler.AddEvent($("news_next").firstChild,"click",NewsReader.NextNews);
			}

			$("news_box_overview").style.marginRight="-1.2em";

			$("newsfeed_container").style.paddingTop="1em";
			$("newsfeed_container").style.paddingBottom="1em";
			$("newsfeed_container").style.paddingLeft="2em";
			$("newsfeed_container").style.paddingRight="2em";
			this.NC=$(this.Key);
			this.FdT=window.setTimeout("NewsReader.ScrollNews()",this.ScrBrk);
		}
	}
};





/**
	
	AJAX Basic - Common Controls Library
	
	Version:	1.0
	
	Copyright © 2008 by AEYOL SOLUTIONS LTD.
	
	
	Autor(s):	Kristoph Junge (junge@aeyol.com)
	Date:		2007-04-04
	

*/

/* --- AJAX MENU --- */
SlowMenu=function(i,a,n,a2)
{
    return (180-((a2*(n-i)*(n-i))+( i % ((n/2)) + (a*(n-i)) ) ));
};

/* --- FLASH INTRO --- */

abFlsIntro=function()
{
	this.FlsID="";
};
abFlsIntro.prototype=
{
	FlsIntro: function(ID)
	{
		this.FlsIntroFalse(ID);
	},
	FlsIntroFalse: function(ID)
	{
		var Fls;
		
		if (!document.all)
		{
			Fls=document.embeds;
		}
		else
		{
			Fls=window.document[ID];
		}
		
		if (ID!="")
		{
			if (!document.all)
			{
				for (i=0;i<Fls.length;i++)
				{
					if (Fls[i].id==ID)
					{
						Fls[i].TGotoFrame("_flash0",99);
						Fls[i].TPlay("_flash0");
					}
				}
			}
			else
			{
				Fls.TGotoFrame("_flash0",99);
				Fls.TPlay("_flash0");
			}
		}
		
		if (this.FlsID!=ID) {this.FlsID=ID;}
	}
};

/* --- FLASH MENU --- */

abFlsBtnMenu=function()
{
	this.FlsLastID="";
};
abFlsBtnMenu.prototype=
{
	FlsBtn: function(ID)
	{
		this.FlsBtnChng(ID);
	},
	FlsBtnChng: function(ID)
	{
		var Fls;
		
		if (!document.all)
		{
			Fls=document.embeds;
		}
		else
		{
			Fls=window.document["FlsButton_"+this.FlsLastID];
		}
		
		if (this.FlsLastID!="")
		{
			if (!document.all)
			{
				for (i=0;i<Fls.length;i++)
				{
					if (Fls[i].id=="FlsButton_"+this.FlsLastID)
					{
						Fls[i].TGotoFrame("_flash0",54);
						Fls[i].TPlay("_flash0");
					}
				}
			}
			else
			{
				Fls.TGotoFrame("_flash0",54);
				Fls.TPlay("_flash0");
			}
		}
		
		
		var ClickID=ID.split("_");
		AgpFlsMenuButtonClick(ClickID[0],ClickID[1]);
		
		if (this.FlsLastID!=ID) {this.FlsLastID=ID;}
	},
	FlsBtnOpn: function(ID)
	{
		var Fls;
		
		clearTimeout(FlsViewTimer);
		
		if (!document.all)
		{
			Fls=document.embeds;
		}
		else
		{
			Fls=window.document["FlsButton_"+ID];
		}
		
		if (!document.all)
		{
			for (i=0;i<Fls.length;i++)
			{
				if (Fls[i].id=="FlsButton_"+ID)
				{
					Fls[i].TGotoFrame("_flash0",45);
				}
			}
		}
		else
		{
			Fls.TGotoFrame("_flash0",45);
		}
		if (this.FlsLastID!=ID) {this.FlsLastID=ID;}
	}
};

FlsIntroShow=function()
{
	if (ClientBrwsPltfrm.indexOf("Linux")>=0)
	{
		if (!$("intro_display")) {}
		else
		{
			if ($("intro_display").style.visibility=="hidden")
			{
				$("intro_display").style.visibility="visible";
			}
		}
	}
};

FlsIntroHide=function()
{
	if (ClientBrwsPltfrm.indexOf("Linux")>=0)
	{
		if (!$("intro_display")) {}
		else
		{
			if ($("intro_display").style.visibility=="visible" || $("intro_display").style.visibility=="")
			{
				$("intro_display").style.visibility="hidden";
			}
		}
	}
};

/* --- TAB --- */

TabButtonMouseOver=function(Tab,Button)
{
	if ($(Tab+"_"+Button).className=="Tab TabSelected")
	{
		$(Tab+"_"+Button).className="Tab TabSelected TabOn";
	}
	else if ($(Tab+"_"+Button).className!="Tab TabOff")
	{
		$(Tab+"_"+Button).className="Tab TabOn";
	}
};
TabButtonMouseOut=function(Tab,Button)
{
	if ($(Tab+"_"+Button).className=="Tab TabSelected TabOn")
	{
		$(Tab+"_"+Button).className="Tab TabSelected";
	}
	else if ($(Tab+"_"+Button).className!="Tab TabOff")
	{
		$(Tab+"_"+Button).className="Tab";
	}
};
TabButtonSelect=function(Tab,Button)
{
	if ($(Tab+"_"+Button).className!="Tab TabOff")
	{
		$(Tab+"_"+$(Tab+"_value").innerHTML).className="Tab";
		$(Tab+"_value").innerHTML=Button;
		$(Tab+"_"+Button).className="Tab TabSelected TabOn";
		return true;
	}
};
TabGetSelected=function(Tab)
{
	return $(Tab+"_value").innerHTML;
};



/* --- DATAFORM --- */

DataFormEditTextBox=function(DataForm,Key)
{
	if (!$(DataForm+"_"+Key).readOnly)
	{
		$(DataForm+"_"+Key).className="Active";
	}
};
DataFormEndEditTextBox=function(DataForm,Key)
{
	Hide(DataForm+"_"+Key);
	Show(DataForm+"_"+Key);
};
DataFormEditAddressBox=function(DataForm,Key)
{
	$(DataForm+"_"+Key).className="Active";
};
DataFormEndEditAddressBox=function(DataForm,Key)
{
	Hide(DataForm+"_"+Key);
	Show(DataForm+"_"+Key);
};
DataFormEditDateBox=function(DataForm,Key)
{
	$(DataForm+"_"+Key).className="Active";
};
DataFormGetDate=function(DataForm,Key)
{
	var ISODate=
	$(DataForm+"_"+Key+"_year").value+"-"+
	$(DataForm+"_"+Key+"_month").value+"-"+
	$(DataForm+"_"+Key+"_day").value;
	return ISODate;
};
DataFormGetSelectedOption=function(DataForm,Option)
{
	var Count=parseInt($(DataForm+"_"+Option+"_count").value);
	for (var i=0;i<Count;i++)
	{
		if ($(DataForm+"_"+Option+"_"+i).checked)
		{
			return $(DataForm+"_"+Option+"_"+i).value;
		}
	}
};
DataFormSetSelectedOption=function(DataForm,Option,Value)
{
	var Count=parseInt($(DataForm+"_"+Option));
	for (var i=0;i<Count;i++)
	{
		if ($(DataForm+"_"+Option+"_"+i).value==Value)
		{
			$(DataForm+"_"+Option+"_"+i).checked=true;
			return true;
		}
	}
};
DataFormCheckListChange=function(DataForm,CheckList,Value,Check)
{
	if (Check.checked)
	{
		$(DataForm+"_"+CheckList).value+=(($(DataForm+"_"+CheckList).value) ? ";" : "")+Value;
	}
	else
	{
		var TmpChecked=";"+$(DataForm+"_"+CheckList).value+";";
		TmpChecked=TmpChecked.replace(";"+Value+";",";");
		TmpChecked=TmpChecked.replace(";;",";");
		if (TmpChecked.substr(0,1)==";") {TmpChecked=TmpChecked.substr(1,TmpChecked.length-1);}
		if (TmpChecked.substr(TmpChecked.length-1,1)==";") {TmpChecked=TmpChecked.substr(0,TmpChecked.length-1);}
		$(DataForm+"_"+CheckList).value=TmpChecked;
	}
};



/* --- PROGRESSBAR --- */

ProgressBarSetValue=function(ProgressBar,Value)
{
	$(ProgressBar+"_label").innerHTML=Value+"%";
	
	if (Value>0)
	{
		$(ProgressBar+"_value").style.width=Value+"%";
	}
	else
	{
		$(ProgressBar+"_value").style.width="1px";
	}
};
ProgressBarScrollTo=function(ProgressBar,Value,Wait)
{
	ProgressBarSetValue(ProgressBar,0);
	for (var i=1;i<=Value;i=i+5)
	{
		window.setTimeout("ProgressBarSetValue('"+ProgressBar+"','"+i+"')",(i*25)+Wait);
	}
	ProgressBarSetValue(ProgressBar,Value);
};



/* --- DATAGRID --- */

DataGridGetSelectedRows=function(DataGrid)
{
	var CheckedStr="";
	for (var i=0;i<parseInt($(DataGrid+"_count").innerHTML);i++)
	{
		if ($(DataGrid+"_check_"+i).checked)
		{
			if (CheckedStr!="") {CheckedStr+=",";}
			CheckedStr+=i;
		}
	}
	return CheckedStr;
};
DataGridRowMultiCheck=function(DataGrid,Row,Checkbox)
{
	if ($(DataGrid+"_row_"+Row).className!='RowDisabled')
	{		
		if (Checkbox!=false)
		{
			$(DataGrid+"_check_"+Row).checked=!$(DataGrid+"_check_"+Row).checked;
		}
		if ($(DataGrid+"_check_"+Row).checked)
		{
			$(DataGrid+"_row_"+Row).className="RowSelected";
		}
		else
		{
			$(DataGrid+"_row_"+Row).className="Row";
		}
	}
};
DataGridRowCheck=function(DataGrid,Row)
{
	if ($(DataGrid+"_row_"+Row).className!='RowDisabled')
	{	
		var LastSelected=DataGridGetSelectedRows(DataGrid);
		
		if (LastSelected!='' && Row!=LastSelected)
		{
			$(DataGrid+"_check_"+LastSelected).checked=false;
			$(DataGrid+"_row_"+LastSelected).className="Row";
		}
	
		$(DataGrid+"_check_"+Row).checked=true;
		$(DataGrid+"_row_"+Row).className="RowSelected";
	}
};
DataGridGetColumn=function(DataGrid)
{
	return $(DataGrid+"_column").innerHTML;
};
DataGridGetDirection=function(DataGrid)
{
	return $(DataGrid+"_direction").innerHTML;
};
/*
DataGridGetSelected=function(DataGrid)
{
	return $(DataGrid+"_selected").innerHTML;
};
*/
DataGridGetCount=function(DataGrid)
{
	return parseInt($(DataGrid+"_count").innerHTML);
};
DataGridGetSelected=function(DataGrid)
{
	var CheckedStr="";
	for (var i=0;i<parseInt($(DataGrid+"_count").innerHTML);i++)
	{
		if (!$(DataGrid+"_check_"+i).disabled)
		{
			if ($(DataGrid+"_check_"+i).checked)
			{
				if (CheckedStr!="") {CheckedStr+=",";}
				CheckedStr+=$(DataGrid+"_check_"+i).value;
			}
		}
	}
	return CheckedStr;
};



/* --- SWITCH --- */

SwitchNext=function(Switch)
{
	if (parseInt($(Switch+"_index").value)<parseInt($(Switch+"_count").value)-1)
	{
		$(Switch+"_"+(parseInt($(Switch+"_index").value)+1)+"_select").onclick();
	}
};
SwitchPrevious=function(Switch)
{
	if (parseInt($(Switch+"_index").value)>0)
	{
		$(Switch+"_"+(parseInt($(Switch+"_index").value)-1)+"_select").onclick();
	}
};
SwitchSelectItem=function(Switch,Index,Key)
{
	$(Switch+"_value").value=Key;
	$(Switch+"_"+$(Switch+"_index").value).style.display="none";
	$(Switch+"_"+$(Switch+"_index").value+"_select").className="PopupItem";
	$(Switch+"_index").value=Index;
	$(Switch+"_"+$(Switch+"_index").value).style.display="block";
	$(Switch+"_"+$(Switch+"_index").value+"_select").className="PopupItemSelected";
	$(Switch+"_popup").style.marginTop="-"+($(Switch+"_"+$(Switch+"_index").value+"_select").offsetTop+1)+"px";
};
SwitchHidePopup=function(Switch)
{
	$(Switch+"_popup").style.marginTop="";
	$(Switch+"_popup").style.display="none";
};
SwitchShowPopup=function(Switch)
{
	$(Switch+"_popup").style.display="block";
	if (document.all)
	{
		//(Switch+"_popup").style.marginLeft="30px";
	}
	else
	{
		//$(Switch+"_popup").style.marginLeft=($(Switch+"_container").offsetLeft+$(Switch).offsetLeft+4)+"px";
	}
	
	$(Switch+"_popup").style.marginTop="-"+($(Switch+"_"+$(Switch+"_index").value+"_select").offsetTop+1)+"px";
};



/* --- TREEVIEW --- */

TreeViewNode=function(OE,ItemKey,Select)
{
	if (Select=="2")
	{
		var CompVal=","+$(OE+"_selected").innerHTML+",";
		if (CompVal.match(","+ItemKey+","))
		{
			CompVal=CompVal.replace(","+ItemKey+",",",");
			CompVal=CompVal.replace(",,",",");
			if (CompVal.substr(0,1)==",") {CompVal=CompVal.substr(1);}
			if (CompVal.substr(CompVal.length-1,1)==",") {CompVal=CompVal.substr(0,CompVal.length-1);}
			$(OE+"_selected").innerHTML=CompVal;
			if ($(OE+"_nodes_"+ItemKey+"_childs"))
			{
				if ($(OE+"_nodes_"+ItemKey+"_childs").style.display=="")
				{
					$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeExpanded";
				}
				else
				{	
					$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeCollapsed";
				}
			}
			else
			{
				$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeSingle";
			}
			$(OE+"_nodes_"+ItemKey+"_checked").style.display="none";
		}
		else
		{
			$(OE+"_selected").innerHTML=(($(OE+"_selected").innerHTML) ? $(OE+"_selected").innerHTML+"," : "")+ItemKey;
			
			if ($(OE+"_nodes_"+ItemKey+"_childs"))
			{
				$(OE+"_nodes_"+ItemKey+"_childs").style.display="";
				$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeExpanded NodeSelected";
			}
			else
			{
				$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeSingle NodeSelected";
			}
			$(OE+"_nodes_"+ItemKey+"_checked").style.display="";
		}
	}
	else
	{
		if (Select=="1")
		{
			var SelKey=$(OE+"_selected").innerHTML;
			if (SelKey!="" && SelKey!="0")
			{
				if ($(OE+"_nodes_"+SelKey+"_childs"))
				{$(OE+"_nodes_"+SelKey+"_button").className="TreeNode "+(($(OE+"_nodes_"+SelKey+"_childs").style.display=="") ? "NodeExpanded" : "NodeCollapsed");}
				else
				{$(OE+"_nodes_"+SelKey+"_button").className="TreeNode NodeSingle";}
			}
			$(OE+"_selected").innerHTML=ItemKey;
		}
		
		if ($(OE+"_nodes_"+ItemKey+"_childs"))
		{
			if ($(OE+"_nodes_"+ItemKey+"_childs").style.display=="")
			{$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode "+(($(OE+"_nodes_"+ItemKey+"_childs").style.display=="") ? "NodeExpanded" : "NodeCollapsed")+" NodeSelected";}
			else
			{
				$(OE+"_nodes_"+ItemKey+"_childs").style.display="";
				$(OE+"_expanded").innerHTML+=(($(OE+"_expanded").innerHTML) ? "," : "")+ItemKey;
				$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode "+(($(OE+"_nodes_"+ItemKey+"_childs").style.display=="") ? "NodeExpanded" : "NodeCollapsed")+" NodeSelected";
			}
		}
		else
		{$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeSingle NodeSelected";}			
	}
};
TreeViewSwitch=function(OE,ItemKey,Select)
{
 	if ($(OE+"_nodes_"+ItemKey+"_childs").style.display=="")    
  	{
		$(OE+"_nodes_"+ItemKey+"_childs").style.display="none";
		var TmpExpanded=","+$(OE+"_expanded").innerHTML+",";
		TmpExpanded=TmpExpanded.replace(","+ItemKey+",",",");
		TmpExpanded=TmpExpanded.replace(",,",",");
		if (TmpExpanded.substr(0,1)==",") {TmpExpanded=TmpExpanded.substr(1,TmpExpanded.length-1);}
		if (TmpExpanded.substr(TmpExpanded.length-1,1)==",") {TmpExpanded=TmpExpanded.substr(0,TmpExpanded.length-1);}
		$(OE+"_expanded").innerHTML=TmpExpanded;	
		if (Select)
		{
			if ($(OE+"_selected").innerHTML==ItemKey)
			{$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeCollapsed NodeSelected";}
			else {$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeCollapsed";}
		}
		else {$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeCollapsed";}
  	}
	else
	{
		$(OE+"_nodes_"+ItemKey+"_childs").style.display="";
		$(OE+"_expanded").innerHTML+=(($(OE+"_expanded").innerHTML) ? "," : "")+ItemKey;
		if (Select)
		{                          
			if ($(OE+"_selected").innerHTML==ItemKey) {$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeExpanded NodeSelected";}
			else {$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeExpanded";}
		}
		else {$(OE+"_nodes_"+ItemKey+"_button").className="TreeNode NodeExpanded";}
  	}
};
TreeViewGetSelected=function(OE)
{
 	return $(OE+"_selected").innerHTML;
};
TreeViewGetExpanded=function(OE)
{
 	return $(OE+"_expanded").innerHTML;
};



/* --- AGP FLASH MAIN MENU --- */

AgpFlsMenuButtonClick=function(Menu,Button)
{
	if ($(Menu+"_selected_1").value)
	{
		if ($(Menu+"_"+$(Menu+"_selected_1").value))
		{
			$(Menu+"_"+$(Menu+"_selected_1").value+"_submenu").style.display="none";
		}
	}
	$(Menu+"_selected_1").value=Button;
	$(Menu+"_"+Button+"_submenu").style.display="block";
	$(Menu+"_"+Button+"_submenu").style.height=($("left_container").offsetHeight-($(Menu+"_"+Button).offsetHeight*$("amnuMainMenu_count").value)-5)+"px";
};


/* --- AGP MAIN MENU --- */

AgpMenuButtonClick=function(Menu,Button)
{
	if ($(Menu+"_selected_1").value)
	{
		if ($(Menu+"_"+$(Menu+"_selected_1").value))
		{
			$(Menu+"_"+$(Menu+"_selected_1").value).className="Button";
			$(Menu+"_"+$(Menu+"_selected_1").value+"_submenu").style.display="none";
		}
	}
	$(Menu+"_selected_1").value=Button;
	$(Menu+"_"+Button).className="Button ButtonSelected";
	$(Menu+"_"+Button+"_submenu").style.display="block";
	$(Menu+"_"+Button+"_submenu").style.height=($("left_container").offsetHeight-($(Menu+"_"+Button).offsetHeight*$("amnuMainMenu_count").value)-5)+"px";
};
AgpMenuButtonMouseOver=function(Menu,Button)
{
	if ($(Menu+"_"+Button).className.length<21)
	{
		$(Menu+"_"+Button).className="Button ButtonOn";
	}
};
AgpMenuButtonMouseOut=function(Menu,Button)
{
	if ($(Menu+"_"+Button).className.length<21)
	{
		$(Menu+"_"+Button).className="Button";
	}
};
AgpMenuSubButtonClick=function(Menu,Button,SubButton)
{
	if ($(Menu+"_selected_1").value && $(Menu+"_selected_2").value)
	{
		if ($(Menu+"_"+$(Menu+"_selected_2").value))
		{
			$(Menu+"_"+$(Menu+"_selected_2").value).className="SubButton";
		}
	}
	$(Menu+"_selected_2").value=Button+"_"+SubButton;
	$(Menu+"_"+Button+"_"+SubButton).className="SubButton SubButtonSelected";
};
AgpMenuSubButtonMouseOver=function(Menu,Button,SubButton)
{
	if ($(Menu+"_"+Button+"_"+SubButton).className!="SubButton SubButtonSelected")
	{
		$(Menu+"_"+Button+"_"+SubButton).className="SubButton SubButtonOn";
	}
};
AgpMenuSubButtonMouseOut=function(Menu,Button,SubButton)
{
	if ($(Menu+"_"+Button+"_"+SubButton).className!="SubButton SubButtonSelected")
	{
		$(Menu+"_"+Button+"_"+SubButton).className="SubButton";
	}
};
AgpMenuButtonLink=function(Target)
{
	document.location=Target;
};
AgpMenuButtonAnchor=function(Anchor)
{
	var URL=String(document.location);
	if (URL.lastIndexOf("#"))
	{
		document.location=URL.substring(0,URL.lastIndexOf("#"))+"#"+Anchor;
	}
	else
	{
		document.location=URL+"#"+Anchor;
	}
};
AgpMenuButtonCleanAnchor=function(Anchor)
{
	var URL=String(document.location);
	if (URL.lastIndexOf("#M"))
	{
		document.location=URL.substring(0,URL.lastIndexOf("#M"));
	}
};

/* --- AGP INTRO MENU --- */
var IntroFadeTimer=false;
var IntroRotateTimer=false;
var IntroFadeID=0;
var IntroRotateID=1;

IntroChangeTimer=function(ID1,ID2,Count)
{
	window.clearTimeout(IntroRotateTimer);
	SetOpacity($(ID2),10);
	
	for (i=1;i<6;i++)
	{	
		if (i==IntroFadeID)
		{
			Show("intro_text_"+IntroFadeID);
			Show("intro_subtext_"+IntroFadeID);
		}
		else
		{
			Hide("intro_text_"+i);
			Hide("intro_subtext_"+i);
		}
	}
	
	if (Count>=10)
	{
		window.clearTimeout(IntroFadeTimer);
		$(ID2).src=$(ID1).src;
		$("intro_area_image").useMap="introimg_map";
		IntroChangeInterval();
	}
	else
	{
		SetOpacity($(ID1),Count);
		SetOpacity($(ID2),(10-Count));
		
		Count++;
		IntroFadeTimer=window.setTimeout("IntroChangeTimer(\'"+ID1+"\',\'"+ID2+"\',"+(Count)+")",100);
	}
};

IntroClearInterval=function()
{
	if (IntroFadeID!=0)
	{
		IntroRotateID=IntroFadeID;
		IntroRotateID++;
	}
	else
	{
		IntroRotateID++;
	}
	
	if (IntroRotateID>5) {IntroRotateID=1;}
	
	window.clearTimeout(IntroRotateTimer);
	IntroChangeImage(IntroRotateID);
	IntroRotateTimer=window.setTimeout("IntroClearInterval()",8000);
};

IntroChangeInterval=function()
{
	IntroRotateTimer=window.setTimeout("IntroClearInterval()",24000);
};

IntroChangeImage=function(ID)
{
	var FadeImage="intro_fade_image";
	var AreaFadeImage="intro_area_image";
		
	if (IntroFadeID!=ID || IntroFadeID==0)
	{		
		$("intro_area_image").useMap="";
		
		SetOpacity($(FadeImage),0);
		
		window.clearTimeout(IntroFadeTimer);
		
		$(FadeImage).src=$(FadeImage).src.replace(/\_[1-9]/g,"_"+ID);	
		
		IntroFadeTimer=window.setTimeout("IntroChangeTimer(\'"+FadeImage+"\',\'"+AreaFadeImage+"\',0)",100);
	}
	
	IntroFadeID=ID;
};


/* --- HEADER USER INTERFACE SWITCH --- */

UserInterfaceSwitch=function()
{
	var UsrIntfMnu=String($("user_interface_menu").src);
	
	ResizeUserMenu('Close');
	if (UsrIntfMnu.indexOf("_eo.gif")>0)
	{
		$("user_interface_menu").src=UsrIntfMnu.replace(/\_eo\.gif/g,"_po.gif");
	}
	else if (UsrIntfMnu.indexOf("_po.gif")>0)
	{
		$("user_interface_menu").src=UsrIntfMnu.replace(/\_po\.gif/g,"_eo.gif");
	}
};


/* --- SEARCH BAR --- */

var SearchBarCaption="";
SearchBarCaptionShowHide=function(ID,Caption)
{
	((SearchBarCaption=="") ? SearchBarCaption=Caption : "");
	
	if ($(ID).value==Caption || $(ID).value=="")
	{
		if ($(ID).value==Caption)
		{
			$(ID).style.color="#000000";
			$(ID).style.fontSize="1.3em";
			$(ID).value="";
		}
		else if ($(ID).value=="")
		{
			$(ID).style.color="#CCCCCC";
			$(ID).style.fontSize="0.9em";
			$(ID).value=SearchBarCaption;
		}
	}
	else
	{
		$(ID).style.color="#000000";
		$(ID).style.fontSize="1.3em";
	}
};


/* --- DROPDOWN MENU --- */

DropDownMenuButtonMouseOver=function(Button)
{
	$(Button+"_submenu").style.display="block";
};
DropDownMenuButtonMouseOut=function(Button)
{
	$(Button+"_submenu").style.display="none";
};
DropDownMenuSubButtonClick=function(Button)
{
	$(Button+"_submenu").style.display="none";
};

DropDownMenuOver=function(ID)
{
	$(ID+"_hover").className="Button ButtonOver";
};
DropDownMenuOut=function(ID)
{
	$(ID+"_hover").className="Button";
};




ObjectExplorerClickItem=function(OE,Key)
{
	alert(Key);
};


/* --- OBJECT EXPLORER --- */

OEGetSelected=function(OE)
{
 	return $(OE+"_selected").innerHTML;
};
OEGetFocus=function(OE)
{
	return $(OE+"_focus").innerHTML;
};
OEIsSelected=function(OE,ItemKey,Select)
{
	if (Select=="2")
	{
		var CompVal=","+$(OE+"_selected").innerHTML+",";
		return CompVal.match(","+ItemKey+",");
	}
	else if (Select=="1")
	{
		return ($(OE+"_selected").innerHTML==ItemKey);
	}
};
OESetSelected=function(OE,ItemKey,Select)
{
	$(OE+"_selected").innerHTML=(($(OE+"_selected").innerHTML) ? $(OE+"_selected").innerHTML+"," : "")+ItemKey;
	return true;	
};
OESetUnselected=function(OE,ItemKey,Select)
{
	var CompVal=","+$(OE+"_selected").innerHTML+",";
	CompVal=CompVal.replace(","+ItemKey+",",",");
	CompVal=CompVal.replace(",,",",");
	if (CompVal.substr(0,1)==",") {CompVal=CompVal.substr(1);}
	if (CompVal.substr(CompVal.length-1,1)==",") {CompVal=CompVal.substr(0,CompVal.length-1);}
	$(OE+"_selected").innerHTML=CompVal;
	return true;
};
OEHasFocus=function(OE,ItemKey)
{
	if ($(OE+"_focus").innerHTML!="")
	{
		return ($(OE+"_focus").innerHTML==ItemKey);
	}
};
OESetFocus=function(OE,ItemKey)
{
	$(OE+"_focus").innerHTML=ItemKey;
	return true;
};
OEClickItem=function(OE,ItemKey,Select)
{	
	if (!OEHasFocus(OE,ItemKey))
	{
		var PrevFocusKey=OEGetFocus(OE);
		if (Select=="1") {OESetUnselected(OE,PrevFocusKey,Select);}
		if (PrevFocusKey)
		{
			if (OEIsSelected(OE,PrevFocusKey,Select))
			{
				$(OE+"_item_"+PrevFocusKey+"_body").className="ObjectBody ObjectSelected";
			}
			else
			{
				$(OE+"_item_"+PrevFocusKey+"_body").className="ObjectBody ObjectUnselected";
			}
		}
		OESetFocus(OE,ItemKey);
	}
	
	if (OEIsSelected(OE,ItemKey,Select))
	{
		OESetUnselected(OE,ItemKey,Select);
		$(OE+"_item_"+ItemKey+"_body").className="ObjectBody ObjectUnselected ObjectFocus";
	}
	else
	{
		OESetSelected(OE,ItemKey,Select);
		$(OE+"_item_"+ItemKey+"_body").className="ObjectBody ObjectSelected ObjectFocus";
	}
};



/* --- CALENDAR --- */

CalendarSelectWorkingDay=function(CLD,Day,Max)
{
	if (Max==1 || $(CLD+"_selected_day").innerHTML=="")
	{
		$(CLD+"_selected_day").innerHTML=Day;
	}
	else
	{
		var SelStr=String($(CLD+"_selected_day").innerHTML);
		var SelArr=SelStr.split(",");
		SelArr.unshift(Day);
		if (SelArr.length>Max)
		{
			$(CLD+"_"+SelArr[SelArr.length-1]).className="Calendar Element";
			SelArr=SelArr.slice(0,Max);
		}
		$(CLD+"_selected_day_count").innerHTML=SelArr.length;
		$(CLD+"_selected_day").innerHTML=SelArr.join(",");
	}
	$(CLD+'_'+Day).className="Calendar Element SelectedDay";
};
CalendarGetSelectedDay=function(CLD)
{
	return $(CLD+"_selected_day").innerHTML;
};
CalendarGetSelectedDayCount=function(CLD)
{
	return parseInt($(CLD+"_selected_day_count").innerHTML);
};

/* --- PAGE NAV --- */

PageNavHover=function(ID)
{
	if (!document.all)
	{
		if ($(ID).src.indexOf("arrow_left.png")>-1)
		{
			$(ID).src=$(ID).src.replace(/arrow_left\.png/g,"arrow_left_on.png");
		}
		else if ($(ID).src.indexOf("arrow_left_on.png")>-1)
		{
			$(ID).src=$(ID).src.replace(/arrow_left_on\.png/g,"arrow_left.png");
		}
		
		if ($(ID).src.indexOf("arrow_right.png")>-1)
		{
			$(ID).src=$(ID).src.replace(/arrow_right\.png/g,"arrow_right_on.png");
		}
		else if ($(ID).src.indexOf("arrow_right_on.png")>-1)
		{
			$(ID).src=$(ID).src.replace(/arrow_right_on\.png/g,"arrow_right.png");
		}
	}
};

/* --- START BUTTON ---*/

abStartButton=function(Key)
{
	this.Key=Key;
	this.MoveTimer=false;
	this.HideTimer=false;
	this.Moving=false;
	this.State=0;
	this.Step=0;
	this.FirstLoad=false;
};
abStartButton.prototype=
{
	OnLoad: function()
	{
		window.clearTimeout(this.HideTimer);
		if (this.State==1) {return false;}
		window.clearTimeout(this.MoveTimer);
		
		this.Moving=true;
		this.FirstLoad=true;
		
		if (!document.all)
		{
			$('menu_start_img').src=App.AppURL+'/system/themes/greensmooze/gfx/startbutton/startbutton.png';
			$('menu_start_bg_img').src=App.AppURL+'/system/themes/greensmooze/gfx/startbutton/startbutton_bg.png';
		}
		
		this.ShowStep();
	},
	Show: function()
	{
		window.clearTimeout(this.HideTimer);
		if (this.State==1 && !this.FirstLoad) {return false;}
		window.clearTimeout(this.MoveTimer);
		
		this.Moving=true;
		this.FirstLoad==false;
		
		if (!document.all)
		{
			$('menu_start_img').src=App.AppURL+'/system/themes/greensmooze/gfx/startbutton/startbutton_on.png';
			$('menu_start_bg_img').src=App.AppURL+'/system/themes/greensmooze/gfx/startbutton/startbutton_bg_on.png';
		}
		else
		{
			$('menu_start').style.display="none";
			$('menu_start_bg').style.display="none";
			$('menu_start_ieover').style.display="";
			$('menu_start_ieover_bg').style.display="";
		}
		
		Show('menu_subcontainer'); 
		
		this.ShowStep();
	},
	ShowStep: function()
	{
		$('menu_frame').style.left=(-144+((144/8)*this.Step))+"px";
		
		if (this.Step==8)
		{
			this.Moving=false;
			this.State=1;
		}
		else if (this.Step<8)
		{
			this.Step++;
			this.MoveTimer=window.setTimeout(this.Key+".ShowStep();",10);
		}
	},
	Hide: function()
	{
		if (this.Moving) {return false;}
		window.clearTimeout(this.MoveTimer);
		
		window.clearTimeout(this.HideTimer);
		this.HideTimer=window.setTimeout(this.Key+".HideStep();",700);
	},
	HideStep: function()
	{
		this.Moving=true;
		
		$('menu_frame').style.left=(-144+((144/8)*this.Step))+"px";
		
		if (this.Step==0)
		{
			this.Moving=false;
			this.State=0;
			Hide('menu_subcontainer');
			
			if (!document.all)
			{
				$('menu_start_img').src=App.AppURL+'/system/themes/greensmooze/gfx/startbutton/startbutton.png';
				$('menu_start_bg_img').src=App.AppURL+'/system/themes/greensmooze/gfx/startbutton/startbutton_bg.png';
			}			
			else
			{
				$('menu_start_ieover').style.display="none";
				$('menu_start_ieover_bg').style.display="none";
				$('menu_start').style.display="";
				$('menu_start_bg').style.display="";
			}
			
		}
		else if (this.Step>0)
		{
			this.Step--;
			this.MoveTimer=window.setTimeout(this.Key+".HideStep();",10);
		}
	}
};

/* --- START MENU --- */

abStartMenu=function(Key)
{
	this.Key=Key;
	this.Steps=5;
	this.Interval=1;
	this.Level=0;
	this.History= new Array();
	this.MoveTimer=false;
	this.Moving=false;
};
abStartMenu.prototype=
{
	SetSelected: function(Level,Path)
	{
		this.Level=Level;
		var PathArr=Path.split(".");
		for (var i=0;i<PathArr.length;i++) {this.History.push(PathArr.slice(0,i).join("_"));}
	},
	NavRoot: function()
	{
		if (this.Moving) return false;
		this.Level=0;
		this.Moving=true;
		this.MoveOutStep();
	},
	NavOut: function()
	{
		if (this.Moving) return false;
		this.Level--;
		this.Moving=true;
		this.MoveOutStep();
	},
	NavIn: function(Level,Path,Childs)
	{
		if (this.Moving) return false;
		if (Childs=="1")
		{
			this.History.push(Path);
			this.Selected=Path;
			this.Level=Level+1;
			Show(this.Key+"_level_"+(Level+1));
			Show(this.Key+"_boxes_"+Path);
			this.Moving=true;
			this.MoveInStep();
			//$(StartMenu+"_body").style.marginLeft=(((Level+1)*180*-1)+50)+"px";
		}
		else
		{
			
		}
	},
	MoveInStep: function(Step)
	{
		if (!Step) {Step=1;}
		
		$(this.Key+"_body").style.marginLeft=(((((this.Level-1)*180)+parseInt((180/this.Steps)*Step))*-1))+"px";
		
		if (Step==this.Steps)
		{
			this.Moving=false;
		}
		else if (Step<this.Steps)
		{
			this.MoveTimer=window.setTimeout(this.Key+".MoveInStep("+(Step+1)+")",this.Interval);
		}
	},
	MoveOutStep: function(Step)
	{
		if (!Step) {Step=1;}
		
		$(this.Key+"_body").style.marginLeft=(((((this.Level)*180)+(180-parseInt((180/this.Steps)*Step)))*-1))+"px";
		
		if (Step==this.Steps)
		{
			Hide(this.Key+"_boxes_"+this.History[this.History.length-1]);
			this.History.pop();
			this.Moving=false;
		}
		else if (Step<this.Steps)
		{
			this.MoveTimer=window.setTimeout(this.Key+".MoveOutStep("+(Step+1)+")",this.Interval);
		}
	}
};


QuickListSwitch=function(QL,Key)
{
	if ($(QL+"_"+Key+"_container").style.display=="none")
	{
		$(QL+"_"+Key+"_container").style.display="block";
		$(QL+"_"+Key+"_switch").className="AgpQuickCollapse";
	}
	else
	{
		$(QL+"_"+Key+"_container").style.display="none";
		$(QL+"_"+Key+"_switch").className="AgpQuickExpand";
	}
};


ThermoBarSetValue=function(ThermoBar,Value)
{
	$(ThermoBar+"_value").style.height=((160/100)*(100-Value))+"px";
};




ValidateEmail=function(ID)
{
	var Result=false;
	var Email=$(ID).value;
	
	var re = new RegExp();
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	
	if (!re.test(Email))
	{
		return false
	}
	else
	{
		return true;
	}
};

ValidateUsername=function(ID)
{
	if ($(ID).value=="")
	{
		alert("Sie haben keinen Benutzernamen eingegeben!");
		return false;
	}
	else if ($(ID).length>24)
	{
		alert("Der eingegebene Benutzername ist zu lang!");
		return false;
	}
	else if ($(ID).length<6)
	{
		alert("Der eingebene Benutzername ist zu kurz!");
		return false;
	}
	else if ($(ID).value!="")
	{
		return true;
	}
};

ValidatePassword=function(ID)
{
	if ($(ID).value=="")
	{
		alert("Sie haben kein Passwort eingegeben!");
		return false;
	}
	else if ($(ID).length<6)
	{
		alert("Das eingebene Passwort ist zu kurz!");
		return false;
	}
	else if ($(ID).value!=$(ID+"_confirm").value)
	{
		alert("Die eingegebenen Passwörter stimmen nicht überein!");
		return false;
	}
	else if ($(ID).value!="")
	{
		return true;
	}
};

ValidateBirthday=function(Day,Month,Year,MinAge)
{
    if (Day=="" || Month=="" || Year=="")
    {
        return false;
    }
    else
    {
        var BirthdayYear=Year;
        var BirthdayMonth=Month;
        var BirthdayDay=Day;
        
        if (BirthdayMonth.substr(0,1)=="0") {BirthdayMonth=BirthdayMonth.substr(1)}
        if (BirthdayDay.substr(0,1)=="0") {BirthdayDay=BirthdayDay.substr(1)}
        
        var ActualDate = new Date();
        var BirthDate = new Date(BirthdayYear,BirthdayMonth-1,BirthdayDay);
        var MinDate = new Date(ActualDate.getYear()+1900-MinAge, ActualDate.getMonth(), ActualDate.getDay(), ActualDate.getHours(), ActualDate.getMinutes(), ActualDate.getSeconds());
        
		return (BirthDate <= MinDate);
    }
}

ValidateDate=function(Day,Month,Year)
{
    if ((Day>=1 && Day<=31) && (Month>=1 && Month<=12) && (Year>=1900 && Year<=2200))
    {
        return true;
    }
    else
    {
        return false;
    }
}



/*

	FAHREXPERTE.DE
	JavaScript Object Library


	Version:	1.0

	Copyright © 2008 by AEYOL SOLUTIONS LTD.


	Author(s):	Kristoph Junge (junge@aeyol.com)
	Date:		2007-04-25
	Modified:	2007-09-14

*/



/* --- TRAIN OBJECT --- */

abTrain=function(){};
abTrain.prototype=
{
	Class: 0,
	CategoryStr: "",
	OnlyFalse: false,
	RotateAnswers: false,
	Question: false,
	Index: 0,
	TrueCount: 0,
	FalseCount: 0,
	ProcessedStr: "",
	ResultStr: "",
	StartStamp: "",
	QuestionType: "",
	QuestionCompareStr: "",
	QuestionAnswerCount: 0,
	QuestionImage: "",
	QuestionImageWidth: 0,
	QuestionImageHeight: 0,

	ShowQuestion: function()
	{
		var Ajax = new abAjax();
		Ajax.Parent=this;

		Ajax.onError=function()
		{
			alert("Error");
		}
		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

			Train.QuestionCompareStr=xmlResponse.getElementsByTagName("compare_str")[0].firstChild.data;
			Train.QuestionType=xmlResponse.getElementsByTagName("question_type")[0].firstChild.data;
			Train.QuestionAnswerCount=xmlResponse.getElementsByTagName("answer_count")[0].firstChild.data;


			Hide("TrainQuestionImage_container");
			Hide("TrainNumericAnswers");
			Hide("TrainTextAnswers");
			Hide("TrainAnswer1"); Hide("TrainAnswer2"); Hide("TrainAnswer3");
			Hide("TrainAnswerInfo1"); Hide("TrainAnswerInfo2"); Hide("TrainAnswerInfo3");

			if (ResponseCode="200")
			{
				var Answers=Ajax.Parent.QuestionCompareStr.split(",");

				$("TrainQuestionSourceName").innerHTML=DecodeXMLValue(xmlResponse.getElementsByTagName("category_name")[0].firstChild.data);
				$("TrainQuestionNo").innerHTML=(Train.Index+1)+".";
				$("TrainQuestionText").innerHTML=DecodeXMLValue(xmlResponse.getElementsByTagName("question_text")[0].firstChild.data);
				$("TrainQuestionPoints").innerHTML=xmlResponse.getElementsByTagName("question_points")[0].firstChild.data;
				$("TrainQuestionOriginalID").innerHTML=xmlResponse.getElementsByTagName("original_id")[0].firstChild.data;

				ThermoBarSetValue('TrainDifficultyBar',xmlResponse.getElementsByTagName("train_skill")[0].firstChild.data);

				if (xmlResponse.getElementsByTagName("image_file")[0])
				{
					Train.QuestionImage=xmlResponse.getElementsByTagName("image_file")[0].firstChild.data;
					Train.QuestionImageWidth=xmlResponse.getElementsByTagName("image_width")[0].firstChild.data;
					Train.QuestionImageHeight=xmlResponse.getElementsByTagName("image_height")[0].firstChild.data;
					$("TrainQuestionImage").src=App.AppURL+"/content/images/question/thumb/"+Train.QuestionImage;
					$("TrainQuestionImage").width=xmlResponse.getElementsByTagName("thumb_width")[0].firstChild.data;
					$("TrainQuestionImage").height=xmlResponse.getElementsByTagName("thumb_height")[0].firstChild.data;
					$("TrainQuestionImage_container").onclick=ShowQuestionImageWindow;
					Show("TrainQuestionImage_container");
				}

				if (xmlResponse.getElementsByTagName("question_type")[0].firstChild.data=="TXT")
				{
					Show("TrainTextAnswers");

					for (var i=0;i<Answers.length;i++)
					{
						if (xmlResponse.getElementsByTagName("answer_"+(i+1))[0])
						{
							$("TrainAnswer"+(i+1)+"_text").innerHTML=DecodeXMLValue(xmlResponse.getElementsByTagName("answer_"+(i+1))[0].firstChild.data);
							$("TrainAnswer"+(i+1)+"_check").disabled=false;
							$("TrainAnswer"+(i+1)+"_check").checked=false;
							$("TrainAnswer"+(i+1)).className="Answer";
							Show("TrainAnswer"+(i+1));
						}
					}
				}
				else if (xmlResponse.getElementsByTagName("question_type")[0].firstChild.data=="NUM")
				{
					Hide("TrainAnswer1_number");
					Hide("TrainAnswer2_number");
					$("TrainAnswer1_number").disabled=false;
					$("TrainAnswer2_number").disabled=false;
					$('TrainAnswer1_number').value='';
					$('TrainAnswer2_number').value='';

					Show("TrainNumericAnswers");

					for (var i=0;i<Answers.length;i++)
					{
						Show("TrainAnswer"+(i+1)+"_number");
					}

					if (xmlResponse.getElementsByTagName("answer_info_1")[0].firstChild)
					{
						$("TrainAnswerInfo1").innerHTML=xmlResponse.getElementsByTagName("answer_info_1")[0].firstChild.data+"&nbsp;";
						Show("TrainAnswerInfo1");
					}
					if (xmlResponse.getElementsByTagName("answer_info_2")[0].firstChild)
					{
						$("TrainAnswerInfo2").innerHTML="&nbsp;"+xmlResponse.getElementsByTagName("answer_info_2")[0].firstChild.data;
						Show("TrainAnswerInfo2");
					}
					if (xmlResponse.getElementsByTagName("answer_info_3")[0].firstChild)
					{
						$("TrainAnswerInfo3").innerHTML="&nbsp;"+xmlResponse.getElementsByTagName("answer_info_3")[0].firstChild.data;
						Show("TrainAnswerInfo3");
					}
				}

				Hide("TrainQuestionLoader");
				$("TrainQuestion_container").style.height="";
				Show("TrainQuestion");
				Show("btnTrainAnswer");
			}
			else
			{
				alert("Error");
			}
		}

		$("TrainQuestion_container").style.height=$("TrainQuestion").offsetHeight+"px";

		var PostStr="question="+this.Question[this.Index];
		if (this.RotateAnswers) {PostStr+="&rotateanswers=1";}

		Hide("TrainQuestion");
		Show("TrainQuestionLoader");
		$("TrainQuestionImage").src="";
		Ajax.PostData(App.AppURL+"/load.xml?query=train_question&"+App.SessionName+"="+App.SessionID
		,PostStr,false);
	},
	Start: function(Class,CategoryStr,OnlyFalse,RotateAnswers)
	{
		this.Class=Class;
		this.CategoryStr=CategoryStr;
		this.OnlyFalse=OnlyFalse;
		this.RotateAnswers=RotateAnswers;
		this.Index=0;
		this.TrueCount=0;
		this.FalseCount=0;
		this.StartStamp="";
		this.ProcessedStr="";
		this.ResultStr="";

		var Ajax = new abAjax();
		Ajax.Parent=this;

		var GetStr=
		"class="+this.Class+
		"&categories="+this.CategoryStr+
		((this.OnlyFalse) ? "&onlyfalse=yes" : "")+
		((this.RotateAnswers) ? "&rotateanswers=yes" : "");

		Ajax.onError=function()
		{
			alert("Error");
		}
		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

			if (ResponseCode="200")
			{
				var QuestionStr=xmlResponse.getElementsByTagName("questions")[0].firstChild.data;
				Ajax.Parent.StartStamp=xmlResponse.getElementsByTagName("startstamp")[0].firstChild.data;
				Train.Question=QuestionStr.split(",");
				App.LoadForm('display_container','train_form','',Train.Init);
			}
			else
			{
				alert("Error");
			}
		}

		Ajax.PostData(App.AppURL+"/load.xml?query=train_create&"+App.SessionName+"="+App.SessionID,GetStr,false);
	},
	Init: function()
	{
		MenuBarHide('left');
		//$('display_container').style.height="550px";
		MenuBarShow("right");
		App.LoadForm('right_container','train_bar','',Train.InitStatus);
	},
	InitStatus: function()
	{
		Train.ShowQuestion();
		$('dfTrainStatus_index').innerHTML=((Train.Index+1)+"/"+(Train.Question.length));
	},
	Next: function()
	{
		if (this.Index>=this.Question.length)
		{
			MenuBarHide("right");
			this.Submit();
		}
		else
		{
			$("TrainResultImage").className="TrainResultNone";
			$('dfTrainStatus_index').innerHTML=((Train.Index+1)+"/"+(Train.Question.length));
			Train.ShowQuestion();
			Hide("btnTrainNext");
		}
	},
	Submit: function()
	{
		var VarStr=
		"startstamp="+this.StartStamp+
		"&class="+this.Class+
		"&categories="+this.CategoryStr+
		"&processed_str="+this.ProcessedStr+
		"&result_str="+this.ResultStr;

		if (this.OnlyFalse) {VarStr+="&onlyfalse=1";}
		if (this.RotateAnswers) {VarStr+="&rotateanswers=1";}

		var Ajax = new abAjax();
		Ajax.Parent=this;

		MenuBarHide('right');

		Ajax.onError=function()
		{
			alert("Error");
		}
		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

			if (ResponseCode="200")
			{
				var TrainInsertID=xmlResponse.getElementsByTagName("trainid")[0].firstChild.data;
				App.LoadForm("display_container","train_result","train="+TrainInsertID);
			}
			else
			{
				alert("Error");
			}
		}

		$("display_container").innerHTML='<table align="center" border="0"><tr><td stlye="padding-top: 20px; font-weight: bold;">Bitte warten, die Übung wird ausgewertet...</td></tr></table>';

		Ajax.PostData(App.AppURL+"/load.xml?query=train_save&"+App.SessionName+"="+App.SessionID,VarStr,false);
	},
	ValidateQuestion: function(QuestionID)
	{
		var Answers=this.QuestionCompareStr.split(",");
		var Result=true;

		if (this.QuestionType=="TXT")
		{
			for (var i=0;i<Answers.length;++i)
			{
				if ($("TrainAnswer"+(i+1)+"_check").checked!=Answers[i])
				{
					$("TrainAnswer"+(i+1)).className="AnswerFalse";
					Result=false;
				}
				$("TrainAnswer"+(i+1)+"_check").disabled=true;
			}
		}
		else if (this.QuestionType=="NUM")
		{
			if (Answers.length==0)
			{
				Result=false;
			}
			else
			{
				Answers[0]=Answers[0].replace(".",",");
				if ($("TrainAnswer1_number").value!=Answers[0])
				{
					$("TrainAnswer1_number").value=Answers[0];
					Result=false;
				}
				$("TrainAnswer1_number").disabled=true;
				if (Answers.length==2)
				{
					Answers[1]=Answers[1].replace(".",",");
					if ($("TrainAnswer2_number").value!=Answers[1])
					{
						$("TrainAnswer2_number").value=Answers[1];
						Result=false;
					}
					$("TrainAnswer2_number").disabled=true;
				}
			}
		}
		return Result;
	},
	Answer: function()
	{
		Hide("btnTrainAnswer");
		Show("btnTrainNext");

		this.ProcessedStr+=((this.ProcessedStr!="") ? "," : "")+this.Question[this.Index];

		if (this.ValidateQuestion(this.Question[this.Index]))
		{
			$("TrainResultImage").className="TrainResultTrue";
			this.TrueCount++;
			this.ResultStr+=((this.ResultStr!="") ? ",Y" : "Y");
		}
		else
		{
			$("TrainResultImage").className="TrainResultFalse";
			this.FalseCount++;
			this.ResultStr+=((this.ResultStr!="") ? ",N" : "N");
		}

		this.Index++;

		$('dfTrainStatus_true').innerHTML=Train.TrueCount;
		$('dfTrainStatus_false').innerHTML=Train.FalseCount;
	},
	Cancel: function()
	{
		MenuBarHide('right');
		//$('display_container').style.height="";
		App.LoadMenuForm('mnuUser','home','user_home');
		MenuBarShow('left');
	}
}



/* --- EXAM OBJECT --- */

abExam=function(){};
abExam.prototype=
{
	PageIndex: 1,
	PageCount: 1,
	QuestionsPerPage: 6,
	QuestionCount: 0,
	QuestionStr: "",
	StartStamp: 0,
	Class: 0,
	ResultRate: 0.0,
	ExamID: 0,

	MovePage: function(Page)
	{
		$("exam_pagenav_top_"+this.PageIndex).className="PageButton";
		$("exam_pagenav_top_"+Page).className="SelectedPageButton";
		$("exam_pagenav_bottom_"+this.PageIndex).className="PageButton";
		$("exam_pagenav_bottom_"+Page).className="SelectedPageButton";

		$("exam_page_"+this.PageIndex).style.display="none";
		$("exam_page_"+Page).style.display="";

		this.PageIndex=parseInt(Page);

		if (this.PageIndex==1)
		{
			Hide('btnExamPrevious');
			Show('btnExamNext');
		}
		else if (this.PageIndex==this.PageCount)
		{
			Hide('btnExamNext');
			Show('btnExamPrevious');
		}
		else
		{
			Show('btnExamNext');
			Show('btnExamPrevious');
		}
	},
	FirstPage: function()
	{
		this.MovePage(1);
	},
	LastPage: function()
	{
		this.MovePage(this.PageCount);
	},
	PreviousPage: function()
	{
		if (this.PageIndex>1)
		{
			this.MovePage(this.PageIndex-1);
			location.href="#";
		}
	},
	NextPage: function()
	{
		if (this.PageIndex<this.PageCount)
		{
			this.MovePage(this.PageIndex+1);
			location.href="#";
		}
	},
	CheckTrail: function()
	{
		var Ajax = new abAjax(); Ajax.Parent=this;
		var Result=false;

		Ajax.onError=function() {Ajax.Parent.onTerminate(0);}
		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

			if (ResponseCode=="200") {Result=true;}
		}
		Ajax.PostData(App.AppURL+"/load.xml?query=exam_count_check&"+App.SessionName+"="+App.SessionID,"",true);
		return Result;
	},
	Start: function(Class)
	{
		this.PageIndex=1;
		this.PageCount=1;
		this.QuestionsPerPage=6;
		this.QuestionCount=0;
		this.QuestionStr="";
		this.StartStamp=0;
		this.Class=Class;
		this.ResultRate=0.0;
		this.ExamID=0;

		if (this.CheckTrail()==true)
		{
			var GetStr="class="+this.Class;

			var Ajax = new abAjax(); Ajax.Parent=this;

			Ajax.onError=function()
			{
				alert("Error");
			}
			Ajax.onLoaded=function()
			{
				var xmlResponse=Ajax.Request.responseXML.documentElement;
				var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

				if (ResponseCode="200")
				{
					Ajax.Parent.QuestionStr=xmlResponse.getElementsByTagName("question_str")[0].firstChild.data;
					Ajax.Parent.QuestionCount=xmlResponse.getElementsByTagName("question_count")[0].firstChild.data;
					Ajax.Parent.StartStamp=xmlResponse.getElementsByTagName("startstamp")[0].firstChild.data;
					Ajax.Parent.PageCount=Math.ceil(Ajax.Parent.QuestionCount/Ajax.Parent.QuestionsPerPage);

					App.PostData('display_container','exam_form','','question_str='+Ajax.Parent.QuestionStr,Ajax.Parent.Init);
				}
				else
				{
					alert("Error");
				}
			}

			Ajax.PostData(App.AppURL+"/load.xml?query=exam_create&"+App.SessionName+"="+App.SessionID,GetStr,false);
			MenuBarHide("left");
		}
		else
		{
			alert('Sie haben bereits die 2 möglichen Prüfungssimulationen der Testversion absolviert!');
			ShowUserOrderWindow();
		}
	},
	Init: function()
	{
		$("exam_pagenav_top_1").className="SelectedPageButton";
		$("exam_pagenav_bottom_1").className="SelectedPageButton";
		$("exam_page_1").style.display="";
	},
	ValidateQuestion: function(QuestionID)
	{
		var Answers=$("exam_question_"+QuestionID+"_compare").value.split(",");
		var Result=true;

		if ($("exam_question_"+QuestionID+"_type").value=="TXT")
		{
			for (var i=0;i<Answers.length;++i)
			{
				if ($("exam_answer_"+QuestionID+"_"+(i+1)+"_check").checked!=Answers[i])
				{
					Result=false;
					$("exam_answer_"+QuestionID+"_"+(i+1)+"_image").className="AnswerFalse";
				}
				$("exam_answer_"+QuestionID+"_"+(i+1)+"_check").disabled=true;
			}
		}
		else if ($("exam_question_"+QuestionID+"_type").value=="NUM")
		{
			if (Answers.length>0)
			{
				Answers[0]=Answers[0].replace(".",",");
				if ($("exam_answer_"+QuestionID+"_number1").value!=Answers[0])
				{
					$("exam_answer_"+QuestionID+"_number1").value=Answers[0];
					Result=false;
				}
				$("exam_answer_"+QuestionID+"_number1").disabled=true;
				if (Answers.length==2)
				{
					Answers[1]=Answers[1].replace(".",",");
					if ($("exam_answer_"+QuestionID+"_number2").value!=Answers[1])
					{
						$("exam_answer_"+QuestionID+"_number2").value!=Answers[1];
						Result=false;
					}
					$("exam_answer_"+QuestionID+"_number2").disabled=true;
				}
			}
		}
		return Result;
	},
	Submit: function()
	{
		var Questions=this.QuestionStr.split(",");
		var ResultStr="";
		var FailPoints=0;
		var MaxPoints=0;
		var False5Count=0;
		var TrueCount=0;
		var FalseCount=0;

		Hide("exam_content_container");
		Show("exam_result_container");
		Hide("btnExamSubmit");
		Show("btnExamShowResult");

		for (var i=0;i<Questions.length;i++)
		{
			if (ResultStr!="") {ResultStr+=",";}

			MaxPoints+=parseInt($("exam_question_"+Questions[i]+"_points").value);

			if (this.ValidateQuestion(Questions[i]))
			{
				TrueCount++;
				ResultStr+=Questions[i]+"-Y";
			}
			else
			{
				FalseCount++;
				ResultStr+=Questions[i]+"-N";
				FailPoints+=parseInt($("exam_question_"+Questions[i]+"_points").value);
				if (parseInt($("exam_question_"+Questions[i]+"_points").value)==5) {False5Count++;}
			}
		}

		var VarStr=
		"class="+this.Class+
		"&start_stamp="+this.StartStamp+
		"&true_count="+TrueCount+
		"&false_count="+FalseCount+
		"&false5_count="+False5Count+
		"&fail_points="+FailPoints+
		"&max_points="+MaxPoints+
		"&result_str="+ResultStr;

		var Ajax = new abAjax(); Ajax.Parent=this;

		Ajax.onError=function()
		{
			alert("Error");
		}
		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

			if (ResponseCode="200")
			{
				Ajax.Parent.ExamID=xmlResponse.getElementsByTagName("exam_id")[0].firstChild.data;
				Ajax.Parent.ResultRate=xmlResponse.getElementsByTagName("result_rate")[0].firstChild.data;
				App.LoadForm("exam_result_container","exam_result","exam="+Ajax.Parent.ExamID);
			}
			else
			{
				alert("Error");
			}
		}

		/*$("exam_result_container").innerHTML="Bitte warten, die Prüfung wird ausgewertet...";*/

		Ajax.PostData(App.AppURL+"/load.xml?query=exam_save&"+App.SessionName+"="+App.SessionID,VarStr,false);
	},
	ShowFaults: function()
	{
		/*App.MenuBarHide("menu_left");*/
		Show("exam_content_container");
		Hide("exam_result_container");
	},
	ShowResults: function()
	{
		Hide("exam_content_container");
		Show("exam_result_container");
	},
	Cancel: function()
	{
		MenuBarHide('right');
		$('display_container').style.height="";
		App.LoadMenuForm('mnuUser','home','user_home');
		MenuBarShow('left');
	}
};

GetSignCategoryName=function(Category)
{
	switch (Category)
	{
		case 1: return 'Gefahrzeichen'; break;
		case 2: return 'Vorschriftzeichen'; break;
		case 3: return 'Richtzeichen'; break;
		case 4: return 'Verkehrseinrichtungen'; break;
		case 5: return 'Zusatzzeichen'; break;
	}
};



/*

	FAHREXPERTE.DE
	Interface Function Library
	Version:	1.0

	Copyright © 2008 by AEYOL SOLUTIONS LTD.

*/



/* --- GLOBALS --- */

var APP_LOCATION_PATH = window.location.pathname;

var App = new abApp("fex","http://www.fahrexperte.de");

var User = new abUser("http://www.fahrexperte.de/user.php","lsid");
var School = new abUser("http://www.fahrexperte.de/school.php","ssid");
var UserSessionTimer=false;

var Exam = new abExam();
var Train = new abTrain();

var TrainSelectionTriggered=false;

PopUpImageUploadResult=function(newfile)
{
	App.UnlockDisplay();
};

StartBannerRotation=function()
{
	window.setInterval("App.LoadForm('frLeftBanner_container','banner_left')",(5000));
};



Init=function()
{
	/* Start handler */
	fixPNG();

	if (APP_LOCATION_PATH=="/")
	{
		LoadStart();
	}

};

/* --- INIT ONLOAD EVENT --- */
EventHandler = new abEventHandler();
EventHandler.AddEvent(window,"load",Init);
/* ----------------------- */
/* --- INIT ONLOAD END --- */
/* ----------------------- */

Unload=function()
{
	User.Logout(true);
	School.Logout(true);
};

window.onbeforeunload=Unload;
window.onresize=App.ArrangeDisplayLock;



/* --- USER OBJECT EVENTS --- */

User.onLogin=function()
{
	App.SessionName="lsid";
	App.SessionID=User.SessionID;
	UserSessionTimer=window.setTimeout("User.Ping()",(50000));

	$("frUserStatus_container").innerHTML=User.Username;
	Show("frUserStatus");
	App.CloseMenuWindow();
	App.LoadForm('frUserMenu_container','user_menu','',LoadUserStart);
	App.CreateInlineMessage("Information","Willkommen im Benutzerbereich","information");
};
User.onLoginFailed=function(Reason)
{
	switch (Reason)
	{
		case "100": alert("Login fehlgeschlagen! Der Benutzername existiert nicht."); break;
		case "101": alert("Login fehlgeschlagen! Das eingegebene Passwort ist falsch."); break;
		case "102": alert("Login fehlgeschlagen! Der Benutzer ist bereits eingeloggt."); break;
		default: alert("Login fehlgeschlagen! Es ist ein Fehler aufgetreten."); break;
	}
};
User.onBeforeLogout=function()
{
	window.clearTimeout(UserSessionTimer);
};
User.onLogout=function()
{
	App.SessionName="";
	App.SessionID="";

	Hide("frUserStatus");
	$("frUserStatus_container").innerHTML="";
	App.ActiveMenu="";
	App.ActiveMenuButton="";
	App.ActiveMenuWindow="";
	App.ActiveMenuWindowButton="";

	App.LoadForm('frUserMenu_container','user_login_menu');
	App.LoadMenuForm('mnuPublic','start','start','city_id='+App.Vars.GEOLOC_CITY_ID,LoadStart);
	App.CreateInlineMessage("Information","Sie haben sich abgemeldet","information");
};
User.onPong=function()
{
	App.SessionID=User.SessionID;
	UserSessionTimer=window.setTimeout("User.Ping()",(50000));
};
User.onTerminate=function(Reason)
{
	App.SessionName="";
	App.SessionID="";

	$("frUserStatus_container").style.backgroundColor="red";
	$("frUserStatus_container").innerHTML="<b>Verbindung getrennt</b>";

	switch (Reason)
	{
		case "100": alert("Session invalid"); break;
		case "50": alert("Session pong query 1 failed"); break;
		case "51": alert("Session pong query 2 failed"); break;
		default: alert("Session pong unknown error"); break;
	}
};
UserLoginKeyPress=function(e)
{
	if (e)
	{
		var CharCode = ((window.event) ? e.keyCode : e.which);
		if (CharCode==13)
		{
			User.Login($('dfUserLogin_username').value,$('dfUserLogin_password').value);
		}
	}
};



/* --- SCHOOL USER OBJECT EVENTS --- */

School.onLogin=function()
{
	App.SessionName="ssid";
	App.SessionID=School.SessionID;
	UserSessionTimer=window.setTimeout("School.Ping()",(50*1000));

	$("frUserStatus_container").innerHTML="<b>"+School.Username+"</b>";
	App.UnloadWindow('wndSchoolLogin');
	Show("frUserStatus");
	App.LoadForm('frUserMenu_container','school_menu','',LoadSchoolStart);
	App.CreateInlineMessage("Information","Willkommen im Fahrschulbereich","information");
};
School.onLoginFailed=function(Reason)
{
	switch (Reason)
	{
		case "100": alert("Login failed! School doesent exist."); break;
		case "101": alert("Login failed! Invalid password."); break;
		default: alert("Login failed! An error ocurred."); break;
	}
};
School.onLogout=function()
{
	App.SessionName="";
	App.SessionID="";
	Hide("frUserStatus");
	$("frUserStatus_container").innerHTML="";
	App.ActiveMenu="";
	App.ActiveMenuButton="";
	App.ActiveMenuWindow="";
	App.ActiveMenuWindowButton="";

	App.LoadForm('frUserMenu_container','user_login_menu');
	App.LoadMenuForm('mnuPublic','start','start','',LoadStart);
	App.CreateInlineMessage("Information","Sie haben sich abgemeldet","information");
};
School.onBeforeLogout=function()
{
	window.clearTimeout(UserSessionTimer);
};
School.onPong=function()
{
	App.SessionID=School.SessionID;
	UserSessionTimer=window.setTimeout("School.Ping()",(50*1000));
};
School.onTerminate=function(Reason)
{
	App.SessionName="";
	App.SessionID="";

	$("frUserStatus_container").style.backgroundColor="red";
	$("frUserStatus_container").innerHTML="<b>Verbindung getrennt</b>";

	switch (Reason)
	{
		case "100": alert("Session invalid"); break;
		case "50": alert("Session pong query 1 failed"); break;
		case "51": alert("Session pong query 2 failed"); break;
		default: alert("Session pong unknown error"); break;
	}
};





/* --- FORM LOAD CALLBACKS --- */

LoadClassMain=function()
{

};

LoadSchoolRadianForm=function()
{
    $("dfSchoolRadian_zip").focus();
    $("dfSchoolRadian_zip").select();
};

LoadUserStart=function()
{
	App.LoadMenuForm('mnuUser','home','user_home');
};
LoadSchoolStart=function()
{
	App.LoadMenuForm('mnuSchool','school_home','school_home');
};
LoadExamResult=function()
{
	ProgressBarScrollTo("pgExamResult",Exam.ResultRate,1000);
};
LoadUserActivatePrepaid3=function()
{
	App.LoadForm('frUserMenu_container','user_menu');
	App.LoadForm('display_container','user_home');
};
LoadUserOrder4=function()
{
	App.LoadForm('frUserMenu_container','user_menu');
	App.LoadForm('display_container','user_home');
};
LoadUserPwdRemail2=function()
{
	$("dfPwdRemail_email").focus();
};
LoadUserPwdChange=function()
{
	$('dfPwdChange_oldpassword').value='';
	$('dfPwdChange_newpassword').value='';
	$('dfPwdChange_renewpassword').value='';
};
LoadSchoolLogin=function()
{
	$('dfSchoolLogin_password').focus();
	$('dfSchoolLogin_password').select();
};
LoadUserTerminate=function()
{
	$('dfUserTerminate_password').focus();
	$('dfUserTerminate_password').select();
};
LoadUserRegisterTrail1=function()
{
	$("dfUserRegisterTrail1_email").focus();
	$('dfUserRegisterTrail1_email').select();
};
LoadUserRegisterPrepaid1=function()
{
	$('dfUserRegisterPrepaid1_tan').focus();
	$('dfUserRegisterPrepaid1_tan').select();
};
LoadUserRegisterPrepaid2=function()
{
	$('dfUserRegisterPrepaid2_email').focus();
	$('dfUserRegisterPrepaid2_email').select();
};
LoadSchoolSearch=function(Arguments)
{
	$("dfSchoolSearch_zip").focus();
	$("dfSchoolSearch_zip").select();
};
LoadSignSearch=function()
{
	$("dfSignSearch_keyword").focus();
	$("dfSignSearch_keyword").select();
};
LoadManualSearch=function()
{
	$("dfManualSearch_keyword").focus();
	$("dfManualSearch_keyword").select();
};
LoadContactForm1=function()
{
	$("dfContactForm_subject").focus();
};
LoadUserSettings=function()
{
	App.LoadForm('wndUserSettingsData_container','user_data');
};
LoadUserLogin=function()
{
	$("dfUserLogin_username").focus();
	$("dfUserLogin_username").select();
};
LoadSchoolLogin=function()
{
	$("dfSchoolLogin_schoolid").focus();
	$("dfSchoolLogin_schoolid").select();
};
LoadStart=function()
{
	App.ArrangeDisplayLock();
	window.onresize=App.ArrangeDisplayLock;
	NewsReader = new abNewsReader();
	NewsReader.ScrollInit("news_box");

};
LoadSchoolHome=function()
{

};
LoadSchoolFrame=function()
{
	App.LoadForm('wndSchoolList_window_container','school_list');
	App.LoadForm('wndSchoolMap_tab_container','school_region');
	App.LoadForm('wndSchoolSearch_window_container','school_search');
};



/* --- MISC INTERFACE FUNCTIONS --- */

ShowAboutWindow=function()
{
	App.CreateWindow('wndAbout','Über Fahrexperte.de',700,500);
	App.ActivateWindow('wndAbout');
	App.LoadForm('wndAbout_container','about');
	return false;
};
ShowTourWindow=function()
{
	App.CreateWindow('wndTour','Fahrexperte.de Tour',700,500);
	App.ActivateWindow('wndTour');
	App.LoadForm('wndTour_container','tour');
	return false;
};
ShowLegalWindow=function()
{
	App.CreateWindow('wndLegal','Impressum',700,500);
	App.ActivateWindow('wndLegal');
	App.LoadForm('wndLegal_container','legal');
	return false;
};
ShowLinksWindow=function()
{
	App.CreateWindow('wndLinks','nützliche Links',700,500);
	App.ActivateWindow('wndLinks');
	App.LoadForm('wndLinks_container','links');
	return false;
};
ShowContactWindow=function()
{
	App.CreateWindow('wndContact','Kontaktformular',700,500);
	App.ActivateWindow('wndContact');
	App.LoadForm('wndContact_container','contact_form1');
	return false;
};
ShowDisclaimerWindow=function()
{
	App.CreateWindow('wndDisclaimer','Haftungsausschluss',700,500);
	App.ActivateWindow('wndDisclaimer');
	App.LoadForm('wndDisclaimer_container','disclaimer');
	return false;
};
ShowUserRegisterWindow=function(Mode)
{
	VarStr="";
	App.CreateWindow('wndUserRegister','Registrierung',600,500);
	App.ActivateWindow('wndUserRegister');
	switch (Mode)
	{
		case 'trail': App.LoadForm('wndUserRegister_container','user_register_trail1','s=1',LoadUserRegisterTrail1); break;
		case 'prepaid': App.LoadForm('wndUserRegister_container','user_register_prepaid1','',LoadUserRegisterPrepaid1); break;
		default: App.LoadForm('wndUserRegister_container','user_register_menu'); break;
	}
	return false;
};
ShowSchoolRegisterWindow=function()
{
	App.CreateWindow('wndSchoolRegister','Fahrschulen Registrierung',600,425);
	App.ActivateWindow('wndSchoolRegister');
	App.LoadForm('wndSchoolRegister_container','school_register1');
	return false;
};


ShowSchoolOrderProofWindow=function()
{
	App.CreateWindow('wndSchoolOrderProof','Infopaket anfordern',600,500);
	App.ActivateWindow('wndSchoolOrderProof');
	App.LoadForm('wndSchoolOrderProof_container','order_license_package1');
	return false;
};

ShowSchoolPwdRemailWindow=function()
{
	App.CreateWindow('wndSchoolPwdRemail','Passwort Vergessen',320,150);
	App.ActivateWindow('wndSchoolPwdRemail');
	App.LoadForm('wndSchoolPwdRemail_container','school_pwdremail');
	return false;
};
ShowSchoolLoginWindow=function()
{
	App.CreateWindow('wndSchoolLogin','Fahrschulen Login',400,300);
	App.ActivateWindow('wndSchoolLogin');
	App.LoadForm('wndSchoolLogin_container','school_login','',LoadSchoolLogin);
	return false;
};
ShowUserPwdRemailWindow=function()
{
	App.CreateWindow('wndUserPwdRemail','Passwort Vergessen',300,150);
	App.ActivateWindow('wndUserPwdRemail');
	App.LoadForm('wndUserPwdRemail_container','user_pwdremail');
	return false;
};
ShowUserOrderWindow=function()
{
	App.CreateWindow('wndUserOrder','Vollversion bestellen',700,500);
	App.ActivateWindow('wndUserOrder');
	App.LoadForm('wndUserOrder_container','user_order1');
	return false;
};
ShowConditionsWindow=function()
{
	App.CreateWindow('wndConditions','Allgemeine Geschäftsbedingungen',700,500);
	App.ActivateWindow('wndConditions');
	App.LoadForm('wndConditions_container','conditions');
	return false;
};
ShowPrivacyPolicyWindow=function()
{
	App.CreateWindow('wndPrivacyPolicy','Datenschutzerklärung',700,500);
	App.ActivateWindow('wndPrivacyPolicy');
	App.LoadForm('wndPrivacyPolicy_container','privacy_policy');
	return false;
};

ShowWebCatalogWindow=function()
{
	App.CreateWindow('wndWebCatalog','Webkatalog',700,500);
	App.ActivateWindow('wndWebCatalog');
	App.LoadForm('wndWebCatalog_container','links');
	return false;
};

ShowUserActivatePrepaidWindow=function()
{
	App.CreateWindow('wndUserActivatePrepaid','Vollversion freischalten',700,500);
	App.ActivateWindow('wndUserActivatePrepaid');
	App.LoadForm('wndUserActivatePrepaid_container','user_activate_prepaid1');
	return false;
};
ShowUserPwdChangeWindow=function()
{
	App.CreateWindow('wndUserPwdChange','Passwort ändern',500,300);
	App.ActivateWindow('wndUserPwdChange');
	App.LoadForm('wndUserPwdChange_container','user_pwdchange');
	return false;
};
ShowUserTerminate=function()
{
	App.CreateWindow('wndUserTerminate','Benutzerkonto kündigen',500,300);
	App.ActivateWindow('wndUserTerminate');
	App.LoadForm('wndUserTerminate_container','user_terminate','',LoadUserTerminate);
	return false;
};
ShowUserClassChangeWindow=function()
{
	App.CreateWindow('wndUserClassChange','Klasse ändern',600,420);
	App.ActivateWindow('wndUserClassChange');
	App.LoadForm('wndUserClassChange_container','user_class_change');
	return false;
};
ShowUserMasterlicenseActivateWindow=function()
{
	App.CreateWindow('wndUserMasterlicenseActivate','Vollversion bestellen',700,500);
	App.ActivateWindow('wndUserMasterlicenseActivate');
	App.LoadForm('wndUserMasterlicenseActivate_container','user_activate_masterlicense1');
	return false;
};


ShowSignDetailWindow=function(SignID)
{
	App.CreateWindow('wndSignDetail','Verkehrszeichen',600,500);
	App.ActivateWindow('wndSignDetail');
	App.LoadForm('wndSignDetail_container','sign_detail','sign='+SignID);
	return false;
};
ShowNewsDetailWindow=function(NewsID)
{
	App.CreateWindow('wndNewsDetail','News',700,500);
	App.ActivateWindow('wndNewsDetail');
	App.LoadForm('wndNewsDetail_container','news_detail','news='+NewsID);
	return false;
};
ShowManualDetailWindow=function(ManualID)
{
	App.CreateWindow('wndManualDetail','Gesetze',700,500);
	App.ActivateWindow('wndManualDetail');
	App.LoadForm('wndManualDetail_container','manual_detail','id='+ManualID);
	return false;
};
ShowQuestionImageWindow=function(e,ImageID,Width,Height)
{
	if (!ImageID) {ImageID=Train.QuestionImage;}
	if (!Width) {Width=Train.QuestionImageWidth;}
	if (!Height) {Height=Train.QuestionImageHeight;}

	App.CreateWindow('wndQuestionImage','Volldarstellung',Width,(parseInt(Height)+40));
	App.ActivateWindow('wndQuestionImage');
	App.LoadForm('wndQuestionImage_container','question_image','id='+ImageID);

	return false;
};
MenuBarShow=function(MenuBar)
{
	switch (MenuBar)
	{
		case "left":
			$("left_container").style.display="block";
			$("left_frame").style.width="184px";
			$("display_frame").style.marginLeft="190px";
			return true;
		case "right":
			$("right_container").style.display="block";
			$("right_frame").style.width="184px";
			$("display_frame").style.marginRight="190px";
			return true;
	}
};
MenuBarHide=function(MenuBar)
{
	switch (MenuBar)
	{
		case "left":
			$("left_container").style.display="none";
			$("left_frame").style.width="10px";
			$("display_frame").style.marginLeft="10px";
			return true;
		case "right":
			$("right_container").style.display="none";
			$("right_frame").style.width="10px";
			$("display_frame").style.marginRight="10px";
			return true;
	}
};
TriggerTrainSelection=function()
{
	$("lbTrainSelection").innerHTML="Laden...";

	if (DataGridGetSelected('dgTrainSource')!="")
	{
		if (TrainSelectionTriggered)
		{
			window.clearTimeout(TrainSelectionTimer);
			TrainSelectionTimer=window.setTimeout("ShowTrainSelection()",300);
		}
		else
		{
			TrainSelectionTimer=window.setTimeout("ShowTrainSelection()",300);
			TrainSelectionTriggered=true;
		}
	}
	else
	{
		$("lbTrainSelection").innerHTML="Keine&nbsp;Auswahl";
	}
};
ShowTrainSelection=function()
{
	var Ajax = new abAjax();
	Ajax.Parent=this;

	if (DataGridGetSelected('dgTrainSource')!="")
	{
		var GetStr='categories='+DataGridGetSelected('dgTrainSource')+'&class='+$('swTrainClass_value').value;

		if ($('dfTrainOptions_onlyfalse').checked) {GetStr+='&onlyfalse';}

		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

			if (ResponseCode=="200")
			{
				if ($("dfTrainOptions_onlyfalse").checked)
				{
					$("lbTrainSelection").innerHTML=
					xmlResponse.getElementsByTagName("false_count")[0].firstChild.data+"&nbsp;Fragen&nbsp;ausgewählt";
				}
				else
				{
					$("lbTrainSelection").innerHTML=
					xmlResponse.getElementsByTagName("question_count")[0].firstChild.data+"&nbsp;Fragen&nbsp;ausgewählt&nbsp;/&nbsp;"+
					xmlResponse.getElementsByTagName("false_count")[0].firstChild.data+"&nbsp;zuletzt&nbsp;falsch";
				}
			}
		};

		Ajax.GetData(App.AppURL+"/load.xml?query=train_selection&"+GetStr+"&"+App.SessionName+"="+App.SessionID,false);
	}
	else
	{
		$("lbTrainSelection").innerHTML="Keine&nbsp;Auswahl";
	}
};
UpdateUserData=function()
{
	var Data="";
	Data+="name="+$("fid_user_name").value;
	Data+="&surname="+$("fid_user_surname").value;
	Data+="&password="+$("fid_user_password").value;
	Data+="&zip="+$("fid_user_zip").value;
	Data+="&city="+$("fid_user_city").value;
	Data+="&address="+$("fid_user_address").value;
	App.PostData("wndUserData_container","user_data","",Data);
};
UpdateUserClassSelection=function(ClassStr,BaseChapter)
{
	if (!ClassStr)
	{
		alert("Sie müssen mindestens eine Klasse auswählen!");
		return false;
	}
	else
	{
		var Ajax = new abAjax();
		var Result=false;
		Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
		Ajax.onLoaded=function()
		{
			var xmlResponse=Ajax.Request.responseXML.documentElement;
			var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;
			if (ResponseCode=="200") {Result=true;}
		};
		Ajax.PostData(App.AppURL+"/load.xml?query=user_class_change&"+App.SessionName+"="+App.SessionID,"selection="+ClassStr,true);
		return Result;
	}
};
UpdateUserClassActive=function(ClassID)
{
	var Ajax = new abAjax();
	var Result=false;
	Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
	Ajax.onLoaded=function()
	{
		var xmlResponse=Ajax.Request.responseXML.documentElement;
		var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;
		if (ResponseCode=="200") {Result=true;}
	};
	Ajax.PostData(App.AppURL+"/load.xml?query=user_class_change&"+App.SessionName+"="+App.SessionID,"active="+ClassID,true);
	return Result;
};
RemailPwd=function()
{
	var Data="email="+$("fid_user_email").value;
	App.PostData("display_container","remail_password","",Data);
};
SubmitSchoolRegister=function()
{
	var SchoolData="title="+escape($("fid_registerschool_title").value)
	+"&city="+escape($("fid_registerschool_city").value)
	+"&address="+escape($("fid_registerschool_address").value)
	+"&zip="+escape($("fid_registerschool_zip").value)
	+"&email="+escape($("fid_registerschool_email").value);

	App.PostData("display_container","school_register","",SchoolData);
};
RegisterSchool=function()
{
	App.LoadForm("display_container","school_register","","");
};
UserTerminate=function(Password)
{
	if (Password=='')
	{
		alert('Bitte geben Sie zur Bestätigung Ihr Passwort ein.');
	}
	else if (!UserPasswordCheck($('dfUserTerminate_password').value))
	{
		alert('Das eingegebene Passwort ist falsch!');
	}
	else
	{
		if (confirm('Wollen Sie Ihr Benutzerkonto wirklich löschen? Ihre gesamten Daten werden unwiederuflich gelöscht!'))
		{
			var Ajax = new abAjax();
			var Result=false;

			$('wndUserTerminate_container').innerHTML="Bitte warten. Ihr Benutzerkonto wird gelöscht...";

			Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
			Ajax.onLoaded=function()
			{
				var xmlResponse=Ajax.Request.responseXML.documentElement;
				var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

				if (ResponseCode=="200") {Result=true;}
				else {Result=false;}
			};
			Ajax.PostData(App.AppURL+"/load.xml?query=user_terminate&"+App.SessionName+"="+App.SessionID,"password="+Password,true);

			App.UnloadWindow('wndUserTerminate');

			if (Result)
			{
				User.Logout();
				alert('Sie haben Ihr Benutzerkonto unwiederruflich gelöscht! Sie erhalten eine Bestätigung der Kündigung an Ihre E-Mail Adresse.');
			}
		}
	}
};
UsernameCheck=function(Username)
{
	var Ajax = new abAjax();
	var Result=false;

	Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
	Ajax.onLoaded=function()
	{
		var xmlResponse=Ajax.Request.responseXML.documentElement;
		var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

		if (ResponseCode=="200") {Result=true;}
		else {Result=false;}
	};
	Ajax.PostData(App.AppURL+"/load.xml?query=username_check","username="+Username,true);

	return Result;
};
UserEmailCheck=function(Email)
{
	var Ajax = new abAjax();
	var Result=false;

	Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
	Ajax.onLoaded=function()
	{
		var xmlResponse=Ajax.Request.responseXML.documentElement;
		var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

		if (ResponseCode=="200") {Result=true;}
		else {Result=false;}
	};
	Ajax.PostData(App.AppURL+"/load.xml?query=useremail_check","email="+Email,true);

	return Result;
};
UserLicenseCheck=function(LicenseCode)
{
	var Ajax = new abAjax();
	var Result=false;

	Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
	Ajax.onLoaded=function()
	{
		var xmlResponse=Ajax.Request.responseXML.documentElement;
		var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

		if (ResponseCode=="200") {Result=true;}
		else {Result=false;}
	};
	Ajax.PostData(App.AppURL+"/load.xml?query=user_license_check","code="+LicenseCode,true);

	return Result;
};
UserPasswordCheck=function(Pwd)
{
	var Ajax = new abAjax();
	var Result=false;

	Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
	Ajax.onLoaded=function()
	{
		var xmlResponse=Ajax.Request.responseXML.documentElement;
		var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

		if (ResponseCode=="200") {Result=true;}
		else {Result=false;}
	};
	Ajax.PostData(App.AppURL+"/load.xml?query=user_pwd_check&"+App.SessionName+"="+App.SessionID,"pwd="+Pwd,true);

	return Result;
};
UserActivationCheck=function(ActivationCode)
{
	var Ajax = new abAjax();
	var Result=false;

	Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
	Ajax.onLoaded=function()
	{
		var xmlResponse=Ajax.Request.responseXML.documentElement;
		var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

		if (ResponseCode=="200") {Result=true;}
		else {Result=false;}
	};
	Ajax.PostData(App.AppURL+"/load.xml?query=user_activation_check","code="+ActivationCode,true);

	return Result;
};
EditSchool=function()
{
	if (ValidateReqNumber("fid_school_id",99999999,10000))
	{
		App.PostData("display_container","school_edit",
		"id="+$("fid_school_id").value
		+"&password="+$("fid_school_password").value);
	}
	else
	{
		$("school_id_invalid_message").style.display="";
		$("fid_school_id").focus();
		$("fid_school_id").select();
	}
};
UpdateSchool=function()
{
	var SchoolData="title="+escape($("fid_school_title").value)
	+"&city="+escape($("fid_school_city").value)
	+"&address="+escape($("fid_school_address").value)
	+"&zip="+escape($("fid_school_zip").value)
	+"&email="+escape($("fid_school_email").value)
	+"&phone1="+escape($("fid_school_phone1").value)
	+"&phone2="+escape($("fid_school_phone2").value)
	+"&fax="+escape($("fid_school_fax").value)
	+"&name="+escape($("fid_school_name").value)
	+"&surname="+escape($("fid_school_surname").value)
	+"&website="+escape($("fid_school_website").value);

	var ClassData="&classes=";

	if($("fid_school_class_a").checked){ClassData+="a,";}
	if($("fid_school_class_a1").checked){ClassData+="a1,";}
	if($("fid_school_class_b").checked){ClassData+="b,";}
	if($("fid_school_class_c").checked){ClassData+="c,";}
	if($("fid_school_class_c1").checked){ClassData+="c1,";}
	if($("fid_school_class_ce").checked){ClassData+="ce,";}
	if($("fid_school_class_d").checked){ClassData+="d,";}
	if($("fid_school_class_d1").checked){ClassData+="d1,";}
	if($("fid_school_class_l").checked){ClassData+="l,";}
	if($("fid_school_class_m").checked){ClassData+="m,";}
	if($("fid_school_class_mofa").checked){ClassData+="mofa,";}
	if($("fid_school_class_s").checked){ClassData+="s,";}
	if($("fid_school_class_t").checked){ClassData+="t,";}
	if(ClassData.length>=1) {ClassData=ClassData.substr(0,ClassData.length-1);}

	SchoolData+=ClassData;

	if($("fid_school_support_asf").checked){SchoolData+="&asf=1";} else {SchoolData+="&asf=0";}
	if($("fid_school_support_asp").checked){SchoolData+="&asp=1";} else {SchoolData+="&asp=0";}
	if($("fid_school_support_fsf").checked){SchoolData+="&fsf=1";} else {SchoolData+="&fsf=0";}
	if($("fid_school_support_automatic").checked){SchoolData+="&automatic=1";} else {SchoolData+="&automatic=0";}
	if($("fid_school_support_vacation").checked){SchoolData+="&vacation=1";} else {SchoolData+="&vacation=0";}
	if($("fid_school_support_disabled").checked){SchoolData+="&disabled=1";} else {SchoolData+="&disabled=0";}

	App.PostData("display_container","school_edit",SchoolData);
};
ExpandCollapseRow=function(ID)
{
	if ($("expand"+ID).style.display=="none")
	{
		$("expandbutton"+ID).src="template/gfx/collapse.gif";
		$("expand"+ID).style.display="";
		$(ID).className="TableRowSelected";
	}
	else
	{
		$("expandbutton"+ID).src="template/gfx/expand.gif";
		$("expand"+ID).style.display="none";
	}
};
ExpandCollapse=function(ID)
{
	if ($("expand"+ID).style.display=="none")
	{
		$("expandbutton"+ID).src="template/gfx/collapse.gif";
		$("expand"+ID).style.display="";
	}
	else
	{
		$("expandbutton"+ID).src="template/gfx/expand.gif";
		$("expand"+ID).style.display="none";
	}
};
Check=function(ID)
{
	if (!$(ID).disabled)
	{$(ID).checked=!$(ID).checked;}
};
SelectOption=function(id)
{
	$(id).checked=true;
};
SwapImage=function(ButtonID,Image)
{
	$(ButtonID).src=Image;
};
SchoolZipMapMouseOver=function(Zip)
{
	$('school_menu_zipmap_img').className="SchoolZipMapOn_"+Zip;
};
SchoolZipMapMouseOut=function()
{
	$('school_menu_zipmap_img').className="SchoolZipMapOff";
};



/* --- SCHOOL SEARCH --- */

SchoolSearchSubmit=function(Keyword,City,Zip,Radian,Back)
{
	var VarStr="";

	if (Keyword) {VarStr+=((VarStr)?"&":"")+"keyword="+escape(Keyword);}
	$('dfSchoolSearch_keyword').value=Keyword;
	if (City) {VarStr+=((VarStr)?"&":"")+"city="+escape(City);}
	$('dfSchoolSearch_city').value=City;
	if (Zip) {VarStr+=((VarStr)?"&":"")+"zip="+escape(Zip);}
	$('dfSchoolSearch_zip').value=Zip;
	if (Radian) {VarStr+=((VarStr)?"&":"")+"radian="+escape(Radian);}
	DataFormSetSelectedOption('dfSchoolSearch','radian',Radian);

	App.PostData("frSchoolSearch_container","school_search_result",((Back) ? 'back='+Back : ''),VarStr)
};
SchoolSearchZipMap=function(Zip)
{
	App.LoadForm('frSchoolSearch_container','school_zipmap','zip='+Zip,'',true);
};
SchoolSearchCityList=function(Zip)
{
	App.LoadForm('frSchoolSearch_container','school_citylist','zip='+Zip);
};
SchoolSearchCity=function(Zip,City)
{
	App.LoadForm('frSchoolSearch_container','school_search_result','zip='+Zip+'&city='+City);
};
SchoolDetail=function(SchoolID)
{
	App.CreateWindow('wndSchoolDetail','Fahrschuldetails',780,500);
	App.ActivateWindow('wndSchoolDetail');
	App.LoadForm('wndSchoolDetail_container','school_detail','school_id='+SchoolID,'',true);
};
SchoolSearchKeyPress=function(e)
{
	if (e)
	{
		var CharCode = ((window.event) ? e.keyCode : e.which);
		if (CharCode==13)
		{
			SchoolSearchSubmit($('dfSchoolSearch_keyword').value,$('dfSchoolSearch_city').value,$('dfSchoolSearch_zip').value,DataFormGetSelectedOption('dfSchoolSearch','radian'));
		}
	}
};
SignSearchKeyPress=function(e)
{
	if (e)
	{
		var CharCode = ((window.event) ? e.keyCode : e.which);
		if (CharCode==13)
		{
			SignSearchSubmit();
		}
	}
};



/* --- MANUAL SEARCH --- */

ManualSearchSubmit=function()
{
	App.LoadForm("frManualSearch_container","manual_search_result","keyword="+escape($("dfManualSearch_keyword").value));
};
ManualSearchKeyPress=function(e)
{
	if (e)
	{
		var CharCode = ((window.event) ? e.keyCode : e.which);
		if (CharCode==13)
		{
			ManualSearchSubmit();
		}
	}
};



/* --- SIGN SEARCH --- */

SignSearchSubmit=function()
{
	App.LoadForm("frSignSearch_container","sign_search_result","keyword="+escape($("dfSignSearch_keyword").value),'',true);
};
SignSearchCategory=function(Category)
{
	App.LoadForm("frSignSearch_container","sign_search_result","category="+Category);
};


UserMasterLicenseCheck=function(ActivationCode)
{
	var Ajax = new abAjax();
	var Result=false;

	Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
	Ajax.onLoaded=function()
	{
		var xmlResponse=Ajax.Request.responseXML.documentElement;
		var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

		if (ResponseCode=="200") {Result=3;}
		else if (ResponseCode=="101") {Result=2;}
		else {Result=1;}
	};
	Ajax.PostData(App.AppURL+"/load.xml?query=masterlicense_check","code="+ActivationCode,true);

	return Result;
};






/* --- ITEM MANAGER --- */

ItemManagerGetAllVars=function()
{
	return "category_id="+escape(TreeViewGetSelected("tvItemManagerCategories"))
	+"&expanded="+escape(TreeViewGetExpanded("tvItemManagerCategories"))
	+"&view="+escape(TabGetSelected("tabItemManagerList"))
	+"&selected="+escape(DataGridGetSelected("dgItemManagerList"))
	+"&order_column="+escape(DataGridGetColumn("dgItemManagerList"))
	+"&order_direction="+escape(DataGridGetDirection("dgItemManagerList"))
	+"&records="+escape($("dfItemManagerFilter_records").value)
	+"&manufacturer="+escape($("dfItemManagerFilter_manufacturer").value)
	+"&supplier="+escape($("dfItemManagerFilter_supplier").value)
	+"&pricelist="+escape($("dfItemManagerFilter_pricelist").value)
	+"&keywords="+escape($("dfItemManagerFilter_keywords").value);
};
ItemManagerReload=function()
{
	App.LoadForm('display_container','masterdata.items',ItemManagerGetAllVars());
};
ItemManagerReloadFilter=function()
{
	App.LoadForm('frItemManagerList_container','masterdata.items.list',ItemManagerGetAllVars());
};
ItemManagerReloadCategories=function()
{
	App.LoadForm('frItemManagerCategories_container','masterdata.items.categories','selected='+escape(TreeViewGetSelected("tvItemManagerCategories"))+'&expanded='+escape(TreeViewGetExpanded("tvItemManagerCategories")),'',true);
};
ItemManagerFolderClick=function(TV,Key)
{
	App.LoadForm("display_container","links","category_id="+escape(Key));
};




ShowUserMasterlicenseRegisterWindow=function(Mode,Promo)
{
	VarStr="";
	App.CreateWindow('wndUserRegister','Registrierung',600,500);
	App.ActivateWindow('wndUserRegister');
	switch (Mode)
	{
		case 'masterlicense': App.LoadForm('wndUserRegister_container','user_register_masterlicense1','promo='+Promo); break;
		default: App.LoadForm('wndUserRegister_container','user_register_menu'); break;
	}

	return false;
};

ShowVisitorRegisterWindow=function()
{
	VarStr="";
	App.CreateWindow('wndVisitorOrder','Bestellung',600,500);
	App.ActivateWindow('wndVisitorOrder');
	App.LoadForm('wndVisitorOrder_container','visitor_order1','s=1');

	return false;
};


LoadSchoolDescriptionSave=function(Headers)
{
	if (Headers['cmd']=='desc_save')
	{
		if (Headers['code']==200)
		{
			App.CreateInlineMessage("Information","Ihre Beschreibung wurde gespeichert.","information");
		}
		else
		{
			App.CreateInlineMessage("Information","Ihre Beschreibung konnte nicht gespeichert werden.","critical");
		}
	}
};


LoadSchoolDataSave=function(Headers)
{
	if (Headers['cmd']=='data_save')
	{
		if (Headers['code']==200)
		{
			App.CreateInlineMessage("Information","Ihre Daten wurde gespeichert.","information");
		}
		else
		{
			App.CreateInlineMessage("Information","Ihre Daten konnte nicht gespeichert werden.","critical");
		}
	}
};




LoadSchoolRegister=function(Headers)
{
	if (Headers['cmd']=='school_register')
	{
		if (Headers['code']==200)
		{
			App.CreateInlineMessage("Information","Ihre Fahrschule wurde bei uns eingetragen und wird schnellstmöglich von einem Mitarbeiter geprüft.","information");
		}
		else
		{
			App.CreateInlineMessage("Information","Ihre Fahrschule konnte nicht hinzugefügt werden.","critical");
		}
	}
};


LoadUserDataChange=function(Headers)
{
	if (Headers['cmd']=='user_data_change')
	{
		if (Headers['code']==200)
		{
			App.CreateInlineMessage("Information","Ihre Daten wurde gespeichert.","information");
		}
		else
		{
			App.CreateInlineMessage("Information","Ihre Daten konnte nicht gespeichert werden.","critical");
		}
	}
	else if (Headers['cmd']=='user_pwd_change')
	{
		if (Headers['code']==200)
		{
			App.CreateInlineMessage("Information","Ihr Passwort wurde gespeichert.","information");
		}
		else
		{
			App.CreateInlineMessage("Information","Ihr Passwort konnte nicht gespeichert werden.","critical");
		}
	}
	else if (Headers['cmd']=='user_class_change')
	{
		if (Headers['code']==200)
		{
			App.CreateInlineMessage("Information","Ihre Klasse wurde geändert.","information");
		}
		else
		{
			App.CreateInlineMessage("Information","Ihre Klasse konnte nicht geändert werden.","critical");
		}
	}
};

ltrim = function(str, chars)
{
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
};




UserUpdateSchool=function(SchoolID)
{
	var Ajax = new abAjax();
	var Result=false;

	Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
	Ajax.onLoaded=function()
	{
		var xmlResponse=Ajax.Request.responseXML.documentElement;
		var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;

		if (ResponseCode=="200") {App.CreateInlineMessage("Information","Sie können Ihre Fahrschule jetzt bewerten.","information");Result=true;}
		else {App.CreateInlineMessage("Fehler","Das merken ist fehlgeschlagen","critical");Result=false;}
	};
	Ajax.PostData(App.AppURL+"/load.xml?query=user_update_school&"+App.SessionName+"="+App.SessionID,"school_id="+escape(SchoolID),true);

	return Result;
};






UserSchoolRate=function(Rate)
{
	var Ajax = new abAjax();
	var Result=false;

	Ajax.onError=function() {Ajax.Parent.onTerminate(0);};
	Ajax.onLoaded=function()
	{
		var xmlResponse=Ajax.Request.responseXML.documentElement;
		var ResponseCode=xmlResponse.getElementsByTagName("code")[0].firstChild.data;
		var Rate=xmlResponse.getElementsByTagName("rate")[0].firstChild.data;

		for (var i=1;i<=5;i++)
		{
			if (i<=Rate)
			{
				$('srSchoolRate_Star'+i).src=App.AppURL+'/system/themes/yellow/gfx/RatingOn.png';
			}
			else
			{
				$('srSchoolRate_Star'+i).src=App.AppURL+'/system/themes/yellow/gfx/RatingOff.png';
			}

			$('srSchoolRate_Star'+i).onmouseover='';
			$('srSchoolRate_Star'+i).onmouseout='';
			$('srSchoolRate_Star'+i).onclick='';
		}

		if (ResponseCode=="200") {App.CreateInlineMessage("Information","Ihre Schule wurde bewertet.","information");}
		else {App.CreateInlineMessage("Fehler","Bewerten fehlgeschlagen!","critical");}
	};
	Ajax.PostData(App.AppURL+"/load.xml?query=school_rate&"+App.SessionName+"="+App.SessionID,"rate="+escape(Rate),true);


	return Result;
};

ShowUserDetailWindow=function(UserID,Username)
{
	App.CreateWindow('wndUserDetail','Benutzer Profil von '+Username,500,400);
	App.ActivateWindow('wndUserDetail');
	App.LoadForm('wndUserDetail_container','user.detail','user_id='+UserID);
	return false;
};











UserListGetAllVars=function()
{
	return "order_column="+escape(DataGridGetColumn("dgUserList"))
	+"&order_direction="+escape(DataGridGetDirection("dgUserList"))
	+(($("dfUserManagerFilter_records")) ? "&records="+escape($("dfUserManagerFilter_records").value) : "")
	+(($("dfUserManagerFilter_keywords")) ? "&keywords="+escape($("dfUserManagerFilter_keywords").value) : "");
};
UserListReload=function()
{
	App.LoadForm('display_container',"user.main",UserListGetAllVars(),LoadUserListSearch);
};
UserListReloadFilter=function(Page)
{
	var QueryString=UserListGetAllVars();
	App.LoadForm('frUserList_container',"user.list",QueryString+((Page) ? ((QueryString!='') ? "&" : "")+"page="+Page : ""),LoadUserListSearch);
};
UserListFilterKeyPress=function(e)
{
	if (e) {var CharCode = ((window.event) ? e.keyCode : e.which); if (CharCode==13) {UserListReloadFilter();}}
};
LoadUserListSearch=function()
{

};





