function sfHover() 
{
	var sfEls,
		nav;
		
	if ((nav = document.getElementById("nav")) != null)
	{
		if ((sfEls = nav.getElementsByTagName("li")) != null)
		{
			for (var i = 0; i < sfEls.length; i++) 
			{
				sfEls[i].onmouseover = function() 
				{
					this._className = this.className;
					this.className += " sfhover";
				}
				sfEls[i].onmouseout = function() 
				{
					this.className = this._className;
				}
			}
		}
	}
}
	
function DownloadDocument(documentID, whiteLabel)
{
	var xmlRequest;
	
	xmlRequest = new XmlRequest();
	xmlRequest.ServerPage = "GetDownloadURL.aspx";
	returnUrl = xmlRequest.ExecuteScalar("<root id=\"" + documentID + "\" />");
	if (returnUrl.search("&popup") != -1) {
		window.open(returnUrl.replace("&popup", ""), "", "", "_blank");
		returnUrl = whiteLabel + "-whitepaper-thanks.aspx?id=" + documentID.toString();
	}
	window.location.href = returnUrl;
}
	
function OnChangeLanguage(language)
{
	var expr,
		url,
		m;
	
	url = window.location.href;
	expr = /(.)(lang=\w+)/i;
	if ((m = url.match(expr)) == null)
		url += (window.location.search.length == 0 ? "?" : "&") + "lang=" + language;
	else
		url = url.replace(expr, m[1] + "lang=" + language);

	window.location.href = url;
}

function OnSetFontSize(size)
{
	var expr,
		url,
		m;
	
	url = window.location.href;
	expr = /(.)(fontsize=\w+)/i;
	if ((m = url.match(expr)) == null)
		url += (window.location.search.length == 0 ? "?" : "&") + "fontsize=" + size;
	else
		url = url.replace(expr, m[1] + "fontsize=" + size);

	window.location.href = url;
}

function ShowInfo()
{
	if (document.getElementById('info_text').className != 'info_text_closed')
		document.getElementById('info_text').className = 'info_text_closed';
	else
		document.getElementById('info_text').className = 'info_text_open';
}	

function SiteSearch(textbox, combobox)
{
	window.location.href = "sitesearch.aspx?condition=" + escape(textbox.value);
}

function Login()
{
	SetReload(true);
	Submit(99, "login");
}

function Logoff()
{
	SetRedirect(true);
	AddSubmitParameter("returnurl", sVRoot + "/?");
	Submit(99, "logoff");
}

function TellAFriend()
{
	window.open('TellAFriend.aspx?url=' + window.location.href,"","dialog=yes, width=500, height=360, scrollbars=no, status=no");			
}

function ToggleInterests(checked) {
    var sfEls,
		interests;

    if (checked) {
        if ((interests = document.getElementById("interests")) != null) {
            if ((sfEls = interests.getElementsByTagName("input")) != null) {
                for (var i = 0; i < sfEls.length; i++) {
                    if (sfEls[i].type == "checkbox")
                        sfEls[i].checked = false;
                    else
                        sfEls[i].value = false;
                }
            }
        }
    }
}

function ToggleOptin(checked) {
    var optin;

    if (checked) {
        if ((optin = getElementByAlias("_optinmarqit")) != null) {
            optin.checked = false;
            document.getElementById('hidden_' + optin.id).value = true;
        }
    }
}

function QuickLogin(e) {
	var event = window.event;

	if (event.keyCode == 13) {
		Login();
	}
}
