

if(lang=='en'){

	label_stunde = 'hour';

	label_stunden = 'hours';	

	label_tag = 'day';

	label_tage = 'days';	

	label_uhr = "";

	end = '_e';

}else{

	label_stunde = 'Stunde';

	label_stunden = 'Stunden';		

	label_tag = 'Tag';

	label_tage = 'Tage';

	label_uhr = "Uhr";	

	end = '';

}



	

	var tarife = {

		typ1 : {

			minimalsatz: 1.70,

			stundensatz: 2.20,

			tagessatz:  18.90,

			tagessatz5: 18.90,

			tagessatz15:18.90,

			tagessatz22:18.90,			

			tagessatz29:18.90,
			
      tagessatz93:18.90			



			},

		typ2 : {

			minimalsatz: 1.40,

			stundensatz: 2.20,

			tagessatz:  14.60,

			tagessatz5:  8.00,

			tagessatz15: 5.90,

			tagessatz22: 3.70,			

			tagessatz29: 3.70,
			
      tagessatz93: 14.60	

		},

		typ3 : {

			minimalsatz: 1.40,

			stundensatz: 2.10,

			tagessatz:  11.30,

			tagessatz5:  5.90,

			tagessatz15: 4.20,

			tagessatz22: 2.70,			

			tagessatz29: 2.20,
			
      tagessatz93:11.30			

		},

		

		berechneStundensatz:function(stunden,typ){

				if(stunden==1){

					return this['typ'+typ].minimalsatz;					

				}

				if(stunden>1){

					_satz = this['typ'+typ].minimalsatz + (this['typ'+typ].stundensatz * (stunden-1)); 

					

					if(_satz > this['typ'+typ].tagessatz){

						return this['typ'+typ].tagessatz;

					}else{

						return _satz;

					}

				}



			},

		

		berechneTagessatz:function(tage,typ){

				if(tage<5){
					return this['typ'+typ].tagessatz * tage;					
				}

				if(tage<15){
					return this['typ'+typ].tagessatz * 4 + (this['typ'+typ].tagessatz5 * (tage-4)) ;										
				}

				if(tage<22){
					return this['typ'+typ].tagessatz * 4 + (this['typ'+typ].tagessatz5 * 10) +  (this['typ'+typ].tagessatz15 * (tage-14)) ;										
				}

				if(tage<29){
					return this['typ'+typ].tagessatz * 4 + (this['typ'+typ].tagessatz5 * 10) +  (this['typ'+typ].tagessatz15 * 7) + (this['typ'+typ].tagessatz22 * (tage-21)) ;										
				}

				if(tage<93){
					return this['typ'+typ].tagessatz * 4 + (this['typ'+typ].tagessatz5 * 10) +  (this['typ'+typ].tagessatz15 * 7) + (this['typ'+typ].tagessatz22 * 7) + (this['typ'+typ].tagessatz29 * (tage-28)) ;										
				}




				if(tage>=93){

					return this['typ'+typ].tagessatz * 4 + (this['typ'+typ].tagessatz5 * 10) + (this['typ'+typ].tagessatz15 * 7) + (this['typ'+typ].tagessatz22 * 7) + (this['typ'+typ].tagessatz29 * 64) + (this['typ'+typ].tagessatz93 * (tage-92)) ;										

				}



				

					

			}

				

	}









//alert(tarife.berechneTagessatz(10,1))



function getPrice(sel,typ){

	

	if(sel.options[sel.selectedIndex].value == 'add'){

		opt = new Option(parseInt(sel.options[sel.selectedIndex-1].text)+1 + ' Tage');

		sel_temp = sel.options[sel.selectedIndex];

		sel.options[sel.options.length-1]=opt;	

		sel.options[sel.options.length]=sel_temp;

		sel.options[sel.selectedIndex-1].selected = true;

		

	}



	zeitraum = sel.options[sel.selectedIndex].text;



	erg=0;

	result = 'Der Preis betr&auml;gt <b>&euro;';	

	var anz = parseInt(zeitraum);	

	if(zeitraum.match(/Stunde/)){

		erg = tarife.berechneStundensatz(anz,typ);

	}else{

		erg = tarife.berechneTagessatz(anz,typ);

	}

	if($('erm') && $('erm').checked){

		erg = erg - erg/10;	

	}

	//alert(erg)

	erg = number_format(erg,2,',','.');	



	result += erg;

	

	$('result_'+typ).innerHTML = result;

}





















































