/*	javascript functions for bus.strassenbahn.tk
	author: manni@manni.org
	please credit the author when re-using any script or concept
	version 3.311, 2010-08-28
*/

/*
- 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.domain='strassenbahn.tk';}catch(error){}

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

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

function getElementsByClass(thetagname,theclassname){
  var allTags=document.getElementsByTagName(thetagname.toLowerCase());
  var takenTags=new Array(); var ac=0;
  for(var i=0;i<allTags.length;i++)
    {
     if(allTags[i].className==theclassname)
      {
       takenTags[ac]=allTags[i];
       ac++;
      }
    }
  return takenTags;
}

// 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('imap')==-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 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 1')==-1&&navigator.userAgent.indexOf('Opera/1')==-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('bus/')!=-1||location.href.indexOf('http://forum.strassenbahn.tk')!=-1)&&location.href.indexOf('http')!=-1){absPrefix='http://bus.strassenbahn.tk/inntram/bus/';}
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 Netscape 7.2, Mozilla 1.5 oder neuer, oder Firefox 0.9.3 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 5 oder neuer (nur Windows), Opera 7 oder neuer, alle Gecko-basierten Browser (z.B. Mozilla ab 1.5, Netscape ab 7.2) 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\">");
}

// if the browser window is too small, stretch it to the minimum size, but only in the frameset page
if(location.href.indexOf('index.html')!=-1)
	{
	keepMinSize();
	}
function keepMinSize(){
if(document.body)
	{
	if(document.body.clientWidth<790){window.resizeBy(10,0);}
	if(document.body.clientHeight<240){window.resizeBy(0,10);}
	}
window.setTimeout("keepMinSize();",150);
}

// 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&&location.href.indexOf('imap.html')==-1)
	{
	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.html')==-1&&location.href.indexOf('showphoto.html')==-1&&location.href.indexOf('schwarzhai')==-1)
			{
			if(cookiesEnabled())
				{
				setCookie('redirectionURL',location.href);
				}
			if(location.href.indexOf('http://forum.strassenbahn.tk')!=-1)
			 {
			 top.location.replace('http://bus.strassenbahn.tk/inntram/bus/neu_index.html');
       }else{
			 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
	{
	top.main.location.href=redirectionURL;
	} catch (error) {
	window.setTimeout("redirectContent_execute('"+redirectionURL+"');",250);
	}
}

// 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" style="width:9px;display:inline;float:none;border:none;height:8px;padding:0;margin: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" class="e" style="width:9px;display:inline;float:none;border:none;height:8px;padding:0;margin: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" style="width:9px;display:inline;float:none;border:none;height:8px;padding:0;margin: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,camRefresh){
var urlPrefix='';
if(camRefresh){camRefresh='?camrefresh';}else{camRefresh='';}
window.showPhoto_imageURL=imageURL;
if(!parent.parent.suppressScriptPicLoader)
	{
	var originalImageWindow=window.open("showphoto.html"+camRefresh,"Foto","toolbar=0,status=1,menubar=0,location=0,resizable=1,scrollbars=1,height=680,width=840");
	try{originalImageWindow.moveTo(0,0);}catch(error){}
	} else {
	window.open(imageURL);
	}
}

// Scale the full view window to the image's size
//
// Used in myImages
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;}
if(validSize)
	{
	// get the screen dimensions
	var screenWidth=window.screen.width;
	var screenHeight=window.screen.height;
	// size corrections
	width=width+40;height=height+80;
	// if the image is bigger than the screen, equal the window size with the screen size
	if(width>screenWidth){width=screenWidth;}
	if(height>screenHeight){height=screenHeight;}
	// resize the window
	window.resizeTo(width,height);
	if(d('loading')){getRidOfElement(1,'loading');} // fade loading message out
	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(){
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) {}
	}
}

function markTdIfLocalTargetInHash_execute(counter,id){
var flashCell=d(id);
if(counter==0){flashCell.style.backgroundColor='#CDD6FF';}
if(counter==1){flashCell.style.backgroundColor='';}
counter++;
if(counter==2){counter=0;}
window.setTimeout("markTdIfLocalTargetInHash_execute("+counter+",'"+id+"');",500);
}

// 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;
}

// 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);
	}
}

// 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>');}
}

// load the given section's thumbnails&acute; (only works with current tn table structure!)
function loadThumbnails(obj){
obj.style.display='none';
if(isIE5||isIE55up){obj.nextSibling.style.display='inline';}
if(isGecko||isOpr){obj.nextSibling.nextSibling.style.display='inline';}
var tn=document.getElementsByTagName('IMG');
var thisSectionId=obj.parentNode.id;
for(var tnc=0; tnc<tn.length; tnc++)
	{
	if (tn[tnc].parentNode.parentNode.parentNode.parentNode.parentNode.id==thisSectionId)
		{
		tn[tnc].src=tn[tnc].src.substring(tn[tnc].src.indexOf('?')+1,tn[tnc].src.length);
		}
	}
}

// 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
	{
	if(window.frames.mainframe.main.document.title&&window.frames.mainframe.main.document.title!='')
		{
		document.title=window.frames.mainframe.main.document.title;
		}
	}catch(error)
	{
	try
		{
		document.title='www.strassenbahn.tk - Gegenwart und Zukunft von Innsbrucks Bussen';
		}catch(error){}
	}
window.setTimeout("setTitle();",500);
}

// 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()",250);
}

// Append date tooltip to photos on photo page
function datePhotos(execute){
if(document.body&&document.body.innerHTML)
	{
	if(execute)
		{
		var thisDate='';
		var allPhotos=document.getElementsByTagName('img');
		for(var i=0;i<allPhotos.length;i++)
			{
			if(allPhotos[i].src.indexOf('photos/')!=-1&&allPhotos[i].onmouseover==null)
				{
				allPhotos[i].onmouseover=function()
					{
					var thisDate=this.src.substring(this.src.lastIndexOf('/')+1,this.src.length).replace('thumb_','').replace('.jpg','');
					thisDate='Bildinformation: '+thisDate.substring(0,thisDate.length);
stm(['',thisDate],['#ffad98','#ffad98','#ffad98','#ffede8','','','','','','','','','','','','',1,2,10,10,5,0.25,'','','']);
					}
				allPhotos[i].onmouseout=htm;
				}
			}
		}else{window.setTimeout("datePhotos(true);",1000);}
	}else{window.setTimeout("datePhotos();",250);}
}
if(location.href.indexOf('photos.html')!=-1||location.href.indexOf('photomuseum.html')!=-1){datePhotos();}

function displayAnchorLinks(){
if(document.body&&document.body.innerHTML&&window.pageLoaded)
	{
	if(d('anchorLinks'))
		{
		var aColl=document.getElementsByTagName('a');
		var anchorLinks='';
		var linkColl='';
		for(var i=0;i<aColl.length;i++)
			{
			if(aColl[i].name!='')
				{
				anchorLinks+='<a href="#'+aColl[i].name+'">'+aColl[i].parentNode.getElementsByTagName('p')[0].innerHTML+'</a><br>';
				}
			}
		d('anchorLinks').innerHTML='<b>Inhalt:</b><br>'+anchorLinks;
		d('anchorLinks').className='parablock';
		}
	} else {
	window.setTimeout("displayAnchorLinks();",250);
	}
}
displayAnchorLinks();

// --- BEGIN FORUM VERSION SCRIPTING ---

if(location.href.indexOf('/mobile/')!=-1){
// ---                               ---
window.isBusPage=true;

function youTubize(){try{
var allParas=getElementsByClass('td','bp');
var yt='';
var embedcode='<object width="300" height="243"><param name="movie" value="###EMBEDCODE###"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="###EMBEDCODE###" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="300" height="243"></embed></object>';
var repcode='';
for(var i=0;i<allParas.length;i++)
  {
  while(allParas[i].innerHTML.indexOf('[youtube]')!=-1)
    {
    yt=allParas[i].innerHTML.substring(allParas[i].innerHTML.indexOf('[youtube]'),allParas[i].innerHTML.indexOf('[/youtube]')+10);
    allParas[i].innerHTML=allParas[i].innerHTML.replace(yt,embedcode.replace('###EMBEDCODE###',yt.replace('[youtube]','').replace('[/youtube]','').replace('/watch?v=','/v/')).replace('###EMBEDCODE###',yt.replace('[youtube]','').replace('[/youtube]','')).replace('/watch?v=','/v/'));
    }
  }
}catch(error){}}

function unborderSmileys(){try{
var allImgs=document.getElementsByTagName('img');
for(var i=0;i<allImgs.length;i++)
  {
  if(allImgs[i].src.indexOf('/images/smiles/')!=-1)
    {
    allImgs[i].style.border=0;
    }
  }

}catch(error){}}

// --- END FORUM VERSION SCRIPTING ---
}
// ---                             ---

