/////////////////////////////////////////////////
// save the form in the AutoComplete data store
function subForm(f)
{

	if (parent.ITPContent == null)
		return;

	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.efaform;
	}


	//x=window.navigator.plugins.length;
	//alert(x);

	//if(window.external) window.external.AutoCompleteSaveForm(f);

	//version=0;
	//if (navigator.appVersion.indexOf("MSIE")!=-1) {
	//	temp=navigator.appVersion.split("MSIE");
	//	version = parseFloat(temp[1]);
	//}

	//if (version>=5) {
	//	window.external.AutoCompleteSaveForm(f);
	//}

	f.submit();
}
////////////////////////////////////////////////
// submit when enter key
function checkReturnKey(f)
{
	if (window.event && window.event.keyCode==13)
	{
		if(document.forms.efaform.execInst && document.forms.efaform.nameState_destination && !(document.forms.efaform.nameState_origin.value!='identified' || document.forms.efaform.nameState_destination.value!='identified'))
			document.forms.efaform.execInst.value='normal';
		preSubmit();
		subForm(f);
	}
	return true;
}

////////////////////////////////////////////////
// train and S-Bahn must have the same value
function preSubmit()
{
	if (document.forms.efaform.execInst && document.forms.efaform.nameState_destination && !(document.forms.efaform.nameState_origin.value!='identified' || document.forms.efaform.nameState_destination.value!='identified'))
		document.forms.efaform.execInst.value = 'normal';

	if (document.forms.efaform.exclMOT_0)
	{
		if (document.forms.efaform.exclMOT_0.checked == true)
		{
			document.forms.efaform.SBahn.value=1;
			document.forms.efaform.SBahn.name = 'exclMOT_1';
		}
	}
	if (document.forms.efaform.inclMOT_0)
	{
		if (document.forms.efaform.inclMOT_0.checked == true)
		{
			document.forms.efaform.SBahn.value=1;
			document.forms.efaform.SBahn.name = 'inclMOT_1';
		}
	}
}

///////////////////////////////////////////////
// button up and down from date
function dateUpDown(upOrDown)
{
	var tag;
	var monat;
        var jahr;

        tag = document.forms.efaform.itdDateDay.value;
        monat = document.forms.efaform.itdDateMonth.value;
        jahr = document.forms.efaform.itdDateYear.value;

        var jahrIntWert = parseInt(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.efaform.itdDateDay.value = tag;
        document.forms.efaform.itdDateMonth.value = monat;
        document.forms.efaform.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.efaform.itdTimeHour.value = hour;
	document.forms.efaform.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.efaform.itdDateYear.value = year;
	document.forms.efaform.itdDateMonth.value = month;
	document.forms.efaform.itdDateDay.value = date;
}

/////////////////////////////////////////////////////////////////////////////////////////
// close Java Applet and open XSLT Map
function openXSLTMapFormJavaApplet()
{
	if (window.opener)
	{
		window.opener.document.forms.efaform.itdLPxx_java.value='0';
		window.opener.document.forms.efaform.command.value="mapRequest_" + window.opener.odvMapRequest.mapUsage ;
		window.opener.document.forms.efaform.submit();
	}
	window.close()
}
