// global variables:

var strSWVersion = 'Version 7.0 F6';	// current software version
var strRevisionDateG = '18.01.2012';	// revision date
var strRevisionDateE = '01-18-2012';	// MM-TT-YYYY: revision date
var strSWDateG = '18.01.2012';			// release date of current version	
var strSWDateE = '01-18-2012';			// MM-TT-YYYY: release date of current version	

var oClosureBegin = new Date(2011, 9, 31);		// office closure - attention: subtract 1 from month
var oClosureEnd = new Date(2011, 10, 9);


var strRootPath = '..';
var nScreenWidth = 1000;
var nColCount = 2;
var bForumLock = false;

function Header(lan, topic, heading, ForumMenu, strRootPathPar)
{
	var bReconstruct = false;		// set this to true to enable forwarding to reconstruction page

	if (bReconstruct)
	{
		if (InputRead('allowentry') == 'yes')
		{
			SessionWrite('allowentry', 'yes');
		}
		else
		{
			if (InputRead('allowentry') == 'no')
			{
				SessionWrite('allowentry', 'no');
			}

			location.href = 'http://www.freiwald.com/reconstruct/index.html';
			return;
		}
	}

	if ((typeof strRootPathPar) != 'undefined')
	{
		strRootPath = strRootPathPar;
	}

	var showmenushow = false;
	var showmenu = true; 

	if ((typeof ForumMenu) != 'undefined') 
	{
		showmenushow = navigator.cookieEnabled;
		showmenu = (CookieRead("MenuForum") != 'no');
	}

	nScreenWidth = 1000;

	if (!showmenu)
	{
		nColCount = 1;

		nScreenWidth = window.innerWidth;

		if ((typeof nScreenWidth) == 'undefined')
		{
			nScreenWidth = document.body.clientWidth;

			if ((typeof nScreenWidth) == 'undefined')
			{
				nScreenWidth = document.documentElement.clientWidth;

				if ((typeof nScreenWidth) == 'undefined')
				{
					nScreenWidth = document.documentElement.clientWidth;
				}		
			
				nScreenWidth = screen.width;
			}
		}

		nScreenWidth = Math.max(850, nScreenWidth - 50);
	}
	else
	{
		if (screen.width >= 1280)
		{
			nColCount = 3;
			nScreenWidth = 1150;
		}
	}

	heading = document.title;
	var doc = document;	

//	window.onload = OnLoad;

	if (window.addEventListener)
		window.addEventListener("load", OnLoad, false)
	else if (window.attachEvent)
		window.attachEvent("onload", OnLoad)
	else
		window.onload=OnLoad

	doc.write('<div id="aussencontainer" style="width: ' + (nScreenWidth - 5) + 'px;">');/*AHe*/
	
	doc.write('   <!--[if IE 6]>');/*AHe*/
	doc.write('      <style type="text/css">');/*AHe*/
	doc.write('      /* some css fixes for IE browsers */');/*AHe*/
/*
	doc.write('      html {overflow-y:hidden;}');		// AHe
*/
	doc.write('      body {overflow-y:auto;}');/*AHe*/
	doc.write('      #bg {position:absolute; z-index:-1;}');/*AHe*/
	doc.write('      #content {position:static;}');/*AHe*/
	doc.write('      </style>');/*AHe*/
	doc.write('   <![endif]-->');/*AHe*/

	doc.write('   <!--[if lt IE 8]>');
	doc.write('      <style type="text/css">');
	doc.write('      .table-button { overflow: hidden; }');
	doc.write('      </style>');
	doc.write('   <![endif]-->');

	PageHeader(lan);

	doc.write('<div class="page_content" style="width: ' + (nScreenWidth - 9) + 'px;">');

	LeftColumn(lan, topic, heading, ForumMenu); 
	RightColumn(lan, ForumMenu);
	CenterColumn(lan, heading, showmenu, showmenushow);
}


function SubmitSearchQuery(nLan) 
{
	window.location = strRootPath + '/' + ((nLan == 2) ? 'seiten' : 'pages') + '/search.htm?SEARCHTERM='
		+ escape(document.getElementById('SEARCHTERM').value);
	return false;
}



function OnFocusSearchQuery(nLan, oInput)
{
	if (oInput.value == ((nLan == 2) ? 'Suchen auf freiwald.com...' : 'Search freiwald.com...'))
	{
		oInput.value = '';
		oInput.style.color = '';
	}

	return false;
}


function Search(nLan)
{
	var doc = document;

	doc.write('<div class="search">');
		doc.write('<table cellspacing="0" cellpadding="0"><tr><td valign="bottom">');
			doc.write('<form name="SEARCH" accept-charset="ISO-8859-1" onSubmit="return SubmitSearchQuery(' + nLan + ')" action=".">');
			
			var strTerm = ParameterRead('SEARCHTERM');
			var strStyle = '';
			
			if (strTerm == '')
			{
				strTerm = (nLan == 2) ? 'Suchen auf freiwald.com...' : 'Search freiwald.com...';				
				strStyle = 'style="color: #79663c;"';
			}
			
			doc.write('<input type="text" size="24" id="SEARCHTERM" name="SEARCHTERM" onFocus="OnFocusSearchQuery(' + nLan + ', this)" value="' + strTerm + '" ' + strStyle + '>'); 
			doc.write('</form>');
		doc.write('</td>');
		doc.write('<td valign="bottom">');
			doc.write('<img src="' + strRootPath + '/images/search.gif" onClick="SubmitSearchQuery(' + nLan + ')">');
		doc.write('</td></tr></table>');
	doc.write('</div>');
}



function Language(lan)
{
	var doc = document;

	var strCurrentLocation = document.URL;
	var url = strCurrentLocation.toString().substr(0, 5);

	var strLinkEnglish;
	var strLinkGerman;

	if (strCurrentLocation.indexOf('/forum/') >= 0)
	{
		strLinkEnglish = strCurrentLocation + ((strCurrentLocation.indexOf('?') >= 0) ? '&' : '?') + 'nlang=en';
		strLinkGerman = strCurrentLocation + ((strCurrentLocation.indexOf('?') >= 0) ? '&' : '?') + 'nlang=de';
	}
	else
	{	
		strLinkEnglish = (url == "https") ? 'https://secure.freiwald.com/pages/' : '../pages/';
		strLinkGerman = (url == "https") ? 'https://secure.freiwald.com/seiten/' : '../seiten/';
	}

	if (strCurrentLocation.indexOf('/forum/') < 0)
	{
		var strName = window.location.href
		var nIndex = strName.lastIndexOf('/');

		if (nIndex >= 0)
		{
			strName = strName.substr(nIndex + 1);
		}
		else
		{
			strName = "index.html";
		}
	
		strLinkEnglish += strName;
		strLinkGerman += strName;
	}
	
	doc.write('<div class="language">');
		doc.write('<table cellspacing="0" cellpadding="0"><tr><td class="language-german">');
			doc.write(((lan == 2) ? '<b>' : '') + '<a href="' + strLinkGerman + '">' + ((lan == 2) ? 'Deutsch' : 'German') + '</a>' + ((lan == 2) ? '</b>' : ''));
		doc.write('</td>');
		doc.write('<td class="language-english">');
			doc.write(((lan != 2) ? '<b>' : '') + '<a href="' + strLinkEnglish + '">' + ((lan == 2) ? 'Englisch' : 'English') + '</a>' + ((lan != 2) ? '</b>' : ''));
		doc.write('</td></tr></table>');
	doc.write('</div>');
}


function PageHeader(lan)
{
	var doc = document;	

	doc.write('<div class="menu-header-l" style="width: ' + (nScreenWidth - 1) + 'px;"><div class="menu-header-r"><div class="menu-header-c">'); 

		doc.write('<div class="menu_header">'); 

		doc.write('<table width="100%" height="100%" cellspacing="0" cellpadding="0" ><tr>');
			doc.write('<td width="100%" valign="bottom">');
				doc.write('<img src="' + strRootPath + '/' + ((lan == 2) ? 'bilder' : 'images') + '/header.gif">');
			doc.write('</td>');

			doc.write('<td valign="bottom">');
				Search(lan);
			doc.write('</td>');

			doc.write('<td valign="bottom">');
				Language(lan);
			doc.write('</td>');
		doc.write('</tr></table>');

		doc.write('</div>');

	doc.write('</div></div></div>');

	doc.write('<div class="menu-right-l" style="width: ' + (nScreenWidth - 13) + 'px;"><div class="menu-right-r"><div class="menu-right-c">'); 

		doc.write('<div class="menu_right"><div class="menu_right_text">');/*AHe*/
		MenuRight(lan);
		doc.write('</div></div>');

	doc.write('</div></div></div>');
}




