String.implement({parseQueryString:function(decodeKeys,decodeValues){if(decodeKeys==null){decodeKeys=true}if(decodeValues==null){decodeValues=true}var vars=this.split(/[&;]/),object={};if(!vars.length){return object}vars.each(function(val){var index=val.indexOf("=")+1,value=index?val.substr(index):"",keys=index?val.substr(0,index-1).match(/([^\]\[]+|(\B)(?=\]))/g):[val],obj=object;if(!keys){return}if(decodeValues){value=decodeURIComponent(value)}keys.each(function(key,i){if(decodeKeys){key=decodeURIComponent(key)}var current=obj[key];if(i<keys.length-1){obj=obj[key]=current||{}}else{if(typeOf(current)=="array"){current.push(value)}else{obj[key]=current!=null?[current,value]:value}}})});return object},cleanQueryString:function(method){return this.split("&").filter(function(val){var index=val.indexOf("="),key=index<0?"":val.substr(0,index),value=val.substr(index+1);return method?method.call(null,key,value):(value||value===0)}).join("&")}});