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

function getFile(fileName)
{
    oxmlhttp = null;

    try
	{
        oxmlhttp = new XMLHttpRequest();
        oxmlhttp.overrideMimeType("text/xml");
    }

    catch(e)
	{
        try
		{
            oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }

        catch(e)
		{
            return null;
        }
    }

    if(!oxmlhttp) return null;

    try
	{
       oxmlhttp.open("GET",fileName,false);
       oxmlhttp.send(null);
    }

    catch(e)
	{
       return null;
    }

    return oxmlhttp.responseText;
}

function addReferers()
{
	var referers = document.getElementById('referers');
	var referersCache = getFile('http://www.babedot.com/cache/top_referers.txt');

	referers.innerHTML = referersCache;
}

/* XHTML target attribute */
function externalLinks() 
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++) 
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
		{
			anchor.target = "_blank";
		}
	}
} 

function bookmark(title, url)
{
	if (document.all)
	{
		window.external.AddFavorite(url, title);
	}
	else if (window.sidebar)
	{
		window.sidebar.addPanel(title, url, "")
	}
}

window.onload = function()
{
	addReferers();
	externalLinks();
} 