function MenuRight(lan)
{
	var doc = document;	

	var url = document.URL.toString().substr(0, 5);
	var prefix = '';

	if (lan == 2)
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/seiten/' : '../seiten/';
	}
	else if (lan == 0)
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/pages/' : 'pages/';
	}	
	else
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/pages/' : '../pages/';
	}
	
	strOutput="<ul>";
	MenuRightEntry((lan <= 1)? "Home"							: "Hauptseite",						prefix + "index.html"); 
	MenuRightEntry((lan <= 1)? "Getting Started"				: "Erste Schritte",					prefix + "start.htm"); 
	MenuRightEntry((lan <= 1)? "Products"						: "Produkte",						prefix + "overview.htm"); 

	if (!bForumLock)
	{
		if (lan == 2)
		{
			MenuRightEntry("Forum",	prefix + "../forum?nlang=de"); 
		}
		else
		{
			MenuRightEntry("Forum",	prefix + "../forum?nlang=en"); 
		}
	}

	MenuRightEntry((lan <= 1)? "Download"						: "Download",						prefix + "download.htm"); 
	MenuRightEntry((lan <= 1)? "Shop"							: "Shop",							prefix + "register.htm"); 
	MenuRightEntry((lan <= 1)? "Terms & Conditions"				: "AGB",							prefix + "agb.htm"); 

	MenuRightEntry((lan <= 1)? "Contact"						: "Impressum",						prefix + "contact.htm"); 

	doc.write('</ul>');
}


function LeftColumn(lan, topic, heading, ForumMenu)
{
	if (nColCount <= 1)
	{
		return;
	}

	var doc = document;	

	doc.write('<div class="left_column">');/*AHe*/

	doc.write('<div class="left_menu">');
		LeftMenu(lan, ForumMenu); 
	doc.write('</div> <!-- class="left_menu"-->');

	if (nColCount <= 2)
	{
		Splash(lan, topic);
		ShowHits(lan);
	}

	doc.write('</div> <!-- class="left_column"-->');/*AHe*/
}


function RightColumn(lan, ForumMenu)
{
	if (nColCount <= 2)
	{
		return;
	}

	var doc = document;	

	doc.write('<div class="right_column">');/*AHe*/

	doc.write('<div class="right_menu">');
		RightMenu(lan, ForumMenu); 
	doc.write('</div> <!-- class="right_menu"-->');

	Splash(lan);
	ShowHits(lan);

	doc.write('</div> <!-- class="right_column"-->');/*AHe*/
}



function LeftMenu(lan, strForumMenu)
{
	if (nColCount <= 2)
	{
		BreakingNews(lan, true);
	}

	var doc = document;	

	var url = document.URL.toString().substr(0, 5);
	var prefix = '';

	if (lan == 2)
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/seiten/' : '../seiten/';
	}
	else if (lan == 0)
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/pages/' : 'pages/';
	}
	else
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/pages/' : '../pages/';
	}

/*
	if (((typeof ForumMenu) != 'undefined') && (nColCount <= 2))
	{
		MenuOben((lan == 1)? 'Forum' : 'Forum', 'menu_forum');
		doc.write(ForumMenu);
		MenuUnten('menu_forum');
	}
*/

	if (nColCount <= 2)
	{
		ForumMenu(lan);
	}

	MenuOben((lan <= 1)? 'Products' : 'Produkte','menu_products');/*AHe*/
	MenuEntry((lan <= 1)? "TrainController&#8482;"				: "TrainController&#8482;",				prefix + "traincontroller.htm"); 
	MenuEntry((lan <= 1)? "TrainProgrammer&#8482;"				: "TrainProgrammer&#8482;",				prefix + "trainprogrammer.htm"); 
	MenuEntry((lan <= 1)? "Handheld Control +SmartHand&#8482;"	: "Handsteuerung +SmartHand&#8482;",	prefix + "handheld.htm"); 
	MenuEntry((lan <= 1)? "Auto Control +Street&#8482;"			: "Autosteuerung +Street&#8482;",		prefix + "street.htm"); 
	MenuEntry((lan <= 1)? "Sound +4DSound&#8482;"				: "Sound +4DSound&#8482;",				prefix + "sound.htm"); 
	MenuEntry((lan <= 1)? "Network +Net&#8482;"					: "Netzwerk +Net&#8482;",				prefix + "network.htm"); 
//	MenuEntry((lan <= 1)? "Rocomotion&#8482;"					: "Rocomotion&#8482;",					prefix + "rocomotion.htm"); 
	MenuUnten('menu_products');/*AHe*/

	MenuOben((lan <= 1)? 'News' : 'Aktuelles','menu_news');/*AHe*/
	if (lan <= 1)
	{
		MenuEntry("Latest Announcements", prefix + "../forum/viewforum.php?f=10&language=english"); 
	}
	else
	{
		MenuEntry("Neueste Ank&uuml;ndigungen", prefix + "../forum/viewforum.php?f=11&language=german"); 
	}

	MenuEntry((lan <= 1)? "Version History"					: "Versionshistorie",				prefix + "history.htm"); 
	MenuUnten('menu_news');/*AHe*/


	MenuOben((lan <= 1)? 'Online Shop' : 'Online-Shop','menu_shop');/*AHe*/
	MenuEntry((lan <= 1)? "Ordering & Pricing"				: "Bestellung & Preise",			prefix + "register.htm"); 
	MenuEntry((lan <= 1)? "Upgrade License"					: "Upgrade-Lizenz",					prefix + "upgrade.htm"); 
	if (lan <= 1)
	{
		MenuEntry("Your Shopping Cart", "https://secure.freiwald.com/pages/cart.htm"); 
	}
	else
	{
		MenuEntry("Ihr Warenkorb", "https://secure.freiwald.com/seiten/cart.htm"); 
	}
	MenuUnten('menu_shop');/*AHe*/


	MenuOben((lan <= 1)? 'Links' : 'Verweise','menu_links');/*AHe*/
	MenuEntry((lan <= 1)? "About us"						: "&Uuml;ber uns",					prefix + "vision.htm"); 
	MenuEntry((lan <= 1)? "References"						: "Referenzen",						prefix + "references.htm"); 
	MenuEntry((lan <= 1)? "Digital Systems"					: "Digitalsysteme",					prefix + "hardware.htm"); 
	MenuEntry((lan <= 1)? "Advice & Help"					: "Rat & Tat",					prefix + "references.htm#Rat_und_Tat"); 
	MenuEntry((lan <= 1)? "Training Courses"				: "Seminare",					prefix + "references.htm#Seminare"); 
	MenuEntry((lan <= 1)? "Exhibition Layouts"				: "Ausstellungsanlagen",		prefix + "references.htm#Ausstellungsanlagen"); 
	MenuEntry((lan <= 1)? "Press"							: "Presse",						prefix + "references.htm#Presse"); 

	MenuEntry((lan <= 1)? "Dealers"							: "H&auml;ndler",						prefix + "dealerlist.htm"); 
	MenuUnten('menu_links');/*AHe*/
}





function RightMenu(lan, strForumMenu)
{
	BreakingNews(lan, true);

	var doc = document;	

	var url = document.URL.toString().substr(0, 5);
	var prefix = '';

	if (lan == 2)
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/seiten/' : '../seiten/';
	}
	else if (lan == 0)
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/pages/' : 'pages/';
	}
	else
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/pages/' : '../pages/';
	}

/*
	if ((typeof ForumMenu) != 'undefined')
	{
		MenuOben((lan == 1)? 'Forum' : 'Forum', 'menu_forum');
		doc.write(ForumMenu);
		MenuUnten('menu_forum');
	}
*/

	ForumMenu(lan);
}



function ForumMenu(lan)
{
	if (bForumLock)
	{
		var doc = document;

		doc.write('<font color="red">');

		if (lan==2)
		{
			doc.write('Momentan ist das Forum nicht erreichbar.');
		}	
		else
		{
			doc.write('The forum is currently not accessible.');
		}

		doc.write('</font>');

		return;
	}

	document.write('<iframe name="iframe" id="iframe" src="' + strRootPath + '/forum/forummenu.php" scrolling="no" width="100%" style="height: 12.5em;" frameborder="0" allowtransparency="true" onload=""></iframe>'); 
}



function MenuSwitch(nLan)
{
	if (navigator.cookieEnabled)
	{
		var bShowMenu = (CookieRead("MenuForum") != 'no');

		document.write('|&nbsp;');
		
		if (bShowMenu)
		{
			document.write('<a href="' + document.URL.toString() + '" onclick="MenuHide()">' + ((nLanguage != 2) ? 'Hide Menu' : 'Men&uuml; verbergen') + '</a>');
		}
		else
		{	
			document.write('<a href="' + document.URL.toString() + '" onclick="MenuShow()">' + ((nLanguage != 2) ? 'Show Menu' : 'Men&uuml; anzeigen') + '</a>');
		}
	}
}


function MenuHide()
{
	CookieWrite("MenuForum", "no", 3*24*60*60*1000);
	location.reload();
}

function MenuShow()
{
	CookieWrite("MenuForum", "yes", 3*24*60*60*1000);
	location.reload();
}

function MenuTitle(Title)
{
	var doc = document;	

	doc.write('<div class="menu_title">');
	VerticalText(Title);
	doc.write('</div> <!-- class="menu_title"-->');

}
function MenuTitleTop()
{
	var doc = document;	

	doc.write('<div class="box-h-l">');/*AHe*/
	doc.write('<div class="box-h-r">');/*AHe*/
	doc.write('<div class="box-h-c">');/*AHe*/
}
function MenuTitleFoot()
{
	var doc = document;	

	doc.write('</div> <!-- class="box-h-c"-->');/*AHe*/
	doc.write('</div> <!-- class="box-h-r"-->');/*AHe*/
	doc.write('</div> <!-- class="box-h-l"-->');/*AHe*/
}
function MenuFooter()
{
	var doc = document;	

	doc.write('<div class="box-f-l">');/*AHe*/
	doc.write('<div class="box-f-r">');/*AHe*/
	doc.write('<div class="box-f-c">');/*AHe*/
	doc.write('</div> <!-- class="box-f-c"-->');/*AHe*/
	doc.write('</div> <!-- class="box-f-r"-->');/*AHe*/
	doc.write('</div> <!-- class="box-f-l"-->');/*AHe*/
}

