var searchOptions = {
	
	curRangeId: "",
	curRangeOptions: new Object(),
	rangeOptions: new Object(),
	
	selectRange: function(id) {
		this.curRangeId = id;
		if(id=="0") return;
		for(var rangeId in this.rangeOptions) {
			if(rangeId==id) {
				this.curRangeOptions = this.rangeOptions[id];
				break;
			}
		}
		this.checkRangeOptions();
	},
	
	checkRangeOptions: function() {
		var opt = this.curRangeOptions;

		
		// languages
		var languages = opt["languages"].split("|");
		var found_language = false;
		for(var i = 0; i<languages.length; i++) {
			var l = languages[i];
			if(document.getElementById('languages_'+l).checked) {
				found_language = true;
				break;
			}
		}
		if(!found_language) {
			for(var i = 0; i<languages.length; i++) {
				var l = languages[i];
				document.getElementById('languages_'+l).checked = true;
			}
		}

		// formats
		var formats = opt["formats"].split("|");
		var found_format = false;
		for(var i = 0; i<formats.length; i++) {
			var f = formats[i];
			if(document.getElementById('formats_'+f).checked) {
				found_format = true;
				break;
			}
		}
		if(!found_format) {
			for(var i = 0; i<formats.length; i++) {
				var f = formats[i];
				document.getElementById('formats_'+f).checked = true;
			}
		}
	},
	
	init: function() {
		this.rangeOptions["group:1"] = new Object();
		this.rangeOptions["group:1"]["offline_only"] = false;
		this.rangeOptions["group:1"]["languages"] = "german";
		this.rangeOptions["group:1"]["formats"] = "html|pdf";
		this.rangeOptions["group:3"] = new Object();
		this.rangeOptions["group:3"]["offline_only"] = false;
		this.rangeOptions["group:3"]["languages"] = "german|english|french";
		this.rangeOptions["group:3"]["formats"] = "mp3";
		this.rangeOptions["group:2"] = new Object();
		this.rangeOptions["group:2"]["offline_only"] = false;
		this.rangeOptions["group:2"]["languages"] = "german";
		this.rangeOptions["group:2"]["formats"] = "pdf|print";
		this.rangeOptions["group:4"] = new Object();
		this.rangeOptions["group:4"]["offline_only"] = false;
		this.rangeOptions["group:4"]["languages"] = "english";
		this.rangeOptions["group:4"]["formats"] = "print";
		this.rangeOptions["group:5"] = new Object();
		this.rangeOptions["group:5"]["offline_only"] = false;
		this.rangeOptions["group:5"]["languages"] = "english";
		this.rangeOptions["group:5"]["formats"] = "html";
		this.rangeOptions["group:6"] = new Object();
		this.rangeOptions["group:6"]["offline_only"] = false;
		this.rangeOptions["group:6"]["languages"] = "french";
		this.rangeOptions["group:6"]["formats"] = "html";
		this.rangeOptions["site:1"] = new Object();
		this.rangeOptions["site:1"]["offline_only"] = false;
		this.rangeOptions["site:1"]["languages"] = "german";
		this.rangeOptions["site:1"]["formats"] = "html|pdf";
		this.rangeOptions["site:2"] = new Object();
		this.rangeOptions["site:2"]["offline_only"] = false;
		this.rangeOptions["site:2"]["languages"] = "german|english|french";
		this.rangeOptions["site:2"]["formats"] = "mp3";
		this.rangeOptions["site:3"] = new Object();
		this.rangeOptions["site:3"]["offline_only"] = false;
		this.rangeOptions["site:3"]["languages"] = "german";
		this.rangeOptions["site:3"]["formats"] = "pdf|print";
		this.rangeOptions["site:4"] = new Object();
		this.rangeOptions["site:4"]["offline_only"] = false;
		this.rangeOptions["site:4"]["languages"] = "german";
		this.rangeOptions["site:4"]["formats"] = "print";
		this.rangeOptions["site:5"] = new Object();
		this.rangeOptions["site:5"]["offline_only"] = false;
		this.rangeOptions["site:5"]["languages"] = "german";
		this.rangeOptions["site:5"]["formats"] = "html";
		this.rangeOptions["site:6"] = new Object();
		this.rangeOptions["site:6"]["offline_only"] = false;
		this.rangeOptions["site:6"]["languages"] = "german";
		this.rangeOptions["site:6"]["formats"] = "print";
		this.rangeOptions["site:7"] = new Object();
		this.rangeOptions["site:7"]["offline_only"] = false;
		this.rangeOptions["site:7"]["languages"] = "german";
		this.rangeOptions["site:7"]["formats"] = "print";
		this.rangeOptions["site:8"] = new Object();
		this.rangeOptions["site:8"]["offline_only"] = false;
		this.rangeOptions["site:8"]["languages"] = "german";
		this.rangeOptions["site:8"]["formats"] = "pdf|print";
		this.rangeOptions["site:9"] = new Object();
		this.rangeOptions["site:9"]["offline_only"] = false;
		this.rangeOptions["site:9"]["languages"] = "english";
		this.rangeOptions["site:9"]["formats"] = "print";
		this.rangeOptions["site:10"] = new Object();
		this.rangeOptions["site:10"]["offline_only"] = false;
		this.rangeOptions["site:10"]["languages"] = "german";
		this.rangeOptions["site:10"]["formats"] = "html";
		this.rangeOptions["site:11"] = new Object();
		this.rangeOptions["site:11"]["offline_only"] = false;
		this.rangeOptions["site:11"]["languages"] = "english";
		this.rangeOptions["site:11"]["formats"] = "html";
		this.rangeOptions["site:12"] = new Object();
		this.rangeOptions["site:12"]["offline_only"] = false;
		this.rangeOptions["site:12"]["languages"] = "english";
		this.rangeOptions["site:12"]["formats"] = "html";
		this.rangeOptions["site:13"] = new Object();
		this.rangeOptions["site:13"]["offline_only"] = false;
		this.rangeOptions["site:13"]["languages"] = "german";
		this.rangeOptions["site:13"]["formats"] = "html";
		this.rangeOptions["site:14"] = new Object();
		this.rangeOptions["site:14"]["offline_only"] = false;
		this.rangeOptions["site:14"]["languages"] = "english";
		this.rangeOptions["site:14"]["formats"] = "html";
		this.rangeOptions["site:15"] = new Object();
		this.rangeOptions["site:15"]["offline_only"] = false;
		this.rangeOptions["site:15"]["languages"] = "english";
		this.rangeOptions["site:15"]["formats"] = "print";
		this.rangeOptions["site:16"] = new Object();
		this.rangeOptions["site:16"]["offline_only"] = false;
		this.rangeOptions["site:16"]["languages"] = "french";
		this.rangeOptions["site:16"]["formats"] = "html";
		this.rangeOptions["site:17"] = new Object();
		this.rangeOptions["site:17"]["offline_only"] = false;
		this.rangeOptions["site:17"]["languages"] = "german";
		this.rangeOptions["site:17"]["formats"] = "html";
		this.rangeOptions["site:18"] = new Object();
		this.rangeOptions["site:18"]["offline_only"] = false;
		this.rangeOptions["site:18"]["languages"] = "german";
		this.rangeOptions["site:18"]["formats"] = "html";
		this.rangeOptions["site:19"] = new Object();
		this.rangeOptions["site:19"]["offline_only"] = false;
		this.rangeOptions["site:19"]["languages"] = "german";
		this.rangeOptions["site:19"]["formats"] = "html";
		this.rangeOptions["site:20"] = new Object();
		this.rangeOptions["site:20"]["offline_only"] = false;
		this.rangeOptions["site:20"]["languages"] = "german";
		this.rangeOptions["site:20"]["formats"] = "html";
		this.rangeOptions["site:21"] = new Object();
		this.rangeOptions["site:21"]["offline_only"] = false;
		this.rangeOptions["site:21"]["languages"] = "german";
		this.rangeOptions["site:21"]["formats"] = "html";
	}
	
}
searchOptions.init();
