function RedirectToPage(page)
{
  //if a page has a relative path to itself
  var currentPage;
  var relPath = page;
  var redirectPage;
  
  if (document.getElementById('baseUrl'))
  {
   currentPage = document.getElementById('baseUrl').href;
  }
  else
  {
    currentPage = window.location.href;
  }

	redirectPage = currentPage.substring(0, currentPage.lastIndexOf('/'));
	while (relPath.indexOf('../') >= 0)
	{
		redirectPage = currentPage.substring(0, currentPage.lastIndexOf('/'));
		relPath = relPath.substring(relPath.indexOf('../') + 3);
	}
	redirectPage = redirectPage + '/' + relPath;

	
  window.location.href = redirectPage;
}