function init_price(){

	for(var i=1;i<=3;i++){

		getPrice($('auswahl_'+i),i)

	}

}











function /*out: String*/ number_format( /* in: float   */ number, 

                                        /* in: integer */ laenge, 

                                        /* in: String  */ sep, 

                                        /* in: String  */ th_sep ) {



  number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);

  str_number = number+"";

  arr_int = str_number.split(".");

  if(!arr_int[0]) arr_int[0] = "0";

  if(!arr_int[1]) arr_int[1] = "";

  if(arr_int[1].length < laenge){

    nachkomma = arr_int[1];

    for(i=arr_int[1].length+1; i <= laenge; i++){  nachkomma += "0";  }

    arr_int[1] = nachkomma;

  }

  if(th_sep != "" && arr_int[0].length > 3){

    Begriff = arr_int[0];

    arr_int[0] = "";

    for(j = 3; j < Begriff.length ; j+=3){

      Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);

      arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";

    }

    str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));

    arr_int[0] = str_first + arr_int[0];

  }

  return arr_int[0]+sep+arr_int[1];

}









function showList(sele){

//	alert($(sele).selectedIndex)	

	

	ar_sele = sele.split(/_/);

	nr = ar_sele[1];	

	if(nr==1){

		titel ='Kurzzeitparkpl&auml;tze (P1,P2) ';

		bgcol = '#F12919';

	}else if(nr==2){

		titel='Parkhaus (P4) ';

		bgcol = '#078641';		

	}else if(nr==3){

		titel='Dauerparkpl&auml;tze (P3,P5,P7) ';	

		bgcol = '#078641';

	}else{

		titel='No titel ';	

	}



list = window.open('','list'+nr,'width=300,height=640,scrollbars=yes,status=yes')





//headerbereich





list.document.writeln('<style>BODY,TD,TH{font-family:verdana;font-size:12px;margin:0;padding:0}TABLE{border:1px solid '+bgcol+'};TD{padding-left:16px;padding-top:3px;padding-bottom:3px;} </style>');

list.document.writeln('<center><table cellpadding=0 cellspacing=0 width="100%"><caption>PARKTARIFE SALZBURG AIRPORT</caption><tr><th colspan="2" style="color:white;background-color:' + bgcol + '">' + titel + '</th></tr>');





//stunden ausgeben

if(nr==1){stunden=9}else{stunden=7}



for(var z=1;z<=stunden;z++){

	if(z>1){mz='n'}else{mz=''}

	anz = z;

	if(anz==9 && nr==1){anz= '9-24'}

	if(anz==7 && nr>1){anz= '9-24'}

	list.document.writeln('<tr><td>'+ anz +' Stunde' +  mz +  '</td><td>&euro; ',number_format(tarife.berechneStundensatz(z,nr),2,',','.'),'</td></tr>');

}





//tage ausgeben

if(nr>1){

	selindex = $(sele).selectedIndex;

	tage=21;

	if(selindex>13){

	tage = selindex-6;

	}

	for(var z=1;z<=tage;z++){

		if(z>1){mz='e'}else{mz=''}

		//list.document.writeln(z,': ',number_format(tarife.berechneTagessatz(z,nr),2,',','.'),'<br>');

		list.document.writeln('<tr><td>'+ z +' Tag' +  mz +  '</td><td>&euro; ',number_format(tarife.berechneTagessatz(z,nr),2,',','.'),'</td></tr>');

	}

}







list.document.writeln('</table><div style="text-align:right"><a href="javascript:print()">drucken</a> | <a href="javascript:close()">schlie&szlig;en</a>');

list.document.close();



}





function posMe(pic,x,y){

	offset=0;

	scal = 1.175;

	x = parseInt(x/scal)

	y = parseInt(y/scal)





	pic.parentNode.style.left= x+offset + 'px';

	pic.parentNode.style.top = y + 'px';

	

		

//	alert(pic.parentNode.style.left)



}





