//------------------------------------------------------------------------
//-- JavaScript Menus
//-- Ryan J. McDonough
//-- rmcdonough@typetzone.com
//-- Type T
//-- http://www.typetzone.com
//-- last modified 02/21/01
//------------------------------------------------------------------------

//-- Netscape resize fix
version = 2.0;

if (document.layers) {	
	if(!window.saveInnerWidth) {
  		window.onresize = resize;
  		window.saveInnerWidth = window.innerWidth;
  		window.saveInnerHeight = window.innerHeight;
		}
	}
	
function resize() {
    if (saveInnerWidth < window.innerWidth || 
        saveInnerWidth > window.innerWidth || 
        saveInnerHeight > window.innerHeight || 
        saveInnerHeight < window.innerHeight ) 
    {
        window.location.reload();
        scroll(0,0);
    }
}


//---------------------------------------------------------------------
//-- Opens a centered Pop-up window
//---------------------------------------------------------------------
function spawn(page,id,h,w) 
{
	h = parseInt(h);
	w = parseInt(w);
	if (document.layers) 
	{
    	boxTop  = (screen.availHeight)/2 - h;
        boxLeft  = (screen.availWidth - w)/2;
		coffeWin = window.open(page,id,'innerHeight='+h+',innerWidth='+w+',top='+boxTop+',left='+boxLeft+',menubar,toolbar,scrollbars');
	}
    else if (document.all) 
    {
    	boxTop  = (screen.height)/2 - h;
    	boxLeft  = (screen.width - w)/2;
    	coffeeWin = window.open(page,id,'height='+h+',width='+w+',top='+boxTop+',left='+boxLeft+',menubar,toolbar,scrollbars');
	}
}


//---------------------------------------------------------------------
//-- Define the image arrays and the image path for each section.
//---------------------------------------------------------------------
buttonPath = "/images/buttons/";
imageName = new Array();
imageOff = new Array();
imageOver = new Array();
imgType = ".gif";

//---------------------------------------------------------------------
//-- Common Buttons for All pages
//---------------------------------------------------------------------
imageName[0] = "ancil_home";
imageName[1] = "ancil_login";
imageName[2] = "ancil_search";
imageName[3] = "ancil_sitemap";
imageName[4] = "ancil_contact";
imageName[5] = "ancil_careers";
imageName[6] = "ancil_forms";

pageLoaded = false;
preLoadDone = false;

bName = navigator.appName;
os    = navigator.platform.toLowerCase();

//---------------------------------------------------------------------
//--Magic Menu Functions Begin Below
//---------------------------------------------------------------------


// here we establish the objRef and the objStyle to be evaluated in the show/hide functions below
// Netscape 6 likes document.getElementById
// Netscape 4.0 likes document.layers



function init() 
{
	preLoad();
	pageLoaded = true;
	createTopButton();
}

function preLoad() {
	window.status = "Preloading images......"
	for (i = 0; i < imageName.length; i++) {
		imageOff[i] = new Image();
		imageOff[i].src = buttonPath + imageName[i] + imgType;
		window.status = "Loading off state for Image: " + imageName[i];
		
		imageOver[i] = new Image();
		imageOver[i].src = buttonPath + imageName[i] + "_over" + imgType;
		window.status = "Loading over state for Image: " + imageName[i];
		}
	window.status = "Loading Complete."
	preLoadDone = true;
	}

//---------------------------------------------------------------------
//-- Roll over functions.
//-- These function execute the rollover functions for each image. Each 
//-- image is given an ID that is found in the images array. This ID corresponds
//-- to the name of the image. The functions are called in this order:
//-- ONMOUSOVER="imgOver('1');"	
//-- ONMOUSOUT="imgOff('1');"	
//-- ONMOUSDOWN="imgDown('1');"	
//-- ONMOUSEUP="imgOff('1');"
//-- ONCLICK="activateImage('1');
//--
//-- Not all functions need to be called
//-- for this script to function properly.
//---------------------------------------------------------------------	
	

function imgOver(imgID) {
	if (pageLoaded)
	{
		document.images[imageName[imgID]].src = imageOver[imgID].src;
	}
}
	
function imgOff(imgID) {
	if (pageLoaded)
	{
		document.images[imageName[imgID]].src = imageOff[imgID].src;
	}
}


//---------------------------------------------------------------------	
//-- Sets a "back to top" button to appear in the same location whenever
//-- the user scrolls. The button only appears when the window exeeds 
//-- 400 pixels in height.
//---------------------------------------------------------------------	

//-- Creates the top button layer
function createTopButton()
{
	/*topBtn = ""
	+ "<div id=\"topButton\" style=\"position: absolute; top: 400px;"
	+ "left: 160px; height:23px; width:19px; visibility: hidden;\">"
	+ "<a href=\"#top\"><img src=\"/images/icons/top_button.gif\"" 
	+ "alt=\"Back to Top\" width=\"19\" height=\"23\" border=\"0\">"
	+ "</a></div>"; 
	if (document.all)
	{	
		document.body.insertAdjacentHTML("afterEnd", topBtn);
	}*/
		
}


function setTopLink() 
{
	/*if (pageLoaded)
	{
		if (document.getElementById)
		{
			
			if (document.body.scrollTop > 300)
			{
				if (document.getElementById("topButton").style.position != "fixed")
				{
					document.getElementById("topButton").style.position = "fixed";
				}
				document.getElementById("topButton").style.visibility = "visible";
			}
			else if (document.body.scrollTop < 300)
			{
				document.getElementById("topButton").style.visibility = "hidden";
			}
		}

		else if (document.all && document.all["topButton"]) 
		{
			
			if (document.body.scrollTop > 400) 
			{
				document.all["topButton"].style.visibility = "hidden";
				document.all["topButton"].style.top = document.body.scrollTop + 400;
				document.all["topButton"].style.visibility = "visible";
			}
		}
		else if (document.layers && document.layers["topButton"])		
		{
			if (self.pageYOffset > 700) 
			{
				document.layers["topButton"].visibility = "hidden";	
				document.layers["topButton"].top = self.pageYOffset + 420;
				document.layers["topButton"].visibility = "visible";
			}
		}
		else
		{
			alert("no top button");
		}
	}*/
}



function nsTopLink() 
{
	if (document.layers) 
	{
		setInterval("setTopLink()",10);
	}
}
