function initHelpWindow() {

	window.focus();

	var help_content = "FAQs/FAQs_interface_1.html";

	<!-- Function to extract URL params -->
	if (location.search.length > 0) {

		urlStr = location.href;
		paramArray = urlStr.split("?");
		paramStr = "";

        // Rebuild, in case multipl '?' queries in href
		for ( var i=1; i < paramArray.length; i++ ) {
			paramStr += paramArray[i] + "?";
		}

        paramStr = paramStr.substring(0,paramStr.length-1);

        help_content = paramStr;

		var paramStrArray = paramStr.split("&");
		for (var i = 0; i < paramStrArray.length; i++) {
			var lhs = paramStrArray[i].substring(0, paramStrArray[i].indexOf("="));
			var rhs = paramStrArray[i].substring(paramStrArray[i].indexOf("=") + 1, paramStr.length);

			if ( lhs == "content" ) {
				help_content = rhs;
			}
		}
	}

	setContentFrame( help_content );
}


function setContentFrame( urlStr ) {
	frames["content"].location.href = urlStr;
}


function submitSearch() {
	if ( document.forms["searchForm"].query.value != "" ) {
		document.forms["searchForm"].submit();
	}
	else {
		document.forms["searchForm"].query.style.borderStyle = "solid";
		document.forms["searchForm"].query.style.borderWidth = 1;
		document.forms["searchForm"].query.style.borderColor = "#FF0000";
	}
}

// Search through the Table Of Contents, and name each 'A' element the same as its 'href'
// This enables the TOC to reload and "move" to the currently selected heading, without
// Needing to specify the name="" and href="" of each help document.
// DOESN'T SEEM TO WORK - CAN'T RENAME TAGS... ;o(
function nameAnchors() {

    var refs = document.getElementsByTagName("a");
    var refCounter=0;
    var ref;

    // Loop through, trying to find refs which match the URL
    while ( ref = refs[refCounter++] ) {
        try { 
            ref.tagName = ref;
        }
        catch(er) {
            // alert("Unable to set '" + ref + "'");
        }
    }
}

// Find the URL link, and hilight the text
// Called from the content window, so should be able to extract the URL we're trying to hilight
function hilightTopic() {

    ensureContentFrameShowing();

    var indexFrame = top.frames["index"];

    // Back out if indexFrame not found, or search results are present
    if ( (indexFrame == null) || (indexFrame.searchResults != null) ) {
        return;
    }

    var url = document.location.href;

    // Strip off the trailing '#', if present
    var urlParts = url.split('#');
    url = urlParts[0];

    var toc = indexFrame.document;

    var urlParts = url.split('/');
    var page = urlParts[urlParts.length-1];

    // Commented out to prevent messing browser history
    // No easy way to neatly not mess with the history, http://developer.irt.org/script/history.htm
    // toc.location.href="/help/toc.html#" + page;

    // alert(url + " == " + toc );

    var refs = toc.getElementsByTagName("a");
    var refCounter=0;
    var ref;

    // alert(refs + " ... " + refs.length);

    var s = "";

    // Loop through, trying to find refs which match the URL
    while ( ref = refs[refCounter++] ) {
        // alert(ref);
        s += ref + " ";

        if ( ref == url ) {
            ref.style.color = "#FF7722";
        }
        else {
            ref.style.color = "";
            ref.style.background = ""
            ref.style.padding = ""
            ref.style.margin= ""
        }

        // If the style is a major heading, make it bold - so IE doesn't forget!
        if ( ref.className == 'tf' ) { ref.style.fontWeight = "bold" }
    }

    // alert("done. " + s);
}

// Simple function to reduce liklihood of spiders picking up our email addresses for spamming
function writeEmail(username, subject, extension) {

    if ( extension == null ) {
        extension = 'com';
    }

    var addr = username + '@' + "BullionVault" + '.'+ extension;
    var link = "mailto:" + addr;

    if ( subject != null ) {
        link += "?subject=" + subject;
    }

    document.write("<a href='" + link + "'>" + addr + "</a>");
}

// Popup a small, detailed help window on some elements
function moreInfo( urlStr ) {
    window.open(urlStr, "bvMoreHelp", 'width=320,height=480,resizable=yes,dependent=no,scrollbars=yes');
}

function showVaultStatements() {
    window.open("/audit/vault_statements.html", "bvVaultStatements", 'width=920,height=500,resizable=yes,dependent=no,scrollbars=yes');
    return false;
}

function brochurePageLoaded() {
	if ( window.top != this ) {
		window.top.scrollbars.visible = true;
		window.top.resizeTo( 626, 596 );
		window.top.location.href = window.location;
	}
}

function ensureHelpFrameShowing() {

    if ( window == top ) { 
        top.location.href = "/help";
    }
}

// Check whether help content is being displayed in frame, as expected
// - only called from content frames.
function ensureContentFrameShowing() {

    var href = document.location.href;

    if ( window == top && href.indexOf('http') >= 0 ) {
        var a = href.split('/help/');
        var h = a[0] + '/help/?' + a[1];
        top.location.href = h;
    }
}

function getSite() {
    var site = location.href.split('://')[1].split('/')[0];
    return site;
}

function getUrlParamHash() {

    var href = location.href;

    var paramHash = new Object();

    var splitHref = href.split('?');

    if ( splitHref[1] ) {

        var params = splitHref[1].split('&');

        for ( var i=0; i<params.length; i++ ) {
            var keyValue = params[i].split('=');

            paramHash[keyValue[0]] = keyValue[1] || "";
        }
    }

    return paramHash;
}
