var prefix = 'http://www.picosearch.com/';
// no prefix makes broken rollovers
//var prefix = '';

if(location.protocol == "https:"){
	prefix = 'https://www.picosearch.com/';
}

//  browser sniffer
var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;

//  This function swaps images, using the "img" array, defined below.
function menuHi(num, imgname) {
	if (menusReady==false) return;
	if (num/2==currentSection) return;  //  do nothing if highlight is for current section
	if (num%2==0 && currMenu!=-1) {  //  hide current menu after 1 sec.
		del = (menus[currMenu].length > 0) ? 1000 : 1;
		menuTimeout = setTimeout('hideMenu()',del);
	}
	if (num%2==0 && num/2==currMenu && menus[currMenu].length > 0) return;  //  leave highlight on if it's the current menu and menu has items
	//if (num%2==1) hideMenu();  //  hide last menu
	if (prefix!='' && num>=menus.length*2) {  //  rollover swap for non-menu nav items
		if (num%2==0) document.images['navImg'+currentSection].src = img[1+currentSection*2].src;
		else document.images['navImg'+currentSection].src = img[currentSection*2].src;
	}
	imgname.src = img[num].src;
}

//  Define on and off menu IMG SRC here.  "off" state first, "on" state second
imgsrc = new Array(
	'images/navHomeOff.gif','images/navHomeOn.gif',
	'images/navPlansOff.gif','images/navPlansOn.gif',
	'images/navSignupOff.gif','images/navSignupOn.gif',
	'images/navLoginOff.gif','images/navLoginOn.gif',
	'images/navContactusOff.gif','images/navContactusOn.gif',
	'images/navHelpOff.gif','images/navHelpOn.gif',
	'images/navAboutOff.gif','images/navAboutOn.gif',
	'images/navNewsOff.gif','images/navNewsOn.gif'
);

//  This loop converts the "imgsrc" array into IMG objects.
img = new Array();
for (i = 0; i < imgsrc.length; i++) {
	img[i] = new Image();
	img[i].src = prefix + imgsrc[i];
}