function MenuOben(Title,Menu_Typ) /*AHe neue Funktion, die oberen Teil eines Menu-Blockes abdeckt */
{
	var doc = document;	

	MenuTitleTop();
	MenuTitle(Title);
	MenuTitleFoot();
	doc.write('<div class="' + Menu_Typ + '">');
	doc.write('<div class="menu_box">');
}
function MenuUnten(Menu_Typ) /*AHe neue Funktion, die unteren Teil eines Menu-Blockes abdeckt */
{
	var doc = document;	

	doc.write('</div <!-- class="menu_box"-->');
	doc.write('</div <!-- class="' + Menu_Typ + '"-->');
	MenuFooter();
}

function MenuEntry(Text, Url)
{
	var doc = document;	

	doc.write('<li>');
	doc.write('<a href="' + Url + '">' + Text + '</a>');
	doc.write('</li>');
}


function MenuTitleRight() /* momentan identisch mit MenuTitleTop */
{
	var doc = document;	

	doc.write('<div class="box-h-l">');/*AHe*/
	doc.write('<div class="box-h-r">');/*AHe*/
	doc.write('<div class="box-h-c">');/*AHe*/
}

function MenuRightEntry(Text, Url)
{
	var doc = document;	
	VerticalText('<li><a href="' + Url + '">' + Text + '</a></li>', 'float:left;');/*AHe*/
}

function NaviEntry(Text, Url, bBullet)/*AHe*/
{
	if ((typeof Url) != 'undefined')
	{
		document.write('<li><a href="' + Url + '">' + Text + '</a></li>');
	}
	else
	{
		document.write('<li>' + Text + '</li>');
	}

	if ((typeof bBullet) == 'undefined')
	{
		bBullet = true;
	}

	if (bBullet)
	{
		document.write('<li>&bull;</li>');
	}
}


function BreakingNews(lan, bLeftMenu)
{
	var doc = document;	
	var strCode = GetVerticalTextCode((lan == 2) ? 'Letzte Neuigkeiten' : 'Breaking News');

	if (bLeftMenu)
	{
//		return;

		MenuOben(strCode, 'left_header');
		doc.write('<div class="left_content" onmouseover="TickerPause(true);" onmouseout="TickerPause(false);">');

		var i;

		for (i = 0; i < 2; i++)
		{
			if (i == 0)
			{
				doc.write('<div id="ticker" name="ticker" style="overflow:hidden;">');
			}
			else		
			{
				doc.write('<div style="overflow:hidden;">');
				doc.write('<hr>');
			}

			var oNow = new Date();
			
			if (oNow.getTime() <= (oClosureEnd.getTime() + 1000 * 60 * 60 * 24 * 1))	
			{
				doc.write('<font color="red"><b>');

				if (lan==2)
				{
					doc.write(oClosureBegin.getDate() + '.' + (oClosureBegin.getMonth() + 1) + '. bis ' + oClosureEnd.getDate() + '.' + (oClosureEnd.getMonth() + 1) + '.' + oClosureEnd.getYear() + ':<br>Unser B&uuml;ro ist geschlossen.<br>Alle in diesem Zeitraum eingehenden Bestellungen werden danach so schnell wie m&ouml;glich bearbeitet.<br>Vielen Dank f&uuml;r Ihr Verst&auml;ndnis.');
					doc.write('<hr>');
				}	
				else
				{
					doc.write((oClosureBegin.getMonth() + 1) + '-' + oClosureBegin.getDate() + ' to ' + (oClosureEnd.getMonth() + 1) + '-' + oClosureEnd.getDate() + '-' + oClosureEnd.getYear() + ':<br>Our office is closed.<br>All orders received during this period will be processed as soon as possible thereafter.<br>Thank you very much for your understanding.');
					doc.write('<hr>');
				}

				doc.write('</b></font>');
			}

			doc.write('<font color="#303030">');

			if (lan==2)
			{
//				doc.write('18.11. bis 21.11.2010:<br>Besuchen Sie uns auf der Modellbahn K&ouml;ln.<br><a href="http://www.freiwald.com/forum/viewtopic.php?f=11&t=13831">Mehr ></a>');
//				doc.write('<hr>');
				doc.write(strSWDateG + ':<br>Aktuelle Software:<br>' + strSWVersion + ' <a href="' + strRootPath + '/seiten/download.htm">Download ></a>');
				doc.write('<hr>');
				doc.write('18.11.2011:<br>Autosteuerung +Street<span class="TM">&#8482;</span> freigegeben.');
				doc.write('<hr>');
				doc.write('12.04.2011:<br>Wir begr&uuml;&szlig;en das 10000. Mitglied in unserem Forum !');
				doc.write('<hr>');
				doc.write('18.03.2011:<br>TrainController<span class="TM">&#8482;</span> und TrainProgrammer<span class="TM">&#8482;</span> bieten jetzt volle Unterst&uuml;tzung der M&auml;rklin CS2 !');
			}	
			else
			{
//				doc.write('11-18 to 11-21-2010:<br>Visit us at the train show in Koeln.<br><a href="http://www.freiwald.com/forum/viewtopic.php?f=10&t=13830">More ></a>');
//				doc.write('<hr>');
				doc.write(strSWDateE + ':<br>Current Software:<br>' + strSWVersion + ' <a href="' + strRootPath + '/pages/download.htm">Download ></a>');
				doc.write('<hr>');
				doc.write('11-18-2011:<br>Auto Control +Street<span class="TM">&#8482;</span> released.');
				doc.write('<hr>');
				doc.write('04-12-2011:<br>We welcome member no. 10000 in our forum !');
				doc.write('<hr>');
				doc.write('03-18-2011:<br>TrainController<span class="TM">&#8482;</span> and TrainProgrammer<span class="TM">&#8482;</span> now with official support of Maerklin CS2 !');
			}

			doc.write('</font>');

			if (i == 0)
			{
			}
			else		
			{
				doc.write('<hr>');
			}

			doc.write('</div>');		// ticker;
		}

		doc.write('</div> <!-- class="left_content"-->');
		MenuUnten('left_header');
	}
	else
	{
		return;

		MenuTitleRight()
		doc.write('<div class = "center_header">');
		var strCode = GetVerticalTextCode((lan == 2) ? 'Frohe Weihnachten' : 'Merry Christmas');
		CenterText(strCode);
		doc.write('</div> <!-- class=center_header-->');
		MenuTitleFoot()
		doc.write('<div class="right_content">');

		doc.write('<table width="100%"><tr>');

/*
		doc.write('<td width="100%" align="center">');

			doc.write('<font color="red" style="font-family:\'Arial\'; font-size:11pt;"><b>');

			if (lan==2)
			{
				doc.write('Neues Update 7.0 F2 (inklusive Unterst&uuml;tzung f&uuml;r M&auml;rklin Central Station 2) freigegeben!<br><br></font><font color="black" style="font-size:10pt;"><a href="http://www.freiwald.com/forum/viewtopic.php?f=11&t=14872">Weiterlesen...</a>');
			}	
			else
			{
				doc.write('New Update 7.0 F2 (inclusive support for Maerklin Central Station 2) released!<br><br></font><font color="black" style="font-size:10pt;"><a href="http://www.freiwald.com/forum/viewtopic.php?f=10&t=14871">Read more...</a>');
			}

			doc.write('<br>');
			doc.write('</font>');

		doc.write('</td>');
*/

		doc.write('<td valign="center">');
		doc.write('<img align="center" title="" alt="Christmas" src="../images/christmas/christmas_l.jpg" style="height: 2cm;">');
		doc.write('</td>');

		doc.write('<td width="100%" align="center">');

			doc.write('<font color="red" style="font-family:\'Arial\'; font-size:11pt;"><b>');

			if (lan==2)
			{
				doc.write('<br>Wir w&uuml;nschen allen Anwendern, Freunden und Gesch&auml;ftspartnern mit Ihren Familien<br>ein fr&ouml;hliches Weihnachtsfest<br>und einen guten Start in ein gesundes und erfolgreiches Neues Jahr !');
			}	
			else
			{
				doc.write('<br>We wish all users, friends and partners<br>Merry Christmas<br>and a Happy New Year !');
			}

			doc.write('<br><br>');
			doc.write('</font>');

		doc.write('</td>');

		doc.write('<td valign="center">');
		doc.write('<img align="center" title="" alt="Christmas" src="../images/christmas/christmas_r.jpg" style="height: 2cm;">');
		doc.write('</td>');

		doc.write('</tr></table>');

		doc.write('</div> <!-- class="right_content"-->');
		MenuFooter();/*AHe*/
	}
}



