
//  Replace the currently shown layer
var current_layer = null;
function replace_layer(replacement_layer)
{
    if (!current_layer) return;
    if (!replacement_layer) return;

    current_layer.setVisibility('hidden');
    replacement_layer.setVisibility('visible');
    current_layer = replacement_layer;
}


// Hide / show sets of layers
var layer_array = new Array();
var temp = null;

// Show this layer
function set_layer(new_layer)
{
    layer_array[layer_array.length] = new_layer;
    new_layer.setVisibility('visible');
}

// Clear all the layers that were set
function clear_layers()
{
    var i;
    for (i = 0; i < layer_array.length; i++)
	{
	    layer_array[i].setVisibility('hidden');
	}
    layer_array.length = 0;
}


//  Dummy functions for unsupported operations
function do_nothing(name, right, bottom)
{
    ;
}


/*
 * This function parses comma-separated name=value argument pairs from
 * the query string of the URL. It stores the name=value pairs in 
 * properties of an object and returns that object.
 */
function getArgs(separator) {
    var args = new Object();
    var query = location.search.substring(1);  // Get query string.
    var pairs = query.split(separator);              // Break at separator.
    for(var i = 0; i < pairs.length; i++) {
	var pos = pairs[i].indexOf('=');       // Look for "name=value".
	if (pos == -1) continue;               // If not found, skip.
	var argname = pairs[i].substring(0,pos);  // Extract the name.
	var value = pairs[i].substring(pos+1); // Extract the value.
	args[argname] = unescape(value);          // Store as a property.
    }
    return args;                               // Return the object.
}


/*
 * These functions write email links that don't sniff well...
 */
function esrever(ni)
{
    var tuo = new String();
    for (i=0; i < ni.length; i++) {
	tuo = ni.charAt(i) + tuo;
    }
    return tuo;
}
      
function rul(resu, mod)
{
    var temp = new String("moc.");
    return esrever(temp.concat(mod, "@", resu));
}

function writeUs (resu, sep, mod, com)
{
    document.write(esrever(":otliam'=ferh A<"));
    document.write(rul(resu, mod));
    document.write(esrever(">'"));
    document.write(rul(resu, mod));
    document.write(esrever(">A/<"));
}

function mailOpen(resu, sep, mod, com)
{
    document.write(esrever(":otliam'=ferh A<"));
    document.write(rul(resu, mod));
    document.write(esrever(">'"));
}

function mailClose()
{
    document.write(esrever(">A/<"));
}

function anchorOpen(url, etc)
{
    document.write("<a href=");
    document.write(url);
    document.write(" ");
    document.write(etc);
    document.write(">");
}


function anchorClosed(url, etc)
{
    document.write("</a>");
}


// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Older stuff here...

// Determine the version
nav_version = 2;
if (((navigator.appName == "Netscape")
     && (parseInt(navigator.appVersion) >= 3))
    || ((navigator.appName == "Microsoft Internet Explorer")
	&& (parseInt(navigator.appVersion) >= 4)))
{
    nav_version = 3;
}
if (((navigator.appName == "Netscape")
     && (parseInt(navigator.appVersion) >= 4))
    || ((navigator.appName == "Microsoft Internet Explorer")
	&& (parseInt(navigator.appVersion) >= 4)))
{
    nav_version = 4;
}


// Turn on the image highlight
function rollover_on(img)
{
    if (nav_version >= 3) 
	{
	    img.src = this.highlight.src;
	}
}


// Turn off the image highlight
function rollover_off(img)
{
    if (nav_version >= 3) 
	{
	    img.src = this.normal.src;
	}
}


// Constructor for a rollover
function Rollover(normal, highlight)
{
    if (nav_version >= 3) 
	{
	    this.normal = new Image();
	    this.normal.src = normal;
	    this.highlight = new Image();
	    this.highlight.src = highlight;
	}
    this.on = rollover_on;
    this.off = rollover_off;
}


//  Turn on the follower
function follower_on(index) 
{
    if (nav_version >= 3) 
	{
	    //  Move the current graphic to the last spot
	    this.files[this.last] = this.files[index];
	    this.images[this.last].src = this.files[index];
      
	    //  Replace the current with the new one
	    this.files[index] = this.normal;
	    this.images[index].src = this.highlight;
      
	    //  Remember where it is
	    this.last = index;
	}
}


//  Turn off the follower
function follower_off(index)
{
    if (nav_version >= 3) 
	{
	    this.images[index].src = this.normal;
	}
}


//  Add a new element to the followers array
function follower_add(index, image, file)
{
    this.images[index] = image;
    this.files[index] = file;        
}
 

//  Create the followers array
function Followers(index, normal, highlight)
{
    this.last = index;

    this.normal = normal;
    this.highlight = highlight;

    this.images = new Array();
    this.files = new Array();
        
    this.on = follower_on;
    this.off = follower_off;
    this.add = follower_add;
}


//  Add a new element to the counters array
function counter_add(index, image)
{
    this.images[index] = image;
}


//  Set the new value for the counter
function counter_set(value)
{
    var i;
    for (i = 0; i < this.last; i++)
	{
	    this.images[i].src = this.files[Math.floor(value)%10];
	    value = Number(value)/10;
	}
} 


//  Create the counter array
function Counter(index, f0, f1, f2, f3, f4, f5, f6, f7, f8, f9)
{
    this.last = index;

    this.images = new Array();
    this.files = new Array();

    this.files[0] = f0;
    this.files[1] = f1;
    this.files[2] = f2;
    this.files[3] = f3;
    this.files[4] = f4;
    this.files[5] = f5;
    this.files[6] = f6;
    this.files[7] = f7;
    this.files[8] = f8;
    this.files[9] = f9;

    this.add = counter_add;
    this.set = counter_set;
}


// Count down seconds in the status line
var time_left = 0;
var status_message = "";
function count_down(message, seconds)
{
    time_left = seconds;
    status_message = message;
    do_count_down();
}

function do_count_down()
{
    defaultStatus = status_message + time_left;
    time_left--;

    if (time_left > 0)
	{
	    setTimeout("do_count_down()", 1000);
	}
}


// Time the loading so we know when to change pages
var load_time;
function start_timer()
{
    load_time = 0;
    setTimeout("tic_time()", 1000);
}
function tic_time()
{
    load_time++;
    setTimeout("tic_time()", 1000);
}

// Constructor for the Preload
function Preload(pic)
{
    if (nav_version >= 3) 
	{
	    this.pic = new Image();
	    this.pic.src = pic;
	}
}

// Change to the next page
function next_page(end_time, url)
{
    if (end_time <= load_time)
	{
	    self.location.href = url;
	}
    else
	{
	    setTimeout("next_page("+end_time+", '"+url+"')",
		       1000 * (end_time - load_time));
	}
} 


