/* -------------------------------------------------
Script:   	 evisit_pagename.js
Purpose:  	 Get filename to add to evisit page to allow
		 	 for page veiw analysis.
Author:		 Seth Carter, updated by Stuart Holmes
Last Update: 2008/12/15
------------------------------------------------- */

function parseURI(strSourceURI) {
	var arrURIParts = new Array("Source", "Protocol", "Authority", "Domain", "Port", "Path", "DirectoryPath", "FileName", "Query", "Anchor");
	var regexURI = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(strSourceURI);
	var objURI = new Object;

	for (var i = 0; i < 10; i++) {
		objURI[arrURIParts[i]] = (regexURI[i] ? regexURI[i] : "");

	}

	if (objURI.DirectoryPath.length > 0) {
		objURI.DirectoryPath = objURI.FileName.replace(/\/?$/, "/");

	}

	return objURI;

}

function getSection() {
	var arrURIComponents = parseURI(document.URL);
	var arrPathComponents = arrURIComponents['FileName'].replace(/^\/+|\/+$/g, "").split("\/");
	return (arrPathComponents[0] != "") ? arrPathComponents[0] : "home";

}