function CenterColumn(lan, heading, showmenu, showmenushow)
{
	var doc = document;	
	var url = document.URL.toString().substr(0, 5);
	var link = '';
	var image = '';

	strStyle = '';

	if (nColCount <= 1)
	{
		strStyle += ' margin-left: 0em;'; 
	}

	if (nColCount <= 2)
	{
		strStyle += ' margin-right: 0em;'; 
	}

	doc.write('<div class="center_column"' + ((strStyle != '') ? ' style="' + strStyle + '"' : '') + '>');

	BreakingNews(lan, false);
	MenuTitleRight()

	if ((typeof heading) != 'undefined')
	{
			doc.write('<div class="center_header" >');
			CenterText(GetVerticalTextCode(heading, 'float: left; '));
			doc.write('</div> <!-- class=center_header-->');

			if (showmenushow)
			{
				if (showmenu)
				{
					doc.write('<a href="' + document.URL.toString() + '" onclick="MenuHide()">' + ((lan <= 1) ? 'Hide Menu' : 'Men&uuml; verbergen') + '</a>');
				}
				else
				{	
					doc.write('<a href="' + document.URL.toString() + '" onclick="MenuShow()">' + ((lan <= 1) ? 'Show Menu' : 'Men&uuml; anzeigen') + '</a>');
				}
			}
	}
	MenuTitleFoot()

	doc.write('<div class="page_right">');
	doc.write('<div class="right_content">');
	
}



function RightFooter(lan)
{
	var doc = document;	

	var strCurrentLocation = document.URL;
	var url = strCurrentLocation.toString().substr(0, 5);

	doc.write('<div class="right_footer">');

	doc.write('<div id="navi-footer-l" style="width: ' + (nScreenWidth - 19) + 'px;"><div id="navi-footer-r"><div id="navi-footer-c"><div id="navi-footer-text">');/*AHe*/

	// insert all text base links:

	var prefix = '';

	if (lan == 2)
	{
		prefix = (url == "https") ? 'http://www.freiwald.com/seiten/' : '../seiten/';
	}
	else
	{

		prefix = (url == "https") ? 'http://www.freiwald.com/pages/' : '../pages/';
	}

	VerticalTop('float:right;');
	doc.write('<div><ul>');
	
	NaviEntry((lan != 2)? "Contact"						: "Impressum",						prefix + "contact.htm"); 
	NaviEntry((lan != 2)? "Privacy Statement"			: "Datenschutzerkl&auml;rung",						prefix + "privacy.htm"); 
	NaviEntry('Copyright &copy; 2011 Freiwald Software');

	if (lan != 2)
	{
		NaviEntry('Revised: ' + strRevisionDateE);				// MM-DD-YYYY
		NaviEntry('Terms & Conditions', prefix + 'agb.htm', false); 
	}		
	else
	{
		NaviEntry('Stand: ' + strRevisionDateG);
		NaviEntry('AGB', prefix + 'agb.htm', false); 
	}

	doc.write('&nbsp;&nbsp;');

	doc.write('</ul></div>');
	VerticalBottom();

	doc.write('</div></div></div></div> <!-- class="right_footer"-->');
}



function Footer(lan)
{
	TickerStart();

	var doc = document;	

	doc.write('</div> <!-- class="right_content"-->');
	MenuFooter();/*AHe*/
	doc.write('</div>	<!-- class="page_right" -->');

	doc.write('<br clear="all" />');

	doc.write('</div> <!-- class="page_content"-->');

		RightFooter(lan);

	doc.write('</div>	<!-- id="aussencontainer" -->');
}

/****************************************************************************************************/
/*																									*/
/* The splash boxes																					*/
/*																									*/
/****************************************************************************************************/


function SplashContent(nLan, strImage, upper, lower)
{
	var doc = document;	

	doc.write('<div class="splash_upper">');
		VerticalText('<center>' + upper + '</center>', 'width: 100%;');
	doc.write('</div>');

	doc.write('<div class="splash_center">');

		var nSep = strImage.indexOf('/');
//		Photo(nLan, strImage.substr(0, nSep), strImage.substr(nSep), PHOTOBLOCK | PHOTONOBORDER | PHOTONOSHADOW, ' ')
		Image(nLan, strRootPath + '/images/layout/' + strImage + '.jpg', '', PHOTOBLOCK | PHOTONOBORDER | PHOTONOSHADOW);
//		doc.write('<img src="' + '../images/layout/' + strImage + '.jpg' + '">');

//		doc.write('<div style="width: 160px; height: 90px;"></div>');

	doc.write('</div>');

	doc.write('<div class="splash_lower">');
		VerticalText('<center>' + lower + '</center>', 'width: 100%;');
	doc.write('</div>');
}


function Splash(nLan, topic)
{
	var doc = document;	

	var astrImage = new Array();

	var nImage = 0;

	astrImage[nImage++] = 'berlin/101'; 
	astrImage[nImage++] = 'berlin/102'; 
	astrImage[nImage++] = 'berlin/103'; 
	astrImage[nImage++] = 'dietenhofen/101'; 
	astrImage[nImage++] = 'driburg/101'; 
	astrImage[nImage++] = 'eversum/101'; 
	astrImage[nImage++] = 'eversum/102'; 
	astrImage[nImage++] = 'koenigstein/101'; 
	astrImage[nImage++] = 'koenigstein/102'; 
	astrImage[nImage++] = 'oberhausen/101'; 
	astrImage[nImage++] = 'oberhausen/102'; 
	astrImage[nImage++] = 'oberhausen/103'; 
	astrImage[nImage++] = 'oberhausen/104'; 
	astrImage[nImage++] = 'oberhausen/105'; 
	astrImage[nImage++] = 'oberhausen/106'; 
	astrImage[nImage++] = 'oberhausen/107'; 
	astrImage[nImage++] = 'selbitz/101'; 
	astrImage[nImage++] = 'selbitz/102'; 
	astrImage[nImage++] = 'selbitz/103'; 
	astrImage[nImage++] = 'selbitz/104'; 
	astrImage[nImage++] = 'veit/101'; 
	astrImage[nImage++] = 'veit/102'; 
	astrImage[nImage++] = 'veit/103'; 

	var now = new Date();
	var nImage = (now.getSeconds()) % astrImage.length;
	strImage = astrImage[nImage];

	var astrTitle = new Array();
	var astrText = new Array();

	var nIndex = 0;
	
	if (nLan==1)
	{	
		var i;

		for (i = 0; i < 3; i++)
		{
			astrTitle[nIndex] = 'TrainController<span class="TM">&#8482;</span>';
			astrText[nIndex++] = 'The leading software for Model Railroad Computer Control!';
		}

		for (i = 0; i < 2; i++)
		{
			astrTitle[nIndex] = 'TrainProgrammer<span class="TM">&#8482;</span>';
			astrText[nIndex++] = 'For all DCC-, Selectrix- and LocoNet compatible Decoder and Devices!';
		}

		astrTitle[nIndex] = 'TrainController<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Award Winning!';

		astrTitle[nIndex] = 'Railroad & Co.&#8482;<BR>Forum';
		astrText[nIndex++] = 'More than<BR>10000<BR>Members!';

		astrTitle[nIndex] = '+SmartHand<br>Mobile<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Control your layout with your cell phone!';

		astrTitle[nIndex] = '+SmartHand<br>Mobile<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Control your layout with a second PC!';

		astrTitle[nIndex] = '+SmartHand<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'The smart handheld railroad control system!';

		astrTitle[nIndex] = '+Net<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Control your layout in a network with several computers!';

		astrTitle[nIndex] = '+Street<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Realistic control of street traffic!';

		astrTitle[nIndex] = '+4DSound<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Realistic multi train/<BR>multi channel surround sound for your trains!';

		astrTitle[nIndex] = 'Railroad & Co.&#8482;';
		astrText[nIndex++] = 'New:<BR>Version 7!';

		astrTitle[nIndex] = 'Railroad & Co.&#8482;';
		astrText[nIndex++] = 'Order all programs conveniently on the Internet!';
	}
	else
	{
		var i;

		for (i = 0; i < 3; i++)
		{
			astrTitle[nIndex] = 'TrainController<span class="TM">&#8482;</span>';
			astrText[nIndex++] = 'Das f&uuml;hrende Programm zur Steuerung von Modellbahnen!';
		}

		for (i = 0; i < 2; i++)
		{
			astrTitle[nIndex] = 'TrainProgrammer<span class="TM">&#8482;</span>';
			astrText[nIndex++] = 'F&uuml;r alle DCC-, Selectrix- und LocoNet- kompatiblen Decoder und Ger&auml;te!';
		}

		astrTitle[nIndex] = 'TrainController<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Als Testsieger ausgezeichnet!';

		astrTitle[nIndex] = 'Railroad & Co.&#8482;<BR>Forum';
		astrText[nIndex++] = 'Mehr als 10000 Mitglieder!';

		astrTitle[nIndex] = '+SmartHand<br>Mobile<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Steuern Sie Ihre Anlage mit Ihrem Handy!';

		astrTitle[nIndex] = '+SmartHand<br>Mobile<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Steuern Sie Ihre Anlage mit einem zweiten PC!';

		astrTitle[nIndex] = '+SmartHand<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Das intelligente Handreglersystem f&uuml;r Ihre Anlage!';

		astrTitle[nIndex] = '+Net<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Steuern Sie Ihre Anlage im Netzwerk mit mehreren Computern!';

		astrTitle[nIndex] = '+Street<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Abwechslungsreicher Stra&szlig;enverkehr!';

		astrTitle[nIndex] = '+Street<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Volle Unterst&uuml;tzung von Abstandssteuerungen!';

		astrTitle[nIndex] = '+4DSound<span class="TM">&#8482;</span>';
		astrText[nIndex++] = 'Realistischer Mehrzug-/<BR>Mehrkanal-Sound<BR>f&uuml;r jede Modellbahn!';

		astrTitle[nIndex] = 'Railroad & Co.&#8482;';
		astrText[nIndex++] = 'Jetzt aktuell:<BR>Version 7!';

		astrTitle[nIndex] = 'Railroad & Co.&#8482;';
		astrText[nIndex++] = 'Alle Produkte<br>bequem &uuml;ber<br>Internet bestellen!';
	}

//	if(topic==0)
	{
		topic = (Math.round(Math.random() * 100));	
	}

	topic = topic % astrText.length;

	doc.write('<div class="menu_splash">');
	
	MenuDarkHeader() /*AHe 100806 */
	SplashContent(nLan, strImage, astrTitle[topic], astrText[topic]);

	doc.write('</div> <!-- class="menu_splash"-->');

	MenuDarkFooter() /*AHe 100806 */
}


