
/* - urlparse.js - */
// http://www.lsmonline.com/portal_javascripts/urlparse.js?original=1
if(typeof Poly9=='undefined')
var Poly9={};Poly9.URLParser=function(url){this._fields={'Username':4,'Password':5,'Port':7,'Protocol':2,'Host':6,'Pathname':8,'URL':0,'Querystring':9,'Fragment':10};this._values={};this._regex=null;this.version=0.2;this._regex=/^((\w+):\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?([^#]*)/;for(var f in this._fields){this['get'+f]=this._makeGetter(f);this['set'+f]=this._makeSetter(f)}
this.getURL=this._getURL;if(typeof url!='undefined')
this._parse(url)}
Poly9.URLParser.prototype.setURL=function(url){this._parse(url)}
Poly9.URLParser.prototype._getURL=function(){var s;s=this.getProtocol();s+="://"
if(this.getUsername()!=''){s+=this.getUsername()}
if(this.getPassword()!=''){s+=":";s+=this.getPassword()}
if(this.getUsername()!=''){s+="@"}
s+=this.getHost();if(this.getPort()!=''){s+=":"+this.getPort()}
s+=this.getPathname();if(this.getQuerystring()!=''){s+="?"+this.getQuerystring()}
if(this.getFragment()!=''){s+="#"+this.getFragment()}
return s}
Poly9.URLParser.prototype._initValues=function(){for(var f in this._fields)
this._values[f]=''}
Poly9.URLParser.prototype._parse=function(url){this._initValues();var r=this._regex.exec(url);if(!r) throw "DPURLParser::_parse -> Invalid URL"
for(var f in this._fields) if(typeof r[this._fields[f]]!='undefined')
this._values[f]=r[this._fields[f]]}
Poly9.URLParser.prototype._makeGetter=function(field){return function(){return this._values[field]}}
Poly9.URLParser.prototype._makeSetter=function(field){return function(value){this._values[field]=value}}
