function mtr_GetBrowser() {

  var UserAgent, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  UserAgent = navigator.userAgent;

  s = "MSIE";
  if ((i = UserAgent.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(UserAgent.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = UserAgent.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(UserAgent.substr(i + s.length));
    return;
  }

  s = "Gecko";
  if ((i = UserAgent.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

}

function mtr_AddEventListener( element, event_name, observer, capturing ) {

	if ( gmtr_GetBrowser.isIE) { // IE
		element.attachEvent( "on" + event_name, observer );
		return;
	}

	if (element.addEventListener ) // DOM2
		element.addEventListener( event_name, observer, capturing );
}

function mtr_RemoveEventListener( element, event_name, observer, capturing ) {

	if ( gmtr_GetBrowser.isIE) { // IE
		element.detachEvent( "on" + event_name, observer );
		return;
	}

	if (element.removeEventListener ) // DOM2
		element.removeEventListener( event_name, observer, capturing );
}

function mtr_GetAbsPosLeft(element) {

	return (element.offsetParent) ? element.offsetLeft + mtr_GetAbsPosLeft(element.offsetParent) : element.offsetLeft;

}

function mtr_GetAbsPosTop(element) {

	return (element.offsetParent) ? element.offsetTop + mtr_GetAbsPosTop(element.offsetParent) : element.offsetTop;

}

function mtr_GetPageHeight() {

	if(document.documentElement.scrollHeight > document.documentElement.clientHeight)
		return document.documentElement.scrollHeight;
		
	return document.documentElement.clientHeight;
}

function mtr_ScrollToElement(name) {
	window.scrollTo( 0, mtr_GetAbsPosTop(document.getElementsByName(name)[0]));
	return false;
}

function mtr_ScrollToAnchor() {

	if(window.location.hash) 
		window.setTimeout("mtr_ScrollToElement(window.location.hash.substring(1))",400);

};
function MTRAjaxParseResponse(text, targetDOMele) {
	var comp = text.split("###");
	if(comp.length > 1) {
		eval(comp[0]);
		if(targetDOMele)
			targetDOMele.innerHTML = comp[1];
	} else {
		if(targetDOMele)
			targetDOMele.innerHTML = text;
	}
}
function MTRAjax(URL, Handler, WaitMsg) {
var objHTTPReq;

	this.createHTTPReq = function() {
		try {
			objHTTPReq = new XMLHttpRequest();
		} catch(w3c) {
			var dummy = new Date().getTime();
			URL += "&_dmy_="+dummy;
			try {
				objHTTPReq = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(msie) {

				try {
					objHTTPReq = new ActiveXObject("Microsoft.XMLHTTP");
				}

				catch(msieold) {
					alert("Your Browser must support AJAX to display this site!");
					objHTTPReq = null;
					return false;
				} // catch(msieold)

			} // catch(msie)

		} // catch(w3c)

		return true;

	} // this.createHTTPReq = function()

	if(!this.createHTTPReq())
		return -10;

	objHTTPReq.onreadystatechange = function() {

		if (objHTTPReq.readyState == 4) {
			if ((objHTTPReq.status != 200) && (objHTTPReq.status != 0))
				return false;

			switch(typeof Handler) {
				case "function":
					Handler(objHTTPReq.responseText, objHTTPReq.readyState );
					break;
				case "string":
					MTRAjaxParseResponse(objHTTPReq.responseText, document.getElementById(Handler));
					break;
			}

			return true;
		}
		return false;
	};

	if(gLogin.sID)
		URL += '&sid=' + gLogin.sID;
		
	if(gmtr_GetBrowser.isIE)
		URL += '&ie_d='+Math.random();

	var temp = window.location.search.match(/DBGSESSID.+/);
	if(temp )
		URL += '&' + temp;		
	
	try {
		objHTTPReq.open("GET", URL, true);
		objHTTPReq.send(null);
	} catch(msie) {
	}

	if(WaitMsg && (typeof(Handler) == "string"))
		document.getElementById(Handler).innerHTML = WaitMsg;

	return 0;
}

// shadow box stuff start
function mtr_ShBox_MoveStart(evt, Element) {

	switch(typeof Element) {
		case "string":
			gCurrDDEle =document.getElementById(Element);
			break;
		case "object":
			gCurrDDEle = Element;
			break;
		default:
			return;
	}

	gCurrDDEle.posX = mtr_GetAbsPosLeft(gCurrDDEle);
	gCurrDDEle.posY = mtr_GetAbsPosTop(gCurrDDEle);
	gCurrDDEle.posHitX = evt.clientX;
	gCurrDDEle.posHitY = evt.clientY;

	mtr_AddEventListener(document, "mousemove", mtr_ShBox_Move, true);
	mtr_AddEventListener(document, "mouseup", mtr_ShBox_MoveEnd, true);


	if(gmtr_GetBrowser.isIE) {
		evt.cancelBubble = true;
		evt.returnValue = false;

	} else {
		evt.preventDefault();
		evt.stopPropagation();
	}

	gCurrDDEle.style.margin="0";
	mtr_ShBox_Move(evt);

}

function mtr_ShBox_MoveEnd() { // terminate moving

	gCurrDDEle = gOldMouseX = gOldMouseY = 0;

	mtr_RemoveEventListener(document, "mousemove", mtr_ShBox_Move, true);
	mtr_RemoveEventListener(document, "mouseup", mtr_ShBox_MoveEnd, true);

}


function mtr_ShBox_Move(evt) {

	if(gCurrDDEle) {
var		lEvt = evt || window.event;


var		NewX = gCurrDDEle.posX + lEvt.clientX - gCurrDDEle.posHitX;
var		NewY = gCurrDDEle.posY + lEvt.clientY - gCurrDDEle.posHitY;

		if(!isNaN(NewX))
			gCurrDDEle.style.left = NewX + "px";

		if(!isNaN(NewY))
			gCurrDDEle.style.top  = NewY + "px";

		if(gmtr_GetBrowser.isIE) {
			lEvt.cancelBubble = true;
			lEvt.returnValue = false;
		} else {
			lEvt.preventDefault();
			lEvt.stopPropagation();
		}

	}

	return true;
}

function mtr_ShBox_Add(Where, What, Id, Params) {

var html = "<div id=\""+ Id + "\" class=\"mtr_ShBox_container\" style=\"width:" + Params["width"] + "; top:" + Params["top"] + "; left:" + Params["left"] + ";\">"+
	"<div class=\"mtr_ShBox_shdw\" style=\"height:" + Params["height"] + ";\"></div>"+
	"<div onmousedown=\"mtr_ShBox_MoveStart(event, this.parentNode)\" class=\"mtr_ShBox_canv normal\" style=\"width:97%; height:" + Params["height"] + ";\">"+
		"<div onmousedown=\"mtr_ShBox_MoveStart(event, this.parentNode.parentNode)\" class=\"mtr_ShBox_ctrl\">&nbsp;X</div>" +
		"<div class=\"mtr_ShBox_inner\">"+
			What +
		"</div>" +
	"</div>"+
	"</div>";

	var eleDiv = document.createElement("div");
	eleDiv.innerHTML =html;

	switch(typeof Where) {
		case "string":
			InsBeforeEle =document.getElementById(Where);
			break;
		case "object":
			InsBeforeEle = Where;
			break;
		default:
			return;
	}

	InsBeforeEle.parentNode.insertBefore(eleDiv,InsBeforeEle);
}
// shadow box stuff end

// modal overlay stuff:
function mtr_ModalOverlay_Remove(ID) {
	window.status = "";
	var Body = document.getElementsByTagName("body")[0];
	var SCont = document.getElementById(ID);

	Body.removeChild(SCont);
}


function mtr_ModalOverlay_ImgOnMouseWheel(event,element) {

	if (!event)
		event = window.event;

	if(!element)
		element = event.target;

	var fact;

	if (event.preventDefault) {
		if(event.detail > 0)
			fact =1.1;
		else if(event.detail < 0)
			fact =0.9;
		event.preventDefault();
	} else {
		if(event.wheelDelta > 0)
			fact=0.9;
		else if(event.wheelDelta < 0)
			fact=1.1;
	}

	mtr_ModalOverlay_ImgOnLoad(element,fact);

	return false;
}


function mtr_ModalOverlay_ImgOnLoad(img, fact) {

	var Container=document.getElementById("mtr_OverlContainer");
	Container.style.display ="block";
	Container.style.left= "50%";
	Container.style.top= "50%";

	if(img.width) {

		if(!img.orgwidth) {

			img.orgwidth = img.width;
			img.orgheight = img.height;
			img.width = img.orgwidth;
			img.height = img.orgheight;

			if(window.addEventListener)
				img.addEventListener("DOMMouseScroll", mtr_ModalOverlay_ImgOnMouseWheel, false);

			img.alt = img.width + " x " + img.height;
			if((img.height<400) && (img.width<400))
				fact=2.0;

			var x,y;
			if (self.innerHeight) {
				x = self.innerWidth;
				y = self.innerHeight;
			}
			else if (document.documentElement && document.documentElement.clientHeight)	{
				x = document.documentElement.clientWidth;
				y = document.documentElement.clientHeight;
			}
			else if (document.body) {
				x = document.body.clientWidth;
				y = document.body.clientHeight;
			}

			if(img.width > (x-60)) {
				var factx = img.width / (x-60);
				img.width /=  factx;
				img.height /=  factx;
			}
			if(img.height > (y-60)) {
				var facty = img.height / (y-60);
				img.width /=  facty;
				img.height /=  facty;
			}
		}

		if(fact) {
			if(fact == 1.0) {
				img.width = img.orgwidth;
				img.height = img.orgheight;
			} else {
				img.width *= fact;
				img.height *= fact;
			}
		}

		var bckgnd=document.getElementById("mtr_OverlImgBckgnd");
		if(bckgnd) {
			bckgnd.width = img.width;
			bckgnd.height = img.height;
		}

		Container.style.marginLeft=img.width/-2 + "px";

		var temp = img.height/-2;
		if(window.pageYOffset)
			temp += window.pageYOffset;
		else
			temp += document.documentElement.scrollTop;

		if(temp < ((this.window.innerHeight -80)/ -2))
			temp= (this.window.innerHeight -90)/ -2;

		Container.style.marginTop = temp +  "px";
		Container.style.width = (img.width + 20) + "px";
			
		Container=document.getElementById("mtr_OverlControl");
		Container.style.width = (img.width + 20) + "px";
		
		Container=document.getElementById("mtr_Overl");
		Container.style.backgroundImage ="none";

		if(img.width ==0) window.setTimeout("mtr_ModalOverlay_ImgOnLoad(document.getElementById('mtr_ImgOverlImg'),1)", 1000);

	}
}

function mtr_ModalOverlay_ShowImg(URL, Params) {

	if(typeof Params == "undefined")
		 Params = {};

	if(typeof Params.Caption == "undefined")
		Params.Caption = "";
	else
		Params.Caption = "&nbsp;" + Params.Caption;

	var Style="";
	var HTML ="";

	if((typeof Params.BackgroundURL == "string") && Params.BackgroundURL)
		HTML += "<img id=\"mtr_OverlImgBckgnd\" class=\"mtr_OverlImg\" src=\"" + Params.BackgroundURL + "\" style=\" position:absolute;\"/>";
	else
		Style += "background-color:#A0A0A0;";


	HTML += "<img id=\"mtr_OverlImg\" class=\"mtr_OverlImg\" src=\""+ URL+"\" style=\""+ Style +"\" onLoad =\"mtr_ModalOverlay_ImgOnLoad(this)\" onclick=\"mtr_ModalOverlay_Remove('mtr_OverlSCont')\" onMouseWheel= \"return mtr_ModalOverlay_ImgOnMouseWheel(event,this)\"/>";

	window.status = "Use mousewheel to zoom";

	if(typeof Params.Subtitle == "string")
		HTML += "<div class=\"mtr_OverlImgSubtitle\">"+Params.Subtitle+"</div>";

	var innerHTML =
	 "<div class=\"mtr_Overl\" id=\"mtr_Overl\" style=\"height:" + mtr_GetPageHeight() + "px;\"></div>" +
	 "<div id=\"mtr_OverlContainer\" class=\"mtr_OverlContainer\" style=\"display:none;\">" +
	  "<div onmousedown=\"mtr_ShBox_MoveStart(event, this.parentNode)\" class=\"mtr_OverlControl\" id=\"mtr_OverlControl\">"+

	   "<span title=\"close\" id=\"mtr_OverlClosebutt\" class=\"mtr_OverlControlElement\" onclick=\"mtr_ModalOverlay_Remove('mtr_OverlSCont')\">&nbsp;x&nbsp;</span>"+
	   "<span title=\"open in new browser\" class=\"mtr_OverlControlElement\" onclick=\"window.open('"+URL+"', 'mtr_Overl'); mtr_ModalOverlay_Remove('mtr_OverlSCont');\">&nbsp; &nbsp;&gt;&gt;</span>" +

	   "<span title=\"orginal size\" class=\"mtr_OverlControlElement\" onclick=\"mtr_ModalOverlay_ImgOnLoad(document.getElementById('mtr_OverlImg'),1.0)\">&nbsp;1:1&nbsp;&nbsp;</span>" +
	   "<span title=\"larger\" class=\"mtr_OverlControlElement\" onclick=\"mtr_ModalOverlay_ImgOnLoad(document.getElementById('mtr_OverlImg'),1.5)\">+</span>" +
	   "<span title=\"smaller\" class=\"mtr_OverlControlElement\" onclick=\"mtr_ModalOverlay_ImgOnLoad(document.getElementById('mtr_OverlImg'),0.5)\">&nbsp;-</span>" +
		Params.Caption +
	   "</div>" +
	  HTML +
	 "</div>";

	var eleDiv = document.createElement("div");
	eleDiv.innerHTML = innerHTML;
	eleDiv.id="mtr_OverlSCont";
	eleDiv.setAttribute("class","mtr_OverlSCont");

	var BodyEle= document.getElementsByTagName("body")[0];
	BodyEle.appendChild(eleDiv,BodyEle);
	
}

function mtr_ModalOverlay_BoxOnLoad(EleID, stage) {
var EleDOM = document.getElementById(EleID);

	if(!stage && gmtr_GetBrowser.isIE) {
		window.setTimeout("mtr_ModalOverlay_BoxOnLoad('"+ EleID + "',1)", 300);
		return;
	}

	EleDOM.parentNode.previousSibling.style.backgroundImage ='none';
	var Container=document.getElementById("mtr_OverlContainer");
	Container.style.display ="block";

	var temp = EleDOM.offsetHeight/-2;
	if(window.pageYOffset)
		temp += window.pageYOffset;
	else
		temp += document.documentElement.scrollTop;

	Container.style.marginTop = temp +  "px";

}

function mtr_ModalOverlay_ShowBox(HTML, Params) {

	if(typeof Params == "undefined")
		 Params = {};

	if(typeof Params.Style == "undefined")
		Params.Style = "width:48em; height:27em; margin-left:-24em; margin-top:-14em;";

	if(typeof Params.Caption == "undefined")
		Params.Caption = '';

	var closeButtonHTML = '<span title="close" id="mtr_OverlClosebutt" class="mtr_OverlControlElement" onclick="mtr_ModalOverlay_Remove(\'mtr_OverlSCont\')">&nbsp;x&nbsp;</span>';;
	if(typeof Params.hideClosebutton != "undefined")
		closeButtonHTML = '';
	
	var innerHTML =	
		'<div class="mtr_Overl" id="mtr_Overl" style="height:' + mtr_GetPageHeight() + 'px; background-image:none;"></div>' +
		'<div id="mtr_OverlContainer" class="mtr_OverlContainer" style="' + Params.Style  + '">' +
		 '<div onmousedown="mtr_ShBox_MoveStart(event, this.parentNode)" class="mtr_OverlControl">'+
		  closeButtonHTML +  
		  '<span class="mtr_OverlCaption">' + Params.Caption + '</span>'+
		 '</div>' +
'<iframe style="position:absolute; border:none; width:100%; height:100%" frameborder="0"></iframe>'+
		 '<div id="mtr_OverlInner" class="mtr_OverlInner">' +
		  HTML +
		 '</div>' +
		'</div>';
		
	var eleDiv = document.createElement('div');
	eleDiv.innerHTML = innerHTML;
	eleDiv.id = "mtr_OverlSCont";
	eleDiv.setAttribute("class","mtr_OverlSCont");

	document.getElementsByTagName("body")[0].appendChild(eleDiv);

	document.getElementById("mtr_OverlInner").style.display="none";
	var InnerConta = document.getElementById("mtr_OverlContainer");
	InnerConta.style.overflow="hidden";
	
	var tempbox = new mtr_Dnyamize(0, parseInt(InnerConta.offsetWidth), function(mtr_Dyn, finished) 
		{
			if(finished){
				mtr_Dyn.DomEle.style.overflow="visible"; 
				var temp = document.getElementById("mtr_OverlInner")
				if(temp)
					temp.style.display="block";
				if(typeof Params.onFinish == "function") 
					Params.onFinish();
				return;
			}	 
			mtr_Dyn.DomEle.style.width = mtr_Dyn.CVal + "px";
		}, 
		400, 30, InnerConta);	

}

function mtr_ModalOverlay_ShowDialogBox(HTML, Params) {

	
	if(typeof Params == "undefined")	
		Params = {};
		
	if(!Params.boxType)
		Params.boxType = 'info';

	if(!Params.Style)
		Params.Style = "width:30em; height:10em; margin-left:-15em; margin-top:-10em;";

	switch(Params.boxType ) {
	
		case 'waitmsg':

			if(!Params.Caption)
				Params.Caption = '...einen Moment bitte...';

			mtr_ModalOverlay_ShowBox('<div class="dlgBoxText"><div class="waitanim" style="margin:1em 1em 1em 0; float:left"></div>' + HTML + '</div>', Params);

			break;

		case 'info':

			if(!Params.Caption)
				Params.Caption = 'Information:';

			// add OK button
			HTML += '<div class="dlgBoxButtonConta"><button class="dlgBoxButton" id="mtr_modboxbuttOK" onclick="mtr_ModalOverlay_Remove(\'mtr_OverlSCont\')">OK</button></div>';

			if(!Params.onFinish)
				Params.onFinish = function() {document.getElementById('mtr_modboxbuttOK').focus()};

			mtr_ModalOverlay_ShowBox('<div class="dlgBoxText">' + HTML + '</div>', Params);

			break;
			
	}
}

// modal overlay stuff end

function mtr_Dnyamize(StartVal, EndVal, Callback, Duration, Interval, DomEle) {

	this.UpdateValLinear = function() {
		var Dat = new Date();
		var Now = Date.parse(Dat) + Dat.getMilliseconds();
		this.CVal = this.SVal + ((Now - this.DynStartTime) / this.DynDeltaTime) * this.DeltaVal;
		return false;
	}

	this.UpdateVal = function() {
		var Dat = new Date();
		var Now = Date.parse(Dat) + Dat.getMilliseconds();
		var Passed = Now - this.DynStartTime;

		if(Passed > this.DynDeltaTime) {
			this.CVal = this.EVal;
			return true;
		}

		switch(this.ApproachFunct) {
			case 1:
				this.CVal = this.SVal + (Passed / this.DynDeltaTime) * this.DeltaVal;
				break;
			case 2:
				var Arg = ((Math.PI * Passed) / (2*this.DynDeltaTime));
				this.CVal = this.SVal + (1-Math.cos(Arg)) * this.DeltaVal;
				break;
			default:
				var Arg = ((Math.PI * Passed) / (2*this.DynDeltaTime));
				this.CVal = this.SVal + Math.sin(Arg) * this.DeltaVal;
				break;
		}

		return false;
	}

	this.TimerFunc = function() {

		myself.TimerHnd = 0;

		var EndReached = myself.UpdateVal();
		myself.Callback(myself, EndReached);

		if(EndReached)
			return;

		myself.TimerHnd = window.setTimeout(function(){myself.TimerFunc();}, myself.DynTimerInterval );
	}

	this.SVal = StartVal;
	this.EVal = EndVal;
	this.DeltaVal = EndVal - StartVal;
	this.ApproachFunct = 0;

var Dat = new Date();
	this.DynStartTime = Date.parse(Dat) + Dat.getMilliseconds();
	this.DynDeltaTime = Duration;
	this.DynEndTime = this.DynStartTime + this.DynDeltaTime ;
	this.DynTimerInterval = Interval;
	this.Callback=Callback;
	
	switch(typeof DomEle) {
		case "string":
			this.DomEle = document.getElementById(DomEle);
			break;
		case "object":
			this.DomEle = DomEle;
			break;
	}

var myself=this;

	this.TimerFunc();

	return 0;
}
var gGlobals = {
	UpdateStatusLine: function(text) {
		window.status = text;
	}
};
	
var gLocale = {

	Locale : "de",
	
	StaticTexts: {
		mtr_top1: "Magnatrax",
		mtr_top2: "Infos",
		mtr_top3: "Beispiele",
		mtr_top4: "Bestellen",
		mtr_top5: "Suchen",
		
		mtr_impressum: "Impressum"
	},
					
	SetupStaticTexts: function() {
		// setup static texts: 
		for (var Index in gLocale.StaticTexts) 
			document.getElementById(Index).innerHTML = gLocale.StaticTexts[Index];
	
		// setup special static texts:
		document.getElementById("mtr_version").innerHTML = gGlobals.Version;

		return false;
	},
	
	Translate: function(text) {
		return text;
	}
};

var gTopicNavigation = {

	loadTopicJS: function (codeFileName) {
	
		//create script filename
		var scriptID = 'mtr_topicJS_'+codeFileName;
		var head = document.getElementsByTagName("head")[0];
		
		// already loaded ?
		if(document.getElementById(scriptID ))
			head.removeChild(document.getElementById(scriptID ));
//			return;

		// append external script to doc-header
		var script = document.createElement('script');
		script.id = scriptID;
		script.type = 'text/javascript';
		script.src = 'locales/'+ gLocale.Locale+'/'+codeFileName+'.js';

		head.appendChild(script);
	},
	
	doTransition: function (newtext, readystate) {

		MTRAjaxParseResponse(newtext, document.getElementById("mtr_conta_body"));
		gTopicNavigation.loadTopicJS(gTopicNavigation.lastContent);

		// subtopic number in uri found ?
		if(!this.hashed) { // not already done?
			var temp = parseInt(window.location.hash.substring(1,window.location.hash.length));
			if(!isNaN(temp)) { // valid subtopic number
				gInfo_SubTopicNavigation.subtopic_click(temp );
				this.hashed = true; // don't do it again in this live
			}
		}
		
	},

	getContent: function(content) {
		
		this.lastContent = content;
		
		switch(typeof content) {
			case "string":

				var dummy = MTRAjax("\index.php?ajax=getcont&contid="+content , gTopicNavigation.doTransition,"");

				return 0;
				return  this.TopicMenuCurrentSelected.id;
				break;

			case "object":
				return  content.innerHTML;
				break;
		}
		
		return 0;
	},
	
	Select: function (what) {

		gLogin.beatHeart();

		// no change?
		if(this.TopicMenuLastSelected && (this.TopicMenuLastSelected.id == what.id))
			return false;

		if(!this.TopicMenuLastSelected) 
			this.TopicMenuLastSelected = document.getElementById("mtr_top2");
			
		this.TopicMenuLastSelected.className="mtr_topicbutt_std";

		this.TopicMenuLastSelected = what;
		this.TopicMenuLastSelected.className="mtr_topicbutt_hi";
		
		gInfo_SubTopicNavigation.reset();
		
		// transition from topic old -> new
		var temp = this.getContent(this.TopicMenuLastSelected.id);
		if(temp)
			document.getElementById("mtr_conta_body").innerHTML = temp;
		
		return false;
	}
	
};

var gInfo_SubTopicNavigation = {

	reset: function() {
		if(this.previousSubtopicmenu) 
			delete this.previousSubtopicmenu;
	},

	subtopic_click: function(subtopicID) {
	
		gLogin.beatHeart();
				
		if(!this.previousSubtopicmenu) 
			this.previousSubtopicmenu = document.getElementById("infos_menusubtopic01");
		
		if(subtopicID < 10)
			var what = document.getElementById("infos_menusubtopic0"+subtopicID);
		else
			var what = document.getElementById("infos_menusubtopic"+subtopicID);
		
		this.previousSubtopicmenu.className ="";
		
		what.className ="selected";
		
		var temp =document.getElementById("infos_subtopicsubtopic") ;
		this.subtopiccontainer = document.getElementById("infos_subtopiccontscroller");

		var newPos = -42 * (subtopicID-1);
		this.previousSubtopicmenu = what;

		temp = parseInt(this.subtopiccontainer.style.top);
		if(isNaN(temp))
			temp = 0;

		var AniSubtopInfos = mtr_Dnyamize(temp, newPos, function(mtr_Dyn, finished) {
			gInfo_SubTopicNavigation.subtopiccontainer.style.top = mtr_Dyn.CVal + "em";
			}, 400, 30, this.subtopiccontainer );

		return false;
	}
};

var gLogin = {

	sID:  0,
	
	usrClick: function(what) {

		if(what.value==" log-in") {
			what.value="";
		}
			
		this.usr = what.form.usr;
		this.psw = what.form.psw;
		
		what.className="";
		
		if(gLogin.usr.style.width !="6em")
			var Ani = mtr_Dnyamize(2, 6, function(mtr_Dyn, finished) {
				gLogin.usr.style.width = mtr_Dyn.CVal + "em";
				gLogin.psw.style.width = (8-mtr_Dyn.CVal) + "em";
				}, 500, 30, what);
				
	},
	
	pswClick: function(what) {

		if(what.value=="pass") {
			what.value="";
			what.type="password";
		}

		what.className="";

		this.usr = what.form.usr;
		this.psw = what.form.psw;

		if(this.psw.style.width !="4em") {

			var AniPwd = mtr_Dnyamize(2, 6, function(mtr_Dyn, finished) {
				gLogin.psw.style.width = mtr_Dyn.CVal + "em";
				gLogin.usr.style.width = (8-mtr_Dyn.CVal) + "em";
				}, 500, 30, what);
		}

	},

	doLogin: function (responseText, readystate ) {

		// clear wait msg
		mtr_ModalOverlay_Remove('mtr_OverlSCont');
			
		// called by ajax!
		gLogin.beatHeart();
		
		// don't update any HTML directly, use ajaxed JS instead
		MTRAjaxParseResponse(responseText);
	},
	
	formSubmit: function (what) {
	
		gLogin.loginForm = what;
		gLogin.userName = what.usr.value.trim();
		gLogin.userPWD = what.psw.value.trim();

		// display wait msg
		gGlobals.UpdateStatusLine(gLocale.Translate("....anmelden..."));
	
		mtr_ModalOverlay_ShowDialogBox('<br/>Die Benutzerdaten werden geprüft...',{boxType:'waitmsg'});
		
		var dummy = MTRAjax("\index.php?ajax=userlogin&usr="+encodeURIComponent(gLogin.userName.encode121()) +"&psw="+encodeURIComponent(gLogin.userPWD.encode121()), gLogin.doLogin);

		return false;
	},

	doLogout: function (responseText, readystate ) {

		this.sID = 0;
		window.location.reload();
				
	},
	
	logOut: function(what) {
		mtr_ModalOverlay_ShowDialogBox('<br/>Abmeldung läuft...',{boxType:'waitmsg'});
		var dummy = MTRAjax("\index.php?ajax=userlogout&usr="+encodeURIComponent(gLogin.userName), gLogin.doLogout);
		
		return false;
	},
	
	checkTimeout: function() {
		
		if(!this.lastHeartBeat)
			return;
			
		var now = new Date();
		if((now-this.lastHeartBeat) > 3600000)
			this.logOut(0);
		else
			this.beatHeart();
	},
	
	beatHeart: function() {
		this.lastHeartBeat = new Date();
	},
	
	isLoggedIn: function() {
		return(this.sID != 0);
	}
};

String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
   return this.replace(/^\s+/g,"");
}
String.prototype.rtrim = function() {
   return this.replace(/\s+$/g,"");
}
String.prototype.encode121 = function(){
	return this.replace(/[a-zA-Z]/g, function(c){
		return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
	});
}

var gmtr_GetBrowser = new mtr_GetBrowser();
var gCurrDDEle = null, gOldMouseX=0, gOldMouseY=0; // required by ShBox