
//Copyright Mangolab Ltd. 2008. All rights reserved.
//SUMMARY:
// - URL utilities
//HISTORY:
// 23.10.08 Version 1.0 - <FC> - Reviewd / FB ref: CASE:1496

//Functions for backwards compatibility:
function GetPageNameNoSearchString(AUrl){
//this is now the same as GetPageName, but is retained as a container for
//backwards compatibility in existing calls
return GetPageName(AUrl);
}

//Current functions:
function GetPageName(AUrl){
//first remove any search params as they may have a slash within a parameter within them
var StrCleanUrl = GetURLNoSearchString(AUrl);
var ThisPage = StrCleanUrl.substring(StrCleanUrl.lastIndexOf("/")+1);
if (ThisPage==""){
   ThisPage = StrCleanUrl.substring(StrCleanUrl.lastIndexOf("\\")+1);//beware escape char!
   }
return ThisPage;
}

function GetBaseUrl(AUrl){
var ThisBaseUrl = AUrl.substring(0,(AUrl.lastIndexOf("/"))+1);
if (ThisBaseUrl==""){
   ThisBaseUrl = AUrl.substring(0,(AUrl.lastIndexOf("\\"))+1);//beware escape char!
   }
return ThisBaseUrl;
}

function GetURLNoSearchString(AUrl){
//if there's no search string we just use StrPage, otherwise we whip it off
var StrURL=AUrl;
var StrNoSearch=AUrl.substring(0,StrURL.indexOf("?")); //ie indexof not lastIndexOF
if (StrNoSearch!=''){
   StrURL=StrNoSearch;
   }
//alert('Aurl='+AUrl+' StrPage='+StrPage);
return StrURL;
}