function anim(str){

	arPlabels = ['p1_1','p1_2','p2','p3','p5','p7','parkhaus']

	arLabels = str.split(',');



	for(var j=0; j<arPlabels.length; j++){		

		

		$(arPlabels[j]).src='http://www.salzburg-airport.com/pics/' + arPlabels[j] + end +'.gif';	

	}		

	

	for(var i=0; i<arLabels.length; i++){



		



		$(arLabels[i]).src='http://www.salzburg-airport.com/pics/' + arLabels[i] + '_anim' + end + '.gif';		

	}









}









//parameters Date A Date B

//return differnce in days / Hours

function getDiffDate(dateA,dateB,format){



	sec  = 1000;

	min  = 60*sec;

	hour = 60*min;

	days = 24*hour;

	

	msA = dateA.getTime();

	msB	= dateB.getTime();	

	

	msDiff = msB - msA;

	

	if(format == 'sec'){

		return msDiff/sec;

	}else if(format == 'min'){

		return msDiff/min;	

	}else if(format == 'hour'){

		return msDiff/hour;	

	}else{

		return msDiff/days;	

	}



}







function getTimeOpt(select){



	str='';

	for(i=0;i<24;i++){

		

		if(i>9){space=' '; }else{space=' '; }

		if(select == i){sel='selected';}else{sel='';}

		if(lang){

			if(i>12){ampm = i-12; label_uhr='p.m.'}else{ampm = i;label_uhr='a.m.'}

			if(ampm>9){space=''; }else{space='&nbsp;'; }



			str+= '<option ' +  sel + ' value="' + i + '">'+ space +  ampm   +' ' + label_uhr + ' </option>';

		}else{

			str+= '<option ' +  sel + ' value="' + i + '">'+  i   +' ' + label_uhr + ' </option>';

		}

	}

	

	return str;



}













function getDate(days){

	

	if(!days){days=0}

	milliseconds = new Date().getTime() + (days*1000*60*60*24);

	if(lang=='en'){

		weekdays = ['Su','Mo','Tu','We','Th','Fr','Sa'];

	}else{

		weekdays = ['So','Mo','Di','Mi','Do','Fr','Sa'];

	}

	today    = new Date(milliseconds);

	weekday  = today.getDay();

	day      = today.getDate();

	if(day<10){day = '0' + day}

	month    = today.getMonth()+1;

	if(month<10){month = '0' + month}	

	year     = today.getFullYear();





	return weekdays[weekday] + ', ' + day + '.' + month + '.' + year;





}









