VRT = YAHOO.namespace("trp.vrt.common");

if (typeof VRT.parseUri == "undefined")
{

VRT.parseUri =function(){
	
		return{
			
			options: {
				strictMode: false,
				key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
				q:   {
					name:   "queryKey",
					parser: /(?:^|&)([^&=]*)=?([^&]*)/g
				},
				parser: {
					strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
					loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
				}
			},
		
			parse:function (str) 
			{
				var	o   = VRT.parseUri.options,
					m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
					uri = {},
					i   = 14;
			
				while (i--) uri[o.key[i]] = m[i] || "";
			
				uri[o.q.name] = {};
				uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
					if ($1) uri[o.q.name][$1] = $2;
				});
			
				return uri;
			},
			
			removeMetricsAttrs:function(uriAttrs)
			{
				//returns querystring with metrics attrs removed.
				//expects the qureyKey object as arg
				//the v_ that we are keying on in under control of metrics team written by the wta tags
				for (var props in uriAttrs.queryKey) 
				{
				    //alert("prop name " + props);
					if(props.indexOf("v_") > -1)
					{
						//alert("deleting " + props);
						delete uriAttrs.queryKey[props];
					}
				}
				
				var buffer = new StringUtils.StringBuffer();
				for (var i in uriAttrs.queryKey)
				{
					buffer.append(i + "=" + uriAttrs.queryKey[i] + "&");
				}
				
				var newQstr = buffer.toString();
				uriAttrs.query = newQstr.substring(0, newQstr.lastIndexOf("&"))
				
				
			}
			
		
		};//end public methods
	
}();

}