//see glimmer_read.js for all comments on versions, licenses, etc.
loaded = false; //this variable is set when the script is sourced, and
				//then set to true when initAll is finished (after the body loads)
layer_refer = "";
browser_version = "";
layer_name = new Array();
layer_obj = new Array();
end = "";
pause = "pause";
jump = "jump";


layers = new Array();

function init() {
    if (checkVer() > 3){
        initAll();
        layer_menu0a.hide();
        layer_menu0a.bounce(144,486);
        }
    }


var timeOut;
var timerRunning = false;    
    
    
function showMenu() {
    rollOver('aboutUs');
    if (!timerRunning) {
        layer_menu0a.show();
        timerID = setTimeout("menuOn();",10);
        }
    else {
        timerID = setTimeout("menuOn();",10);
        }
    }    
    
function menuOn() {
    rollOver('aboutUs','aboutUs');
    clearTimeout(timerID);
	timerID = setTimeout("layer_menu0a.show();",500);
	timerRunning = true;

    }
    
function menuOff() {

    if(timerRunning) {

	    clearTimeout(timerID);
	    timerID = setTimeout("layer_menu0a.hide();rollOff('aboutUs','aboutUs');",2000);
	    
	    timerRunning = false;

	    }
    }    


//these first functions are executive, they do control operations
//across the layer specific functions

//returns browser version (not type)
function checkVer() {
    browser = navigator.userAgent;
    browser_version = parseInt(navigator.appVersion);
    if(browser.indexOf("Opera") > 1) {browser_version = 3;}
    return browser_version;
}

//do nothing - sometimes useful
function voidOut() {
	}

//scan through all tags for ids and fill out arrays
//for layer names and object names
function readAll() {
  if (document.getElementById) {
		j = 0;
		d = document.getElementsByTagName("div");
		for ( zz = 0; zz < d.length; zz++ )
		{    
		if (d[zz].id != "") {
			layer_name[j] = "layer_"+d[zz].id;
			layer_obj[j] = d[zz].id;
			j = j+1;
			}
		}
	}
	if (document.all) {
		j = 0;
		for ( zz = 0; zz < document.all.tags('DIV').length; zz++ )
		{    
		if (document.all.tags('DIV')[zz].id != "") {
			layer_name[j] = "layer_"+document.all.tags('DIV')[zz].id;
			layer_obj[j] = document.all.tags('DIV')[zz].id;
			j = j+1;
			}
		}
	}
	if (document.layers) {
		j = 0;
		for ( zz = 0; zz < document.layers.length; zz++ )
		{    
		if (document.layers[zz].name != "") {
			layer_name[j] = "layer_"+document.layers[zz].name;
			layer_obj[j] = document.layers[zz].name;
			j = j+1;
			}
		}
	}
}

//initialize all layer objects based on tags with ids.
function initAll() {
	var q;
	readAll();
	for ( q = 0; q < layer_obj.length; q++ ){
		eval(layer_name[q] +"= new layer('"+layer_obj[q]+"'\)");
        layers[q] = eval(layer_name[q]);
		}
	loaded = true;
	}	

function layer(name,father) {
	this.name = name;
	this.obj_name = 'layer_' + name;
    this.layer = name_layer(name);
	this.refresh = layer_refresh;
	this.refresh();
	this.extend = layer_extend;
	this.report = layer_report;
    this.hide = layer_hide;
    this.show = layer_show;
    this.bounce = layer_bounce;
	}  
    
function layer_refresh() {
	if(document.all) {
	this.top = parseInt(this.layer.pixelTop);
	this.left = parseInt(this.layer.pixelLeft);
	this.height = document.all[this.name].offsetHeight;
	this.width = document.all[this.name].offsetWidth;
	this.zIndex = this.layer.zIndex;
	this.visibility = this.layer.visibility;
    this.bgColor = this.layer.backgroundColor;
	}
	else if (document.layers) {
	this.top = this.layer.top;
	this.left = this.layer.left;
	this.height = this.layer.clip.height;
	this.width = this.layer.clip.width;
	this.zIndex = this.layer.zIndex;
	this.visibility = this.layer.visibility;
    this.bgColor = this.layer.bgColor;
	}
    else if (document.getElementById) {
	this.top = parseInt(this.layer.top);
	this.left = parseInt(this.layer.left);
	this.height = this.layer.height;
	this.width = this.layer.width;
	this.zIndex = this.layer.zIndex;
	this.visibility = this.layer.visibility;
    this.bgColor = this.layer.bgColor;
	}
	else {
	this.top = 0;
	this.left = 0;
	this.visibility = null;
	} 
}

function layer_extend(layer_element) {
	if (document.all) {
		layer_element_place = 'document.all["'+layer_element+'"].style';
		}
	if (document.layers) {
		layer_element_place = this.layer.document.layer_element;
		}
	else {layer_element_place = layer_element;}
	eval(this.obj_name +'.'+layer_element +'='+ layer_element_place);
	}

function name_layer(name) {
  if (document.getElementById) {
  	return(eval('document.getElementById("'+name+'").style'));
	}
  else if (document.layers) {
	return(eval('document.layers["'+name+'"]'));
 	}
  else if (document.all) {
	return(eval('document.all["' + name + '"].style'));
	}
  else{return("empty");}
}

function screenReload() {
    if (document.body) {
        eval("browserWidth = " + document.body.clientWidth);
        eval("browserHeight = " + document.body.clientHeight);     
        }
    else {
        eval("browserWidth = " + innerWidth);
        eval("browserHeight = " + innerHeight);
        }
    this.location.reload();
    }
	
window.onresize = screenReload;
	
//support function for debugging purposes.  will send an alert of current layer state
function layer_report() {
	alert("-REPORT-\nname:"+this.name+"\nobject name:"+this.obj_name+"\nlayer name:"+this.layer+"\ntop:"+this.top+"\nleft:"+this.left);
	alert("height:"+this.height+"\nwidth:"+this.width+"\nvisibility:"+this.visibility+"\nzindex:"+this.zIndex);
	}

//end glimmer


function windowWidth() {
    var width = 0;

    windowRef = window;
  
    if (typeof(windowRef.innerWidth) == 'number') {
        width = windowRef.innerWidth;
        }
    else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number') {
        width = windowRef.document.body.clientWidth;  
        }
    return width;
}



//move layer to x,y without hitting any points in between
function layer_bounce(top,left,codette){
        
    browserWidth = windowWidth();
    
    if (document.all) {
        menuPos = browserWidth/2 + 118;
    }
    else if (document.layers && (navigator.userAgent.indexOf("Win")!=-1) || (document.getElementById)) {
        menuPos = browserWidth/2 + 108;
    }
    else {
        menuPos = browserWidth/2 + 114;
    }
    
    this.layer.top = top;
    
    if (browserWidth>724) {
        this.layer.left = menuPos;
        }
    else {
        this.layer.left = left;
        }
	
	this.refresh();
	if (codette){runMe(codette);}
	}

//show the layer
function layer_show(x,y,codette){
	this.layer.visibility = "visible";
	this.refresh();
	if (codette){runMe(codette);}
	}
	
//hide the layer
function layer_hide(x,y,codette){
	this.layer.visibility = "hidden";
	this.refresh();
	if (codette){runMe(codette);}
	}
