// trimString start
function trimString( val ){
	var a = 0;
	var e = val.length - 1;
	while( val.charAt(a) == " " && a < e ){ a++; }
	if ( a >= e ) return ""
	while( val.charAt(e) == " " && a < e ){ e--; }	
	return val.substring(a, e + 1);
}
// trimString end

function doSubmit(){
	var f=document.formular
	f.suche.value=trimString(f.suche.value)
	if(f.suche.value==""){
		f.suche.value="Außer Betrieb"
	} else {
		f.submit()
	}
}
// highlighting Images 001010(dr)
// Determine browser.
var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;

var highlightSuffix = "_hl"
var statusSuffix = "_hl"
var gesetztesHighlight = new String()

if (typeof startHighlight != "undefined") gesetztesHighlight = startHighlight
	
var statusHighlight = true
var debug = false
// bis hier anpassbar
var haveImages = document.images
var allGraphicsLoaded = false
var pictureArray = new Array()
var statusArray = new Array()
var highlighted = new String()

var status_lowlight = "lowlight"
var status_highlight = "highlight"
var status_status = "status"

function HighlightedPicture(src, suffix, obj, status){
	if (status) 
		this.status = status
	else
		this.status = status_lowlight
	this.Image = obj
	this.Lowlight = new Image()
	this.Lowlight.src = src + "." + suffix
	this.Highlight = new Image()
	this.Highlight.src = src + highlightSuffix + "." + suffix
	this.Status = new Image()
	if (statusHighlight){
		this.Status.src = src + statusSuffix + "." + suffix
	}
}
function initImageHighlight(){
	if (haveImages){
    	var s = new String()
        var src = new String()
        var suffix = new String()
        loadAllImages( document )
        allGraphicsLoaded = true
        if ( gesetztesHighlight != "" ) 
			pressed( gesetztesHighlight )
	}
}
function loadAllImages( doc ){
 	preloadingImages( doc )
	if (isMinNS4){
		for (var i = 0; i < doc.layers.length; i++){
			if (typeof doc.layers[i].document != "undefined")			
				loadAllImages( doc.layers[i].document );
		}
	}
}
function preloadingImages( doc ){
	for (var i=0; i < doc.images.length; i++){
		s = doc.images[i].name
		if (s.length > 0){
			var status = status_lowlight
			src = doc.images[i].src
			suffix = src.substring(src.length - 3, src.length).toLowerCase()			
			if ( src.indexOf( highlightSuffix + "." ) != -1 ){
				src = src.substring(0, src.length - 4 - highlightSuffix.length )
				status = status_status
			} else if ( src.indexOf( statusSuffix + "." ) != -1 ){
				src = src.substring(0, src.length - 4 - statusSuffix.length )
				status = status_status
			} else {
				src = src.substring(0, src.length - 4)
			}
			pictureArray[ s ] = new HighlightedPicture(src, suffix, doc.images[i], status)
		}
	}
}
function changeImage( name, what ){
	if ( !allGraphicsLoaded ) return
	var src = new String()
	var imgObj = pictureArray[name]
	if ( typeof pictureArray[name] == "undefined" ) return
	
	if ( what == status_highlight ){
		if (pictureArray[ name ].status == status_highlight) return
       	src = pictureArray[ name ].Highlight.src
	} else {
		if ( what != status_status ){
			src = pictureArray[ name ].Lowlight.src
		} else {
			if (statusHighlight){
				src = pictureArray[ name ].Status.src
			}
		}
	}	
	pictureArray[ name ].Image.src = src
	pictureArray[ name ].status = what
}
// public Methods
// highlight, lowlight, pressed
function pressed( name ){
	if (name == highlighted) return
   	var tmp = highlighted
	if (statusHighlight) 
		changeImage( name, status_status )
	else
		changeImage( name, status_highlight )
    highlighted = name
    if ( tmp != "" ){
    	changeImage( tmp, status_lowlight )
	}
}
function lowlight( name ){
	if ( !allGraphicsLoaded ) return
	if ( pictureArray[name].status == status_status ) return
	changeImage( name, status_lowlight )
}
function highlight( name ){
	if ( !allGraphicsLoaded ) return
	if ( pictureArray[name].status == status_status ) return
	changeImage( name, status_highlight )
}
// highlighting Images	

//Default browsercheck, added to all scripts!
// browsercheck
function checkBrowser(){
	this.ver 	= navigator.appVersion;
	this.agent 	= navigator.userAgent;
	this.dom 	= document.getElementById ? 1 : 0;
	this.ie5 	= (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0;
	this.ie6 	= (this.ver.indexOf("MSIE 6") > -1 && this.dom) ? 1 : 0;
	this.ie4 	= (document.all && !this.dom) ? 1 : 0;
	this.ie 	= this.ie4 || this.ie5 || this.ie6;
	this.mac 	= this.agent.indexOf("Mac") > -1;
	this.opera5 = this.agent.indexOf("Opera 5") > -1;
	this.ns6 	= (this.dom && parseInt(this.ver) >= 5) ? 1 : 0; 
	this.ns4 	= (document.layers && !this.dom) ? 1 : 0;
	this.bw 	= (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.dom);
	return this
}
// Making browsercheck object
var bw = new checkBrowser();

if (bw.ns4) {
	window.onresize=ReloadThisPage
	origWidth  = window.innerWidth;
	origHeight = window.innerHeight;
}
function ReloadThisPage() {
	if (origWidth == window.innerWidth && origHeight == window.innerHeight)
    	return;
	window.location.href = window.location.href;
}

function openWindow( url, winname, width, height, left, top ) {
	var trails = "toolbar=yes,directories=yes,status=yes,scrollbars=yes,resizable=yes,menubar=yes,location=yes";
	if (width) trails += ",width=" + width;
	if (height) trails += ",height=" + height;
	if (left) trails += ",left=" + left;
	if (top) trails += ",top=" + top;
	if (!winname) winname = "UseAlwaysThisWindow"
	newWindow = window.open( url, winname, trails);
}
function timedOpenWindow( sekunden, url, winname, width, height, left, top) {
	setTimeout("openWindow('"+url+"', '"+winname+"', "+width+", "+height+", "+left+", "+top+")", sekunden * 1000)
}
