if (top.location != self.location)
{
	top.location = self.location;
}

function submitForm()
{
    document.getElementById('submitform').disabled = true;
    document.getElementById('submitform').value = "Please Wait";
    return true;
}

function setCookie(name, value, expires, path, domain, secure)
{
    var today = new Date();
    today.setTime(today.getTime());
    if (expires)
    {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires = new Date(today.getTime() + (expires));

    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toUTCString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
        end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function externalLinks()
{
    if (!document.getElementsByTagName) return false;
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++)
    {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "nofollow" || anchor.getAttribute("rel") == "external"))
        {
            anchor.target = "_blank";
            if (!anchor.className)
            {
                anchor.className = "external";
            }
            else
            {
                newClassName     = anchor.className + " external";
                anchor.className = newClassName;
            }
        }
    }
}

function extLinkDisplay() {
	if (!document.getElementById) return false;
    var theDiv = document.getElementById('footer');
	for (var i=0; i < theDiv.childNodes.length; i++)
	{
		if (theDiv.childNodes[i].nodeType == 1 && theDiv.childNodes[i].nodeName.toLowerCase() == 'p')
		{
			if (theDiv.childNodes[i].className == "smaller")
			{
			    txt = document.createTextNode(" | ");
			    theDiv.childNodes[i].appendChild(txt);
			    theImage = document.createElement('img');
			    theImage.setAttribute("src","/images/external.gif");
				theImage.setAttribute("width","7");
				theImage.setAttribute("height","8");
				theImage.setAttribute("alt","External Link");
				theDiv.childNodes[i].appendChild(theImage);
                txt = document.createTextNode(" Indicates a link to an external website (link will open in new window)");
			    theDiv.childNodes[i].appendChild(txt);
                break;
			}
		}
	}
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function')
    {
        window.onload = func;
    }
    else
    {
        window.onload = function()
        {
            oldonload();
            func();
        }
    }
}

addLoadEvent(externalLinks);
addLoadEvent(extLinkDisplay);