/**
 * @title Statistics customization for US
 * @author DENIS ROUSSEAU
 * @version 1.4.2.0.0
 */
/*****************************************************************************
 * Globals declarations (if not done in configuration-stat.js)
 *****************************************************************************/
if (typeof STAT_PathRemover != 'object') 
{
    xtsd = getXtsd();
    xtsite = '';
    xtn2 = '';
    xtpage = '';
	xtdi = '0' ;
    xt_multc = '';
    gasiteID = '';
    
    STAT_PathRemover = 
    {
        Common: '',
        Next: false
    };
}
/*****************************************************************************
 * Settings maps
 ******************************************************************************/
/* Retrieve only site accounts */
function getStatGlobalMap()
{
    var sm = [];
    var pm = getXtsiteByLang();
    for (var i = 0; i < pm.length; i++) 
    {
        sm.push([pm[i][0], '', getXtsd(), pm[i][1]]);
    }
    /*----------------------------------------------------------------------------------*/
    return sm;
}
/* Retrieve all settings, or only level 2 and pages */
function getStatSettingsMap()
{
    var sm = [];
    var pm = getLevel2SiteForSite();
    for (var i = 0; i < pm.length; i++) 
    {
        sm.push([pm[i][0], '', '', '', pm[i][1]]);
    }
    /*----------------------------------------------------------------------------------*/
    return sm;
}
function getStatPreviewMap()
{
    var pm = [];
    pm.push(['*', getXtsitePreview(), getXtsdPreview()]); // default
    return pm;
}

/*****************************************************************************
 * Statistic Customization functions
 *****************************************************************************/
function getCustomPath(sp, isGlobal)
{
	var msp = sp ;
	if (isGlobal)
	{
		msp = 'en' + msp ;
	}
	return msp ;
}
/**************************************************************
 * Retrieve Preview status
 */
function isCustomPreview()
{
    return (window.location.hostname != 'products.schneider-electric.us');
}

/**************************************************************
 * Retrieve page exclusion status
 */
function isCustomExcluded(uri)
{
    var r = false;
    var axPages = getExcludedPages();
    for (var k = 0; k < axPages.length; k++) 
    {
        var page = axPages[k];
        if (comparePath(uri, page)) 
        {
            r = true;
            break;
        }
    }
    return r;
}
/**************************************************************
 * Display an alert
 */
function doCustomAlert(alertType)
{
    if (isCustomPreview()) 
    {
        if (alertType == "configuration-stat.js") 
        {
            alert("Statistic alert! Wrong or missing:\r\n/templatedata/Configuration/Xiti/presentation/configuration-stat.js\r\nPlease ensure that it has been properly updated and submitted,\r\nor contact statistic support.");
        }
    }
}
/**************************************************************
 * Custom parameters
 */
function setCustomXt()
{
    xtdi = getDi(stat_condition._path) ;
}

/*******************************************************************
 * Retrieve site ID (depending on current language) from XtBasePath
 */
function getXts(bp)
{
    var g = "" + bp;
    var a = getXtsiteByLang();
    var s = "";
    var c = g.split("/");
    var e = c[0];
    for (var l = 0; l < a.length; l++) 
    {
        if (a[l][0] == e) 
        {
            s = a[l][1];
            break;
        }
    }
    return s;
}

/******************************************************************************
 * Retrieve Xiti di entry
 */
function getDi(uri)
{
    var rules = getAllImportanceDegree();
    var rest = "";
    var di = "0";
    for (var i = 0; i < rules.length; i++) 
    {
        if (uri.substring(0, rules[i][0].length) == rules[i][0]) 
        {
            di = rules[i][1];
            break;
        }
    }
    return di;
}




