	function PageQuery(q) {
		if(q.length > 1) this.q = q.substring(1, q.length);
		else this.q = null;
		this.keyValuePairs = new Array();
		if(q) {
			for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
			}
		}
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function(s) {
			for(var j=0; j < this.keyValuePairs.length; j++) {
				if(this.keyValuePairs[j].split("=")[0] == s)
					return this.keyValuePairs[j].split("=")[1];
			}
			return false;
		}
		this.getParameters = function() {
			var a = new Array(this.getLength());
			for(var j=0; j < this.keyValuePairs.length; j++) {
				a[j] = this.keyValuePairs[j].split("=")[0];
			}
			return a;
		}
		this.getLength = function() { return this.keyValuePairs.length; }
	}
	function queryString(key){
		var page = new PageQuery(window.location.search);
		return unescape(page.getValue(key));
	}
	function displayItem(key){
		if(queryString(key)=='false')
		{
			//alert("you didn't enter a ?name=value querystring item.");
			return "";
		}else{
			return queryString(key);
		}
	}
	
	var bln_region_override_on = "FALSE";
	var bln_init_region_override_on = "FALSE";
	
	function filter_country(region_id, element_name, default_value, all){
			if (region_id == "---------------") { 
				// they've selected the dashed separator line, reset the region menu
				region_id='All';
				filter_region('','region_span','All','true');
			}
			if (region_id == "European River Cruises") {
				region_id = "Europe";
				bln_region_override_on = "TRUE";
			} else {
				bln_region_override_on = "FALSE";
			}			
			
			my_country_span = document.getElementById('country_span');
			country_html = my_country_span.innerHTML.substr(0,my_country_span.innerHTML.indexOf('>')+1);
			if(all == "true"){
				country_html += '<option value="All">All</option>';
			}
			for (n=0;n<country_list.length;n++){
				if(country_list[n][1] == default_value || (country_list[n][1] == displayItem('country') && default_value != 'All')){
				selected = "selected";
				}
				else {
				selected = "";
				}
				if(country_list[n][0] == region_id || region_id == 0 || region_id == 'All'){
					if (country_list[n][1] != 'All') country_html += '<option  value="'+country_list[n][1]+'" '+selected+'>'+country_list[n][2]+'</option>';
				}
			}
			country_html += "</select><br>" 
			my_country_span.innerHTML = country_html;
		}

	function filter_region(country_id, element_name, default_value,all){ 
		my_region_span = document.getElementById('region_span');
		region_id = 'All';
		region_html = my_region_span.innerHTML.substr(0,my_region_span.innerHTML.indexOf('>')+1);
		for (n=0;n<country_list.length;n++){
			if(country_list[n][2] == country_id){
			region_id = country_list[n][0];
			}

		}
		for (n=0;n<region_list.length;n++){
			if(region_list[n][0] == region_id || region_list[n][0] == default_value){
			selected = "selected";
			}
			else {
			selected = "";
			}
			region_html += '<option  value="'+region_list[n][0]+'" '+selected+'>'+region_list[n][1]+'</option>';
		}
		region_html += "</select><br>" 
		//alert(region_id + ' ' + country_id + ' ' + bln_init_region_override_on + ' ' + bln_region_override_on);
		if (bln_init_region_override_on == "FALSE") {
			if (country_id != 'All') {
					if (region_id != 'Europe') {
						my_region_span.innerHTML = region_html;
					} else {
						if (bln_region_override_on == "FALSE") {
							my_region_span.innerHTML = region_html;	
						}
					}
			}
		} else {
			bln_init_region_override_on = "FALSE";
		}
	}
	
	function validateDate(changedControl){
		var fromDate; //node
		var toDate; //node
		var fromDateCompare; //date
		var toDateCompare; //date
		
		if (changedControl.parentNode.id == 'from_date') {
			fromDate = changedControl;
			
			containerChildren = document.getElementById('to_date').childNodes;

			toDate = getFirstChildByTagName(containerChildren, 'select');
			
			if (validObject(fromDate)&&validObject(toDate)) {
				
				fromDateCompare = new Date (fromDate.value);
				toDateCompare = new Date (toDate.value);
				
				if (fromDateCompare > toDateCompare) {
					toDate.selectedIndex = 0;
				}
			}
		} else {
			toDate = changedControl;
			
			containerChildren = document.getElementById('from_date').childNodes;
			
			fromDate = getFirstChildByTagName(containerChildren, 'select');
			
			if (validObject(fromDate)) {
				
				toDateCompare = new Date (toDate.value);
				fromDateCompare = new Date (fromDate.value);
				
				if (fromDateCompare > toDateCompare) {
					fromDate.selectedIndex = 0;
				}
			}
		}
		
	}
	
	function getFirstChildByTagName(objParent, strTag) {
		for (n=0;n<objParent.length;n++){
			if (validObject(objParent[n].tagName)){
				if(objParent[n].tagName.toLowerCase() == strTag.toLowerCase()){
					return objParent[n];
				}
			}
		}
	}
	
	function validObject(objToTest) { 
		if (objToTest == null || objToTest == undefined) { 
			return false; 
		} else { 
			return true; 
		} 
	} 