/*	javascript functions for strassenbahn.tk

	author: manni@manni.org

	please credit the author when re-using any script or concept

	version 3.56, 2011-12-26

*/



/*

- calling non-framed pages will call the frame and then redirect the content frame, when cookies are activated

- 'photo_' in the URL will not call the frameset but instead resize the window

*/



try{document.execCommand("BackgroundImageCache", false, true);}catch(error){} // no bgimg caching on IE5.5-6

try{document.domain='strassenbahn.tk';}catch(error){} // ensure main page and forum/ftp clientside connectivity



// send to strassenbahn.tk if coming from manni.org

try{

if(location.href.indexOf('manni.org')!=-1&&location.href.indexOf('.html')==-1){top.location.href=location.href.replace('www.manni.org','www.strassenbahn.tk');}

if(location.href.indexOf('manni.org')!=-1&&location.href.indexOf('news_')!=-1){top.location.href=location.href.replace('www.manni.org','www.strassenbahn.tk');}

}catch(error){}

if(location.href.indexOf('http://bus.strassenbahn.tk/')!=-1){location.href=location.href.replace('http://bus.strassenbahn.tk','http://www.strassenbahn.tk');}

if(location.href.indexOf('http://strassenbahn.tk/')!=-1){location.href=location.href.replace('http://strassenbahn.tk','http://www.strassenbahn.tk');}



function d(id){return document.getElementById(id);}



// display deep link

var l=location.href;

if(l.indexOf('main')==-1&&l.indexOf('index.html')==-1&&l.indexOf('navigation')==-1&&l.indexOf('animation')==-1&&l.indexOf('showphoto')==-1&&l.indexOf('poll')==-1)

	{

	document.write('<div class="update" align=right style="width:98%;position:absolute;top:0px;left:0px;">'+location.href+'</div>');

	}



// include the CSS stylesheets

var isDOM=document.getElementById ? true:false;

var isGecko=false; if(navigator.userAgent.indexOf('Gecko')!=-1){isGecko=true;}

var isFF4up=false; if(isGecko && navigator.userAgent.indexOf('Firefox/1')==-1 && navigator.userAgent.indexOf('Firefox/2')==-1 && navigator.userAgent.indexOf('Firefox/3')==-1){isFF4up=true;} 

var isNN4=document.layers ? true:false;

var isIE4=document.all ? true:false;

var isOpr=false;

var isOpr7up=false;

var isIE5=false;

var isIE55up=false;

var isMac=false;

var isSafari=false;

var isKhtml=false;

if (navigator.userAgent.indexOf('Mac')!=-1){isMac=true;}

if (navigator.userAgent.indexOf('KHTML')!=-1||navigator.userAgent.indexOf('Khtml')!=-1||navigator.userAgent.indexOf('khtml')!=-1){isKhtml=true;}

if (navigator.userAgent.indexOf('Safari')!=-1){isSafari=true;isKhtml=false;}

if (isDOM && isIE4 && !isOpr) {var isIE55up=true;isIE4=false;isDOM=false;} else {var isIE55up=false;}

if (navigator.userAgent.indexOf('Opera')!=-1) {isOpr=true;isDOM=false;isNN4=false;isIE4=false;isIE55up=false;}

if(isOpr&&navigator.userAgent.indexOf('Opera 0')==-1&&navigator.userAgent.indexOf('Opera/0')==-1&&navigator.userAgent.indexOf('Opera 2')==-1&&navigator.userAgent.indexOf('Opera/2')==-1&&navigator.userAgent.indexOf('Opera 3')==-1&&navigator.userAgent.indexOf('Opera/3')==-1&&navigator.userAgent.indexOf('Opera 4')==-1&&navigator.userAgent.indexOf('Opera/4')==-1&&navigator.userAgent.indexOf('Opera 5')==-1&&navigator.userAgent.indexOf('Opera/5')==-1&&navigator.userAgent.indexOf('Opera 6')==-1&&navigator.userAgent.indexOf('Opera/6')==-1){isOpr7up=true;}

if (navigator.userAgent.indexOf('MSIE 5.0')!=-1&&!isOpr) {isIE5=true;isIE4=false;isIE55up=false;}

var isValid=false;

var absPrefix='';

if(location.href.indexOf('http://')!=-1||location.href.indexOf('schwarzhai')!=-1){absPrefix='http://www.strassenbahn.tk/inntram/';}

if (isIE5||isIE55up) {document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\""+absPrefix+"ie.css\">");isValid=true;}

if (isGecko||isSafari) {document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\""+absPrefix+"dm.css\">");isValid=true;}

if (isOpr7up) {document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\""+absPrefix+"op.css\">");isValid=true;}

//document.write('<scr'+'ipt language=\"javascript\" src=\"glossarisator.js\"></scr'+'ipt>');

if(isIE5&&!isIE55up){var undefined='undefined';}



// tell old Gecko users to update

if(isGecko&&!isSafari)

	{

	var nu=navigator.userAgent;

	var GVers=Number(nu.substring(nu.indexOf('rv:')+3,nu.indexOf('rv:')+6));

	if(GVers<1.5)

		{

		isValid=false;

		alert('Du verwendest Netscape 6, Netscape 7.0 oder eine alte Version von Mozilla. Zahlreiche Browserfunktionen sind in diesen alten Browsern fehlerhaft. Bitte aktualisiere auf Firefox 2.0 oder neuer, ansonsten kannst Du z.B. die News-Artikel nicht lesen und viele andere Funktionen nicht nutzen.');

		}

	}



if(!isValid)

	{

	alert('Du brauchst einen modernen, W3C DOM-faehigen Browser, um www.strassenbahn.tk nutzen zu koennen. Internet Explorer 6 oder neuer (nur Windows), Opera 9 oder neuer, alle Gecko-basierten Browser (z.B. Mozilla ab 1.5, Firefox ab 2.0) sind geeignet, unter Mac OS X kannst Du auch Safari verwenden. Du kannst damit fortfahren, mit Deinem Browser die Seite zu nutzen, es werden jedoch leider wahrscheinlich Probleme auftreten.');

	document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\""+absPrefix+"dm.css\">");

}



// see if we're not framed when we actually should; if so, set the redir cookie and call the frameset

window.topReferrer='top';

if(!isSafari)

	{

	try

		{

		var topLocTest=top.location.href;

		} catch (error) {window.topReferrer='top.frames[0]';}

	try

		{

		if((eval(window.topReferrer).location.href==location.href)&&location.href.indexOf('index.php')==-1&&location.href.indexOf('index.html')==-1&&location.href.indexOf('showphoto.html')==-1&&location.href.indexOf('schwarzhai')==-1&&location.href.indexOf('updatelog.html')==-1&&location.href.indexOf('forum')==-1)

			{

			if(cookiesEnabled())

				{

				setCookie('redirectionURL',location.href);

				}

			eval(window.topReferrer).location.replace('index.html'+location.search);

			}

		} catch (error) {}

	}



// see if the redirection cookie contains a URI; if yes, execute the redirection

function redirectContent(){

if(cookiesEnabled())

	{

	var redirectionURL=getCookie('redirectionURL');

	if(redirectionURL!=undefined&&redirectionURL!=''&&redirectionURL!=null&&redirectionURL!='null'&&(redirectionURL.indexOf('.html')!=-1||redirectionURL.indexOf('.cgi')!=-1))

		{

		setCookie('redirectionURL','');

		redirectContent_execute(redirectionURL);

		} else if(getCookie('askForForum')==1)

		{

		redirectContent_execute('http://forum.strassenbahn.tk/');

		}

	}

}

if(location.href.indexOf('index.html')!=-1){redirectContent();}



// try redirecting until the frame is accessible

function redirectContent_execute(redirectionURL){

try

	{

	window.frames.main.location.href=redirectionURL;

	} catch (error) {

	window.setTimeout("redirectContent_execute('"+redirectionURL+"');",1);

	}

}



// pep up certain links with icons