function MenuDarkHeader() /*AHe 100806 */
{
	var doc = document;	

	doc.write('<div class="fr_dark_h_l">');
	doc.write('<div class="fr_dark_h_r">');
	doc.write('<div class="fr_dark_h_c">');
	doc.write('</div> <!-- class="fr_dark_h_c"-->');
	doc.write('</div> <!-- class="fr_dark_h_r"-->');
	doc.write('</div> <!-- class="fr_dark_h_l"-->');
}

function MenuDarkFooter() /*AHe 100806 */
{
	var doc = document;	

	doc.write('<div class="fr_dark_f_l">');
	doc.write('<div class="fr_dark_f_r">');
	doc.write('<div class="fr_dark_f_c">');
	doc.write('</div> <!-- class="fr_dark_f_c"-->');
	doc.write('</div> <!-- class="fr_dark_f_r"-->');
	doc.write('</div> <!-- class="fr_dark_f_l"-->');
}




/****************************************************************************************************/
/*																									*/
/* hit counter																						*/
/*																									*/
/****************************************************************************************************/



function ShowHits(nLan)
{
	return;		// disabled for the time being

	if (!navigator.cookieEnabled)
	{
		return;
	}

	var url = document.URL.toString().substr(0, 5);
	
	if (url == "https")
	{
		return;
	}	

	var doc = document;

	if (!IsMyself() && (CookieRead("ShowClusterMap") != 'no'))
	{
		doc.write('<a href="http://www2.clustrmaps.com/counter/maps.php?url=http://www.freiwald.com" id="clustrMapsLink"><img src="http://www2.clustrmaps.com/counter/index2.php?url=http://www.freiwald.com" style="border:0px solid; width: 1px;" alt="Locations of visitors to this page" title="Locations of visitors to this page" id="clustrMapsImg" onError="this.onError=null; this.src=\'http://clustrmaps.com/images/clustrmaps-back-soon.jpg\'; document.getElementById(\'clustrMapsLink\').href=\'http://clustrmaps.com\'" /></a>');
	}

//	if (IsMyself())
	{
		doc.write('<div class="box_hits"><center>');
//		doc.write((nLan == 2) ? 'Woher kommen unsere Besucher?' : 'Where our visitors come from:');

		doc.write('<a href="http://www2.clustrmaps.com/counter/../stats/maps-clusters/www.freiwald.com-world.jpg" id="clustrMapsLink" target="_blank"><img src="http://www2.clustrmaps.com/stats/maps-clusters/www.freiwald.com-thumb.jpg" style="border:0px solid; width: 159px;" alt="Locations of visitors to this page" title="Locations of visitors to this page" id="clustrMapsImg" onError="this.onError=null; this.src=\'http://clustrmaps.com/images/clustrmaps-back-soon.jpg\'; document.getElementById(\'clustrMapsLink\').href=\'http://clustrmaps.com\'" /></a><br>');

		doc.write('<small>');
//		doc.write((nLan == 2) ? 'Zum Vergr&ouml;ssern<br>Landkarte anklicken.' : 'Click to map for larger image.');
		doc.write('</small>');
		doc.write('</center></div> <!-- class="box_hits"-->');
	}	

	CookieWrite("ShowClusterMap", "no", 30*60*1000);
}


/****************************************************************************************************/
/*																									*/
/* Cookie helper functions																			*/
/*																									*/
/****************************************************************************************************/


function CookieWrite(name, value, expires)
{
	var cook = name + '=' + value + ';path=/';

	if ((typeof expires) != 'undefined')
	{
		var a = new Date();
		a = new Date(a.getTime() + expires);
		cook = cook + ';expires=' + a.toGMTString() + ';';
	}

	document.cookie = cook;
}

function CookieRead(name)
{
	var a = document.cookie;

	var res = '';
	while(a != '')
	{
		var cookiename = a.substring(0,a.search('='));
		
		var n = a.search(';');

		if (n < 0)	
		{
			n = a.length;
		}

		var cookiewert = a.substring(a.search('=')+1, n);

		while (cookiename.substring(0, 1) == ' ')
		{
			cookiename = cookiename.substring(1);
		}

		if(name == cookiename)
		{
			res = cookiewert;
			a = '';
		}
		else
		{
			var i = a.search(';')+1;
			if(i == 0){i = a.length}
			a = a.substring(i,a.length);
		}
	}

	return(res)
}


/****************************************************************************************************/
/*																									*/
/* "Pseudo Session Var" helper functions															*/
/*																									*/
/****************************************************************************************************/

function SessionRead(name)
{
	var strSession = CookieRead('SESSION');
	var aSession = strSession.split(' ');

	for (var i = 0; i < aSession.length; i += 2)
	{
		if (aSession[i] == name)
		{
			return decodeURI(aSession[i + 1]);
		}
	}

	return '';
}


function SessionWrite(name, value)
{
	var strSession = CookieRead('SESSION');
	var aSession = strSession.split(' ');

	for (var i = 0; i < aSession.length; i += 2)
	{
		if (aSession[i] == name)
		{
			if (value != '')
			{
				aSession[i+1] = encodeURI(value);
			}
			else
			{
				aSession.splice(i, 2);
			}
						
			break;
		}
	}

	if ((i >= aSession.length) && (value != ''))
	{
		aSession[i] = name;
		aSession[i+1] = encodeURI(value);		
	}

	strSession = aSession.join(' ');
	CookieWrite('SESSION', strSession, 30*60*1000);

	if ((value != '') && (SessionRead(name) == ''))
	{
		if (CalcLanguage() == 2)
		{
			alert("Achtung: die Benutzung von Cookies muss eingeschaltet sein,\nda unser Shopsystem sonst nicht funktioniert.");
		}
		else
		{
			alert("Attention: the use of cookies must be enabled,\notherwise our shop system will not work.");
		}

		return;
	}
}


/****************************************************************************************************/
/*																									*/
/* Param line helper functions																			*/
/*																									*/
/****************************************************************************************************/



function ParameterRead(name)
{
	var a = location.href;

	var n = -1;

	for (var c = 0; c < a.length; c++)
	{
		if (a.substring(c, c+1) == '?')
		{
			n = c;
			break;
		}
	
	}

	if (n < 0)
	{
		return '';
	}

	a = a.substring(n+1,a.length);

	var res = '';
	while(a != '')
	{
		var cookiename = a.substring(0,a.search('='));
		
		var n = a.search('\&');

		if (n < 0)	
		{
			n = a.length;
		}

		var cookiewert = a.substring(a.search('=')+1, n);

		while (cookiename.substring(0, 1) == ' ')
		{
			cookiename = cookiename.substring(1);
		}

		if(name == cookiename)
		{
			res = cookiewert;
			a = '';
		}
		else
		{
			var i = a.search('&')+1;
			if(i == 0){i = a.length}
			a = a.substring(i,a.length);
		}
	}

	for (var c = 0; c < res.length; c++)
	{
		if (res.substring(c, c+1) == '+')
		{
			res = res.substring(0, c) + ' ' + res.substring(c + 1, res.length);
		}
	
	}

	return unescape(res);

	return decodeURIComponent(res);
}




function ParameterConvert(arrParam, arrValue)
{
	var a = location.href;
	var n = a.indexOf('?');

	if (n < 0)
	{
		return '';
	}

	a = a.substring(n+1,a.length);

	while(a != '')
	{
		var cookiename = a.substring(0,a.search('='));
		
		var n = a.search('\&');

		if (n < 0)	
		{
			n = a.length;
		}

		var cookiewert = a.substring(a.search('=')+1, n);

		while (cookiename.substring(0, 1) == ' ')
		{
			cookiename = cookiename.substring(1);
		}

		arrParam[arrParam.length] = cookiename;
		arrValue[arrValue.length] = unescape(cookiewert);

		var i = a.search('&')+1;
		if(i == 0){i = a.length}
		a = a.substring(i,a.length);
	}
}