//  This function is called when the page loads.  It writes the dHTML menus using the "menus" array, defined below.
//  The "prefix" variable is defined in the HEAD of each page.  See "menus" array (below) for more info.
function drawMenus() {
	for (i=0;i<menus.length;i++) {
		if (NS4) {
		} else {
			if (!document.getElementById && !document.layers) return; //This is Netscape 3, so abort.
		}
		if (menus[i].length>0) {
			if (NS4) {
			// find widest menu item
			
				for (j=0;j<menus[i].length;j+=2) {
					with(document.widthcheck.document) {
						open();
						write('<SPAN CLASS="menuItemNS4">'+menus[i][j]+'<\/SPAN>');
						close();
					}
					tempwidth = document.widthcheck.clip.width + 16;
					if (tempwidth > menuWidth[i]) menuWidth[i] = tempwidth;
				}
		
			// write menu rectangle and rollover highlights
			
				htmlStr = '';
				htmlStr += '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\r';
				htmlStr += '<TR><TD BGCOLOR="#333366" COLSPAN="3"><IMG class="n4img" SRC="'+prefix+'images/dot-tran.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\r';
				for (j=0;j<menus[i].length;j+=2) {
					htmlStr += '<TR>\r';
					htmlStr += '<TD BGCOLOR="#333366"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="1" HEIGHT="1"><\/TD>\r';
					htmlStr += '<TD BGCOLOR="#FFFFFF"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="'+menuWidth[i]+'" HEIGHT="20" BORDER="0" NAME="menu'+i+'itemblock'+j+'"><\/TD>\r';
					htmlStr += '<TD BGCOLOR="#333366"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="1" HEIGHT="1"><\/TD>\r';
					htmlStr += '<TD><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="4" HEIGHT="20" NAME="menu'+i+'right'+j+'"><\/TD>\r';
					htmlStr += '<\/TR>\r';
				}
				htmlStr += '<TR><TD BGCOLOR="#333366" COLSPAN="3"><IMG class="n4img" SRC="'+prefix+'images/dot-tran.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\r';
				htmlStr += '<\/TABLE>\r';
				menuObj = eval('document.menu'+i+'blocks.document');
				menuObj.open();
				menuObj.write(htmlStr);
				menuObj.close();
				menuObj = eval('document.menu'+i+'blocks');
				menuObj.left = menuPlace[i] + 2;
				menuObj.top += 4;

			// write menu items
			
				htmlStr = '';
				htmlStr += '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\r';
				for (j=0;j<menus[i].length;j+=2) {
					htmlStr += '<TR>\r';
					htmlStr += '<TD><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="1" HEIGHT="20"><\/TD>\r';
					htmlStr += '<TD><A HREF="'+prefix+menus[i][j+1]+'" onMouseOver="highlight('+j+',true)" onMouseOut="highlight('+j+',false)" CLASS="menuItemNS4" target="_top">'+menus[i][j]+'<\/A><\/TD>\r';
					htmlStr += '<\/TR>\r';
				}
				htmlStr += '<\/TABLE>\r';
				menuObj = eval('document.menu'+i+'.document');
				menuObj.open();
				menuObj.write(htmlStr);
				menuObj.close();
				menuObj = eval('document.menu'+i);
				menuObj.left = 8 + menuPlace[i];
				menuObj.top += 4;

			} else {
				htmlStr = '';
				htmlStr += '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\r';
				htmlStr += '<TR><TD BGCOLOR="#333366" COLSPAN="5"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\r';
				for (j=0;j<menus[i].length;j+=2) {
					htmlStr += '<TR>\r';
					htmlStr += '<TD BGCOLOR="#333366"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="1" HEIGHT="1"><\/TD>\r';
					htmlStr += '<TD BGCOLOR="#FFFFFF" ID="menu'+i+'padleft'+j+'"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="5" HEIGHT="1"><\/TD>\r';
					htmlStr += '<TD BGCOLOR="#FFFFFF" NOWRAP ID="menu'+i+'item'+j+'" onMouseOver="highlight('+j+',true)" onMouseOut="highlight('+j+',false)" onClick="document.location=\''+prefix+menus[i][j+1]+'\'" STYLE="cursor:hand"><A HREF="'+prefix+menus[i][j+1]+'" CLASS="menuItem" target="_top">'+menus[i][j]+'<\/A><\/TD>\r';
					htmlStr += '<TD BGCOLOR="#FFFFFF" ID="menu'+i+'padright'+j+'"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="5" HEIGHT="1"><\/TD>\r';
					htmlStr += '<TD BGCOLOR="#333366"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="1" HEIGHT="1"><\/TD>\r';
					htmlStr += '<TD ID="menu'+i+'right'+j+'"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="4" HEIGHT="20"><\/TD>\r';
					htmlStr += '<\/TR>\r';
				}
				htmlStr += '<TR><TD BGCOLOR="#333366" COLSPAN="5"><IMG SRC="'+prefix+'images/dot-tran.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\r';
				htmlStr += '<\/TABLE>\r';
				menuObj = (IE4) ? eval('document.all.menu'+i) : document.getElementById('menu'+i);
				menuObj.innerHTML = htmlStr;
				menuObj.style.left = menuPlace[i] + 3;
			}
		}
	}
	menusReady = true;
}

//  This function is called when the mouse rolls over menu IMGs.  It hides/unhides the appropriate menu.
function showMenu(men,isVisible) {
	if (menusReady==false) return;
	if (men!=currMenu) hideMenu();  //  hide last menu if new menu is activated
	currMenu = men;
	if (NS4) {
		menuDiv = eval('document.menu'+men);
		menublockDiv = eval('document.menu'+men+'blocks');
		menuDiv.visibility = (isVisible==true) ? 'visible' : 'hidden';
		menublockDiv.visibility = menuDiv.visibility;
	} else {
		menuDiv = (IE4) ? eval('document.all.menu'+men) : document.getElementById('menu'+men);
		menuDiv.style.visibility = (isVisible==true) ? 'visible' : 'hidden';
	}
	if (currentSection!=-1) {  //  turn on/off menu highlight depending on mouse location
		if (isVisible==true && men!=currentSection) document.images['navImg'+currentSection].src = img[currentSection*2].src;
		else document.images['navImg'+currentSection].src = img[1+currentSection*2].src;
	}
	clearTimeout(menuTimeout);
}


