// To be used with mm_menu.js
// the action of the menu item should be menu_OpenLocation(location)
// the location should begin with a /


//the root of the site should include a trailing /
// if the site is in the server root then the value should be "/"
// if the base url is http://www.abc.com/site123/ the value should be "/site123/"
var menu_helper_site_root = "/";

function menu_OpenLocation(newLocation){
	var protocol = window.location.protocol;
	
	//this is only done on the developers machines not running a web server
	if (protocol.indexOf('file') > -1){
		try{
			var images = document.getElementsByTagName("img");
			var imageSrc = "";
			
			if (images != null && images.length >= 0)
			{
				var currentPath = window.location.href;
				var imageSrc = images[0].src;
				//determine the idenitacl parts of the path
				// c:\popweaver\js  
				var j = 0;
				while( j < imageSrc.length && j < currentPath.length && imageSrc.charAt(j) == currentPath.charAt(j))
				{
					j++;
				}
				var index = currentPath.lastIndexOf(menu_helper_site_root, j+1);
				newLocation = currentPath.substr(0,index) + menu_helper_site_root + newLocation.substr(1);
			}
		} catch (e){
			window.status = "error loading new page";
		}

	}
	else
	{
		//if the newLocation does not contain a / in front assume they are going else where
		if ( newLocation.charAt(0) == '/')
		{
			//remove the extra / from the root and new location
			newLocation = menu_helper_site_root + newLocation.substr(1);
		}
	}
	window.location = newLocation;
}