// JavaScript Document

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
	var obj = MM_findObj(objName);
	if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}
	}
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}



//**********************BERECHNUNG DER ZEIT - MUSS AUF JEDE SEITE !***********

function datum() {
	jetzt = new Date();
	tag = jetzt.getDate();
	monat = jetzt.getMonth();
	monat++;
	jahr = jetzt.getFullYear();
	stunde = jetzt.getHours();
	minute = jetzt.getMinutes();
	if(minute < 15) {
		minute = "00";
	} else if (minute < 30) {
		minute="15";
	} else if (minute < 45) {
		minute="30";
	} else {
		minute="45";
	}
	if (document.form11.VON_DATUM)
		document.form11.VON_DATUM.value = tag+"."+monat+"."+jahr;
	if (document.form11.VON_ZEIT)
		document.form11.VON_ZEIT.value = stunde+":"+minute;
}

//*******************************************************************************

function checkme() { // Filter für keine Eingabe an ASS - by C.S.

	// DE
	if (document.form11.STARTGEMEINDE &&
		document.form11.STARTGEMEINDE.value == "Ort")
		document.form11.STARTGEMEINDE.value = "";
	if (document.form11.START.value &&
		document.form11.START.value== "Haltestelle bzw. Adresse")
		document.form11.START.value = "";
	if (document.form11.ZIELGEMEINDE &&
		document.form11.ZIELGEMEINDE.value == "Ort")
		document.form11.ZIELGEMEINDE.value = "";
	if (document.form11.ZIEL.value &&
		document.form11.ZIEL.value == "Haltestelle bzw. Adresse")
		document.form11.ZIEL.value = "";
	// EN
	if (document.form11.STARTGEMEINDE.value == "place")
		document.form11.STARTGEMEINDE.value = "";
	if (document.form11.START.value == "stop")
		document.form11.START.value = "";
	if (document.form11.ZIELGEMEINDE.value == "place")
		document.form11.ZIELGEMEINDE.value = "";
	if (document.form11.ZIEL.value == "stop")
		document.form11.ZIEL.value = "";

	// ??
	if (document.form11.SGE &&
		document.form11.SGE.value == "Ort")
		document.form11.SGE.value = "";
	if (document.form11.SHS &&
		document.form11.SHS.value == "Haltestelle bzw. Adresse")
		document.form11.SHS.value = "";
	if (document.form11.ZGE &&
		document.form11.ZGE.value == "Ort")
		document.form11.ZGE.value = "";
	if (document.form11.ZHS &&
		document.form11.ZHS.value == "Haltestelle bzw. Adresse")
		document.form11.ZHS.value = "";
}
function killtext(k) {
	if (k==1 && document.form11.STARTGEMEINDE.value == "Ort")
		MM_changeProp('STARTGEMEINDE','','value','','INPUT/TEXT');
	if (k==2 && document.form11.START.value == "Haltestelle bzw. Adresse")
		MM_changeProp('START','','value','','INPUT/TEXT');
	if (k==3 && document.form11.ZIELGEMEINDE.value == "Ort")
		MM_changeProp('ZIELGEMEINDE','','value','','INPUT/TEXT');
	if (k==4 && document.form11.ZIEL.value == "Haltestelle bzw. Adresse")
		MM_changeProp('ZIEL','','value','','INPUT/TEXT');
}

//v2ScScript
var fenster_von_openWindow = null;
function openWindow(url, w, h, windowname) {

	if (windowname == '' || windowname == 'undefined') {
		windowname = "popup";
	}

	if (fenster_von_openWindow == null ) {
		fenster_von_openWindow = window.open(url, windowname, "width="+w+",height="+h+",scrollbars=yes, resizable=yes" );
		fenster_von_openWindow.focus()
		//window.open("/vrm/popup.html", "Fahrplanauskunft", "width=600,height=400,scrollbars=no, resizable=no" );
	} else {
		if (fenster_von_openWindow.closed ) {
			fenster_von_openWindow = window.open(url, windowname, "width="+w+",height="+h+",scrollbars=yes, resizable=yes" );
			fenster_von_openWindow.focus()
			//window.open("/vrm/popup.html", "Fahrplanauskunft", "width=600,height=400,scrollbars=no, resizable=no" );
		}
	}
}

//v2ScScript
var fenster = null;
function go(links, w, h, types) {

	if ( fenster == null ) {
		fenster = window.open("", "Ergebnis", "width="+w+",height="+h+",scrollbars=yes, resizable=yes" );
		fenster.focus()
		//window.open("/vrm/popup.html", "Fahrplanauskunft", "width=600,height=400,scrollbars=no, resizable=no" );
	} else {
		if ( fenster.closed ) {
			fenster = window.open("", "Ergebnis", "width="+w+",height="+h+",scrollbars=yes, resizable=yes" );
			fenster.focus()
			//window.open("/vrm/popup.html", "Fahrplanauskunft", "width=600,height=400,scrollbars=no, resizable=no" );
		}
	}
	/*
	// PopUp für die Fahrplanauskunft
	if ((typeof links) == 'string' && links.search(/.+assRoute\.cgi/) > -1) {
		var Fahrplanauskunft = window.open("/vrm/popup.html", "Fahrplanauskunft", "width=600,height=400,scrollbars=no, resizable=no" );
		Fahrplanauskunft.focus();
	}
	*/

	if (types == 1) {
		document.form1.target = "Ergebnis";
		document.form1.action = links;
		document.form1.submit();
		document.form1.action = "javascript:go()";
		document.form1.target = "_self";
		//document.location.reload();
	}

	if (types == 2) {
		document.form22.target = "Ergebnis";
		document.form22.action = links;
		document.form22.submit();
		document.form22.action = "javascript:go()";
		document.form22.target = "_self";
		//document.location.reload();
	}

	if (types == 3) {
		document.form11.target = "Ergebnis";
		document.form11.action = links;
		document.form11.submit();
		document.form11.action = "javascript:go()";
		document.form11.target = "_self";
		//document.location.reload();
	}
}

var fenster2 = null;
function goo(links, w, h, types) {
	if ( fenster2 == null ) {
		fenster2 = window.open("", "Hinweis", "width="+w+",height="+h+",scrollbars=yes, resizable=yes" );
	} else {
		if ( fenster.closed ) {
			fenster2 = window.open("", "Hinweis", "width="+w+",height="+h+",scrollbars=yes, resizable=yes" );
		} else {
			fenster2.focus();
		}
	}

	if (types == 1) {
		document.form1.target="Hinweis";
		document.form1.action=links;
		document.form1.submit();
		document.form1.action="javascript:go()";
		document.form1.target="_self";
		document.location.reload();
	}

	if (types == 2) {
		document.form22.target="Hinweis";
		document.form22.action=links;
		document.form22.submit();
		document.form22.action="javascript:go()";
		document.form22.target="_self";
		document.location.reload();
	}

	if (types == 3) {
		document.form11.target="Hinweis";
		document.form11.action=links;
		document.form11.submit();
		document.form11.action="javascript:go()";
		document.form11.target="_self";
		document.location.reload();
	}
}

function toggleDebug(id) {
	var elem = document.getElementById(id);
	//alert(elem);
	if (elem) {
		if (elem.className == 'aus') {
			elem.className = 'ein';
		} else {
			elem.className = 'aus';
		}
	}
	return false;
}



