function toggleDivVis(theDiv) {
    theDivElement   = document.getElementById(theDiv);
    if (theDivElement) {
        if (theDivElement.style.display=="none")
            theDivElement.style.display = "";
        else
            theDivElement.style.display = "none";
    }
}

var iPath   = "images/";
var curPage = "";

function preLoad() {
    if (document.images) {
        var argLen  = arguments.length;
        if (argLen>15) { argLen = 15; }
        for(var i = 0; i < argLen; i++) {
            var arg     = arguments[i];
            self[arg + "_" + suf] = new Image();
            self[arg + "_" + suf].src = iPath + arg;
        }
    }
}

function mouseX(evt)
{
    if (!evt) evt = window.event;

    if (evt.pageX)
        return evt.pageX;
    else if (evt.clientX)
        return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft);
    else
        return 0;
}

function mouseY(evt)
{
    if (!evt) evt = window.event;

    if (evt.pageY)
        return evt.pageY;
    else if (evt.clientY)
        return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    else
        return 0;
}

var over = false;

function mouseOver()    { over = true; }
function mouseOut()     { over = false; }

function trackMouse(evt) {
    if (over) {
        projectPreviewDiv                       = document.getElementById("projectPreviewDiv");
        projectPreviewDivShadow                 = document.getElementById("projectPreviewDivShadow");
/**/
        projectPreviewDiv.style.top             = parseInt(mouseY(evt)) + 10 + "px";
        projectPreviewDiv.style.left            = parseInt(mouseX(evt)) + 10 + "px";
        projectPreviewDivShadow.style.top       = parseInt(mouseY(evt)) + 13 + "px";
        projectPreviewDivShadow.style.left      = parseInt(mouseX(evt)) + 13 + "px";
/**/
        }
}

if (document.layers)
    document.captureEvents(Event.MOUSEMOVE);

document.onmousemove            = trackMouse;



function toggleImg(newImgId) {
    imgElement                      = document.getElementById("projectPreviewImg");
    captionElement                  = document.getElementById("projectCaptionDiv");
    divElement                      = document.getElementById("projectPreviewDiv");
    divElementShadow                = document.getElementById("projectPreviewDivShadow");
    divElement.style.position       = "absolute";

    switch (newImgId) {
        case "ProjectHoneyPot":
            imgElement.setAttribute("src", "/images/ss_php.gif");
            captionElement.innerHTML            = "Project Honeypot is a data-gathering and reporting service that piggybacks code on volunteer websites in order to track how website crawlers use and distribute emails harvested from webpages.";
            mouseOver();
            updatePreviewDiv();
            updatePreviewDivShadow();
            break;
        case "UTCPR":
            imgElement.setAttribute("src", "/images/ss_utcpr.gif");
            captionElement.innerHTML            = "Utah's Kids Protection Registry: a service provided by the state of Utah to ensure that families may opt-out of receiving adult-oriented advertising by electronic means.";
            mouseOver();
            updatePreviewDiv();
            updatePreviewDivShadow();
            break;
        case "MICPR":
            imgElement.setAttribute("src", "/images/ss_micpr.gif");
            captionElement.innerHTML            = "Michigan's Children Protection Registry: a service provided by the state of Michigan to ensure that families may opt-out of receiving adult-oriented advertising by electronic means.";
            mouseOver();
            updatePreviewDiv();
            updatePreviewDivShadow();
            break;
        case "DeconstructingSundance":
            imgElement.setAttribute("src", "/images/ss_dec_sun.gif");
            captionElement.innerHTML            = "Deconstructing Sundance website documenting the use of a spam-email categorization tool to identify possible award winners at the 2006 Sundance Film Festival.";
            mouseOver();
            updatePreviewDiv();
            updatePreviewDivShadow();
            break;
        case "RegistryCompliance":
            imgElement.setAttribute("src", "/images/ss_regcomp.jpg");
            captionElement.innerHTML            = "A central site for marketers who would like to easily manage their accounts on multiple states' registries.";
            mouseOver();
            updatePreviewDiv();
            updatePreviewDivShadow();
            break;
        case "x":
            default:
            imgElement.setAttribute("src", "/images/x.gif");
            captionElement.innerHTML            = "Hilight a project to see some information then click to learn more.";
            mouseOut();
            divElement.style.display            = "none";
            divElementShadow.style.display      = "none";
            break;
    }
}

function updatePreviewDiv() {
    divElement                                  = document.getElementById("projectPreviewDiv");
    divElement.style.display                    = "";
}

function updatePreviewDivShadow() {
    divElementShadow                            = document.getElementById("projectPreviewDivShadow");
    divElement                                  = document.getElementById("projectPreviewDiv");

    divElementShadow.style.border               = divElement.style.border;
    divElementShadow.style.color                = divElement.style.color;

    divElementShadow.style.display              = "";
}


function onLoad() {
    toggleImg("x");
    preLoad("ss_php.gif", "ss_utcpr.gif", "ss_micpr.gif", "ss_dec_sun.gif", "x.gif", "ss_regcomp.jpg");
}
