function cleanArray(actual){
	var newArray = new Array();
	for(var i = 0; i<actual.length; i++){
		if (actual[i]){
			newArray.push(actual[i]);
		}
	}
	return newArray;
}

function buildOmniVars(){
	var arrPath = new Array();
	var arrHost = new Array();
	var counter = 0;
	var pageName = "";
	var fileName, i;

	arrHost = cleanArray(document.location.hostname.split("."));
	arrPath = cleanArray(document.location.pathname.split("/"));
	if (arrHost.length > 0 ) {
		arrPath.splice(0,0,arrHost[0]);
	}

	/*	
	i = arrPath.length-1;
	if (i >= 0) {
		fileName = arrPath[i];
		if (fileName.indexOf(".") < 0)  
			arrPath.push("index");
		if (fileName.indexOf("default") >= 0)
			arrPath[i] = "index";
	}
	else {
		arrPath.push("index");
	}
	*/
	
	for (var i=0; i<arrPath.length; i++) {
	  if (arrPath[i] != "") {
		counter++;
		//colon is the delimiter, so if this is not the first word, put it in there
		if (pageName != "") {
		  pageName += ":";
		}
		
		//remove everything after the dot
		pageName += arrPath[i].replace(/\.[a-zA-Z0-9]+$/,"");
		
		//props are the menu structure incrementally 
		if (counter < 5) {
		  objOmni.setVar("prop"+counter, pageName);
		}
		else if (counter == 5) { 
		  objOmni.setVar("prop15", pageName);
		}
	  }
	}

	//pageName is the entire menu structure
	if (pageName != "") {
	  objOmni.setVar("pageName", pageName);
	}

	//prop5 is the page type
	objOmni.setVar("channel", "ning");
	objOmni.setVar("prop5", "ning page view");	
}

buildOmniVars();