//  This function makes the current menu item highlight.
//  It is called when the mouse rolls over a HREF, written in "drawMenus()"
function highlight(itm, isOn) {
	if (NS4) {
		//rightHilite = eval('document.menu'+currMenu+'blocks.document.images["menu'+currMenu+'right'+itm+'"]');
		itemBlock = eval('document.menu'+currMenu+'blocks.document.images["menu'+currMenu+'itemblock'+itm+'"]');
		if (isOn==true) {
			clearTimeout(menuTimeout);
			//rightHilite.src = prefix+'images/dot-purp.gif';
			itemBlock.src = prefix+'images/dot-gray.gif';
		} else {
			del = (menus[currMenu].length > 0) ? 1000 : 1;
			menuTimeout = setTimeout('hideMenu()',del);
			//rightHilite.src = prefix+'images/dot-tran.gif';
			itemBlock.src = prefix+'images/dot-tran.gif';
		}
	} else {
		//rightHilite = (IE4) ? eval('document.all.menu'+currMenu+'right'+itm) : document.getElementById('menu'+currMenu+'right'+itm);
		leftPad = (IE4) ? eval('document.all.menu'+currMenu+'padleft'+itm) : document.getElementById('menu'+currMenu+'padleft'+itm);
		rightPad = (IE4) ? eval('document.all.menu'+currMenu+'padright'+itm) : document.getElementById('menu'+currMenu+'padright'+itm);
		itemTD = (IE4) ? eval('document.all.menu'+currMenu+'item'+itm) : document.getElementById('menu'+currMenu+'item'+itm);
		if (isOn==true) {
			clearTimeout(menuTimeout);
			//rightHilite.bgColor = '#7c6dc1';
			leftPad.bgColor = '#DDDDDD';
			rightPad.bgColor = '#DDDDDD';
			itemTD.bgColor = '#DDDDDD';
		} else {
			del = (menus[currMenu].length > 0) ? 1000 : 1;
			menuTimeout = setTimeout('hideMenu()',del);
			//rightHilite.bgColor = '';
			leftPad.bgColor = '#ffffff';
			rightPad.bgColor = '#ffffff';
			itemTD.bgColor = '#ffffff';
		}
	}
}

//  This function hides the current menu.
function hideMenu() {
	if (menusReady==false) return;
	if (currMenu>-1) {
		showMenu(currMenu,false);
		//divprefix = (NS4) ? eval('document.menuHead'+currMenu+'.document') : document;
		divprefix = document;
		if (currMenu!=currentSection) divprefix.images['navImg'+currMenu].src = img[currMenu*2].src;
	}
	clearTimeout(menuTimeout);
}

//  This function removes the marquee around Windows IE HREFs, which appear when a link is clicked but the page does not refresh.
function blurry(obj) {
	if (IE4 || IE5) obj.blur();
}

menusReady = false;  //  flag to prevent script activation before the page has initialized
currentSection = -1;  //  tracks what section the user is in
currMenu = -1;  //  tracks what menu is currently active
menuTimeout = -1;  //  initializes the menuTimeout object

/*
	The following two-dimensional array holds all the menu information, from left (menus[0]) to right (menus[5]).
	All menu-based HREF definitions are done here.
	The syntax is [menu item as displayed on screen],[relative location from root directory]
	The "prefix" variable, which is defined in the HEAD of each page, allows pages contained in subdirectories to access these relative locations correctly.
	Even though a menu-bar items has no menu items, it must have an empty array associated to it.
*/
menus = new Array();
menus[0] = new Array();
menus[1] = new Array();
menus[2] = new Array();
menus[3] = new Array();
menus[4] = new Array();
menus[5] = new Array(
	'FAQs','faqs.html',
	'New Features','faqs/faq_whats_new.html',
	'What is PicoSearch?','whatis.html',
	'PicoSearch Glossary','glossary.html',
	'Sample Customers','examplesearch.html',
	'License','license.html'
);
menus[6] = new Array(
	'What is PicoSearch?','whatis.html',
	'What People Say about Us','whatpeoplesay.html',
	'Sample Customers','examplesearch.html',
	'New Features','faqs/faq_whats_new.html',
	// 'Press Releases','pressreleases.html',
	'Tell a Friend','tell.html',
	'Link to Us','linktous.html',
	'Jobs at PicoSearch','jobs.html',
	'License','license.html'
);
/*
menus[7] = new Array(
	'Press Releases','news.html',
	'In The Press','press.html'
);
*/

menuWidth = new Array();  //  initialize menuWidth array to minimum 2 pixels
for (i=0;i<menus.length;i++) menuWidth[i]=2;

// see nav.css if you need to add another object
menuPlace = new Array(189,231,274,330,373,439,477,584);  //  x-position of each menu item image

function showNav(pg) {
	obj = eval('document.images.navImg'+pg)
	tmp = obj.src.substring(0,obj.src.indexOf('Off.gif')); // Extract the body of the src string
	tmp += 'On.gif'; // Append the '-on' component;
	obj.src = tmp; // Reset the src to highlight the nav image
	currentSection = pg; // Set the variable that records what section we're currently viewing
}
