/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

	parse the URL for further processing

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/




/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    declare variables
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


var IAmTestingFile;
var theUrl;
var theUrlArrayDash;
var theCurrentFile;
var theCurrentFileName;
var theCurrentFileExtension;
var theCurrentDirectory;
var theCurrentSubDirectory;
var theCurrentSubSubDirectory;
var theCurrentLevel;
var theRelativeWebLocation;
var theUrlArrayQuestionMark;
var theCurrentFeature;


/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    declare testing file
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


IAmTestingFile = "_js/parse_url.js";


/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    harvest and parse url
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


theUrl = window.location.href;
theUrlArrayDash = theUrl.split("/");

switch (theUrl)
	{
	case "http://greatriverenergy.com":
	case "http://greatriverenergy.com/":
	case "http://greatriverenergy.com/index.html":
	case "http://www.greatriverenergy.com":
	case "http://www.greatriverenergy.com/":
	case "http://www.greatriverenergy.com/index.html":
		theCurrentFileName = "index";
		theCurrentFileExtension = "html";
		theCurrentFile = "index.html";
		theCurrentDirectory = "root";
		theCurrentSubDirectory = "none"
		theCurrentSubSubDirectory = "none"
		theCurrentLevel = "root";
		theRelativeWebLocation = "";
		theCurrentFeature = "whatsnew";

	break;

	default:
		switch (theUrlArrayDash.length)
			{
			case 4:
				theCurrentFileName = "index";
				theCurrentFileExtension = "html";
				theCurrentFile = "index.html";
				theCurrentDirectory = "root";
				theCurrentSubDirectory = "none"
				theCurrentSubSubDirectory = "none"
				theCurrentLevel = "root";
				theRelativeWebLocation = "";
				theUrlArrayQuestionMark = theUrl.split("?");
				theCurrentFeature = theUrlArrayQuestionMark[theUrlArrayQuestionMark.length-1];
			break;

			case 5:
				theCurrentLevel = "level 1";
				theCurrentDirectory = theUrlArrayDash[theUrlArrayDash.length-2];
				theCurrentSubDirectory = "none"
				theCurrentSubSubDirectory = "none"
				theRelativeWebLocation = "../";
			break;

			case 6:
				theCurrentLevel = "level 1";
				theCurrentDirectory = theUrlArrayDash[theUrlArrayDash.length-3];
				theCurrentSubDirectory = theUrlArrayDash[theUrlArrayDash.length-2];
				theCurrentSubSubDirectory = "none"
				theRelativeWebLocation = "../../";
			break;

			case 7:
				theCurrentLevel = "level 2";
				theCurrentDirectory = theUrlArrayDash[theUrlArrayDash.length-4];
				theCurrentSubDirectory = theUrlArrayDash[theUrlArrayDash.length-3];
				theCurrentSubSubDirectory = "none"
				theRelativeWebLocation = "../../../";
			break;

			case 8:
				theCurrentLevel = "level 3";
				theCurrentDirectory = theUrlArrayDash[theUrlArrayDash.length-5];
				theCurrentSubDirectory = theUrlArrayDash[theUrlArrayDash.length-4];
				theCurrentSubSubDirectory = theUrlArrayDash[theUrlArrayDash.length-3];
				theRelativeWebLocation = "../../../../";
			break;

			default:
				// alert("=====\nERROR\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: hit the default in the switch statement for theUrlArrayDash.length.");
			break;
			}

		theCurrentFileName = theUrlArrayDash[theUrlArrayDash.length-1].split(".")[0];
		theCurrentFileExtension = theUrlArrayDash[theUrlArrayDash.length-1].split(".")[1];
		theCurrentFile = theUrlArrayDash[theUrlArrayDash.length-1];
	break;
	}


/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    testing messages
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theUrl = " + theUrl)};
if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theRelativeWebLocation = " + theRelativeWebLocation)};
if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theCurrentLevel = " + theCurrentLevel)};
if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theCurrentDirectory = " + theCurrentDirectory)};
if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theCurrentSubDirectory = " + theCurrentSubDirectory)};
if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theCurrentSubSubDirectory = " + theCurrentSubSubDirectory)};
if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theCurrentFileExtension = " + theCurrentFileExtension)};
if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theCurrentFile = " + theCurrentFile)};
if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theCurrentFileName = " + theCurrentFileName)};
if (IAmTesting) {alert("=====\nTESTING\n=====\nFile: " + IAmTestingFile + "\n\nMESSAGE: theCurrentFeature = " + theCurrentFeature)};
