var site = new Array();
var cfile = new Array();

	site.rootFolder = "Pentix2001";
	cfile.location = document.location.href;
	
	site.absRoot = absoluteRoot();
	cfile.relPath = relativePath();
	cfile.path = extractPath(cfile.relPath);
	site.relRoot = relativeRoot();

function absoluteRoot(){
// returns the path of the root of the HomePage (in absolute path)
 var i = cfile.location.indexOf(site.rootFolder);
 var path = cfile.location.substring(0,i+site.rootFolder.length);
 return path;
}

function relativeRoot(){
var r="";
var n=0;
while (n<cfile.path.length){
	r += "../";
	n += 1;
	}
return r;
}

function relativePath(){
// returns just the relative path of the current page, excluding the root.
 var relPath=cfile.location.substring(site.absRoot.length,cfile.location.length);
 return relPath;
}

function extractPath(p){
// given a relative path, it returns an array containing each directory of the path
var n=0;
var path= new Array();
var i=p.indexOf("/",1);
while (i!= -1){
	path[n]=p.substring(1,i);
	p=p.substring(i,p.length);
	n += 1;
	var i = p.indexOf("/",1);
	}
return path;
}


function test(){
alert ("site.rootFolder: " + site.rootFolder
	 + "\nsite.absRoot: " + site.absRoot
	 + "\nsite.relRoot : " + site.relRoot
	 + "\ncfile.location: " + cfile.location
	 + "\ncfile.relPath : " + cfile.relPath
	 + "\ncfile.path : " + cfile.path
	 );
}
