// True only for pages that have auto-refresh set up, like in play.
var isAutoRefreshPage = false;
// BodyOnLoad is associated with the body tag in the template
// for pages that need additional BodyOnLoad functionality use a different document head
function BodyOnLoad()
{	
    toggleGoldIndexButton('NavigationGoldIndexBox');
    preloadImages();
    openNav();   
	checkCookieShowSplash();
    FillRelatedArticles();
    
    var BackToText = getQueryVariableI('PageName');
    var BackToLink = getQueryVariableI('VoteBackToHref');
   
    if (document.getElementById('VoteBackTo')) 
    {  
        if (BackToLink) 
        {
	        document.getElementById('VoteBackTo').href = BackToLink;
	    } 
	    else 
	    {       
            //get the referrer url
            var referrerUrl =  document.referrer;
	        document.getElementById('VoteBackTo').href = referrerUrl;
	    }
	    if (BackToText)
	    {
   	        document.getElementById('VoteBackTo').innerText = 'Back to '+BackToText;
   	    }
   	    else 
   	    {
   	        document.getElementById('VoteBackTo').innerText = "Back to previous page";   	        
   	    }
    }   
    if( document.getElementById('BackTo') ) {
	    document.getElementById('BackTo').href = PageIdAttribute('LinkBack');
   	    document.getElementById('BackTo').innerText = 'Back to '+PageIdAttribute('PageName');
    }
    if( document.getElementById('BriefingSurvey') ) {
        var pageName = document.getElementById('BriefingPageName').value;        
        var voteUrl = "http://"+document.domain+"/GeneralContent/Active/SelectSurveyNet/TakeSurveyInvestor.aspx?PageName=" + pageName;
        window.open(voteUrl,'BriefingSurvey','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
    }
    
    //call FullTextSearch body load if necessary
    if (document.getElementById('PageName') && document.getElementById('LastPageName')) 
    {
        FullTextSearchLoad();
    }
 }

// Get QueryString value no case
function getQueryVariableI(variable)
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++)
	{
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1].replace(/%20/g,' ');
		}
	} 
	return '';
}

// Get QueryString value
function getQueryVariable(variable)
{
	variable = variable.toUpperCase();
	var query = window.location.search.substring(1).toUpperCase();
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++)
	{
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 
	return '';
}