function iconizeLinx(){

var lc=0; var tlc=-1;

if(document.body&&document.body.innerHTML) // wait til loaded

	{

	tlc=document.getElementsByTagName('td').length;

	var liAr=document.getElementsByTagName('a');

	if(location.href.indexOf('navigation.html')==-1)

		{

		for (var i=0;i<liAr.length;i++)

			{

			try{

			if(liAr[i].childNodes[0].nodeType==3)

				{

				while(liAr[i].childNodes[0].nodeValue.indexOf('ß')!=-1)

					{

					liAr[i].childNodes[0].nodeValue=liAr[i].childNodes[0].nodeValue.replace('ß','ss');

					}

				}

			}catch(error){}

			if(!liAr[i].title){liAr[i].title=liAr[i].href;}

			if(liAr[i].href.indexOf('http://forum.strassenbahn.tk')!=-1&&liAr[i].getElementsByTagName('img').length==0)

				{

				liAr[i].innerHTML='<img src="img/icon_forum.gif" border="0">&nbsp;'+liAr[i].innerHTML.replace('&gt;','');

				liAr[i].title='Link ins Inntram-Forum';

				lc++;

				}

			if((location.href.indexOf('manni.org')!=-1||location.href.indexOf('strassenbahn.tk')!=-1||location.protocol.indexOf('file')!=-1)&&(liAr[i].target=='_blank')&&(liAr[i].getElementsByTagName('img').length==0)&&(liAr[i].href.indexOf('mailto:')==-1))

				{

				liAr[i].innerHTML='<img src="img/icon_extlink.gif" border="0">&nbsp;'+liAr[i].innerHTML.replace('&gt;','');

				lc++;

				if(liAr[i].href.indexOf('.jpg')!=-1||liAr[i].href.indexOf('.gif')!=-1||liAr[i].href.indexOf('.png')!=-1)

					{

					liAr[i].title='Bilddatei in einem neuen Fenster anzeigen: '+liAr[i].title;

					} else if (liAr[i].href.indexOf('.pdf')!=-1){

					liAr[i].title='PDF-Datei in einem neuen Fenster anzeigen: '+liAr[i].title;

					} else {

					liAr[i].title='Link in einem neuen Fenster anzeigen: '+liAr[i].title;

					}

				}

				if(liAr[i].href.indexOf('mailto:')!=-1&&liAr[i].getElementsByTagName('img').length==0)

					{

					// guestbook quirk

					if(liAr[i].href.indexOf('mailto:<img')!=-1){liAr[i].innerHTML='';}

					else

						{

						liAr[i].innerHTML='<img src="img/icon_mail.gif" border="0">&nbsp;'+liAr[i].innerHTML.replace('&gt;','');

						liAr[i].title='E-Mail an '+liAr[i].href.replace('mailto:','')+' verfassen';

						lc++;

						}

					}

			}

		}

	}

if(!window.oldTlc||window.oldTlc==undefined){window.oldTlc=0;}

if(tlc!=window.oldTlc||tlc==-1||(tlc==0&&document.getElementsByTagName('table').length==0)){window.setTimeout("iconizeLinx(0);",3000);}

window.oldTlc=tlc;

}

iconizeLinx();



// see if this is a photo file; if so, resize the window

function resizePhotoWindow(){

if(location.href.indexOf('photo_')==-1)

	{



	}

}



// name - name of the cookie

// value - value of the cookie

// [expires] - expiration date of the cookie (defaults to end of current session)

// [path] - path for which the cookie is valid (defaults to path of calling document)

// [domain] - domain for which the cookie is valid (defaults to domain of calling document)

// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission

// * an argument defaults when it is assigned null as a placeholder

// * a null placeholder is not required for trailing omitted arguments

function setCookie(name, value, expires, path, domain, secure) {

  var curCookie = name + "=" + escape(value) +

      ((expires) ? "; expires=" + expires.toGMTString() : "") +

      ((path) ? "; path=" + path : "") +

      ((domain) ? "; domain=" + domain : "") +

      ((secure) ? "; secure" : "");

  document.cookie = curCookie;

}



// name - name of the desired cookie

// * return string containing value of specified cookie or null if cookie does not exist

function getCookie(name) {

  var dc = document.cookie;

  var prefix = name + "=";

  var begin = dc.indexOf("; " + prefix);

  if (begin == -1) {

    begin = dc.indexOf(prefix);

    if (begin != 0) return null;

  } else

    begin += 2;

  var end = document.cookie.indexOf(";", begin);

  if (end == -1)

    end = dc.length;

  return unescape(dc.substring(begin + prefix.length, end));

}



// returns true or false, depending on whether cookies are enabled or not

function cookiesEnabled() {

    expdate = "Thu, 01-Jan-70 00:00:01 GMT";

    document.cookie = "Enabled=true";

    var cookieValid = document.cookie;



    if( cookieValid.indexOf( "Enabled=true" ) != -1 ) {

        window.cookiesEnabled = true;

    } else {

        window.cookiesEnabled = false;

    }

    document.cookie = "Enabled=" + ";expires=" + expdate;



    if( cookiesEnabled ) {

        retval = true;

    } else {

        retval = false;

    }

    return retval;

}



// define the tram control window variables

window.tramCommand='';

window.tramStatus='';



// continuous multi-layer animation

// init values: 999,999,999,999,999,999,0,false

function runTram(posZero,posOne,posTwo,posFive,posSix,posSeven,multiplyer,brake) {

// initially set the beschleuniger

if ((brake==false)&&(multiplyer==0)) {

	multiplyer=0.5;

	}



// beschleunig up to 7.5 in steps of 0.125

if ((brake==false)&&(multiplyer<3.5)) {

	multiplyer=multiplyer+0.02;

	}



if (brake==true) {

	multiplyer=multiplyer-0.05;

	}



// if it's a new run, set the positions to the object's positions

if (posZero==999) {

	if (d('zero').style.left=='') {

	posZero=780;

	} else {

	posZero=d('zero').style.left.replace('px','');

	posZero=Number(posZero);

	}

}

if (posOne==999) {

	if (d('one').style.left=='') {

	posOne=780;

	} else {

	posOne=d('one').style.left.replace('px','');

	posOne=Number(posOne);

	}

}

if (posTwo==999) {

	if (d('two').style.left=='') {

	posTwo=0;

	} else {

	posTwo=d('two').style.left.replace('px','');

	posTwo=Number(posTwo);

	}

}

if (posFive==999) {

	if (d('five').style.left=='') {

	posFive=780;

	} else {

	posFive=d('five').style.left.replace('px','');

	posFive=Number(posFive);

	}

}

if (posSix==999) {

	if (d('six').style.left=='') {

	posSix=0;

	} else {

	posSix=d('six').style.left.replace('px','');

	posSix=Number(posSix);

	}

}

if (posSeven==999) {

	if (d('seven').style.left=='') {

	posSeven=0;

	} else {

	posSeven=d('seven').style.left.replace('px','');

	posSeven=Number(posSeven);

	}

}



// animate it

if(window.CPUSpeed>350&&parent.parent.suppressTramRuns!=1) // ...but only on fast machines and if not suppressed thru preferences

	{

	d('zero').style.left=Math.round(posZero)+'px';

	d('one').style.left=Math.round(posOne)+'px';

	d('two').style.left=Math.round(posTwo)+'px';

	d('five').style.left=Math.round(posFive)+'px';

	d('six').style.left=Math.round(posSix)+'px';

	d('seven').style.left=Math.round(posSeven)+'px';

	} else {  // on a slow machine show a defined cityscape, if this is not yet shown

	if(parent.frames.main.d('cb_TramAni')){parent.frames.main.d('cb_TramAni').checked=true;}

	if(d('zero').style.left!='-200px')

		{

		d('zero').style.left='-200px';

		d('one').style.left='-350px';

		d('two').style.left='-400px';

		d('five').style.left='-500px';

		d('six').style.left='-900px';

		d('seven').style.left='-700px';

		}

	}



// increase the item's positions



// trees

if (posZero<-780) {posZero=posZero+780;}

posZero=posZero-1*multiplyer;

// station

if ((posOne<-720)&&(posOne>-730)) {

	var stopNow=window.tramCommand;

	}

if (posOne<=-780) {

	posOne=posOne+780;

	}

if ((posOne<-460)&&(posOne>-470)) {

	var stopNow=window.tramCommand;

	}

if ((posOne<-210)&&(posOne>-220)) {

	var stopNow=window.tramCommand;

	}

posOne=posOne-0.5*multiplyer;

// masts

if (posTwo<-780) {posTwo=posTwo+780;}

posTwo=posTwo-0.4*multiplyer;

// city

if (posFive<-780) {posFive=posFive+780;}

posFive=posFive-0.2*multiplyer;

// clouds

if (posSix<-780) {posSix=posSix+780;}

posSix=posSix-0.1*multiplyer;

// back

if (posSeven<-780) {posSeven=posSeven+780;}

posSeven=posSeven-0.06*multiplyer;



// init braking, if command given

if (stopNow=='stop') {

	brake=true;

	}



// plug it into the interrupt

var runString = 'runTram('+posZero+','+posOne+','+posTwo+','+posFive+','+posSix+','+posSeven+','+multiplyer+','+brake+')';



if (multiplyer>0.5) {

	window.setTimeout(runString,14);

	} else {

	window.tramStatus='stopped';

	detectTramStatus();

	}



}



//

//---

//



// init the tram on first loading

function initTram() {

window.tramStatus='stopped';

window.tramCommand='stop';

}



// start the tram

function startTram() {

window.tramCommand='run';

var ran_unrounded=((Math.random()*10)*1000)+5000;

var ran_number=Math.round(ran_unrounded);

window.setTimeout("stopTram();",ran_number);

}



// stop the tram

function stopTram() {

window.tramCommand='stop';

window.setTimeout("startTram();",5000);

}



// detect if a command is given

