// SQUARE GIF CODE
//
// These variables keep track of which square gif is being displayed.
var a = 0;
var b = 0;
var c = 0;

function cycleSquare(obj, num)
{
    var src   = obj.src;
    var id    = obj.id;
    var pos   = src.lastIndexOf("/");           // To get the path of the image, we look for the last "/" and grab everything before it
    var path  = src.substring(0,pos+1);         // yielding the path.  If there is no "/" path equates to "".
    var abORc = id.substr(id.length - 1, 1);    // This returns the last character of the id (which has to be either a, b, or c) and tells
                                                // us which image to cycle

    var idx   = "";

    if(abORc == "a")                            // The images used to cycle through have a specific naming convention:
    {                                           //      name_x#
        a   = (a + 1) % num;                    //          where "name" is unique to each page
        idx = (a == 0) ? "" : a + 1;            //                "x" is either "a", "b", or "c"
    }                                           //          and   "#" is "", "2", "3", "4", etc.
    else if(abORc == "b")                       // So the first image on the home page would be named "home_a", the third image
    {                                           // would be named "home_c".  This code checks for the "a", "b", or "c" to determine
        b   = (b + 1) % num;                    // which image to work on, then attaches a number to the end to cycle through all
        idx = (b == 0) ? "" : b + 1;            // available images for that square.  So if the first square on the home page had 4
    }                                           // images to cycle through, then we'd need to look for "home_a", "home_a2", "home_a3"
    else if(abORc == "c")                       // and "home_a4".
    {                                           //
        c   = (c + 1) % num;                    // In the html you'd call this function on a mouseover event like so:
        idx = (c == 0) ? "" : c + 1;            // cycleSquare(this,4) if there were 4 images available.
    }

    obj.src = path + id + idx + ".gif";
}


// LEFT NAVIGATION CODE
function leftNavHover(obj)
{
    var src  = obj.src;
    var pos  = src.lastIndexOf("/");
    var path = src.substring(0,pos+1);
    var id   = obj.id;
    obj.src  = path + id + "ON.gif";
}

function leftNavHoverout(obj)
{
    var src  = obj.src;
    var pos  = src.lastIndexOf("/");
    var path = src.substring(0,pos+1);
    var id  = obj.id;
    obj.src = path + id + ".gif";
}


// POPUP WINDOW CODE
function newWindow(url,width,height)
{
    var features = "width="+width+",height="+height+",menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no";
    var win      = window.open(url, "_legal", features);
}

function showCredits()
{
    var width    = 840;
    var height   = 630;
    var url      = "http://offswitch.com";
    var features = "width="+width+",height="+height+",menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no";
    var win      = window.open(url, "_credits", features);
}
    