var ttCMmatchingAirports = {"":"beliebig","-1":"beliebig","5000":"Nord","5001":"Sued","5002":"West","5003":"Ost","0":"Altenburg-Nobitz","1":"Amsterdam (NL)","3":"Basel-Mulhouse (CH)","4":"Berlin-Schoenefeld","5":"Berlin-Tegel","94":"Billund (DK)","8":"Bremen","9":"Bruessel (B)","10":"Dortmund","11":"Dresden","12":"Duesseldorf","73":"Eindhoven (NL)","13":"Enschede (NL)","14":"Erfurt","15":"Frankfurt","16":"Frankfurt-Hahn","17":"Friedrichshafen","18":"Genf (CH)","19":"Graz (A)","81":"Groningen (NL)","20":"Hamburg","21":"Hannover","23":"Innsbruck (A)","24":"Karlsruhe","27":"Klagenfurt (A)","28":"Koeln-Bonn","29":"Leipzig/Halle","30":"Linz (A)","31":"Luebeck","32":"Luettich (B)","33":"Luxemburg","34":"Maastricht - Aachen (NL)","90":"Memmingen","36":"Muenchen","37":"Muenster-Osnabrueck","49":"Niederrhein (Weeze)","38":"Nuernberg","39":"Paderborn","40":"Rostock","41":"Saarbruecken","42":"Salzburg (A)","43":"Schwerin","44":"Strasbourg (F)","45":"Stuttgart","77":"Warschau (PL)","46":"Wien (A)","47":"Zuerich (CH)","48":"Zweibruecken"};

var ttCMmatchingDuration = {''     : 'beliebig',
							'-1'   : 'beliebig',
							'9'    : '1 - 4 Tage',
							'10'   : '5 - 8 Tage',
							'6_7'  : '1 Woche',
							'7'    : '9 - 12 Tage',
							'3'    : '13 - 15 Tage',
							'6_14' : '2 Wochen',
							'12'   : '16 - 22 Tage',
							'6_21' : '3 Wochen',
							'13'   : '> 22 Tage',
							'6_1'  : '1 Tag',
							'6_2'  : '2 Tage',
							'6_3'  : '3 Tage',
							'6_4'  : '4 Tage',
							'6_5'  : '5 Tage',
							'6_6'  : '6 Tage',
							'6_8'  : '8 Tage',
							'6_9'  : '9 Tage',
							'6_10' : '10 Tage',
							'6_11' : '11 Tage',
							'6_12' : '12 Tage',
							'6_13' : '13 Tage',
							'6_15' : '15 Tage',
							'6_16' : '16 Tage',
							'6_17' : '17 Tage',
							'6_18' : '18 Tage',
							'6_19' : '19 Tage',
							'6_20' : '20 Tage',
							'6_22' : '22 Tage'
							};
var ttCMmatchingRooms    = {"":"egal","-1":"egal","5":"Einzelzimmer","6":"Doppelzimmer","2":"Familienzimmer","0":"Bungalow","7":"Apartment","-2":"weitere Zimmertypen"};
var ttCMmatchingBoard    = {"":"egal","-1":"egal","0":"nur Uebernachtung","1":"Fruehstueck","2":"Halbpension","3":"Vollpension","4":"All Inclusive","5":"Vollpension Plus","6":"Halbpension Plus","7":"All Inclusive Plus"};
var ttCMmatchingCategory = {'1':'1','1.0':'1','1.5':'1.5','2':'2','2.0':'2','2.5':'2.5','3':'3','3.0':'3','3.5':'3.5','4':'4','4.0':'4','4.5':'4.5','5':'5','5.0':'5','5.5':'5.5','6':'6','6.0':'6','6.5':'6.5'}

function tt2cm(type,value) {
	switch (type) {
		case "airport":
			if (engine == 'erde') {
				matchedValue = 'null';
			} else {
			 	matchedValue = ttCMmatchingAirports[value];
			}
			
			break;
		case "date":
			tmpDate = new Date(value * 1000);
			tmpDay = tmpDate.getDate(); tmpMonth = tmpDate.getMonth()+1;
			tmpDay = (tmpDay < 10) ? "0" + tmpDay : tmpDay;
			tmpMonth = (tmpMonth < 10) ? "0" + tmpMonth : tmpMonth;
			matchedValue = tmpDate.getFullYear()+''+tmpMonth+''+tmpDay;
			break;
		case "duration":
			matchedValue = ttCMmatchingDuration[value];
			break;
		case "category":
		    /*
		    matchedValue = (value+2) + " Sterne";
		    */
			if (value >= 0) {
		        matchedValue = (value + 2) + " Sterne";    
		    } else {
		        matchedValue = "egal";
		    }
			break;
        case "category2":
            if (value == -1 || value == "") {
				$matchedValue = 'beliebig';
			}
			else {
				matchedValue = ttCMmatchingCategory[value] + ((parseInt(value) == 1) ? ' Stern' : ' Sterne');
			}
            break;
		case "travellers":
			tmpTravellers = value.split(";");
			adults = 0; children = 0;
			child = new Array();
			for (i = 0; i < tmpTravellers.length; i++) {
			    if (tmpTravellers[i] < 0) continue;
				if (tmpTravellers[i] != '' && tmpTravellers[i] > 16) {
				    adults++;
				} else if (tmpTravellers[i] != '' && tmpTravellers[i] <= 16 ) {
					children++
					child.push(tmpTravellers[i]);
				}
			}
			matchedValue = adults + " Erwachsene(r)" + ", " + children + " Kind(er) (" + child.join(", ") + " Jahre)";
			break;
		case "room":
			if (value >= 0) {
			    matchedValue = ttCMmatchingRooms[value];
			} else {
			    matchedValue = "egal";
			}
			break;
		case "board":
			if (value >= 0) {
			    matchedValue = ttCMmatchingBoard[value];
			} else {
			    matchedValue = "egal";
			}
			break;

	}
	if (matchedValue > " ") return matchedValue;
	else return "("+value+")";
}