function detectTramStatus() {

// get the animation status

// trigger a run

if ((window.tramCommand=='run')&&(window.tramStatus!='running')) {

	window.tramStatus='running';

	runTram(999,999,999,999,999,999,0,false);

	}

// trigger a brake

if (window.tramCommand=='stop') {

	stopTram();

	}

if (window.tramStatus=='stopped') {

	window.setTimeout('detectTramStatus()',2500);

	}

}



// Call a page from the navigation

function callPage(url,stationName){

if(location.href.indexOf('index.html')==-1) // if called from content...

	{

	parent.frames.main.location.href=url;

	} else { // if called from index (main menu)...

	window.frames.mainframe.main.location.href=url;

	}

if(!isSafari){eval(window.topReferrer).document.title='www.strassenbahn.tk: '+stationName;}

}



// show a photo in a new window

function showPhoto(imageURL,slideshowMode){

var urlPrefix='';

if(typeof imageURL=='object'){imageURL=imageURL.getElementsByTagName('img')[0].src.replace('thumb_','');};

if(slideshowMode&&typeof(slideshowMode)!='object'){camRefresh='?camrefresh';}else{camRefresh='';}

window.showPhoto_imageURL=imageURL;

if(!parent.parent.suppressScriptPicLoader)

	{ window.originalImageWindow=window.open("showphoto.html"+camRefresh,"Foto","toolbar=0,status=1,menubar=0,location=0,resizable=1,scrollbars=1,height=680,width=840");

	try

		{

		window.slideshowMode=slideshowMode;

		}catch(error){}

	} else {

	window.open(imageURL);

	}

}

function setSlideshowMode(obj){

window.theobj=obj;

try

	{

	window.originalImageWindow.slideshowMode=obj;

	window.setTimeout("setSlideshowMode(window.theobj);",250);

	}catch(error){}

}



// Scale the full view window to the image's size

function showPhoto_scaleWindow(){

var validSize=false;

var originalImage=d('originalImage');

originalImage.src=opener.showPhoto_imageURL;

// get the image dimensions

var width=originalImage.width;

var height=originalImage.height;

if(width>99&&height>99){validSize=true;window.validSize=true;}

if(validSize)

	{

	// get the screen dimensions

	var screenWidth=window.screen.width;

	var screenHeight=window.screen.height;

	// size corrections
	width=width+40;height=height+100;

	// if the image is bigger than the screen, equalize the window size with the screen size

	if(width>screenWidth||window.fullscreen){width=screenWidth;}

	if(height>screenHeight||window.fullscreen){height=screenHeight;}

	// resize the window

	window.resizeTo(width+6,height+4);

	try{d('slideShowControls').style.width=Number(width-40)+'px';}catch(error){}

	if(d('loading')&&getCPUSpeed()>1599){getRidOfElement(1,'loading');} // fade loading message out

	if(d('loading')&&getCPUSpeed()<1600){d('loading').style.display='none';}



	if(location.href.indexOf('?camrefresh')!=-1){originalImage.id='imgWebcam';updateWebcam();}

	} else {window.setTimeout("showPhoto_scaleWindow();",1000);}

}



// see if there's a local #target; if so, look for an element with the same ID and blink its background color

function markTdIfLocalTargetInHash(){try{

if(location.hash!=''&&location.hash!='#')

	{

	var id='mark_'+location.hash.replace('#','');

	markTdIfLocalTargetInHash_execute(0,id);

	try // try to click the 'load thumbnails' element

		{

		var spans=d(id).getElementsByTagName('span'); // search for clickable span

		for (sp=0; sp<spans.length; sp++)

			{

			if(spans[sp].onclick)

				{

				spans[sp].click(); // send click

				}

			}

		} catch (error) {}

	}

}catch(error){

if(location.href.indexOf('construction.html')!=-1)

  {

  alert(location.hash);

  if(confirm('Die aufgerufene Bildergalerie wurde leider nicht gefunden.\n\Wahrscheinlich ist sie schon älter und wurde daher ins Tram-Baustellen-Archiv verschoben.\n\nIns Archiv wechseln, um dort zu suchen?'))

    {

    location.replace('photos_construction_archive.html'+location.hash);

    }

  }

}}



function markTdIfLocalTargetInHash_execute(counter,id){

var flashCell=d(id);

if(counter==0){flashCell.style.borderColor='#b07070';flashCell.style.borderWidth='4px';}

//if(counter==1){flashCell.style.borderColor='#98adff';}

//counter++;

//if(counter==2){counter=0;}

//window.setTimeout("markTdIfLocalTargetInHash_execute("+counter+",'"+id+"');",500);

}



// correct the polling form's layout

function correctPollLayout(){

try{

if(document.getElementsByTagName('table').length!=0) // see if the poll script has been accessed and the poll is actually displayed...

	{

	document.body.innerHTML=document.body.innerHTML.replace('Ergebnis','Zwischenstand');

	document.getElementsByTagName('font')[1].style.display='none';

	for(var i=0;i<document.getElementsByTagName('input').length;i++)

		{

		if(document.getElementsByTagName('input')[i].value.indexOf('Abstimmen')!=-1)

			{

			document.getElementsByTagName('input')[i].className='input_button'; // style the button

			}

		}

	} else { // ... if not, display the error message

	d('poll').innerHTML='<center><img src="img/warning.gif"></center><br>Die <strong>Umfrage</strong> ist wegen einer technischen St&ouml;rung derzeit leider nicht verf&uuml;gbar!';

	}

}catch(error){}

}



// correct the polling result page's layout

function correctPollResultLayout(){

try{

var allFonts=document.getElementsByTagName('font');

for(var f=0;f<allFonts.length;f++)

	{

	allFonts[f].style.display='none';

	}

}catch(error){}

}



// check if the poll was submitted and if so, switch the frames

function pollResultSwitch(toWhat,hash){

if(toWhat=='result'&&hash!='')

	{

	d('pollQuestion').style.display='none';

	d('pollResult').style.display='inline';

	window.setTimeout("document.getElementsByTagName('iframe')[0].src='poll_result.html#1';",500); // access the iframe by index because of a Gecko bug

	} else if(toWhat=='poll') {

	d('pollQuestion').style.display='inline';

	d('pollResult').style.display='none';

	document.getElementsByTagName('iframe')[1].src='poll.html'; // access the iframe by index because of a Gecko bug

	}

}



// Measures the approximate CPU speed, writes it into a one-session cookie and returns the app. speed value in MHz

// The value is used within CPU time intensive functions to determine whether to use the time-consuming code version or a slim version of it

// Speed is measured three times per session and the average value is then set as global document variable 'comm_CPUSpeed' and as domain-wide cookie 'comm_CPUSpeed'; measurement precision is around +-150MHz for IE5, IE5.5, IE6 and Gecko; no measuring possible on Opera

function getCPUSpeed(){

var CPUSpeedMeasureCount=getCookie('CPUSpeedMeasureCount');

if(CPUSpeedMeasureCount!=3)

	{

	var CPUSpeed=getCookie('CPUSpeed'); // set local value

	var count=1000000;

	var date1=new Date();

	var start=date1.getTime();

	for (var i=1;i<=count;i++) {} // the measurement loop

	date1=new Date();

	var finish=date1.getTime();

	CPUSpeedSeconds=(finish-start)/1000;

	CPUSpeedLoopsPerMs=Math.round(count/CPUSpeedSeconds/1000);

	CPUSpeed=Math.round(CPUSpeedLoopsPerMs*0.341);

	if(CPUSpeedMeasureCount==2) // third run

		{

		CPUSpeed=Math.floor((Number(CPUSpeed)+Number(CPUSpeed))/2);

		CPUSpeedMeasureCount=3;

		}

	if(CPUSpeedMeasureCount==1) // second run

		{

		CPUSpeed=Math.floor((Number(CPUSpeed)+Number(CPUSpeed))/2);

		CPUSpeedMeasureCount=2;

		}

	if(!CPUSpeedMeasureCount||CPUSpeedMeasureCount=='') // first run

		{

		CPUSpeed=Math.floor((Number(CPUSpeed)+Number(CPUSpeed))/2);

		CPUSpeedMeasureCount=1;

		}

	setCookie('CPUSpeed',CPUSpeed,'','/');

	setCookie('CPUSpeedMeasureCount',CPUSpeedMeasureCount,'','/');

	} else {

	CPUSpeed=getCookie('CPUSpeed');

	}

if((isMac)&&CPUSpeedMeasureCount==3){CPUSpeed=CPUSpeed*2;} // Multipy measurement result by 2 @ PPC and Opr

if((isSafari)&&CPUSpeedMeasureCount==3){CPUSpeed=CPUSpeed*4;} // Multipy measurement result by 4 @ Safari

window.CPUSpeed=CPUSpeed;

if(isOpr){window.CPUSpeed='999999';} // Opera can't measure correctly, so set a high value on it

//setCookie('CPUSpeedMeasureCount','','','/'); // delete counter for debugging

return CPUSpeed;

}



// flashes anything in the page that has an id of 'updatedElement'

