// SITECATALYST CUSTOMIZED CODE //

var sc_SSOID = sc_getSSOUserId();

var sc_UserStatus;
var sc_PopGroupID;
if (sc_SSOID.length > 0)
{
	sc_UserStatus = "Logged In"
	sc_PopGroupID = "1";
}
else
{
	sc_UserStatus = "Logged Out"
	sc_PopGroupID = "";
}

function sc_DeleteCookie( name, path, domain ) 
{
	if ( sc_GetCookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function sc_GetCookie( check_name ) 
{
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function sc_GetDynamicAccountList() {
    var dynamicAccountList =
    "questdev,questglobal2=wwt.quest.com" +
    ";questdev,questglobal2=qa-usquest" +
    ";questdev,questglobal2=qa-ukquest" +
    ";questdev,questglobal2=qa-chquest" +
    ";questdev,questglobal2=stage-us-mp.quest.com" +
    ";questdev,questglobal2=stage-usquest" +
    ";questdev,questglobal2=stage-ukquest" +
    ";questdev,questglobal2=stage-" +

    ";questaustralia,questglobal1=questsoftware.com.au" +
    ";questaustralia,questglobal1=australia.quest.com" +
    ";questjapan,questglobal1=questsoftware.jp" +
    ";questjapan,questglobal1=jp.quest.com" +
    ";questjapan,questglobal1=japan.quest.com" +
    ";questbelgiumluxembourg,questglobal1=questsoftware.be" +
    ";questbrazil,questglobal1=questsoftware.com.br" +
    ";questchina,questglobal1=questsoftware.com.cn" +
    ";questfrance,questglobal1=questsoftware.fr" +
    ";questgermany,questglobal1=questsoftware.de" +
    ";questindia,questglobal1=questsoftware.in" +
    ";questireland,questglobal1=questsoftware.ie" +
    ";questitaly,questglobal1=questsoftware.it" +
    ";questkorea,questglobal1=quest.kr" +
    ";questlatinamerica,questglobal1=questsoftware.com.mx" +
    ";questnetherlands,questglobal1=questsoftware.nl" +
    ";questrussia,questglobal1=quest-software.ru" +
    ";questscandinavia,questglobal1=questsoftware.dk" +
    ";questsoutheastasia,questglobal1=questsoftware.com.sg" +
    ";questspain,questglobal1=questsoftware.es" +
    ";questunitedkingdom,questglobal1=quest-software.co.uk" +
    ";questunitedstates,questglobal1=quest.com"

    return dynamicAccountList;
}

function sc_GetLinkInternalDomain(urlString) {
    var urlPattern = new RegExp("(http|https)://(.*?)/.*$");
    var parsedUrl = urlString.match(urlPattern);
    var domain = parsedUrl[2];
    var parts = domain.split('.');
    if (parts.length > 2) {
        parts.shift();
        domain = "." + parts.join('.');
    } else {
        domain = "." + domain;
    }
    return domain;
}

function sc_GetSiteID() {
    var l_hostname = location.hostname.toLowerCase();
    var s_siteID = l_hostname; //default to hostname
    if (l_hostname.indexOf('stage-') > -1) {
        s_siteID = l_hostname;
    } else if (l_hostname.indexOf('questsoftware.com.au') > -1) {
        s_siteID = "Australia";
    } else if (l_hostname.indexOf('australia.quest.com') > -1) {
        s_siteID = "Australia";
    } else if (l_hostname.indexOf('questsoftware.jp') > -1) {
        s_siteID = "Japan";
    } else if (l_hostname.indexOf('jp.quest.com') > -1) {
        s_siteID = "Japan";
    } else if (l_hostname.indexOf('japan.quest.com') > -1) {
        s_siteID = "Japan";
    } else if (l_hostname.indexOf('questsoftware.be') > -1) {
        s_siteID = "Belgium Luxembourg";
    } else if (l_hostname.indexOf('questsoftware.com.br') > -1) {
        s_siteID = "Brazil";
    } else if (l_hostname.indexOf('questsoftware.com.cn') > -1) {
        s_siteID = "China";
    } else if (l_hostname.indexOf('questsoftware.fr') > -1) {
        s_siteID = "France";
    } else if (l_hostname.indexOf('questsoftware.de') > -1) {
        s_siteID = "Germany";
    } else if (l_hostname.indexOf('questsoftware.in') > -1) {
        s_siteID = "India";
    } else if (l_hostname.indexOf('questsoftware.ie') > -1) {
        s_siteID = "Ireland";
    } else if (l_hostname.indexOf('questsoftware.it') > -1) {
        s_siteID = "Italy";
    } else if (l_hostname.indexOf('quest.kr') > -1) {
        s_siteID = "Korea";
    } else if (l_hostname.indexOf('questsoftware.com.mx') > -1) {
        s_siteID = "Latin America";
    } else if (l_hostname.indexOf('questsoftware.nl') > -1) {
        s_siteID = "Netherlands";
    } else if (l_hostname.indexOf('quest-software.ru') > -1) {
        s_siteID = "Russia";
    } else if (l_hostname.indexOf('questsoftware.dk') > -1) {
        s_siteID = "Scandinavia";
    } else if (l_hostname.indexOf('questsoftware.com.sg') > -1) {
        s_siteID = "South East Asia";
    } else if (l_hostname.indexOf('questsoftware.es') > -1) {
        s_siteID = "Spain";
    } else if (l_hostname.indexOf('quest-software.co.uk') > -1) {
        s_siteID = "United Kingdom";
    } else if (l_hostname.indexOf('quest.com') > -1) {
        s_siteID = "United States";
    }
    if (s_siteID.substr(0, 1) == ".") {
        s_siteID = s_siteID.substr(1);
    }
    return s_siteID;
}