function getPrices(){



	reduction = false;

	if($('erm').checked){reduction=true;}

	arVon = $('datum_von').value.split(/[\.,]/)

	arBis = $('datum_bis').value.split(/[\.,]/)



	arBis[2] = arBis[2].replace(/^0/,'');

	arBis[1] = arBis[1].replace(/^0/,'');

	arVon[2] = arVon[2].replace(/^0/,'');

	arVon[1] = arVon[1].replace(/^0/,'');

	

	arBis[2]--;

	arVon[2]--;

	

	//alert(arVon[3]+ ' - ' +arVon[2]+ ' - ' +arVon[1]+ ' - ' +$('zeit_von').value+ ' - ' + " 0,0,0 \n" + arBis[3]+ ' - ' +arBis[2]+ ' - ' +arBis[1]+ ' - ' +$('zeit_bis').value+ ' - ' + " 0,0,0 \n" )



	b = new Date(arBis[3],arBis[2],arBis[1],$('zeit_bis').value,0,0,0);

	a = new Date(arVon[3],arVon[2],arVon[1],$('zeit_von').value,0,0,0);

	

	//alert(a + "\n" + b)



	stunden = (getDiffDate(a,b,'hour')>1)?label_stunden:label_stunde;



	//Typ1

	result_hours = getDiffDate(a,b,'hour'); 



	//if(result_hours>23){result_hours=24}

	if(result_hours>24){

		$('kurz_tab').style.display = 'none';		

	}else{

		$('kurz_tab').style.display = 'block';		

		price1 = tarife.berechneStundensatz(result_hours,1)

		if(typeof(price1)=='number'){

			if(reduction){price1 = price1 - (price1/10);}

			price1 = number_format(price1,2,',','.');

		}

		$('typ1').innerHTML = result_hours + ' '+ stunden +' -> <b>&euro;' + price1 + '</b>';;	

	}





	//Typ2 und Typ3

	if(getDiffDate(a,b,'hour')<=24){

		price2 = tarife.berechneStundensatz(getDiffDate(a,b,'hour'),2);

		if(typeof(price2)=='number'){

			if(reduction){price2 = price2 - (price2/10);}

			price2 = number_format(price2,2,',','.');

		}

		$('typ2').innerHTML = getDiffDate(a,b,'hour') + ' '+ stunden +' -> <b>&euro;' + price2 + '</b>';;	





		price3 = tarife.berechneStundensatz(getDiffDate(a,b,'hour'),3);

		if(typeof(price3)=='number'){

			if(reduction){price3 = price3 - (price3/10);}

			price3 = number_format(price3,2,',','.');

		}				

		$('typ3').innerHTML = getDiffDate(a,b,'hour') + ' '+ stunden +' -> <b>&euro;' + price3 + '</b>';;	

	}else{

		tage = (getDiffDate(a,b,'days')>1)?label_tag:label_tage;

		stunden = (getDiffDate(a,b,'days')>1)?label_stunden:label_stunde;



		result_days = parseInt(getDiffDate(a,b,'days'));

		result_hours = parseInt(getDiffDate(a,b,'hour'));		

		restwert = result_hours%24;

		result_days = parseInt(result_hours/24);			



		

		price2h=0;

		if(restwert){

				price2h = tarife.berechneStundensatz(result_hours%24,2);
        
				price2h=price2h+0.8;
        if(result_days > 91){        
          if(price2h > 14.6){price2h = 14.6}        
        }else if(result_days > 27){
          if(price2h > 3.7){price2h = 3.7}				
        }else if(result_days > 20){
					if(price2h > 3.7){price2h = 3.7}
				}else if(result_days > 13){
					if(price2h > 5.9){price2h = 5.9}				
				}else if(result_days > 3){
					if(price2h > 8.0){price2h = 8.0}				
				}else if(result_days > 0){
					if(price2h > 14.6){price2h = 14.6}				
				}

		}		

		//alert(result_days + '   '+ price2h)

		price2d = tarife.berechneTagessatz(result_days,2);

		price2 = price2h + price2d; 

		//alert(price2h + '   '+ price2d)

		if(typeof(price2)=='number'){

			if(reduction){price2 = price2 - (price2/10);}

			price2 = number_format(price2,2,',','.');

		}



		tage = (result_days>1)?label_tag:label_tage;

		stunden = (restwert!=1)?label_stunden:label_stunde;



		$('typ2').innerHTML = result_days + ' '+ tage +' ' + restwert + ' ' + stunden  + ' -> <b>&euro;' + price2 + '</b>';	







		price3h=0;

		if(restwert){

			price3h = tarife.berechneStundensatz(result_hours%24,3);

				price3h=price3h+0.7;

        if(result_days > 91){        
          if(price3h > 11.3){price3h = 11.3}        
        }else if(result_days > 27){
          if(price3h > 2.2){price3h = 2.2}				
        }else if(result_days > 20){
					if(price3h > 2.7){price3h = 2.7}
				}else if(result_days > 13){
					if(price3h > 4.2){price3h = 4.2}				
				}else if(result_days > 3){
					if(price3h > 5.9){price3h = 5.8}				
				}else if(result_days > 0){
					if(price3h > 11.3){price3h = 11.3}				
				}

			

		}		

		price3d = tarife.berechneTagessatz(result_days,3);

		price3 = price3h + price3d;	



		//price3 = tarife.berechneTagessatz(result_days,3);

		if(typeof(price3)=='number'){

			if(reduction){price3 = price3 - (price3/10);}

			price3 = number_format(price3,2,',','.');

		}				

		tage = (result_days>1)?label_tag:label_tage;

		stunden = (restwert!=1)?label_stunden:label_stunde;

		$('typ3').innerHTML = result_days + ' '+ tage +' ' + restwert + ' ' + stunden +' -> <b>&euro;' + price3 + '</b>';	



	}



	if($('typ1').innerHTML.indexOf('undefined')>-1){$('typ1').innerHTML = '---'}

	if($('typ2').innerHTML.indexOf('undefined')>-1){$('typ2').innerHTML = '---'}

	if($('typ3').innerHTML.indexOf('undefined')>-1){$('typ3').innerHTML = '---'}



}









