function legacyLoginOrRegister() {
	
	// Get portal alias from URL
	var strPortalAlias = getPortalAliasFromUrl();

	// Get value of URL variable from form
	var strURL = document.frmWHLogin.URL.value;
	
	// Check if the portal alias exists in the URL variable
	var intAliasInURL = strURL.indexOf('/shops/' + strPortalAlias);
	
	// If portal alias does not exist then replace it
	if (intAliasInURL < 0) {
		strURL = strURL.replace(/shops/i, ('shops/' + strPortalAlias));
		document.frmWHLogin.URL.value = strURL;
	}
	
	// Finally submit the form
	document.frmWHLogin.submit();
	
}

function legacyLogout(pstrDefaultProtocol, pstrWebSiteName, pstrMode, pbRememberMe) {
	
	// Get portal alias from URL and build return URL
	var strPortalAlias = getPortalAliasFromUrl();
	var strReturnUrl = '' + pstrDefaultProtocol + pstrWebSiteName + '/shops/' + strPortalAlias + '/Default.aspx';

	// Build logout URL
	var strURL = '' + pstrDefaultProtocol + pstrWebSiteName + '/Security/Login/Logout.asp?Mode=' + pstrMode;
	
	// Add remember me (if applicable)
	if (pbRememberMe) {
		strURL = strURL + '&rem=1';
	}
	
	// Add return url
	strURL = strURL + '&ReturnUrl=' + strReturnUrl;
	
	// Redirect user to logout url
	window.location.href = strURL;
	
}

function getPortalAliasFromUrl() {
	
	// Get current location
	var strCurrentPage = '' + window.location.href + '';
		
	// Get marker points in the url
	var intStart = strCurrentPage.indexOf('/shops/') + 7;
	
	// Extract the portal alias from the url
	var strPortalAlias = '';
	if (intStart > 0) {

		// Get the position of next backslash marking end of portal alias
		var intEnd = strCurrentPage.indexOf('/',intStart);

		// Get the portal alias
		strPortalAlias = strCurrentPage.substring(intStart,intEnd);
	}
	
	return strPortalAlias;

}
