//////////////////////////////////////////////////
//	Linz AG JavaScript			//
//////////////////////////////////////////////////

/////////////////////////////////////////////////
// save the form in the AutoComplete data store
function subForm(f)
{
	
	if (f == "f1") {
		// f = parent.ITPContent.f1;
		f = parent.ITPContent.document.getElementById("f1");
	}
	else if (f == "f2") {
		// f = parent.ITPContent.f2;
		f = parent.ITPContent.document.getElementById("f2");
	}		
	else {
		f = parent.ITPContent.document.forms[0];
	}

	version=0;
	if (navigator.appVersion.indexOf("MSIE")!=-1) {
		temp=navigator.appVersion.split("MSIE");
		version=parseFloat(temp[1]);
	}
	
	if (version>=5 && 
	    window.external && 
	    typeof window.external.AutoCompleteSaveForm === 'function') {
	    window.external.AutoCompleteSaveForm(f);
	}

	f.submit();
}

////////////////////////////////////////////////
// submit when enter key 
function checkReturnKey(f)
{
	if (window.event && window.event.keyCode==13)
	{
		document.forms[0].execInst.value='normal';
		preSubmit();
		subForm(f);
	}
	return true;
}

////////////////////////////////////////////////
// train and S-Bahn must have the same value
function preSubmit()
{
	if (document.forms[0].inclMOT_5)
	{
		if (document.forms[0].inclMOT_5.checked == true)
		{
			document.forms[0].Regionalbus.value=1;
			document.forms[0].Regionalbus.name = 'inclMOT_6';
			document.forms[0].Schnellbus.value=1;
			document.forms[0].Schnellbus.name = 'inclMOT_7';
		}
	}
	if (document.forms[0].inclMOT_11)
	{
		if (document.forms[0].inclMOT_11.checked == true)
		{
			document.forms[0].Zug.value=1;
			document.forms[0].Zug.name = 'inclMOT_0';
			document.forms[0].SBahn.value=1;
			document.forms[0].SBahn.name = 'inclMOT_1';
			document.forms[0].UBahn.value=1;
			document.forms[0].UBahn.name = 'inclMOT_2';
			document.forms[0].StadtBahn.value=1;
			document.forms[0].StadtBahn.name = 'inclMOT_3';
			document.forms[0].Seilbahn.value=1;
			document.forms[0].Seilbahn.name = 'inclMOT_8';
			document.forms[0].Schiff.value=1;
			document.forms[0].Schiff.name = 'inclMOT_9';
		}
	}
}

///////////////////////////////////////////////
// button up and down from date
function dateUpDown(upOrDown) { 
	var tag;
	var monat;
	var jahr;

	tag = document.forms[0].itdDateDay.value;
	monat = document.forms[0].itdDateMonth.value;
	jahr = document.forms[0].itdDateYear.value;

	var jahrIntWert = parseFloat(jahr);

	if (jahrIntWert >= 0 && jahrIntWert <= 75)
	{ jahrIntWert = 2000 + jahrIntWert; }
	else
	{
	    if (jahrIntWert > 75 && jahrIntWert <= 99)
	    { jahrIntWert = 1900 + jahrIntWert; }
	}

	monat = monat - 1;  

	heute = new Date(jahrIntWert, monat, tag);
	var millisecunden = heute.getTime();

	if (upOrDown == 'up')
	{ millisecunden = millisecunden + (24*60*60*1000); }

	if (upOrDown == 'down' )
	{ millisecunden = millisecunden - (24*60*60*1000); }

	heute.setTime(millisecunden);

	tag = heute.getDate();
	if (tag > 0 && tag < 10)
	{ tag = "0"+tag; }

	monat = heute.getMonth() + 1;
	if (monat > 0 && monat < 10)
	{ monat = "0"+monat; }

	jahr = "" + heute.getFullYear();
	jahr = jahr.substr(2,2);

	document.forms[0].itdDateDay.value = tag;
	document.forms[0].itdDateMonth.value = monat;
	document.forms[0].itdDateYear.value = jahr;
}

////////////////////////////////////////////////
// return formated time
function showtime1( hour, minute )
{
	if (hour < 10) {
		hour = "0" + hour;
	}
	else {
		hour = hour;
	}
	if (minute < 10) {
		minute = "0" + minute;
	}
	else {
		minute = minute;
	}

	document.forms[0].itdTimeHour.value = hour;
	document.forms[0].itdTimeMinute.value = minute;

}

////////////////////////////////////////////////
// return formated date
function showdate1( year, month, date )
{
	if (date < 10){
		date = "0" + date;
	}
	else {
		date = date;
	}
	if (month < 10){
		month = "0" + month;
	}
	else {
		month = month;
	}

	if (year < 10){
		year = "0" + year;
	}
	else {
		year = "" + year;
		year = year.substr(2,2);
	}

	document.forms[0].itdDateYear.value = year;
	document.forms[0].itdDateMonth.value = month;
	document.forms[0].itdDateDay.value = date;
}
