/*
This simple script is linked on all PopupBox content fragment pages
and will only get executed if the content page is accessed directly
(which it should not be) and will redirect the page to the appropriate
store page with the deep link to show the content. This will make 
"Open in new Tab" features to work, as well as any weird search indexing
or other ways that the content itself might get accessed directly.
*/

var POPUP_BASE_URL = location.protocol + "//" + location.hostname + "/resources/store/"; // url to the popup parent page
var POPUP_PREFIX = "#view:items/"; // prefix for all popup links on the parent page

// redirect to appropriate parent page with popup deeplink
location.href = POPUP_BASE_URL + POPUP_PREFIX + pageName();

// get the page name without the path or variables
// ex. "http://example.com/stuff/thing.php?q=2#78" returns "thing.php"
function pageName(){
	return location.pathname.split('/').pop();
}
