
String.prototype.startsWith = function(str) {return (this.match("^"+str)==str)}

function getAccountName() 
{	
    // by default, use dev

	var s_account = "nomura.com-dev";
		
	var s_location = window.location ;
	s_location = s_location.toString();
	
	var s_domain;
	if( s_location.startsWith("https://") ){
		s_domain = s_location.replace("https://", "");
	}
	else
	{
		s_domain = s_location.replace("http://", "");
	}	
	if( !isNullOrEmpty(s_domain) ){

	    if (s_domain.startsWith("www.nomura.com"))
		    s_account = "nomura.com-prod";
		else 
		    if (s_domain.indexOf("comstaging") !=-1)
		        s_account = "nomura.com-stg";
	}
	
	return s_account ;	
}

function getVia()
{
  // by default, use dev

	var s_via = "DEV-NAASRP -> DEV-NOMCOM-01";
		
	var s_location = window.location ;
	s_location = s_location.toString();
	
	var s_domain;
	if( s_location.startsWith("https://") ){
		s_domain = s_location.replace("https://", "");
	}
	else
	{
		s_domain = s_location.replace("http://", "");
	}	
	if( !isNullOrEmpty(s_domain) ){

	    if (s_domain.startsWith("www.nomura.com"))
		    s_via = "PROD-NAASRP -> PROD-NOMCOM-01";
		else 
		    if (s_domain.indexOf("comstaging") !=-1)
		        s_via = "STG-NAASRP -> STG-NOMCOM-01";
	}
	
	return s_via ;	
}


function getPageName() 
{	
	var s_title = document.title ;	
	
	
	return s_title ;
}

function getContext() 
{
	var s_context = (window.location.pathname).substring(1,window.location.pathname.indexOf("/",1));
	
	return s_context ;
}


function getDomainName() 
{
	return document.domain ;
	
}

function getAccessPoint() 
{	
	
	var s_location = window.location ;
	var s_domain = s_location.toString();	
	
	
	if (s_domain.indexOf("www.") != -1)
	{				
		s_env = "Extranet" ;
	}
	else
	{
		s_env = "Intranet" ;
	}
	
	return s_env ;
}

function getLanguage() 
{
	var s_language = "en" ;	
	return s_language ;
}


function getUnknown() 
{
	return "Unknown" ;	
}


String.prototype.equalsIgnoreCase=myEqualsIgnoreCase;
String.prototype.equals=myEquals;

function myEquals(arg){
        return ( this.toString() == arg.toString() );
}

function myEqualsIgnoreCase(arg)
{               
        return ( new String(this.toLowerCase()) == (new String(arg)).toLowerCase());
}


function isNullOrEmpty( pString ) {
	var re = /^\s{1,}$/g; //match any white space including space, tab, form-feed, etc. 
	if (  (pString == null) || ( pString == 'undefined') || (pString.search(re) > -1)  || (pString == 'null') || (pString.length == 0) ) {
		return true;
	}
	else {
		return false;
	}
}

function noNull( pString ) {
	return ( isNullOrEmpty(pString) )? "" : pString;
}
