
function upd_tt( pvobj )
{
	pvobj.src='./img/info_down.png';
	document.getElementById( pvobj.id + 'tt' ).style.visibility = 'visible';
	document.getElementById( pvobj.id + 'tt' ).style.top = ( 504 - document.getElementById( pvobj.id + 'tt' ).height );
}
function unl_tt( pvobj )
{
	pvobj.src='img/info.png';
	document.getElementById( pvobj.id + 'tt' ).style.visibility = 'hidden';
}
function upd_ora_tt()
{
	with( document.forms[ 0 ] )
	{
		i0.src='./img/info_down.png';
		i0tt.style.visibility = 'visible';
		i0tt.style.top = ( 515 - i0tt.height );
	}
}
function unl_ora_tt()
{
	with( document.forms[ 0 ] )
	{
		i0.src='./img/info.png';
		i0tt.style.visibility = 'hidden';
	}
}
function submitForm() 
{
	if( !checkComp() )
		return false;
	else
		document.forms[0].submit();
	return
}

function isEmpty( obj )
{
	if ( obj == "" || obj == null || obj == " " )
		return true;
	else
		return false;
}

function checkComp() 
{
     with( document.forms[0] )
	 {
		if( isEmpty( Company.value ) || isEmpty( ContactPerson.value ) || isEmpty( Street ) || isEmpty( PLZ ) || isEmpty( City ) || isEmpty( Phone.value ) )
		{
			alert( "Mindestens ein Pflichtfeld wurde nicht ausgefüllt!" );
			return false;
		}
		else if( isEmpty( eMail.value ) || eMail.value.indexOf('@') == -1 || eMail.value.indexOf('.') == -1 || eMail.value.length < 7 ) 
		{
			alert("Bitte geben sie eine gültige E-Mail-Adresse ein!");
			eMail.focus();
			return false;
		}
	 }
     return true;
}

function offer()
{
	with( document.forms[ 0 ] )
		window.location.href = 'offer.htm?pl=' + dd_pl.options[ dd_pl.selectedIndex ].value + '&ct=' + dd_ct.options[ dd_ct.selectedIndex ].value + '&bi=' + dd_bi.options[ dd_bi.selectedIndex ].innerHTML + '&si=' + dd_si.options[ dd_si.selectedIndex ].value;
}

function calcu()
{
	window.location.href = 'calc.htm?pl=' + dd_pl.selectedIndex + '&ct=' + dd_ct.selectedIndex + '&bi=' + dd_bi.selectedIndex + '&si=' + dd_si.selectedIndex;
}

function recal()
{
	var val = new Array();
	with( document.forms[ 0 ] )
	{
		val[ 0 ] = dd_pl.options[ dd_pl.selectedIndex ].value;
		val[ 1 ] = dd_ct.options[ dd_ct.selectedIndex ].value;
		val[ 2 ] = dd_bi.options[ dd_bi.selectedIndex ].value;
		val[ 3 ] = dd_si.options[ dd_si.selectedIndex ].value;
	}
	recalc( val );
}

function recalc( pvArr )
{
	var cost;
	pvArr[ 2 ] = pvArr[ 2 ].indexOf( 'm' ) > -1 ? 'm' : 'y';
	var seats		= pvArr[ 0 ];
	var time		= pvArr[ 1 ];
	var billTime	= pvArr[ 2 ];
	var train		= pvArr[ 3 ];
	var training = new Array()
	training[ 'muc' ] = 990.00;
	training[ 'cus' ] = 1990.00;
	var costBasic = new Array();
	costBasic[ 'y12' ] = 599.00;
	costBasic[ 'y24' ] = 569.00;
	costBasic[ 'y36' ] = 529.00;
	costBasic[ 'm12' ] = 59.00;
	costBasic[ 'm24' ] = 55.00;
	costBasic[ 'm36' ] = 53.00;
	var seatAdd = new Array();
	seatAdd[ 'y12' ] = 100.00;
	seatAdd[ 'y24' ] = 100.00;
	seatAdd[ 'y36' ] = 100.00;
	seatAdd[ 'm12' ] = 10.00;
	seatAdd[ 'm24' ] = 10.00;
	seatAdd[ 'm36' ] = 10.00;

	cost = costBasic[ pvArr[ 2 ] + pvArr[ 1 ] ] + ( seatAdd[ pvArr[ 2 ] + pvArr[ 1 ] ] * ( seats -= 1 ) );

	document.forms[ 0 ].cs_tr.value = makePr( training[ train ] );
	document.getElementById( 'monYea' ).innerHTML = billTime == 'm' ? 'Monat' : 'Jahr';
	document.forms[ 0 ].rn_cs.value = makePr( cost );
}

function args() 
{
  var erg = new Array();
  var arg = new Array();
  var location = window.location.search;
	   
	if ( location.length > 0 ) 
	{
		location = location.substr( 1, location.length - 1 );
		erg = location.split( "&" );

		for ( i = 0; i < erg.length; i++ ) 
		{
			var x = new Array();
			x = erg[ i ].split( "=" );
			document.getElementById( 'dd_' + x[ 0 ] ).selectedIndex =  x[ 1 ];
			arg[ i ] = document.getElementById( 'dd_' + x[ 0 ] ).options[ document.getElementById( 'dd_' + x[ 0 ] ).selectedIndex ].value;
		}
		recalc( arg );
	}
	else 
	{
		arg[ 0 ] = false;
		recal();
	}
}

function setArgs() 
{
  var erg = new Array();
  var arg = new Array();
  var val = new Array();
  var location = window.location.search;
	if ( location.length > 0 ) 
	{
		location = location.substr( 1, location.length - 1 );
		erg = location.split( "&" );

		for ( i = 0; i < erg.length; i++ ) 
		{
			var x = new Array();
			x = erg[ i ].split( "=" );
			val[ i ] = x[ 1 ];
			if ( x[ 0 ].indexOf( 'c' ) > -1 )
				document.getElementById( x[ 0 ] ).value = x[ 1 ] + ' Monate';
			else if ( x[ 0 ].indexOf( 's' ) > -1 )
				document.getElementById( x[ 0 ] ).value = ( x[ 1 ].indexOf( 'cus' ) > -1  ? 'vor Ort' : 'München' );
			else
				document.getElementById( x[ 0 ] ).value = x[ 1 ];
		}
	}
	recalc( val );
}

function makePr( pvVar )
{
	if ( !pvVar.isNaN )
	{
		pvVar = Math.round( pvVar * 100 ) / 100;
		if ( pvVar.toString().indexOf( '.' ) == -1 )
			return pvVar.toString() + ',00';
		else if ( pvVar.toString().indexOf( '.' ) == pvVar.toString().length - 3 )
			return pvVar.toString().replace( '.', ',' );
		else if ( pvVar.toString().indexOf( '.' ) == pvVar.toString().length - 2 )
			return pvVar.toString().replace( '.', ',' ) + '0';
	}
}


