//The contents of this file is released into the Public Domain

var codemap = new Array();

codemap['S'] = new Array();
codemap['S']['desc'] = 'Situation';
codemap['S']['f'] = 'organic farm';
codemap['S']['g'] = 'house with garden';
codemap['C'] = new Array();
codemap['C']['desc'] = 'We are';
codemap['C']['f'] = 'family';
codemap['C']['c'] = 'community';
codemap['C']['i'] = 'individuals';
codemap['N'] = new Array();
codemap['N']['desc'] = 'Number of';
codemap['N']['a'] = 'adults';
codemap['N']['c'] = 'children';
codemap['A'] = new Array();
codemap['A']['desc'] = 'Accommodation';
codemap['A']['d'] = 'dormitory';
codemap['A']['r'] = 'individual rooms';
codemap['A']['c'] = 'camping';
codemap['A']['v'] = 'caravan';
codemap['K'] = new Array();
codemap['K']['desc'] = 'Can Accommodate Children';
codemap['K']['y'] = 'yes';
codemap['K']['n'] = 'no';
codemap['K']['a'] = 'by arrangement';
codemap['P'] = new Array();
codemap['P']['desc'] = 'Location';
codemap['P']['t'] = 'in a town';
codemap['P']['h'] = 'near other houses';
codemap['P']['i'] = 'not near other houses';
codemap['T'] = new Array();
codemap['T']['desc'] = 'Getting There';
codemap['T']['n'] = 'need own transport';
codemap['T']['t'] = 'can collect at train station';
codemap['T']['f'] = 'accessible by foot';
codemap['W'] = new Array();
codemap['W']['desc'] = 'Work With';
codemap['W']['g'] = 'gardens';
codemap['W']['a'] = 'animals';
codemap['W']['w'] = 'woods';
codemap['W']['t'] = 'alternative technologies';
codemap['W']['c'] = 'children';
codemap['W']['b'] = 'building';
codemap['L'] = new Array();
codemap['L']['desc'] = 'Languages Spoken';
codemap['L']['d'] = 'Dutch';
codemap['L']['c'] = 'Chinese';
codemap['L']['e'] = 'English';
codemap['L']['f'] = 'French';
codemap['L']['g'] = 'German';
codemap['L']['i'] = 'Italian';
codemap['L']['j'] = 'Japanese';
codemap['L']['p'] = 'Portugese';
codemap['L']['s'] = 'Spanish';
codemap['L']['w'] = 'Swedish ';
codemap['D'] = new Array();
codemap['D']['desc'] = 'Diet';
codemap['D']['t'] = 'vegetarian OK';
codemap['D']['n'] = 'vegan OK';
codemap['D']['s'] = 'self catering ';
codemap['G'] = new Array();
codemap['G']['desc'] = 'Can Provide';
codemap['G']['c'] = 'clothes / boots';
codemap['G']['t'] = 'tents';
codemap['G']['b'] = 'bikes';
codemap['X'] = new Array();
codemap['X']['desc'] = 'Prohibitions';
codemap['X']['s'] = 'no smokers (in house)';
codemap['X']['a'] = 'no alcohol';
codemap['H'] = new Array();
codemap['H']['desc'] = 'Hours per Day';
codemap['Y'] = new Array();
codemap['Y']['desc'] = 'Days per Week';
codemap['M'] = new Array();
codemap['M']['desc'] = 'Minimum Stay (Weeks)';
codemap['Z'] = new Array();
codemap['Z']['desc'] = 'Maximum Stay (Weeks)';
codemap['B'] = new Array();
codemap['B']['desc'] = 'Months Most Needed';
codemap['E'] = new Array();
codemap['E']['desc'] = 'Months NOT Needed';

function parselegend(l,s) {
	var o = '<html><head><title>WWOOF Legend';
	o += '</title></head><body><div style="font-weight:bold;font-size:120%;">WWOOF Legend'
	if (s != null) o += ' for host : '+s;
	o += '</div><table border=1>';
	var tokens = l.split('');
	var c = null;
	for (var i = 0; tokens.length > i; i++) {
		var t = tokens[i];

		if (codemap[t] != null) {
			if (c != null) o+= '</td></tr>';
			c = t;
			o += '<tr><td><i>'+codemap[t]['desc']+' :</i></td><td> ';
			cspc = ' '
		} else if (codemap[c] != null && codemap[c][t] != null) {
			o += cspc + codemap[c][t];
			cspc = ', ';
		} else {
			o += ' ' + t;
		}
	}
	o += '</td></tr></table><div align="center" style="padding-top: 1em"><button onclick="window.close()">Close</button></body></html>';
	var w = window.open("javascript:'"+o+"'", 'legend', 'status=1,width=500,height=550');
}