// Return attribute based ontype, associated with page Id.
function PageIdAttribute(type)
{
	var pageId = getQueryVariable('pageId');

	switch(pageId) {
		case '3614':
			if(type == 'MenuName') return 'STOCK ANALYSIS';
			if(type == 'PageName') return 'Active Portfolio';
			if(type == 'LinkBack') return '/Investor/Private/StockAnalysis/ActivePortfolio.htm'; 
			if(type == 'OpenNav') return 'Private/StockAnalysis/'; 
			if(type == 'PageSection') return 'StockAnalysis';
			break;
		case '3604':
			if(type == 'MenuName') return 'STOCK ANALYSIS';
			if(type == 'PageName') return 'Bargain Hunting';
			if(type == 'LinkBack') return '/Investor/Private/StockAnalysis/BargainHunting.htm'; 
			if(type == 'OpenNav') return 'Private/StockAnalysis/'; 
			if(type == 'PageSection') return 'StockAnalysis';
			break;
		case '3725':
			if(type == 'MenuName') return 'STOCK ANALYSIS';
			if(type == 'PageName') return 'Follow Up Folder';
			if(type == 'LinkBack') return '/Investor/Private/StockAnalysis/FollowUpFolder.htm'; 
			if(type == 'OpenNav') return 'Private/StockAnalysis/'; 
			if(type == 'PageSection') return 'StockAnalysis';
			break;
		case '3600':
			if(type == 'MenuName') return 'MARKET SNAPSHOT';
			if(type == 'PageName') return 'Headline Hits';
			if(type == 'LinkBack') return '/Investor/Public/MarketSnapshot/HeadlineHits.htm'; 
			if(type == 'OpenNav') return 'Public/MarketSnapshot/'; 
			if(type == 'PageSection') return 'MarketSnapshot';
			break;
		case '3122':
			if(type == 'MenuName') return 'MARKET SNAPSHOT';
			if(type == 'PageName') return 'Page One';
			if(type == 'LinkBack') return '/Investor/Public/MarketSnapshot/PageOne.htm'; 
			if(type == 'OpenNav') return 'Public/MarketSnapshot/'; 
			if(type == 'PageSection') return 'MarketSnapshot';
			break;
		case '3522':
			if(type == 'MenuName') return 'MARKET SNAPSHOT';
			if(type == 'PageName') return 'After Hours Report';
			if(type == 'LinkBack') return '/Investor/Public/MarketSnapshot/AfterHoursReport.htm'; 
			if(type == 'OpenNav') return 'Public/MarketSnapshot/'; 
			if(type == 'PageSection') return 'MarketSnapshot';
			break;
		case '3730':
			if(type == 'MenuName') return 'MARKET SNAPSHOT';
			if(type == 'PageName') return 'Looking Ahead';
			if(type == 'LinkBack') return '/Investor/Public/MarketSnapshot/LookingAhead.htm'; 
			if(type == 'OpenNav') return 'Public/MarketSnapshot/'; 
			if(type == 'PageSection') return 'MarketSnapshot';
			break;
		case '3512':
			if(type == 'MenuName') return 'MARKET SNAPSHOT';
			if(type == 'PageName') return 'Market Internals';
			if(type == 'LinkBack') return '/Investor/Private/MarketSnapshot/MarketInternals.htm'; 
			if(type == 'OpenNav') return 'Public/MarketSnapshot/'; 
			if(type == 'PageSection') return 'MarketSnapshot';
			break;
		case '3152':
			if(type == 'MenuName') return 'MARKET SNAPSHOT';
			if(type == 'PageName') return 'Stock Market Update';
			if(type == 'LinkBack') return '/Investor/Public/MarketSnapshot/StockMarketUpdate.htm'; 
			if(type == 'OpenNav') return 'Public/MarketSnapshot/'; 
			if(type == 'PageSection') return 'MarketSnapshot';
			break;
		case '3182':
			if(type == 'MenuName') return 'MARKET SNAPSHOT';
			if(type == 'PageName') return 'Bond Market Update';
			if(type == 'LinkBack') return '/Investor/Public/MarketSnapshot/BondMarketUpdate.htm'; 
			if(type == 'OpenNav') return 'Public/MarketSnapshot/'; 
			if(type == 'PageSection') return 'MarketSnapshot';
			break;
		case '3610':
			if(type == 'MenuName') return 'OUR VIEW';
			if(type == 'PageName') return 'Ahead of the Curve';
			if(type == 'LinkBack') return '/Investor/Private/OurView/AheadofTheCurve.htm'; 
			if(type == 'OpenNav') return 'Private/OurView/'; 
			if(type == 'PageSection') return 'OurView';
			break;
		case '3608':
			if(type == 'MenuName') return 'OUR VIEW';
			if(type == 'PageName') return 'Ask an Analyst';
			if(type == 'LinkBack') return '/Investor/Public/OurView/AskAnAnalyst.htm'; 
			if(type == 'OpenNav') return 'Public/OurView/'; 
			if(type == 'PageSection') return 'OurView';
			break;
		case '3611':
			if(type == 'MenuName') return 'OUR VIEW';
			if(type == 'PageName') return 'The Big Picture';
			if(type == 'LinkBack') return '/Investor/Private/OurView/TheBigPicture.htm'; 
			if(type == 'OpenNav') return 'Private/OurView/'; 
			if(type == 'PageSection') return 'OurView';
			break;
		case '3612':
			if(type == 'MenuName') return 'OUR VIEW';
			if(type == 'PageName') return 'Industry Insight';
			if(type == 'LinkBack') return '/Investor/Private/OurView/IndustryInsight.htm'; 
			if(type == 'OpenNav') return 'Private/OurView/'; 
			if(type == 'PageSection') return 'OurView';
			break;
		case '3720':
			if(type == 'MenuName') return 'OUR VIEW';
			if(type == 'PageName') return 'Economic View';
			if(type == 'LinkBack') return '/Investor/Public/OurView/EconomicView.htm'; 
			if(type == 'OpenNav') return 'Public/OurView/'; 
			if(type == 'PageSection') return 'OurView';
			break;
		case '3607':
			if(type == 'MenuName') return 'OUR VIEW';
			if(type == 'PageName') return 'Taking Stock';
			if(type == 'LinkBack') return '/Investor/Private/OurView/TakingStock.htm'; 
			if(type == 'OpenNav') return 'Private/OurView/'; 
			if(type == 'PageSection') return 'OurView';
			break;
		case '3613':
			if(type == 'MenuName') return 'OUR VIEW';
			if(type == 'PageName') return 'Market View';
			if(type == 'LinkBack') return '/Investor/Public/OurView/MarketView.htm'; 
			if(type == 'OpenNav') return 'Public/OurView/'; 
			if(type == 'PageSection') return 'OurView';
			break;
		case '3650':
			if(type == 'MenuName') return 'BRIEFING TV';
			if(type == 'PageName') return 'Briefing TV';
			if(type == 'LinkBack') return '/Investor/GeneralContent/Active/Investor/BriefingTV/BriefingTV.aspx'; 
			if(type == 'OpenNav') return 'Public/BriefingTV/'; 
			if(type == 'PageSection') return 'BriefingTV';
			break;
		case '3214':
			if(type == 'MenuName') return 'CALENDARS';
			if(type == 'PageName') return 'Upgrades/Downgrades';
			if(type == 'LinkBack') return '/Investor/Public/Calendars/UpgradesDowngrades.htm'; 
			if(type == 'OpenNav') return 'Public/Calendars/'; 
			if(type == 'PageSection') return 'Calendars';
			break;
		case '3229':
			if(type == 'MenuName') return 'CALENDARS';
			if(type == 'PageName') return 'Economic Calendar';
			if(type == 'LinkBack') return '/Investor/Public/Calendars/EconomicCalendar.htm'; 
			if(type == 'OpenNav') return 'Public/Calendars/'; 
			if(type == 'PageSection') return 'Calendars';
			break;
		case '3269':
			if(type == 'MenuName') return 'CALENDARS';
			if(type == 'PageName') return 'Earnings Calendar';
			if(type == 'LinkBack') return '/Investor/Private/Calendars/EarningsCalendar.htm'; 
			if(type == 'OpenNav') return 'Public/Calendars/'; 
			if(type == 'PageSection') return 'Calendars';
			break;
		default:
			break;
	}
	return "";
}