

function getNrOfSubLevelsInCurrentURL()
{

	var preSiteURL = "antula";
	var siteName = "";

	var host = window.location.host.toLowerCase();
	var pathName = window.location.pathname.toLowerCase();

	var newURL = window.location.protocol + "//" + (host + "/" + pathName).replace("//", "/");
	newURL = newURL.replace("update/", "");
	pathName = pathName.replace("update/", "");

	//alert(newURL);

	var newPathname = "";
	// Remove any page.???-things from the url.
	lastPartOfURL = newURL.substr(newURL.lastIndexOf("/")+1);
	//directoryPartOfURL = pathName.substr(0, newURL.lastIndexOf("/")+1);
	directoryPartOfURL = pathName.replace(lastPartOfURL, '');

	//alert(directoryPartOfURL);
	
	if( directoryPartOfURL.lastIndexOf(".") > 0 )
	{
		firstSlashAfterDomainDot = directoryPartOfURL.substr(directoryPartOfURL.lastIndexOf("."));
		firstSlashAfterDomainDot = firstSlashAfterDomainDot.substr(firstSlashAfterDomainDot.indexOf("/")+1);
		directoryPartOfURL = firstSlashAfterDomainDot;
	}
	else
	{
		if( directoryPartOfURL.indexOf('/') == 0 )
			directoryPartOfURL = directoryPartOfURL.substring(1);
		
		
	}
	//alert(directoryPartOfURL);
	
	/*
	if( lastPartOfURL.indexOf(".") > 0 )
		directoryPartOfURL = directoryPartOfURL;
	else
	{
		directoryPartOfURL = directoryPartOfURL + "/"
		directoryPartOfURL = directoryPartOfURL.replace("//", "/");
	}
	*/
	
	//alert(directoryPartOfURL);
	
	var pathArray = directoryPartOfURL.split( '/' );
	
	nrOfSubLevels = pathArray.length-1;
	//alert(nrOfSubLevels);
	
	return nrOfSubLevels
}


function getURLOffset()
{
	var nrOfSubLevelsInURL = getNrOfSubLevelsInCurrentURL();
	var retStr = "";
	for( i=0; i<nrOfSubLevelsInURL; i++)
	{
		retStr = retStr + "../";
	}
	
	return retStr;
}











// function getNrOfSubLevelsInCurrentURL_DEPRICATED()
// {

	// var preSiteURL = "antula";
	// var siteName = "";

	// var host = window.location.host.toLowerCase();
	// var pathName = window.location.pathname.toLowerCase();
	// //host = "www.sb12.se";
	// //pathName = "/letsdance/";

	// var newURL = window.location.protocol + "//" + (host + "/" + pathName).replace("//", "/");
	// newURL = newURL.replace("update/", "");
	// pathName = pathName.replace("update/", "");

	// alert(newURL);


	// var newPathname = "";
	// // Remove any page.???-things from the url.
	// lastPartOfURL = newURL.substr(newURL.lastIndexOf("/")+1);
	// directoryPartOfURL = pathName.substr(0, newURL.lastIndexOf("/")+1);


	// //alert(lastPartOfURL);
	// if( lastPartOfURL.indexOf(".") > 0 )
		// directoryPartOfURL = directoryPartOfURL;
	// else
	// {
		// directoryPartOfURL = directoryPartOfURL + "/"
		// directoryPartOfURL = directoryPartOfURL.replace("//", "/");
		// //alert(directoryPartOfURL);
	// }

	// var pathArray = directoryPartOfURL.split( '/' );

	// if( host == "localhost" )
	// {
		// for ( i = 0; i < pathArray.length; i++ ) 
		// {
			// if( pathArray[i].toLowerCase() == preSiteURL )
			// {
				// siteName = pathArray[i+1].toLowerCase();
				// nrOfSubLevels = pathArray.length - (i+3);
			// }
		// }	
	// }
	// else
	// {
		// nrOfSubLevels = pathArray.length-2;
		// //window.location.pathname
	// }

	// return nrOfSubLevels
// }