function InputRead(name)
{
	var strRes = ParameterRead(name);

	if (strRes == '')
	{
		strRes = SessionRead(name);
	}

	if (strRes == '')
	{
		strRes = CookieRead(name);
	}

	return strRes;
}




function WriteHiddenParam(strParam, strValue)
{
	if ((typeof strValue) == 'undefined')
	{
		strValue = InputRead(strParam);
	}

	document.write('<input type="hidden" name="' + strParam + '" value="' + strValue + '">');
}


function PostToURL(strUrl, arrParam, arrValue) 
{
	var form = document.createElement('form');
	form.setAttribute('method', 'POST');
	form.setAttribute('action', strUrl);
	form.setAttribute('style', 'display: none');

	for (var i = 0, l = arrValue.length; i < l; i++)
	{
		var e = document.createElement('input');
		e.setAttribute('type', 'hidden');
		e.setAttribute('name', arrParam[i]);
		e.setAttribute('value', arrValue[i]);

		form.appendChild(e);
	}
	
	document.body.appendChild(form);

	form.submit();
//	document.body.removeChild(form); 
} 



/****************************************************************************************************/
/*																									*/
/* misc helper functions																			*/
/*																									*/
/****************************************************************************************************/


function CalcLanguage()
{
	if (location.href.indexOf("seiten") >= 0)
	{
		return 2;
	}

	return 0;
}



function IsLocalTest()
{
	return (document.URL.toString().substr(0, 4) == 'file');
}


function ForwardToSecure()
{	
	var strHref = location.href;
	var strUrl = "http://www";	

	if (strHref.substring(0, strUrl.length) == strUrl)
	{
		location.href = "https://secure" + strHref.substring(strUrl.length);
	}
}



function IsMyself()
{
	var strMyself = ParameterRead('myself');

	if (strMyself == '1')
	{
		CookieWrite("MySelf", "yes", 10*365*24*60*60*1000); 
		return true;
	}	
	else if (strMyself == '0')
	{
		CookieWrite("MySelf", "no", 10*365*24*60*60*1000); 
		return false;
	}

	if (CookieRead("MySelf") == 'yes')
	{
		return true;
	}	

	return false;
}


function isalpha(c)
{
	if (('A' <= c) && (c <= 'Z'))
	{
		return true;
	}

	if (('a' <= c) && (c <= 'z'))
	{
		return true;
	}

	return false;
}


function isdigit(c)
{
	if (('0' <= c) && (c <= '9'))
	{
		return true;
	}

	return false;
}


function isalnum(c)
{
	return (isdigit(c) || isalpha(c));
}



/****************************************************************************************************/
/*																									*/
/* new functions																			*/
/*																									*/
/****************************************************************************************************/



function OnLoad()
{
	CalcContentDimensions();
}



function CalcContentDimensions()
{
	var arrIFrame = document.getElementsByName('iframe');

	if ((typeof arrIFrame) == 'undefined')
	{
		arrIFrame = document.all.iframe;
	}

	var nCount = 0;

	if ((typeof arrIFrame) != 'undefined')
	{
		nCount = arrIFrame.length;
	}

	for (nIndex = 0; nIndex < nCount; nIndex++)
	{
		var oIFrame = arrIFrame[nIndex];
		oIFrame.style.height = oIFrame.contentWindow.document.body.scrollHeight + 'px';
	}

	return;

	var scroll = document.all.right_content_scroll;
	scroll.style.overflow = 'auto';

	var footer = document.all.right_footer;
	var page = document.all.center_column;

	var rcScroll = CalcElementRect(scroll);
	var rcFooter = CalcElementRect(footer);
	var rcPage = CalcElementRect(page);

	rcScroll.bottom += document.body.clientHeight - rcFooter.bottom - (rcFooter.top - rcPage.bottom);
	
	var nHeight = (rcScroll.bottom - rcScroll.top);

	if (nHeight < 50)
	{
		nHeight = 50;
	}

	var strHeight = nHeight + 'px';
	scroll.style.height = strHeight;
}


function Rect(l, t, r, b)
{
	this.left = l;
	this.top = t;
	this.right = r;
	this.bottom = b;
}




function Size(cx, cy)
{
	this.cx = cx;
	this.cy = cy;
}


function CalcElementRect(o)
{
	var rect = new Rect(0, 0, 0, 0);

	rect.right = o.offsetWidth;
	rect.bottom = o.offsetHeight;

	while(1)
	{
//		alert(o.tagName + ' ' + o.offsetLeft);	

		rect.left += o.offsetLeft;
		rect.top += o.offsetTop;

		o = o.offsetParent; 

		if (o == null)
		{
			break;
		}
	}

	rect.right += rect.left;
	rect.bottom += rect.top;

	return rect;
}



function CalcElementSize(o)
{
	var sz = new Size(0, 0, 0, 0);

	sz.cx = o.offsetWidth;
	sz.cy = o.offsetHeight;

	return sz;
}



function OnGraphicLinkHover(div)
{
	div.id = 'graphiclink_hover';	
}	

function OnGraphicLinkOut(div)
{
	div.id = 'graphiclink';
}	


function GraphicLink(link, image, text, x, y, width, height, alttext, nFlags)
{
	if ((typeof alttext) == 'undefined')
	{
		alttext = text;
	}

	if ((typeof nFlags) == 'undefined')
	{
		nFlags = 0;
	}

	if (nFlags & PHOTOSPLASHOFFSET)
	{
		width = 200;
		height = 125;
	}		

	document.write('<div  id="graphiclink" style="position:absolute; top:' + y + 'px; left:' + x + 'px; width:' + width + 'px;' + ((height != 0) ? ' height: ' + height + 'px;' : '') + ' margin: 0px; padding:10px; " onmouseover="OnGraphicLinkHover(this); " onmouseout="OnGraphicLinkOut(this);" onclick="location.href=\'' + link + '\';">');

		if (nFlags & PHOTOSPLASHOFFSET)
		{
			var nWidth = width;
			var nHeight = height;

			document.write('<div style="position: relative; top: 0px; width:' + nWidth + 'px; height:' + (nHeight - 0) + 'px; ">');

				document.write('<div style="position: absolute; bottom: 0px; left: 0px; width:' + (nWidth - 12) + 'px; ">');

					ShadowTop();
					document.write('<div style="width: 100%; height: ' + (nHeight - 11) + 'px; "></div>');
					ShadowBottom();

				document.write('</div>');

				document.write('<div style="position: absolute; bottom: 4px; left: 1px; width:' + (nWidth - 4) + 'px; ">');
					document.write('<img src="' + image + '" title="" alt="" style="border: 0px; height: ' + (nHeight - 1) + 'px;">');
				document.write('</div>');

			document.write('</div>');
		}
		else
		{
			document.write('<img src="' + image + '" title="" alt="' + alttext + '" style="border: 0px; width: ' + width + 'px;' + ((height != 0) ? ' height: ' + height + 'px;' : '') + '" >');
		}

		if (text != '')
		{
			document.write('<div style="margin-top: 1em; ">');
			document.write(text);
			document.write('</div>');
		}

	document.write('</div>');
}


var PHOTOLEFT			= 1;
var PHOTORIGHT			= 2;
var PHOTOCENTER			= 3;
var PHOTOBLOCK			= 4;
var PHOTOBLOCKLEFT		= 5;
var PHOTOBLOCKRIGHT		= 6;

var PHOTOTEXTOUTSIDE	= 8;
var PHOTONOBORDER		= 16;
var PHOTONOSHADOW		= 32;

var PHOTOSPLASHOFFSET	= 1;


function Photo(nLan, location, image, flags, strText, author)
{
	var strImage = '../images/layout/' + location + '/' + image + '.jpg';

	var strNewText = '';

	switch (location)
	{
		case 'berlin':
		{
			if (((typeof author) == 'undefined') || (author == ''))
			{
				author = 'Technikmuseum';
			}

			strNewText = 'Deutsches Technikmuseum Berlin';
			break;
		}
		case 'dietenhofen':
		{
			if (((typeof author) == 'undefined') || (author == ''))
			{
				author = 'Miniatur Erlebniswelt';
			}

			strNewText = 'Miniatur Erlebniswelt Dietenhofen';
			break;
		}
		case 'driburg':
		{
			if (((typeof author) == 'undefined') || (author == ''))
			{
				author = 'Modellbundesbahn';
			}

			strNewText = 'Modellbundesbahn Bad Driburg';
			break;
		}
		case 'eversum':
		{
			if (((typeof author) == 'undefined') || (author == ''))
			{
				author = 'Freizeitpark';
			}

			strNewText = 'Modellbahn im Freizeitpark Eversum';
			break;
		}
		case 'koenigstein':
		{
			if (((typeof author) == 'undefined') || (author == ''))
			{
				author = 'Miniatur-Elbtalbahn';
			}

			strNewText = 'Miniatur-Elbtalbahn K&ouml;nigstein';
			break;
		}
		case 'oberhausen':
		{
			if (((typeof author) == 'undefined') || (author == ''))
			{
				author = 'MWO';
			}

			strNewText = 'Miniaturwelt Oberhausen';
			break;
		}
		case 'petersburg':
		{
			if (((typeof author) == 'undefined') || (author == ''))
			{
				author = 'Grand-Maket';
			}

			strNewText = 'Grand-Maket St. Petersburg';
			break;
		}
		case 'selbitz':
		{
			if (((typeof author) == 'undefined') || (author == ''))
			{
				author = 'Lokland';
			}

			strNewText = 'Lokland Selbitz';
			break;
		}
		case 'veit':
		{
			if (((typeof author) == 'undefined') || (author == ''))
			{
				author = 'Museum St. Veit';
			}

			strNewText = (nLan == 1) ?
						'Layout in the Museum St. Veit' :
						'Modellbahnanlage im Museum St. Veit';
			break;
		}
	}

	if (((typeof strText) == 'undefined') || (strText == ''))
	{
		strText = strNewText;
	}

	if (nLan == 1)
	{
		strText += ' (Photo: ' + author + ')';
	}
	else
	{
		strText += ' (Foto: ' + author + ')';
	}

	if ((typeof flags) == 'undefined')
	{
		flags = PHOTOCENTER;
	}

	Image(nLan, strImage, strText, flags);
}


