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() {
    preloadImages();
	setWebTrendsContent()
}

// ----------------------------------------------------------------------------
// Used for WebTrends
// ----------------------------------------------------------------------------
function setWebTrendsContent()
{
    // assign document title to WebTrends tag
    var docTitle = document.title;
    if( docTitle != null && docTitle != '' ) {
        docTitle = docTitle.replace('Briefing.com: ','');
        docTitle = docTitle.replace(/ /g, '');
        if( document.getElementById('WT.pi') ) {
            var productName = document.getElementById('WT.pi').content;
            document.getElementById('WT.pi').content = productName+'-'+docTitle;
        }
    }
}

// ----------------------------------------------------------------------------
// pre-cache tour index for previous/next buttons
// ----------------------------------------------------------------------------
var TourIndex = new Array();
TourIndex[0] = "index.htm";
TourIndex[1] = "tour_inplay.htm";
TourIndex[2] = "tour_headlines.htm";
TourIndex[3] = "tour_earnrevcal.htm";
TourIndex[4] = "tour_SameStoreSales.htm";
TourIndex[5] = "tour_calecon.htm";
TourIndex[6] = "tour_allcolumns.htm";
TourIndex[7] = "tour_TechnicalTake.htm";
TourIndex[8] = "tour_SwingTrader.htm";
TourIndex[9] = "tour_SmallCapFocus.htm";
TourIndex[10] = "tour_PageAlerts.htm";
TourIndex[11] = "tour_WatchList.htm";
TourIndex[12] = "tour_trader.htm";
TourIndex[13] = "tour_benchmark.htm";
TourIndex[14] = "tour_offer.htm";
var sPrevious = ""; sNext = "";

// ----------------------------------------------------------------------------
// Tour navigation
// ----------------------------------------------------------------------------
function MoveNext() {
    var sURL = (document.URL);
    if ((sURL.indexOf("tour_navigate.htm", 0) != -1) && (sURL.indexOf("navto=tour_offer.htm", 0) != -1)) {
        sNext = TourIndex[0];
    }
    else {
        for (i = 0; i <=TourIndex.length-1; i++) {
            if (sURL.indexOf(TourIndex[i], 0) != -1) {
                if (i < TourIndex.length-1)
                    sNext = (TourIndex[i+1]);
            }
            else if ((sURL.indexOf(TourIndex[i], 0) == -1) && i == 0) {
                sNext = (TourIndex[i+1]);
            }
        }
    }
    if (sNext.length > 0) {
        location.href = sNext;
    }
}

// ----------------------------------------------------------------------------
// Tour navigation
// ----------------------------------------------------------------------------
function MovePrevious() {
    var sURL = (document.URL);

    if (sURL.indexOf("tour_navigate.htm", 0) != -1) {
        sPrevious = sURL.slice(sURL.indexOf("navto=", 0)+6, (sURL.length));
    }
    else {
        for (i = 0; i <=TourIndex.length-1; i++) {
            if (sURL.indexOf(TourIndex[i], 0) != -1) {
                if (i > 0)
                    sPrevious = (TourIndex[i-1]);
            }
            else if  ((sURL.indexOf(TourIndex[i], 0) == -1) && i == 0) {
                sPrevious = (TourIndex[0]);
            }
        }
    }
    if (sPrevious.length > 0) {
        location.href = sPrevious;
    }
}

// ----------------------------------------------------------------------------
// Tour navigation
// ----------------------------------------------------------------------------
function MoveNavigate() {
    var sNavigate = "tour_navigate.htm"
    var sURL = (document.URL);
    if (sURL.indexOf("tour_", 0) == -1) {
        sNavigate += "?navto=" + TourIndex[0];
    }
    else {
        sNavigate += "?navto=" + sURL.slice(sURL.indexOf("tour_", 0), (sURL.length));
    }
    location.href = sNavigate;

}

// ----------------------------------------------------------------------------
// This function is a utility and is used on other sites
// ----------------------------------------------------------------------------
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// ----------------------------------------------------------------------------
// This function is a utility and is used on other sites
// ----------------------------------------------------------------------------
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

// ----------------------------------------------------------------------------
// Local: loads images for GeneralInfo site
// ----------------------------------------------------------------------------
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		TourOffer_rollover_01_over = newImage("/common/images/Features/TourOffer_rollover_01-over.gif");
		preloadFlag = true;
	}
}
