//  JavaScript QueryParser, version 0.2 (2006.08.10)
//  Copyright (c) 2006 echternacht new media (http://www.echternacht.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// Tooltip requires Prototype (http://prototype.conio.net/)
if((typeof Prototype=='undefined') || 
	parseFloat(Prototype.Version.split(".")[0] + "." +
        	Prototype.Version.split(".")[1]) < 1.5)
	throw("Tooltip requires the Prototype JavaScript framework >= 1.5.0");
	
var QueryParser = Class.create();
QueryParser.version = 0.2;
QueryParser.prototype = {
	
	initialize: function(page) {
		this.params = new Object();
		this.query = "";
		if(page != null && page.length > 1){
			this.query = (page.indexOf("?")>-1) ? page.substring(page.indexOf("?")+1,page.length) : page;
			this.parseurl();
		}
	},
	
	parseurl: function() {
		pairs = this.query.split(/[&;]/);
		for (i = 0; i < pairs.length; i++) {
            pair = pairs[i].split("=");
            key = unescape(pair[0].replace(/\+/g, " "));
            value = (pair[1] != null) ? unescape(pair[1].replace(/\+/g, " ")) : null;
			this.params[key] = value;
        }
	},
	
	getValue: function(search) {
		return (this.params[search]!=null) ? this.params[search] : null;
    }
}