function zoomUpdatedElement(counter){

var flashCell=d('updatedElement');

if(flashCell)

	{

	if(counter==0){flashCell.style.backgroundColor='#CDD6FF';}

	if(counter==1){flashCell.style.backgroundColor='#dDe6FF';}

	if(counter==2){flashCell.style.backgroundColor='#eDf6FF';}

	if(counter==3){flashCell.style.backgroundColor='#fDffFF';}

	if(counter==4){flashCell.style.backgroundColor='#ffffff';}

	if(counter==5){flashCell.style.backgroundColor='#fDffFF';}

	if(counter==6){flashCell.style.backgroundColor='#eDf6FF';}

	if(counter==7){flashCell.style.backgroundColor='#dDe6FF';}

	if(counter==8){flashCell.style.backgroundColor='#CDD6FF';}

	if(counter==9){flashCell.style.backgroundColor='';}

	counter++;

	if(counter==30){counter=0;}

	window.setTimeout("zoomUpdatedElement("+counter+");",50);

	}

}



// correct the width of teaserBlock_5 in Gecko and Op

function correctTb5Width(){

if((isOpr||isGecko)&&d('teaserBlock_5'))

	{

	d('teaserBlock_5').style.width='243px';

	}

}



// fade an element away

// counter = 1 or undefined when starting

// id = id for the element

function getRidOfElement(counter,id){

var x=d(id);

x.onmouseover='';

if(counter==undefined||!counter){counter=1;}

if(isIE55up||isGecko||isKhtml||isSafari)

	{

	if(isIE55up)

		{

		if(counter==1){x.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=60)';}

		if(counter==2){x.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=40)';}

		if(counter==3){x.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=20)';}

		if(counter==4){x.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=10)';}

		if(counter==5){x.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=0)';}

		}

	else if(isGecko)

		{

		if(counter==1){x.style.MozOpacity=.6;}

		if(counter==2){x.style.MozOpacity=.4;}

		if(counter==3){x.style.MozOpacity=.2;}

		if(counter==4){x.style.MozOpacity=.1;}

		if(counter==5){x.style.MozOpacity=0;}

		}

	else if(isKhtml)

		{

		if(counter==1){x.style.KhtmlOpacity=.6;}

		if(counter==2){x.style.KhtmlOpacity=.4;}

		if(counter==3){x.style.KhtmlOpacity=.2;}

		if(counter==4){x.style.KhtmlOpacity=.1;}

		if(counter==5){x.style.KhtmlOpacity=0;}

		}

	else if(isSafari)

		{

		if(counter==1){x.style.KhtmlOpacity=.6;x.style.opacity=.6;}

		if(counter==2){x.style.KhtmlOpacity=.4;x.style.opacity=.4}

		if(counter==3){x.style.KhtmlOpacity=.2;x.style.opacity=.2}

		if(counter==4){x.style.KhtmlOpacity=.1;x.style.opacity=.1}

		if(counter==5){x.style.KhtmlOpacity=0;x.style.opacity=.0}

		}

	counter++;

	} else {

	counter=6;

	}

if(counter==6)

	{

	x.style.display='none';count=false;

	} else {

	window.setTimeout("getRidOfElement("+counter+",'"+id+"');",1);

	}

}



// open the ftp

function callFtp(path){

if(!path||path==undefined){path='';}

var ftpURL='ftp.html?calledFromForum=true';

if(path!=''){ftpURL+='?path='+encodeURI(path);}

if(location.href.indexOf('manni.org')==-1&&location.href.indexOf('strassenbahn.tk')==-1&&location.href.indexOf('http://')!=-1)

	{

	top.location.href='http://www.strassenbahn.tk/inntram/'+ftpURL;

	} else {

	callPage(ftpURL);

	}

}



// fit the ftp frame's height

function fitFtpFrame(){

var m1Height=d('measure1').offsetHeight;

var wHeight=document.body.clientHeight;

if(isSafari){wHeight=window.innerHeight;}

var diff=95;

if(isGecko||isOpr){diff=165;}

d('ftpFrame').style.height=wHeight-m1Height-diff;

window.setTimeout("fitFtpFrame();",250);

}



// update the web cam image

function updateWebcam(){

var wc=d('imgWebcam');

wc.src='http://www.oberthaler.com/webcam/htdocs/m1test.jpg?'+Math.random(1)*999;

window.setTimeout("updateWebcam();",15000);

if(d('insert')) // if full size view, show insert

	{

	d('insert').style.visibility='visible';

	d('banner').style.display='inline';

	window.resizeTo(640+40,480+116);

	}

}



// fit the main table height to 100%

function fitMainTableHeight(){

if(isGecko)

	{

	d('mainframe').style.height=window.innerHeight-8+'px';

	}

if(isOpr)

	{

	d('mainframe').style.height=window.innerHeight-4+'px';

	}

}



// german date phrase, needs the SSI date written into DATE_GMT in the DOMPath's window object

// targetDate in format 'mm/dd/yyyy' or 'dd/mm/yyyy',

// if firstWord is true, the first letter will be uppercase

// if returnMode is true, the result will not be written, but returned instead

// if noDateString is true, the date string (dd.mm.yyyy) will not be appended to the output

function writeDatePhrase(DOMPath,targetDate,firstWord,returnMode,noDateString){

var isNotADate=false;

if(targetDate.indexOf('Vor ')!=-1||targetDate.indexOf('Gestern')!=-1||targetDate.indexOf('Vorgestern')!=-1)

	{

	isNotADate=true;

	}

if(!isNotADate)

	{

	if(!noDateString&&targetDate.indexOf('.')!=-1)

		{

		targetDate=targetDate.substr(3,2)+'/'+targetDate.substr(0,2)+'/'+targetDate.substr(6,4);

		}

	try{

	dateStr=eval(DOMPath).window.DATE_LOCAL;

	var today = new Date(dateStr);

	var targetDay=targetDate.substring(3,5);

	var targetMonth=targetDate.substring(0,2);

	var targetYear=targetDate.substring(6,10);

	var targetDate = new Date(targetDate);

	var timeBeforeTarget = Math.floor(( targetDate.getTime() - today.getTime()) / 86400000)

	var tWord='';

	var tPreBef='in '; if(firstWord){tPreBef='In ';}

	var tPreAft='vor '; if(firstWord){tPreAft='Vor ';}

	var tSuf=' Tagen';

	if(timeBeforeTarget==0){tWord='<strong>heute</strong>'; if(firstWord){tWord='<strong>Heute</strong>';}}

	if(timeBeforeTarget==1){tWord='<strong>morgen</strong>'; if(firstWord){tWord='<strong>Morgen</strong>';}}

	if(timeBeforeTarget==2){tWord='&uuml;bermorgen'; if(firstWord){tWord='&Uuml;bermorgen';}}

	if(timeBeforeTarget==3){tWord=tPreBef+'drei'+tSuf;}

	if(timeBeforeTarget==4){tWord=tPreBef+'vier'+tSuf;}

	if(timeBeforeTarget==5){tWord=tPreBef+'f&uuml;nf'+tSuf;}

	if(timeBeforeTarget==6){tWord=tPreBef+'sechs'+tSuf;}

	if(timeBeforeTarget==7){tWord=tPreBef+'sieben'+tSuf;}

	if(timeBeforeTarget==8){tWord=tPreBef+'acht'+tSuf;}

	if(timeBeforeTarget==9){tWord=tPreBef+'neun'+tSuf;}

	if(timeBeforeTarget==10){tWord=tPreBef+'zehn'+tSuf;}

	if(timeBeforeTarget==11){tWord=tPreBef+'elf'+tSuf;}

	if(timeBeforeTarget>11){tWord=tPreBef+timeBeforeTarget+tSuf;}

	if(timeBeforeTarget==-1){tWord='<strong>gestern</strong>'; if(firstWord){tWord='<strong>Gestern</strong>';}}

	if(timeBeforeTarget==-2){tWord='vorgestern'; if(firstWord){tWord='Vorgestern';}}

	if(timeBeforeTarget==-3){tWord=tPreAft+'drei'+tSuf;}

	if(timeBeforeTarget==-4){tWord=tPreAft+'vier'+tSuf;}

	if(timeBeforeTarget==-5){tWord=tPreAft+'f&uuml;nf'+tSuf;}

	if(timeBeforeTarget==-6){tWord=tPreAft+'sechs'+tSuf;}

	if(timeBeforeTarget==-7){tWord=tPreAft+'sieben'+tSuf;}

	if(timeBeforeTarget==-8){tWord=tPreAft+'acht'+tSuf;}

	if(timeBeforeTarget==-9){tWord=tPreAft+'neun'+tSuf;}

	if(timeBeforeTarget==-10){tWord=tPreAft+'zehn'+tSuf;}

	if(timeBeforeTarget==-11){tWord=tPreAft+'elf'+tSuf;}

	if(timeBeforeTarget<-11){tWord=tPreAft+(0-timeBeforeTarget)+tSuf;}

	if(timeBeforeTarget>-6&&timeBeforeTarget<1){tWord+=' <img src="img/neu.gif">';}

	if(!noDateString){tWord+=' ('+targetDay+'.'+targetMonth+'.'+targetYear+')';}

	}catch(error){}

	}else{

	var tWord='<b>'+targetDate+'</b>';

	}

	if(returnMode){return(tWord);}else{document.write('<span title=generatedDatePhrase>'+tWord+'</span>');}

}



