var navObjs = new Array(7);
var navWidths = new Array(108,108,108,108,108,108,108);
var curNav = null;

function init()
{
	var l = navObjs.length;

	var snc;
	var gnc = getLayerById("gn");
	var x = getPagePosition(gnc, 0, "x");

	for (var i = 0; i <l; i++)
	{
		navObjs[i] = new Object();
		
		navObjs[i].sn = getLayerById("sn"+i+"_m");
		
		snc = getLayerById("sn"+i);
		moveX(snc, x);
		x += navWidths[i] + 1;

		navObjs[i].h = getHeight(navObjs[i].sn);	
		moveY(navObjs[i].sn, -navObjs[i].h);
		showLayer(navObjs[i].sn);

		assignMouseOverHandler(navObjs[i].sn, new Function("cancelHide(" + i + ");"));			
		assignMouseOutHandler(navObjs[i].sn, new Function("navOff(" + i + ");"));
		
		navObjs[i].hideTimer = null;
		navObjs[i].moveTimer = null;
		
	}
	
	initRollovers();

}

function initRollovers() {
	if (!document.getElementById) return

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src'); /* coded src */
			var hsrc = src.replace('red', 'gold');	/* hover src */
			var isrc = src;	/* init src */

			aImages[i].setAttribute('hsrc', hsrc);
			aImages[i].setAttribute('isrc', isrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('isrc'));
			}
			
		}
	}
}


function navOn(n)
{
	cancelHide(n);
	hideAllNavs(n);
	showNav(n);
}

function navOff(n)
{
	if (navObjs[n] != null)
	{
		/* how fast will the layer will linger f the cursor moves away */
		navObjs[n].hideTimer = setTimeout("hideNav("+n+");", 50);
	}
}

function showNav(n)
{
	if (navObjs[n] != null)
	{
		clearTimeout(navObjs[n].moveTimer);
		if (n == curNav)
		{
			var y = getY(navObjs[n].sn) + 20;
			if (y < 0)
			{
				moveY(navObjs[n].sn, y);
				/* this controls how fast the layer will show.  lower # = faster show */
				navObjs[n].moveTimer = setTimeout("showNav("+n+");", 1);
			}
			else
			{
				moveY(navObjs[n].sn, 0);
				navObjs[n].moveTimer = null;
			}
		}
		else
		{
			hideNav(n);
		}
	}
}

function hideNav(n)
{
	if (navObjs[n] != null)
	{
		clearTimeout(navObjs[n].moveTimer);
		var y = getY(navObjs[n].sn) - 20;
		
		if (y > -navObjs[n].h)
		{
			moveY(navObjs[n].sn, y);
			navObjs[n].moveTimer = setTimeout("hideNav("+n+");", 50);
		}
		else
		{
			moveY(navObjs[n].sn, -navObjs[n].h);
			navObjs[n].moveTimer = null;
		}
	}
}

function cancelHide(n)
{
	if (navObjs[n] != null)
	{
		clearTimeout(navObjs[n].hideTimer);
		navObjs[n].hideTimer = null;
	}
}

function hideAllNavs(n)
{
	var l = navObjs.length;
	
	for (var i = 0; i < l; i++)
	{
		if (i != n)
		{
			hideNav(i);
		}
	}
	
	curNav = n;
}

function sNavOver(el)
{
	setStyleAtt(el, "background", "#ffcc00");
	/* ffcc00 = gold, 003399 = dark blue, cc0000 = red */
}

function sNavOut(el)
{
	setStyleAtt(el, "background", "#ffffff");
}

function setStyleAtt(el, att, val)
{
	if (el.style)
	{
		s = el.style;
		eval("el.style." + att + " = val;");
	}
}

function pop(url)
{
	window.open(url, "win", 'width=440,height=500,scrollbars=1');
}

function construction()
{
	var w = 600, h = 450;

	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var popW = 400, popH = 300;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;

	myWindow=window.open('construction.htm','win','width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos+',scrollbars=0');
	myWindow.focus();
}


function comingsoon()
{
	var w = 600, h = 450;

	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var popW = 400, popH = 300;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;

	myWindow=window.open('comingsoon.htm','win','width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos+',scrollbars=0');
	myWindow.focus();
}



/* site search */
//<![CDATA[

function OnLoad() {
	// Create a search control
	var searchControl = new GSearchControl();
		
	// create a drawOptions object. tell the searcher to draw itself in proper mode
	var drawOptions = new GdrawOptions();
	drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
	drawOptions.setSearchFormRoot(document.getElementById("searchForm"));
	
	// create a searcher options object and set mode
	var options = new GsearcherOptions();
	options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);

	// add in search
	var siteSearch = new GwebSearch();
	siteSearch = new GwebSearch();
	siteSearch.setUserDefinedLabel("Search Results");
	siteSearch.setUserDefinedClassSuffix("siteSearch");
	siteSearch.setSiteRestriction("http://www.ebooktechnologies.com");
	searchControl.addSearcher(siteSearch,options);

	// tell the searcher to draw itself and tell it where to attach
	searchControl.draw(document.getElementById("searchResults"),drawOptions);
		
	// select the number of results returned by each of the searchers
	searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);

	// set the link target used for links embedded in search results
	searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF);

	// execute an inital search
	//searchControl.execute(document.getElementById("terms").value);
}
GSearch.setOnLoadCallback(OnLoad);

//]]>