function ShadowTop(flags)
{
	if ((typeof flags) == 'undefined')
	{
		flags = 0;
	}

	if (flags & PHOTONOSHADOW)
	{
		return;
	}

	var strBorder = (flags & PHOTONOBORDER) ? ' border-width: 0px;' : '';

	if (flags & PHOTOTEXTOUTSIDE)
	{
		document.write('<div class="shadow-area" style="overflow: hidden;">');
	}

		document.write('<div class="shadow-container">');
			document.write('<div class="shadow1">');
				document.write('<div class="shadow2">');
					document.write('<div class="shadow3">');
						document.write('<div class="container" style="' + strBorder + '">');
}


function ShadowBottom(flags)
{
	if ((typeof flags) == 'undefined')
	{
		flags = 0;
	}

	if (flags & PHOTONOSHADOW)
	{
		return;
	}

						document.write('</div>');
					document.write('</div>');
				document.write('</div>');
			document.write('</div>');
		document.write('</div>');

	if (flags & PHOTOTEXTOUTSIDE)
	{
		document.write('</div>');
	}
}


function Image(lan, strImage, strText, flags)
{
	if ((typeof strImage) == 'undefined')
	{
		return;
	}

	if ((typeof flags) == 'undefined')
	{
		flags = PHOTOCENTER + PHOTOTEXTOUTSIDE;
	}

	var align = flags & 7;
	var strClass = '';

	switch(align)
	{
		case PHOTOBLOCK:
		{
			strClass = 'class="photoblock" ';
			break;
		}
		case PHOTOCENTER:
		{
			strClass = 'class="photocenter" ';
			break;
		}
		case PHOTOLEFT:
		{
			strClass = 'class="photoleft" ';
			break;
		}	
		case PHOTORIGHT:
		{
			strClass = 'class="photoright" ';
			break;
		}	
		case PHOTOBLOCKLEFT:
		{
			strClass = 'class="photoblockleft" ';
			break;
		}	
		case PHOTOBLOCKRIGHT:
		{
			strClass = 'class="photoblockright" ';
			break;
		}	
	}

	if ((typeof strText) == 'undefined')
	{
		strText = '';
	}

	switch(align)
	{
		case PHOTOBLOCK:
		case PHOTOBLOCKLEFT:
		{
			document.write('<div>');
			break;
		}	
	}

	document.write('<div ' + strClass + '>');
		document.write('<div style="' + ' border: 0px; margin: 0px; padding: 0px;">');

			ShadowTop(flags);
			document.write('<img src="' + strImage + '" class="photo" title="" alt="' + strText + '">');
			ShadowBottom(flags);

			if (strText != '')
			{
				if (flags & PHOTOTEXTOUTSIDE)
				{
					document.write('<div class="phototextoutside">');
						document.write('<span>' + strText + '</span>');
					document.write('</div>');
				}
				else
				{
					document.write('<div class="phototextback">');
						document.write('<span style="color: transparent;">' + strText + '</span>');
					document.write('</div>');
					document.write('<div class="phototext">');
						document.write('<span style="background-color: transparent; ">' + strText + '</span>');
					document.write('</div>');
				}	
			}

		document.write('</div>');

	document.write('</div>');

	switch(align)
	{
		case PHOTOBLOCK:
		case PHOTOBLOCKRIGHT:
		{
			document.write('</div>');
			break;
		}	
	}


}


function ImageShadow(nDrawShadow)
{
	var doc = document;	

	if ((typeof nDrawShadow) != 'undefined')
	{
		doc.write('<div class="photoshadow-l" style="width: ' + nDrawShadow + '%;">');/*AHe*/
	}
	else
	{
		doc.write('<div class="photoshadow-l">');/*AHe*/
	}

	doc.write('<div class="photoshadow-r">');/*AHe*/
	doc.write('<div class="photoshadow-c">');/*AHe*/
	doc.write('</div> <!-- class="photoshadow-c"-->');/*AHe*/
	doc.write('</div> <!-- class="photoshadow-r"-->');/*AHe*/
	doc.write('</div> <!-- class="photoshadow-l"-->');/*AHe*/
}



function ResizeIFrame(iframe)
{
	iframe.style.height = ((iframe.parentNode.style.visibility == 'visible') ? iframe.contentWindow.document.body.scrollHeight : 0) + 'px';
}



function OnClickToggleIFrame(div)
{
	if (div.childNodes[0].style.visibility == 'visible')
	{
		div.childNodes[0].style.visibility = 'hidden';
		div.childNodes[0].style.width = '0px';
		div.childNodes[0].style.height = '0px';
		div.childNodes[1].style.visibility = 'visible';
		div.childNodes[1].style.width = '';
		div.childNodes[1].style.height = '';

		var iframe = div.childNodes[1].childNodes[1].childNodes[0];
		iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px'
	}	
	else
	{
		div.childNodes[0].style.visibility = 'visible';
		div.childNodes[0].style.width = '';
		div.childNodes[0].style.height = '';
		div.childNodes[1].style.visibility = 'hidden';
		div.childNodes[1].style.width = '0px';
		div.childNodes[1].style.height = '0px';

		var iframe = div.childNodes[1].childNodes[1].childNodes[0];
		iframe.style.height = '0px'
	}	
}


function ToggleIFrame(lan, visible, hidden, url)
{
	document.write('<div>');
		document.write('<div class="iframeshow" style="visibility: visible;" onclick="OnClickToggleIFrame(parentNode)"><img src="../images/arrow_right.gif"><span>' + visible + '</span></div>');
		document.write('<div style="height: 0px; visibility: hidden;">');
			document.write('<div class="iframehide" onclick="OnClickToggleIFrame(parentNode.parentNode)"><img src="../images/arrow_left.gif"><span>' + hidden + '</span><br><br></div>');
			document.write('<div><iframe src="' + url + '" scrolling="no" width="100%" style="height: 0px;" frameborder="0" allowtransparency="true"></iframe></div>');
			document.write('<br>');
			document.write('<div class="iframehide" onclick="OnClickToggleIFrame(parentNode.parentNode)"><img src="../images/arrow_left.gif"><span>' + hidden + '</span></div>');
		document.write('</div>');
	document.write('</div>');
}


function VerticalTop(strWidthFloat)
{
	document.write(GetVerticalTopCode(strWidthFloat));
}


function IsIE()
{
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		return true;
	}

	return false;
}


function GetVerticalTopCode(strWidthFloat)
{
	if ((typeof strWidthFloat) == 'undefined')
	{
		strWidthFloat = 'width:auto;';
	}

	var strCode = '';

	if (IsIE())
	{
		strCode += '<div style="height: 100%;';
		strCode += ' ' + strWidthFloat;
		strCode += '">';
			strCode += '<table cellspacing="0" style="height: 100%;">';
				strCode += '<tr>';
					strCode += '<td style="vertical-align: middle; margin: 0px; padding: 0px; spacing: 0px;">';
	}
	else
	{
		strCode += '<div style="display: table; height: 100%; ';
		strCode += ' ' + strWidthFloat;
		
		strCode += '">';
			strCode += '<div style="display: table-cell; vertical-align: middle;">';
	}

	return strCode;
}

function VerticalBottom()
{
	document.write(GetVerticalBottomCode());
}

function GetVerticalBottomCode()
{
	var strCode = '';

	if (IsIE())
	{
					strCode += '</td>';
				strCode += '</tr>';
			strCode += '</table>';
		strCode += '</div>';
	}
	else
	{
			strCode += '</div>';
		strCode += '</div>';
	}

	return strCode;
}


function CenterText(strText)
{
	document.write(GetCenterTextCode(strText));
}


function GetCenterTextCode(strText)
{
	var strCode = '';

	strCode += '<center><table border="0" cellspacing="0">';
		strCode += '<tbody>';
			strCode += '<tr>';

				strCode += '<td style="padding: 0; ">';
				strCode += '<div>' + strText + '</div>';
				strCode += '</td>';

			strCode += '</tr>';

		strCode += '</tbody>';
	strCode += '</table></center>';

	return strCode;
}


function VerticalText(strText, strWidthFloat)
{
	document.write(GetVerticalTextCode(strText, strWidthFloat));
}