// login to the ftp server as admin

// pwd = password string

function ftpAdminLogin(pwd){

d('ftpFrame').src='ftp://inntram-admin:'+pwd+'@ftp.strassenbahn.tk:82';

}



// load the given section's thumbnails&acute; (only works with current table structure!)

function loadThumbnails(obj,close){

obj.style.display='none';

srcprefix='http://forum.strassenbahn.tk/img/photos/';

if(isIE5||isIE55up){obj.nextSibling.style.display='inline';obj.nextSibling.style.width='160px';}

if(isGecko||isOpr){try{obj.nextSibling.nextSibling.style.display='inline';}catch(error){obj.nextSibling.style.display='inline';};}

var tn=document.getElementsByTagName('IMG');

var thisSectionId=obj.parentNode.id;

for(var tnc=0; tnc<tn.length; tnc++)

	{try{

	if (tn[tnc].parentNode.parentNode.parentNode.parentNode.parentNode.id==thisSectionId)

		{

		if(tn[tnc].src=='')

		  {

		  tn[tnc].src=srcprefix+tn[tnc].title.substring(tn[tnc].title.indexOf('?')+1,tn[tnc].title.length);

		  tn[tnc].title='';

		  }

		}

	}catch(error){}}

}



// toggle certain preference settings; for now, this is an automatic popping up of the forum or the ftp window onload

// cmd = 'init' || object

function togglePrefs(cmd){

if(window.cookiesEnabled)

	{

	d('cb_Forum').disabled=false;

	d('cb_ScriptPicLoader').disabled=false;

	}

if(cmd=='init') // on the init call, execute settings and set the checkboxes

	{

	if(getCookie('autoOpenFtp')==1)

		{

		callFtp();

		}

	if(getCookie('suppressScriptPicLoader')==1)

		{

		d('cb_ScriptPicLoader').checked=true;

		parent.parent.window.suppressScriptPicLoader=1;

		}

	if(getCookie('askForForum')==1)

		{

		d('cb_Forum').checked=true;

		}

	} else { // else, if an object is given, save the setting

	var expiryDate=new Date(); expiryDate.setTime(expiryDate.getTime()+Math.round(86400000*365));

	var newSetting=0;

	if(cmd.checked){newSetting=1;}

	if(cmd.id=='cb_ScriptPicLoader')

		{

		setCookie('suppressScriptPicLoader',newSetting,expiryDate,'/','','');

		parent.parent.window.suppressScriptPicLoader=newSetting;

		}

	if(cmd.id=='cb_Forum')

		{

		setCookie('askForForum',newSetting,expiryDate,'/','','');

		}

	}

}



// navigate to an ftp path, if any is given

function ftp_navigateToPath(){

if(location.search.indexOf('path=')!=-1)

	{

	d('ftpFrame').src='ftp://inntram-public:inntram-public@ftp.strassenbahn.tk:82/'+location.search.replace('?path=','');

	}

}



// submit a search

// mode='Site'||'Forum'

function submitSearch(mode){

if(mode=='Site')

	{

	d('siteSearchForm').submit();

	}

}



// begin content management -------------------------------------------------------------------------------------------------



// send article entries and redirect

function index_Send(){

if(location.search.indexOf('buildIndex=true')!=-1)

	{

	var artNr=location.href.substring(location.href.lastIndexOf('/'),location.href.length);

	artNr=Number(artNr.replace('/news_','').replace('.html','').replace('?buildIndex=true',''));

	parent.index_Build(d('articleTitle').innerHTML,d('articleTeaser').innerHTML,d('articleDate').innerHTML,d('articleUpdate').innerHTML,artNr);

	artNr=artNr-1;

	parent.window.index_Progress(parent.window.index_StartArticle-artNr,parent.window.index_TeasersOffset); // show progress display

	parent.window.index_TeasersOffset=parent.window.index_TeasersOffset-1;

	if(artNr>-1&&parent.window.index_TeasersOffset>-1)

		{

		if(!parent.isGecko&&!parent.isOpr)

			{

			location.replace('news_'+artNr+'.html?buildIndex=true');

			} else { // mainly Opera quirk

			window.setTimeout("location.href='news_"+artNr+".html?buildIndex=true';",15);

			}

		}

	}

}



// build article index

function index_Build(articleTitle,articleTeaser,articleDate,articleUpdate,articleNr){

var titleStory=false; var titleStory2=false;

if(window.index_StartArticle==articleNr&&location.href.indexOf('news.html')==-1){titleStory=true;}

if(d('titleStory2')&&window.index_StartArticle==articleNr+1&&location.href.indexOf('news.html')==-1){titleStory2=true;}

if(d('teasersBlock'))

	{

	try

		{

		var headClass='bluehead'; var dateClass='blue_tiny'; var teaserClass='small'; var appEl='teasersBlock'; var appElHead=''; var aHTML='';

		if(titleStory){headClass='title_head'; appElHead=''; dateClass='title_date'; teaserClass='title_teaser'; appEl='titleStory';}

		if(titleStory2){headClass='title_head'; appElHead=' title_head2'; dateClass='title_date'; teaserClass='title_teaser'; appEl='titleStory2';}

		aHTML+='<span class="'+headClass+appElHead+'"><strong><a href="news_'+articleNr+'.html">'+articleTitle+'</a></strong></span><br>';

		if(titleStory||titleStory2){aHTML+='<span class="'+teaserClass+'">'+articleTeaser+'</span><br>';}

		aHTML+='<span class="'+dateClass+'">'+writeDatePhrase('parent.parent',articleDate,true,true)+'</span>';

		if(articleUpdate!='')

			{

			aHTML+='<span class="'+dateClass+'">, upgedated '+writeDatePhrase('parent.parent',articleUpdate,false,true)+'</span>';

			}

		if(!titleStory&&!titleStory2){aHTML+='<br><span class="'+teaserClass+'">'+articleTeaser+'</span>';} // teaser

		aHTML+='<br><br>';

		var teaserBlock=document.createElement('div');

		d(appEl).appendChild(teaserBlock);

		teaserBlock.innerHTML=aHTML;

		}catch(error){

		window.setTimeout("index_Build('"+articleTitle+"','"+articleTeaser+"','"+articleDate+"','"+articleUpdate+"','"+articleNr+"');",100);

		}

	}

}



// build local article index

function index_BuildLocal(){

// temp print silktext title

document.write('<span id="stBuffer">');

silkText(d('articleTitle').innerHTML.replace('amp;',''),0,0,'','','#000080',2,0,'s.gif',true,false,false,0,0,0);

document.write('</span>');

var silkTextTitle=d('stBuffer').innerHTML;

d('stBuffer').innerHTML='';

// create HTML

var aHTML='';

aHTML+='<span class="blue_tiny">'+writeDatePhrase('parent.parent',d('articleDate').innerHTML,true,true)+'</span>';

if(d('articleUpdate').innerHTML!='')

	{

	aHTML+='<span class="blue_tiny">, upgedated '+writeDatePhrase('parent.parent',d('articleUpdate').innerHTML,false,true)+'</span>';

	}

aHTML+='<br>';

aHTML+='<strong><h3>'+silkTextTitle; // title

aHTML+='<br class="br_small">'+d('articleTeaser').innerHTML+'</h3></strong>'; // teaser

var titleBlock=document.createElement('div');

titleBlock.innerHTML=aHTML;

d('articleHeadSpace').appendChild(titleBlock);

}



// build local page index

function page_BuildLocal(){

// temp print silktext title

document.write('<span id="stBuffer">');

silkText(d('pageTitle').innerHTML,0,0,'','','#000080',2,0,'s.gif',true,false,false,0,0,0);

document.write('</span>');

var silkTextTitle=d('stBuffer').innerHTML;

d('stBuffer').innerHTML='';

// create HTML

var aHTML='';

if(d('pageUpdate').innerHTML!='')

	{

	aHTML+='<span class="blue_tiny">Zuletzt upgedated: '+writeDatePhrase('parent.parent',d('pageUpdate').innerHTML,false,true)+'</span><br><br>';

	}

aHTML+=''+silkTextTitle; // title

if(d('pageTeaser').innerHTML!='')

	{

	aHTML+='<br class="br_small"><span class="blue">'+d('pageTeaser').innerHTML+'</span>'; // teaser

	}

var titleBlock=document.createElement('div');

titleBlock.innerHTML=aHTML;

d('pageHeadSpace').appendChild(titleBlock);

}



// initialize the article indexing iframe

