var urlParser = {
	urlOrig : null,
	url : {
		protocol : null,
		domain : null,
		path : null,
		document : null,
		variables : {},
		hash : null
		},
	
	parse : function(url){
		if(!url){ return false; }
		var urltemp = url;
		
		this.url.protocol = this.getPart('^[a-z]+://', url);
		urltemp = urltemp.replace(/^[a-z]+:\/\//, '');
		
		this.url.domain = this.getPart('^[a-z\.]+(?=/)', urltemp);
		urltemp = urltemp.replace(/^[a-z\.]+(?=\/)/, '');
		
		this.url.path = this.getPart('^[^\\?#]+(?=(\\?|#|$))', urltemp);
		urltemp = urltemp.replace(/^[^\?]+(?=(\?|#|$))/, '');
		
		this.url.document = this.getPart('[^/]+$', this.url.path);
		this.url.path = this.url.path.replace(this.url.document, '');
		
		this.url.hash = this.getPart('#.+$', urltemp).replace(/^#/, '');
		urltemp = urltemp.replace(/#.+$/, '').replace(/^\?/, '');
		
		if(urltemp.length > 0){
			if(urltemp.indexOf('&') === -1){
				var test = urltemp.split('=');
				this.url.variables[test[0]] = test[1];
				}
			else{
				var vartemp = urltemp.split('&');
				for(var i in vartemp){
					if(vartemp[i] !== ''){
						var test = vartemp[i].split('=');
						this.url.variables[test[0]] = test[1];
						}
					}
				}
			}
		//alert(getProps(this.url, 'url'));
		return this.url;
		},
	
	joinVars : function(vars){
		var getvars = '';
		for(var i in vars){
			getvars += i + '=' + vars[i] + '&';
			}
		return getvars.replace(/&$/, '');
		},
	
	getPart : function(regexS, url){
		var regex = new RegExp(regexS);
		var results = regex.exec(url);
		if(results === null){ return ""; }
		else{ return results[0]; }
		}
	};