function GetVerticalTextCode(strText, strWidthFloat)
{
	var strCode = '';

	strCode += GetVerticalTopCode(strWidthFloat);
	strCode += strText;
	strCode += GetVerticalBottomCode();

	return strCode;
}



function DisplaySubmitButton(strText, strForm, strIfFunction, bLineBreak)
{
	document.write(GetSubmitButtonCode(strText, strForm, strIfFunction, bLineBreak));
}



function GetSubmitButtonCode(strText, strForm, strIfFunction, bLineBreak)
{
	var strAction;

	if (((typeof strIfFunction) != 'undefined') && (strIfFunction != ''))
	{
		strAction = 'if (' + strIfFunction + ') document.' + strForm + '.submit();"';
	}
	else
	{
		strAction = 'document.' + strForm + '.submit();"';
	}

	return GetButtonCode(strText, strAction, bLineBreak);
}




function DisplayUrlButton(strText, strUrl, bLineBreak, bExtern)
{
	document.write(GetUrlButtonCode(strText, strUrl, bLineBreak, bExtern));
}



function GetUrlButtonCode(strText, strUrl, bLineBreak, bExtern)
{
	var strAction;
	
	if ((typeof strUrl) != 'undefined')
	{
		var strSuffix = strUrl.substr(strUrl.length - 4, strUrl.length).toUpperCase(); 

		switch (strSuffix)
		{
			case '.PDF':
			{
				bExtern = true;
				break;
			}
		}

		if (((typeof bExtern) != 'undefined') && bExtern)
		{
			strAction = 'window.open(\'' + strUrl + '\');';
		}
		else
		{
			strAction = 'location.href=\'' + strUrl + '\'';
		}
	}		
	
	return GetButtonCode(strText, strAction, bLineBreak);
}


function DisplayButton(strText, strAction, bLineBreak)
{
	document.write(GetButtonCode(strText, strAction, bLineBreak));
}


function GetButtonCode(strText, strAction, bLineBreak)
{
	var strCode = '';

	strCode += '<div class="but"';
	
	if (((typeof strAction) != 'undefined') && (strAction != ''))
	{
		strCode += ' onclick="' + strAction + '"';
	}		
		
	strCode += '>';

	strCode += '<div class="but-l">';
	strCode += '<div class="but-r">';
	strCode += '<div class="but-c">';
		
	strCode += GetVerticalTextCode(strText);

	strCode += '</div>';
	strCode += '</div>';
	strCode += '</div>';
	strCode += '</div>';

	if (((typeof bLineBreak) != 'undefined') && bLineBreak)
	{
		strCode += '<div style="clear: left;"></div>';
	}

	return strCode;
}


function TableTop(strTitle)
{
	if ((typeof strTitle) != 'undefined')
	{
		document.write('<div class="box-h-l"><div class="box-h-r"><div class="box-h-c">');
		document.write('<div class="box-title">');
		VerticalText('<h4>' + strTitle + '</h4>', 'width: 100%;');
		document.write('</div></div></div></div>');
	}
	else
	{
		_FrameTop();
	}

	document.write('<table class="tablebg" width="100%" cellpadding="0" cellspacing="0">');
}


function TableBottom()
{
	document.write('<tr><td class="cat-bottom" colspan="100">&nbsp;</tr>');
	document.write('</table>');
	_FrameBottom();
}


function _FrameTop()
{
	document.write('<div class="fr-h-l"><div class="fr-h-r"><div class="fr-h-c"></div></div></div>');
}




function _FrameBottom()
{
	document.write('<div class="fr-f-l"><div class="fr-f-r"><div class="fr-f-c"></div></div></div>');
}



function FrameTop()
{
	_FrameTop();
	document.write('<div class="text_box">');
}



function FrameBottom()
{
	document.write('</div>');		//  class="text_box"
	_FrameBottom();
}



function TableHeader(strEntry0, strEntry1, strEntry2, strEntry3, strEntry4, strEntry5, strEntry6, strEntry7, strEntry8, strEntry9)
{
	TableRowEx(0, 'th', strEntry0, strEntry1, strEntry2, strEntry3, strEntry4, strEntry5, strEntry6, strEntry7, strEntry8, strEntry9);
}


function TableRow(strEntry0, strEntry1, strEntry2, strEntry3, strEntry4, strEntry5, strEntry6, strEntry7, strEntry8, strEntry9)
{
	TableRowEx(0, 'td', strEntry0, strEntry1, strEntry2, strEntry3, strEntry4, strEntry5, strEntry6, strEntry7, strEntry8, strEntry9);
}




function TableRowEx(nLongCol, strType, strEntry0, strEntry1, strEntry2, strEntry3, strEntry4, strEntry5, strEntry6, strEntry7, strEntry8, strEntry9)
{
	var strText = '';

	var astrEntry = new Array();

	astrEntry[0] = strEntry0;

	if ((typeof strEntry1) != 'undefined')
	{
		astrEntry[1] = strEntry1;
	}

	if ((typeof strEntry2) != 'undefined')
	{
		astrEntry[2] = strEntry2;
	}

	if ((typeof strEntry3) != 'undefined')
	{
		astrEntry[3] = strEntry3;
	}

	if ((typeof strEntry4) != 'undefined')
	{
		astrEntry[4] = strEntry4;
	}

	if ((typeof strEntry5) != 'undefined')
	{
		astrEntry[5] = strEntry5;
	}

	if ((typeof strEntry6) != 'undefined')
	{
		astrEntry[6] = strEntry6;
	}

	if ((typeof strEntry7) != 'undefined')
	{
		astrEntry[7] = strEntry7;
	}

	if ((typeof strEntry8) != 'undefined')
	{
		astrEntry[8] = strEntry8;
	}

	if ((typeof strEntry9) != 'undefined')
	{
		astrEntry[9] = strEntry9;
	}

	strText += '<tr>';

	var e;
	for (e = 0; e < astrEntry.length; e++)
	{
		strText += '<' + strType;

		if (strType == 'td')
		{
			strText += ' class="row';

			if (e == nLongCol)
			{
				if (astrEntry.length <= 1)
				{
					strText += '0';
				}
				else
				{
					strText += '1';
				}
			}
			else
			{
				strText += '2';
			}

			strText += '" style="vertical-align: middle;';

			if (strType == 'td')
			{
				if (e == nLongCol)
				{
					strText += ' width: 100%;"';

					if (astrEntry.length <= 1)
					{
						strText += ' colspan="100"';
					}
				}
				else
				{
					strText += '"';
				}
			}
		}
		else if (e == nLongCol)
		{
			strText += ' style="width: 100%;"';
		}
		
		strText += '>';	
		strText += astrEntry[e];	
		strText += '</' + strType + '>';	
	}	

	strText += '</tr>';

	document.write(strText);
}




function FormTableTop(strTitle)
{
	TableTop();
	TableHeader('<div style="text-align: left;">' + strTitle + '</div>');
	document.write('<tr><td class="row1" style="border: 0px">');
	document.write('<table class="formtable" width="100%">');
}


function FormTableBottom(strBottomLine)
{
	var doc = document;

	doc.write('</table>');
	doc.write('</td></tr>');

	if (((typeof strBottomLine) != 'undefined') && (strBottomLine != ''))
	{
		doc.write('<tr><td>');
		CenterText(strBottomLine);
		doc.write('</td></tr>');
	}

	TableBottom();
}

/***********************************************************************************************************/
//
//	Ticker:
//
/***********************************************************************************************************/



function TickerStart()
{
	var arrTicker = document.getElementsByName('ticker');

	if ((typeof arrTicker) == 'undefined')
	{
		arrTicker = document.all.ticker;
	}

	var nCount = 0;

	if ((typeof arrTicker) != 'undefined')
	{
		nCount = arrTicker.length;
	}

	var nIndex = 0;

	for (nIndex = 0; nIndex < nCount; nIndex++)
	{
		oTicker = arrTicker[nIndex];
	
		oTicker.parentNode.style.position = "relative";
		oTicker.parentNode.style.overflow = "hidden";
		oTicker.style.position = "absolute";
		oTicker.style.top = "0px";
		oTicker.style.left = "0px";

		var oTicker2 = oTicker.parentNode.childNodes[1];
		oTicker2.style.position = "absolute";
		oTicker2.style.top = "0px";
		oTicker2.style.left = "0px";

		TickerTick(oTicker);
	}
}


var bTickerPause = false;


function TickerPause(bPause)
{
	bTickerPause = bPause;
}


function TickerTick(oTicker)
{
	if (!bTickerPause)
	{
		var nTop = parseInt(oTicker.style.top);
		nTop--;

		var sz = CalcElementSize(oTicker);

		var oTicker2 = oTicker.parentNode.childNodes[1];
		var sz2 = CalcElementSize(oTicker2);
		var nTop2 = (nTop <= 0) ? (nTop + sz.cy) : (nTop - sz2.cy);
			
		if ((nTop2 < 0) && (nTop < 0))
		{
			nTop = nTop2 + sz2.cy;
		}

		oTicker.style.top = nTop + "px";
		oTicker2.style.top = nTop2 + "px";
	}

	window.setTimeout("TickerTick(oTicker)", 60);
}