function index_Start(){

var iFr=d('teaserInterface');

if(isOpr) // Op quirk

	{

	iFr.style.display='';

	iFr.style.visibility='hidden';

	iFr.style.height='0px';

	iFr.style.width='0px';

	}

iFr.src='news_'+(window.index_StartArticle)+'.html?buildIndex=true';

}



// show loading progress display

function index_Progress(currVal,fullVal){

// create display element

var proW='';

if(!d('progWin'))

	{

	proW=document.createElement('div');

	var pHTML='';

	pHTML+='<center><span class="tiny">Noch <strong><span id="progFull">0</span></strong> zu laden</span><br><table cellspacing="0" cellpadding="0" style="border:2px solid #602020;height:10px;width:100px;"><tr><td id="progCell" style="background-color:#602020;width:1px;"><img src="s.gif"></td><td id="progCellEmpty" width="99"></td></tr></table></center>';

	proW.innerHTML=pHTML;

	proW.id='progWin';

	proW.style.position='absolute';

	proW.style.width='110px';

	proW.style.height='20px';

	proW.style.backgroundColor='#ffa0a0';

	proW.style.border='3px dotted #804040';

	proW.style.padding='2px';

	d('teasersBlock').appendChild(proW);

	}

var progWin=d('progWin');

if(!window.index_showKeepPos)

	{

	progWin.style.display='';

	window.index_showKeepPos=true;

	index_Progress_keepPos();

	}

if(fullVal==0){window.index_showKeepPos=false;;}

d('progFull').innerHTML=fullVal;

try{d('progCell').style.width=((100/fullVal)*currVal)+'px';}catch(error){d('progCell').style.width=fullVal+'px';}

try{d('progCellEmpty').style.width=100-(100/fullVal)+'px';}catch(error){d('progCellEmpty').style.width='0px';}

}

// keep progress display in center position

function index_Progress_keepPos(){

var progWin=d('progWin');

var scrollT=document.body.scrollTop; var scrollL=document.body.scrollLeft;

var wW=document.body.clientWidth; var wH=document.body.clientHeight;

if(isSafari){scrollT=window.pageYOffset;scrollL=window.pageXOffset;wH=window.innerHeight;wW=window.innerWidth;}

progWin.style.left=((wW/2+scrollL)-55)+'px';

progWin.style.top=((wH/2+scrollT)-10)+'px';

if(window.index_showKeepPos)

	{

	window.setTimeout("index_Progress_keepPos();",1000);

	} else {

	progWin.style.display='none';

	}

}



// center the main menu element

function page_Center(){

var mm=d('mainMenu');

var lCorr=398;

if(isGecko){lCorr=390;}

mm.style.left=(document.body.offsetWidth/2)-lCorr+'px';

if(!isOpr){mm.style.top='106px';}

if(isOpr)

	{

	mm.style.top='0px';

	if(mm.style.display=='none')

		{

		d('tdMainframe').style.visibility='visible';

		} else {

		d('tdMainframe').style.visibility='hidden';

		}

	}

window.setTimeout("page_Center()",500);

}



// end content management -------------------------------------------------------------------------------------------------



// lock and release form submit button; to be called onload

// reqFieldId=id for field that must not be empty

// btId= id for submit button

function formLock(reqFieldId,btId){

if(d(reqFieldId).value==''){d(btId).disabled=true;}else{d(btId).disabled=false;}

window.setTimeout("formLock('"+reqFieldId+"','"+btId+"');",500);

}



// lock and release search field buttons

function searchLock(){

if(d('siteSearchQuery').value==''||d('siteSearchQuery').value=='Suchbegriff eingeben')

	{

	d('submitButtonSite').disabled=true;

	} else {

	d('submitButtonSite').disabled=false;

	}

window.setTimeout("searchLock();",500);

}



// keep nav frame on doc top (Opera quirk)

function oprKeepTop(){

window.scrollTo(0,0);

window.setTimeout("oprKeepTop();",500)

}



// try to set the top title

function setTitle(){

try

  {

  top.document.title='www.strassenbahn.tk - '+document.title;

  }catch(error){}

}

if(parent.location.href.indexOf('index')!=-1){setTitle();}

window.onunload=function(){try{top.document.title='www.strassenbahn.tk -  Gegenwart und Zukunft von Innsbrucks Bahnen | AIN';}catch(error){};};



// generate press links

function press_Generate(dead){

var pLArr=pressData.split('*end*');

var loopL=pLArr.length-1;

try {d('pressCount').innerHTML=loopL}catch(error){};

var pSend=false;

var tBack='parent.parent';

if(location.href.indexOf('pressSend=true')!=-1){pSend=true;} // if called for main page teasering...

if(pSend){loopL=5;tBack='parent.parent.parent';}

var thisPL='';var thisPLArr='';var thisDate='';var thisMedia='';var thisURL='';var linkEl=null; var isScan=false; var thisOnclick=""; var thisTarget='_blank'; var strikeCount=0; var thisDead=false; var thisYear=''; var lastYear='';

try{d('pressLinksTOC').innerHTML='';}catch(error){ };

try{d('pressLinks').innerHTML='';}catch(error){ };

for (var i=0; i<loopL; i++) // assemble data

	{

	thisPL=pLArr[i];

	thisPLArr=thisPL.split('*sep*');

	thisDate=thisPLArr[0].replace('*sep*','');

	thisYear=new Date(thisDate); thisYear=thisYear.getFullYear();

	thisMedia=thisPLArr[1].replace('*sep*','');

	thisTitle=thisPLArr[2].replace('*sep*','');

	thisURL=thisPLArr[3].replace('*end*','');

	thisDead=false;

	if(thisURL.indexOf('.jpg')!=-1){isScan=true;}else{isScan=false;} // if it's a JPEG, it must be a scan, placed in /newspress!

	if(!pSend){linkEl=document.createElement('div');}else{linkEl=parent.document.createElement('div');}

	if(isScan){thisMedia+=' (Scan)';thisOnclick='showPhoto(\'http://forum.strassenbahn.tk/download/newspress/'+thisURL+'\');return false;';thisURL='#';thisTarget='';}else{thisMedia+=' (externer Link)';thisOnclick='';thisTarget='_blank';}

	

	if(thisTitle.indexOf('STRIKE')!=-1) // if article is stroke

	 {

	 thisTitle=thisTitle.replace('STRIKE','');

	 thisTitle='<strike style=color:black;>'+thisTitle+'</strike>';

	 thisMedia=' (externer Link, Zieldokument aber nicht mehr verfügbar)';

	 strikeCount++;

	 thisDead=true;

	 }



if((dead&&thisDead)||!thisDead)

    {

	   linkEl.innerHTML='<span style="display:block;"><a onclick="'+thisOnclick+'" href="'+thisURL+'" target="'+thisTarget+'">'+thisTitle+'</a></span><span style="display:block;"><span class="mini">'+thisMedia+'</span><br><span class="blue_tiny">'+writeDatePhrase(tBack,thisDate,true,true)+'</span></span><br>';



	   if(!pSend){d('pressLinks').appendChild(linkEl);}else{parent.d('pressLinks').appendChild(linkEl);}

	   

	   if(thisYear!=lastYear&&!pSend)

	     {

	     // create year headline

	     linkEl.innerHTML='<a name="'+thisYear+'"><div class="roundupsep"></div><b class="blue">'+thisYear+':</b><div class="roundupsep"></div>'+linkEl.innerHTML;

	     // create TOC

	     try{

	     if(d('pressLinksTOC').innerHTML=='')

	       {

	       d('pressLinksTOC').innerHTML='<b>Springe zu Jahr:</b><br><br>';

	       }

	     d('pressLinksTOC').innerHTML+='<a href="#'+thisYear+'">'+thisYear+' </a> ';

	     }catch(error){ }

	     }

	   lastYear=thisYear;

	 }



	}

if(pSend){parent.d('spPressCount').innerHTML=pLArr.length-1;}



try {d('pressCountStrike').innerHTML=strikeCount;}catch(error){};



}



// generate board posting teasers redirection

function board_Redirect(answersCount,topicsCount,guestsOnlineCount,reggedList){

var boardData='';

var rt=d('recenttopicsTable');

var c=0;

var thisDateTime=''; var thisDate=''; var thisTime=''; var thisTitle=''; var thisArea=''; var thisAnswers='';

for (var i=0; i<5; i++) // get data

	{

	thisDateTime=rt.getElementsByTagName('td')[11+c].getElementsByTagName('font')[0].innerHTML;

	thisDate=thisDateTime.substring(0,10);

	thisTime=thisDateTime.replace(thisDate,'');

	thisDate=thisDate.substring(3,5)+'/'+thisDate.substring(0,2)+'/'+thisDate.substring(6,10);

	thisTitle=rt.getElementsByTagName('td')[7+c].getElementsByTagName('a')[0].innerHTML;

	thisURL=rt.getElementsByTagName('td')[7+c].getElementsByTagName('a')[0].href;

	thisArea=rt.getElementsByTagName('td')[8+c].getElementsByTagName('a')[0].innerHTML;

	thisAnswers=rt.getElementsByTagName('td')[10+c].getElementsByTagName('font')[0].innerHTML;

	boardData+=thisTitle+'*sep*'+thisURL+'*sep*'+thisArea+'*sep*'+thisDate+'*sep*'+thisTime+'*sep*'+thisAnswers+'*end*';

	c=c+7;

	}

boardData+='*SEP*'+answersCount+'*SEP*'+topicsCount+'*SEP*'+guestsOnlineCount+'*SEP*'+reggedList;

location.replace('http://www.strassenbahn.tk/inntram/mainupdate.html?'+encodeURI(boardData));

}



