//
// Improved Digg integration script
// 
// This JavaScript will include a "digg it" button on your page if the user has been to digg before.
// Not showing the "digg it" button to non-digg users will keep you from confusing non-digg-savy 
// users and help keep them on your site.
//
// more details are available at http://int2e.com/blog/
//
// This script is (c) int2e LLC 2007
// mail@int2e.com  http://int2e.com
//
// Portions, such as idGet() and some history-checking, are based on code by 
// Henrik Gemal from http://gemal.dk/browserspy/css.html
// Used with permission from Henrik Gemal.

function idGet(id) {
    if (typeof(document.getElementById) != "undefined") {
        return document.getElementById(id);
    } else {
        return document.all[id];
    }
}

document.writeln('<a id="digglink" href="http://digg.com"></a>');
document.writeln('<a id="digglink-www" href="http://www.digg.com"></a>');

document.writeln('<style type="text/css">');
//to make the #... plural, tack on new ones with ', ' between them
document.write('#digglink, #digglink-www { position: absolute; top: 0; }');
document.write('#digglink:visited, #digglink-www:visited { top: 100px; color: #660001; }');
document.writeln("</style>");



var lnk=idGet("digglink");
var lnkwww=idGet("digglink-www");

if (lnk && lnkwww) {
    var visited=0; // zero means digg not visisted
    if (lnk && 'offsetTop' in lnk)
        if (lnk.offsetTop == 100)
            visited=1; //found link visited
    if (lnkwww && 'offsetTop' in lnkwww)
        if (lnkwww.offsetTop == 100)
            visited=10; //found www link visited
    if (lnk && 'currentStyle' in lnk && 'color' in lnk.currentStyle)
	if (lnk.currentStyle.color == '#660001')
	    visited=2; //found link visited
    if (lnkwww && 'currentStyle' in lnkwww && 'color' in lnkwww.currentStyle)
	if (lnkwww.currentStyle.color == '#660001')
	    visited=20; //found www link visited
    if (visited) { //if non-zero, then digg visited
	//var toWrite = idGet("diggjs");
	document.writeln("<script src=\"http://digg.com/tools/diggthis.js\" type=\"text/javascript\"></script>");
	//toWrite.innerHTML = "<script src=\"http://digg.com/tools/diggthis.js\" type=\"text/javascript\"></script>";
        //document.writeln('<strong>Yes you have been visiting the site lately!<' + '/strong><br />');
    } else {
        //document.writeln('No or unable to detect!<br />');
    }
}
