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)); 
}

var accordion = {


	/*	makeAccordions finds all the accordion layouts on the page and makes an accordion
			for each one. If I wanted this function to be more useful, I might make the selector
			that is passed in a variable.	*/
	makeAccordions: function(){
		/*	find all the dl elements with the class "Accordion"	*/
		$$('dl.Accordion').each(function(el){
			/*	make a new accordion with the elements in the dl element.
			
			Element.getElements works like $$() does - it returns an array of
			elements that match that selector. Unlike $$(), getElements starts
			at the Element on which it's called so it acts like a filter.	*/
			var index = parseInt(queryString("display"));
		//	alert("index="+index)
			qwe=new Accordion(el.getElements('dt.stretchtoggle'), el.getElements('dd.stretcher')); //, {show: index}
			
			if ( index ) {
			 	qwe.display(index);
			}
		});
	},
	init: function(){
		this.makeAccordions();
	}
};
/*	window.onDomReady will call my guide.init on page load, but the "this" will be the window, so
		I bind the guide to the function call explicitly. I wouldn't have this problem if I wrote it
		this way:

window.onDomReady(function()[
	guide.init();
});
		But that's more verbose than it needs to be.
		*/
window.onDomReady(accordion.init.bind(accordion));



 
 