// enhance 'neu.gif' with declaring alt text

function declareNeu(waited){

if(document.body&&document.body.innerHTML)

	{

	reformatInputs();

	if(waited)

		{

		var allImg=document.getElementsByTagName('img');

		for(var i=0;i<allImg.length;i++)

			{

			if(allImg[i].src.indexOf('img/neu.gif')!=-1)

				{

				allImg[i].alt='Dieser Inhalt ist neu, wurde vor kurzem upgedated, oder wurde auf dieser Seite als letztes Inhaltselement upgedatet';

				allImg[i].title='Dieser Inhalt ist neu, wurde vor kurzem upgedated, oder wurde auf dieser Seite als letztes Inhaltselement upgedatet';

				}

			}

		}else{

		window.setTimeout("declareNeu(true);",2000);

		}

	}else{

	window.setTimeout("declareNeu(true);",500);

	}

}

declareNeu();



// Send random photo to the calling title page

/*

function displayRandomTitleImage(){

try{

if(parent.location.href.indexOf('main.html')!=-1)

	{

	var photoTarget=parent.d('randomPhoto');

	var allImgs=document.getElementsByTagName('img');

	var allPhotos=new Array(); var p=0;

	var allPhotosParent=new Array();

	for(var i=0;i<allImgs.length;i++)

		{

		if(allImgs[i].src.indexOf('thumb_')!=-1)

			{

			allPhotos[p]=allImgs[i];

			allPhotosParent[p]=allImgs[i].parentNode;

			p++;

			}

		}

	var randomnumber=Math.floor(Math.random()*allPhotos.length)

	photoTarget.src=allPhotos[randomnumber].src.replace('thumb_','');

	parent.d('photoCount').innerHTML=allPhotos.length;

	location.href='about:blank';

	}

}catch(error){}

}

*/



// Slide show

function slideShow(obj){

// init keyboard handler

if(isIE5||isIE55up){document.body.onkeypress=function(){handleKeys(event);}}else{window.addEventListener("keypress",handleKeys,true);}



// get gallery headline

if(isIE5||isIE55up||isFF4up)

	{

	var thisHeadline=obj.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('h3')[0].innerHTML.substring(0,obj.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('h3')[0].innerHTML.indexOf('<'));

	}else{

	var thisHeadline=obj.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('h3')[0].childNodes[0].innerHTML.substring(0,obj.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('h3')[0].childNodes[0].innerHTML.indexOf('<'));

	}

// get image

var thisImgSrc=obj.getElementsByTagName('img')[0].src;

// get image caption, if any

var thisImgCaption='';

if(obj.onmouseover)

	{

	if(isIE5||isIE55up){

	thisImgCaption= obj.onmouseover.toString().substring(obj.onmouseover.toString().indexOf(",'")+2,obj.onmouseover.toString().indexOf("']"));

	}else{

	thisImgCaption= obj.onmouseover.toString().substring(obj.onmouseover.toString().indexOf(', "')+3,obj.onmouseover.toString().indexOf('"]'));

	}

	}

// collect all photos to get count and generate references to prev and next

var thisImgPos=0;

var allImgs=new Array(); var allRefs=new Array(); var a=0; 

// get ONLY the photos within the fucking current section!
allImgs=obj.parentNode.parentNode.getElementsByTagName('img');

for(var i=0;i<allImgs.length;i++)

	{

	if(allImgs[i].src.toLowerCase().indexOf('/photos/')!=-1&&allImgs[i].src.toLowerCase().indexOf('/preview/')==-1)

		{

		allRefs[a]=allImgs[i];

		a++;

		}

	}

var totalImagesOnPage=allRefs.length;
     
if(!opener. oldAllRefs||opener.oldAllReds==undefined)   {opener.oldAllRefs=0;}



// get prev and next references

var thisImageOnPage=0;

for(i=0;i<allRefs.length;i++)

	{

	if(allRefs[i].src==thisImgSrc)

		{

		thisImageOnPage=i+1;

		if(allRefs[i+1]){window.nextRef=allRefs[i+1].parentNode;}

		if(allRefs[i-1]){window.prevRef=allRefs[i-1].parentNode;}

		}

	}



d('slideShowControls').style.display='';

d('headlineText').innerHTML=thisHeadline;

if(thisImgCaption!=''){d('captionText').innerHTML=thisImgCaption;}

d('thisImageOnPage').innerHTML=thisImageOnPage;

d('totalImagesOnPage').innerHTML=totalImagesOnPage;

d('imgName').innerHTML=opener.showPhoto_imageURL.replace('http://www.strassenbahn.tk/inntram/img/photos/','');

if(window.prevRef){d('prevLink').style.visibility='visible';d('prevLink').onclick=function(){eval('opener.showPhoto("'+prevRef.getElementsByTagName('img')[0].src.replace('thumb_','')+'",window.prevRef);')};}else{d('prevLink').style.visibility='hidden';}

if(window.nextRef){d('nextLink').style.visibility='visible';d('nextLink').onclick=function(){eval('opener.showPhoto("'+nextRef.getElementsByTagName('img')[0].src.replace('thumb_','')+'",window.nextRef);')};}else{d('nextLink').style.visibility='hidden';}

d('originalImage').style.position='relative';

//d('originalImage').style.top=d('slideShowControls').offsetHeight+'px';

//window.resizeBy(0,d('slideShowControls').offsetHeight);

setSlideshowPrefs(true);

}

// show slideshow caption info

function showCaption(mode){

var show='hidden';

if(mode){show='visible';}

try{d('captionCell').style.visibility=show;}catch(error){}

}

// handle keyboard actions

function handleKeys(e){

if(isIE5||isIE55up){var kc=e.keyCode;}else{var kc=e.charCode;}

if(window.prevRef){if(kc==45||kc==49||kc==129){eval('opener.showPhoto("'+prevRef.getElementsByTagName('img')[0].src.replace('thumb_','')+'",window.prevRef);')}}

if(window.nextRef){if(kc==43||kc==32||kc==50||kc==120){eval('opener.showPhoto("'+nextRef.getElementsByTagName('img')[0].src.replace('thumb_','')+'",window.nextRef);')}}

}

// set and display slideshow preferences

function setSlideshowPrefs(init){

try{

var cbPermanentDisplay=d('cbPermanentDisplay');

var cbFullscreen=d('cbFullscreen');

var cbBlackBack=d('cbBlackBack');

var expiryDate=new Date(); expiryDate.setTime(expiryDate.getTime()+Math.round(86400000*365));

if(init) // if we are in init mode, try to read cookies

	{

	if(window.cookiesEnabled)

		{

		var cbPermanentDisplayState=getCookie('cbPermanentDisplay');

			if(cbPermanentDisplayState==null){setCookie('cbPermanentDisplay',0,expiryDate,'/','','');cbPermanentDisplayState=0;}

			if(cbPermanentDisplayState==1){cbPermanentDisplay.checked=true;}

		var cbFullscreenState=getCookie('cbFullscreen');

			if(cbFullscreenState==null){setCookie('cbFullscreen',0,expiryDate,'/','','');cbFullscreenState=0;}

			if(cbFullscreenState==1){cbFullscreen.checked=true;}

		var cbBlackBackState=getCookie('cbBlackBack');

			if(cbBlackBackState==null){setCookie('cbBlackBack',0,expiryDate,'/','','');cbBlackBackState=0;}

			if(cbBlackBackState==1){cbBlackBack.checked=true;}

		}

	}

// handle BlackBack

if(cbBlackBack.checked)

	{

	document.body.style.backgroundColor='black'; if(window.cookiesEnabled){setCookie('cbBlackBack',1,expiryDate,'/','','');}

	}else{

	document.body.style.backgroundColor=''; if(window.cookiesEnabled){setCookie('cbBlackBack',0,expiryDate,'/','','');}

	}

// handle permanent display

if(cbPermanentDisplay.checked)

	{

	d('captionCell').style.visibility='visible';

	d('slideShowControls').onmouseout=null;

	if(window.cookiesEnabled){setCookie('cbPermanentDisplay',1,expiryDate,'/','','');}

	}else{

	d('slideShowControls').onmouseout=function(){showCaption(false);}

	if(window.cookiesEnabled){setCookie('cbPermanentDisplay',0,expiryDate,'/','','');}

	}

// handle full screen display

if(cbFullscreen.checked)

	{

	window.fullscreen=true; showPhoto_scaleWindow();

	if(window.cookiesEnabled){setCookie('cbFullscreen',1,expiryDate,'/','','');}

	}else{

	window.fullscreen=false; showPhoto_scaleWindow();

	if(window.cookiesEnabled){setCookie('cbFullscreen',0,expiryDate,'/','','');}

	}

}catch(error){window.setTimeout("setSlideshowPrefs();",250);}

}



// fade out forum tram

// id=object id, mode=true||false, step=start opacity, endVal=end opacity

function transFade(id,mode,step,endVal){

var tt=d(id);

if(isIE55up)

	{

	tt.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+step+')';

	if(step==100){tt.style.filter='';}

	}else{

	tt.style.opacity=step/100;

	tt.style.KhtmlOpacity=step/100;

	tt.style.MozOpacity=step/100;

	}

if(mode){step=step+1;}else{step=step-1;}

if(mode&&step<endVal+1)

	{

	window.setTimeout("transFade('"+id+"',true,"+step+","+endVal+");",1);

	}

if(!mode&&step>endVal)

	{

	window.setTimeout("transFade('"+id+"',false,"+step+","+endVal+");",1);

	if(step==endVal+1){tt.style.visibility='hidden';}

	}

}



// init navigation table

function initNavTable(){

var allLinks=d('tbNav').getElementsByTagName('a');

for(var i=0;i<allLinks.length;i++)

	{

	allLinks[i].onmouseover=function()

		{

		this.parentNode.parentNode.style.backgroundColor='#f0f0f0';

		}

	allLinks[i].onmouseout=function()

		{

		this.parentNode.parentNode.style.backgroundColor='';

		}

	}

}



// check if forum is available; if not, display error message

function checkForum(){

if(d('boardLinks').innerHTML=='')

	{

	d('boardLinks').innerHTML='<center><img src="img/warning.gif"></center><br>Das <strong>Forum</strong> ist wegen einer technischen St&ouml;rung derzeit leider nicht oder nur eingeschr&auml;nkt verf&uuml;gbar!<br><br>';

	d('spLastUpdate0').innerHTML='Die Update-Information ist im Augenblick leider nicht verfügbar.';

	d('spLastUpdate1').innerHTML='';

	d('spLastUpdate2').innerHTML='';

	}

}



// reformat input elements

function reformatInputs(){

var allInp=document.getElementsByTagName('input');

for(var i=0;i<allInp.length;i++)

	{

	if(allInp[i].type=='text'){allInp[i].className='input_text';}

	if(allInp[i].type=='checkbox'){allInp[i].className='input_checkbox';}

	if(allInp[i].type=='radio'){allInp[i].className='input_radio';}

	if(allInp[i].type=='submit'||allInp[i].type=='button'||allInp[i].type=='reset'){allInp[i].className='input_button';}

	}

allInp=document.getElementsByTagName('textarea');

for(i=0;i<allInp.length;i++)

	{

	allInp[i].className='input_textarea';

	}

allInp=document.getElementsByTagName('select');

for(i=0;i<allInp.length;i++)

	{

	allInp[i].className='input_button';

	allInp[i].style.height='auto';

	}

}



// date countdown

 // Ziel-Datum in MEZ

      var jahr=2007, monat=10, tag=17, stunde=0, minute=0, sekunde=0;

      var zielDatum=new Date(jahr,monat-1,tag,stunde,minute,sekunde);



      function countdown() {

		//parent.window.DATETIME_LOCAL='2007/06/03 12:00:00';



		startDatum=new Date();



        // Countdown berechnen und anzeigen, bis Ziel-Datum erreicht ist

        if(startDatum<zielDatum)  {



          var jahre=0, monate=0, tage=0, stunden=0, minuten=0, sekunden=0;



          // Jahre

          while(startDatum<zielDatum) {

            jahre++;

            startDatum.setFullYear(startDatum.getFullYear()+1);

          }

          startDatum.setFullYear(startDatum.getFullYear()-1);

          jahre--;



          // Monate

          while(startDatum<zielDatum) {

            monate++;

            startDatum.setMonth(startDatum.getMonth()+1);

          }

          startDatum.setMonth(startDatum.getMonth()-1);

          monate--;



          // Tage

          while(startDatum.getTime()+(24*60*60*1000)<zielDatum) {

            tage++;

            startDatum.setTime(startDatum.getTime()+(24*60*60*1000));

          }



          // Stunden

          stunden=Math.floor((zielDatum-startDatum)/(60*60*1000));

          startDatum.setTime(startDatum.getTime()+stunden*60*60*1000);



          // Minuten

          minuten=Math.floor((zielDatum-startDatum)/(60*1000));

          startDatum.setTime(startDatum.getTime()+minuten*60*1000);



          // Sekunden

          sekunden=Math.floor((zielDatum-startDatum)/1000);



          // Anzeige formatieren

          var html='Nur noch<br><br><span style="font-size:12px;font-weight:bold;">';

		  if(jahre==1){html+=jahre+' Jahr<br>';}

		  if(jahre!=1&&jahre>0){html+=jahre+' Jahre<br>';}

		  if(monate==1){html+=monate+' Monat<br>';}

		  if(monate!=1&&monate>0){html+=monate+' Monate<br>';}

		  if(tage==1){html+=tage+' Tag<br>';}

		  if(tage!=1&&tage>0){html+=tage+' Tage<br>';}

		  if(stunden==1){html+=stunden+' Stunde<br>';}

		  if(stunden!=1&&stunden>0){html+=stunden+' Stunden<br>';}

		  if(minuten==1){html+=minuten+' Minute<br>';}

		  if(minuten!=1&&minuten>0){html+=minuten+' Minuten<br>';}

		  if(sekunden==1){html+=sekunden+' Sekunde<br>';}

		  if(sekunden!=1&&sekunden>0){html+=sekunden+' Sekunden<br>';}



		  html+='</span><br>bis zum <b>17. Oktober</b>, dem offiziellen Anlieferungs-Datum der ersten Niederflur-Straßenbahn!';



          d('dvCountdown').innerHTML=html;



          setTimeout('countdown()',1000);

        }

        // Anderenfalls alles auf Null setzen

        else d('dvCountdown').innerHTML="<b>Am 17. Oktober vormittags ist die erste Niederflur-Straßenbahn angeliefert worden.</b><br><br>Alle Fotos und Infos bei den <a href=news.html>News</a>!";

      }



// show/hide loading indicator

function loadingIndicator(){try{

var loadInd=d('loadInd');

var scrollT=document.body.scrollTop; var scrollL=document.body.scrollLeft;

var wW=document.body.clientWidth; var wH=document.body.clientHeight;

if(isSafari){scrollT=window.pageYOffset;scrollL=window.pageXOffset;wH=window.innerHeight;wW=window.innerWidth;}

loadInd.style.left=((wW/2+scrollL)-55)+'px';

loadInd.style.top=((wH/2+scrollT)+50)+'px';

if(window.loading)

  {

  loadInd.style.display='block';

	} else {

	loadInd.style.display='none';

	}

}catch(error){}

window.setTimeout("loadingIndicator();",1000);

}

loadingIndicator();



// open article in news roundup

function showRoundupArticle(obj,mode){

if(!mode||mode==undefined)

  {

  d('roundup_'+obj.name).className='firstletter';

  obj.innerHTML=obj.innerHTML.replace('&gt;','&lt;');

  obj.onclick=function()

    {

    showRoundupArticle(obj,true);

    }

  }else{

  d('roundup_'+obj.name).className='firstletter roundup';

  obj.innerHTML=obj.innerHTML.replace('&lt;','&gt;');

  obj.onclick=function()

    {

    showRoundupArticle(obj);

    }

  }

}



// auto-open news roundup article when local anchor found in hash

function autoShowRoundupArticle(){try{

var l=location.hash;

var anchor=l.substring(l.indexOf('#')+1,l.length);

var allAs=document.getElementsByTagName('a');

var obj=false; var thisHref='';

for(var i=0;i<allAs.length;i++)

  {

  thisHref=allAs[i].href;

  if(thisHref.substring(thisHref.indexOf('#'),thisHref.length)=='#'+anchor&&(allAs[i].parentNode&&allAs[i].parentNode.className=='roundupbody'))

    {

    obj=allAs[i];

    }

  }

if(obj)

  {

  showRoundupArticle(obj);

  }else{

  window.setTimeout("autoShowRoundupArticle()",1000);

  }

}catch(error){ }}

if((location.href.indexOf('resources_')!=-1||location.href.indexOf('news_')!=-1)&&location.hash.indexOf('#')!=-1)

  {

  autoShowRoundupArticle();

  }

  

// show/hide dead links on press page

function toggleZombies(obj){

if(obj.checked)

  {

  press_Generate(true);

  }else{

  press_Generate(false);

  }

}
