// JavaScript Document
// These arrays are used to setup the dropdown menus
    var aLinkSet3 = new Array();

	var iProductsCount = 6;
	var aProductsTypes = new Array(4,4,4,4,4,4);
	var aProductsCaptions = new Array('<b>ergomo</b> Pro Powermeter',
		'<b>ergomo</b> Pro Carbon Crankset',
		'<b>ergomo</b> Pro Bottom Bracket',
		'<b>SRM</b>',
		'<b>Campagnolo</b> Chorus crankset',
		'<b><em>Training and Racing with a Powermeter</em></b>');
	
	var aProductsURLs = new Array('ErgomoProProducts.html#ergomopowermeter',
		'ErgomoProProducts.html#ergomocrankset',
		'ErgomoProProducts.html#ergomoBB',
		'ErgomoProProducts.html#SRM',
		'ErgomoProProducts.html#campycrankset',
		'ErgomoProProducts.html#trainwithpower');

var aProductsIEOptions = new Array('toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1',
		'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1');

	var iOrdersCount = 2;
	var aOrdersTypes = new Array(4,4);
	var aOrdersCaptions = new Array('Order menu 1',
		'Order Menu 2');
	var aOrdersURLs = new Array('ErgomoProPowermeter.html',
		'ErgomoCarbonCranks.html');
	var aOrdersIEOptions = new Array('toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1',
		'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1');

var iSupportCount = 2;
	var aSupportTypes = new Array(4,4);
	var aSupportCaptions = new Array('Contact Us',
		'Downloads');
	var aSupportURLs = new Array('OrdersPage.html',
		'ergomo_downloads.html');
	var aSupportIEOptions = new Array('toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1',
		'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1');

	var iFAQsCount = 5;
	var aFAQsTypes = new Array(4,4,4,4,4);
	var aFAQsCaptions = new Array('How do I install the <b>ErgoRacer</b> software?',
		'How do I set up my <b>ergomo</b> pro in the software?',
		'Is there a manual for the installation of my <b>ergomo</b>?',
		'How do I train with a power meter?',
		'<b>ergomo</b> FAQs');
	var aFAQsURLs = new Array('ergomo_FAQ.html#installsw',
		'ergomo_FAQ.html#setupsw',
		'ergomo_FAQ.html#manual',
		'ergomo_FAQ.html#powerTraining',
		'ergomo_FAQ.html');
	var aFAQsIEOptions = new Array('toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1',
		'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1');

var iBrochureCount = 5;
	var aBrochureTypes = new Array(4,4,4,4,4,4,4);
	var aBrochureCaptions = new Array('The <b>ergomo</b> Story',
		'The <b>ergomo</b> Sensor',
		'The <b>ergomo</b> Computer',
		'The <b>ErgoRacer</b> Software',
		'<b>ergomo</b> Techinical Data');
	var aBrochureURLs = new Array('ergomo_TheStory.html',
		'ergomo_Sensor.html',
		'ergomo_Computer.html',
		'ergomo_ErgoRacer.html',
		'ergomo_TechData.html');
	var aBrochureIEOptions = new Array('toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1',
		'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=1');


function ChangeBack(obb)
			{
				obb.background="images/BLUEBACK3.GIF";
			}

			function UnChangeBack(obb)
			{
				obb.background="";
			}

function OpenMenuItem(Itemtype,AppIndex)
     {
	var url = eval("a" + Itemtype + "URLs[AppIndex]");
	var dbname = eval("a" + Itemtype + "Captions[AppIndex]");
	var linktype = eval("a" + Itemtype + "Types[AppIndex]");
	switch (linktype) {
      		case 2:	
			var winname = linktype + AppIndex
			var ieoptions = eval("a" + Itemtype + "IEOptions[AppIndex]");
           		window.open(url,winname,ieoptions);
           		break;
		case 3:
			DoNotesShortcut(1,url,dbname);
			break;
         	case 4:
             		window.location=url;
             		break;
		default:
			alert(linktype);
			break;
         	}
     }


	function LoadLinkSet(aLinkSet,Caption,ItemIndex,action,entrynum)
	{
		re = new RegExp(" ","g");
		if (entrynum == 1)
		{
			aLinkSet[iLinkSetIndex] ='<div class="menuitems" NOWRAP><a href="javascript:' + action + '">&nbsp;' + Caption.replace(re,"&nbsp;") + '&nbsp;</a></div>';
			bLinkSetOpen = true;
		}
		else
		{
			aLinkSet[iLinkSetIndex] +='<div class="menuitems" NOWRAP><a href="javascript:' + action + '">&nbsp;' + Caption.replace(re,"&nbsp;") + '&nbsp;</a></div>';
			
		}
	}

	function LoadLinkSet(aLinkSet,Caption,ItemIndex,action,entrynum)
	{
		re = new RegExp(" ","g");
		if (entrynum == 1)
		{
			aLinkSet[iLinkSetIndex] ='<div class="menuitems" NOWRAP><a href="javascript:' + action + '">&nbsp;' + Caption.replace(re,"&nbsp;") + '&nbsp;</a></div>';
			bLinkSetOpen = true;
		}
		else
		{
			aLinkSet[iLinkSetIndex] +='<div class="menuitems" NOWRAP><a href="javascript:' + action + '">&nbsp;' + Caption.replace(re,"&nbsp;") + '&nbsp;</a></div>';
			
		}
	}

    function GetLongestString(aThisArray,iArrayLength)
	{
	longest = 0;
	for(i=0; i < iArrayLength; i++)
		{
		sThisString = aThisArray[i];
		if(sThisString.length > longest)
			longest = sThisString.length;
		}

	return longest
	}

	function DoSubMenu(x,SubTitle,SubArrayName,aLinkSet,nLinkSet,menpos,width,clickURL)
	{
		iLinkSetIndex = x;
		var a = 1;
		var padlength = GetLongestString(eval("a" + SubArrayName + "Captions"),eval("i" + SubArrayName + "Count"));
		document.write("     <td valign='bottom' width='" + width + "' align='center'>");
		document.write("     <a OnMouseOver='showmenu(event,aLinkSet" + nLinkSet + "[" + x + "],this," + x + "," + menpos + ")' OnMouseOut='delayhidemenu()' ");
		if(clickURL != "")
			document.write("href='" + clickURL + "'");
		document.write(">");
//		document.write("      <table width=100% cellpadding='0' cellspacing='0' border='0'><tr>");
//        document.write("<td style='text-align: left; vertical-align: top; cursor: hand; FONT-WEIGHT: bold; COLOR: #0A75B2'>" + SubTitle + "</td></tr></table></td>");
        document.write(SubTitle + "</a>" );
		var subcount = eval("i" + SubArrayName + "Count");
     		for (iIndex = 0; iIndex < subcount; iIndex++) {
			tmpstr = "OpenMenuItem('" + SubArrayName + "'," + iIndex + ")";
			tmpcaption = eval("a" + SubArrayName + "Captions[iIndex]");
			j = tmpcaption.length;
			for(i=j;i < padlength;i++)
			{
				tmpcaption = tmpcaption + "&nbsp";
			}

			LoadLinkSet(aLinkSet,tmpcaption,iIndex,tmpstr,a);
			a = 0;
       		}
	}
document.write("<td Class=Clickable valign='bottom' width='150' align='center'>&nbsp;");
DoSubMenu(2,"<img src='images/SpecsButton.jpg' border=0>","Brochure",aLinkSet3,"3","0","150","");
DoSubMenu(0,"<img src='images/ProductsButton.jpg' border=0>","Products",aLinkSet3,"3","0","100","ergomoproproducts.html");
DoSubMenu(3,"<img src='images/FAQsButton.jpg' border=0>","FAQs",aLinkSet3,"3","0","100","ergomo_FAQ.html");
//DoSubMenu(4,"<img src='images/SupportButton.jpg' border=0>","Support",aLinkSet3,"3","0","100","ergomo_Support.html");
document.write("<td Class=Clickable valign='bottom' width='100' align='center'><a href='SupportPage.html'><img src='images/DownloadsButton.jpg' border=0></a>");
document.write("<td Class=Clickable valign='bottom' width='100' align='center'><a href='OrdersPage.html'><img src='images/OrderButton.jpg' border=0></a>");
//DoSubMenu(1,"<img src='images/OrderButton.jpg' border=0>","Orders",aLinkSet3,"3","0");
//DoSubMenu(2,"<img src='images/FAQsButton.jpg' border=0>","FAQs",aLinkSet3,"3","0");

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}




//Pop-it menu- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var curx=-1
var curtop=-1
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers
var e1 
var which1 
var tobj1
var x1 
var menpos1 

function showmenu(e,which,tobj,x,menpos,del){

if (!document.all&&!document.getElementById&&!document.layers)
return
clearhidemenu(x)
menuobj=ie4? document.all.popmenu : ns6? document.getElementById("popmenu") : ns4? document.popmenu : ""
menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj
if (ie4||ns6)
menuobj.innerHTML=which
else{
menuobj.document.write('<layer name=gui bgColor=#DED6EF width=165 onmouseover="clearhidemenu()" onmouseout="hidemenu()">'+which+'</layer>')
menuobj.document.close()
}
menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.gui.document.width
menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.gui.document.height

if (menpos == 0)
{
	eventX = findPosX(tobj) + 5 ;
	eventY = findPosY(tobj) + 17 ;
}
else
{
	eventX = findPosX(tobj) + 150;
	eventY = findPosY(tobj) + 20 ;
}
tmptop = eventY;
tmpleft=ie4? document.body.scrollLeft+eventX : ns6? window.pageXOffset+eventX : eventX;
menuobj.thestyle.left= tmpleft + 'px';


var hardtop=ie4? document.body.scrollTop : ns6? window.pageYOffset : 0
if (tmptop>hardtop)
	menuobj.thestyle.top=tmptop + 'px'
else
{
	if (tmptop=hardtop)
		menuobj.thestyle.top=hardtop + 'px'
	else
		menuobj.thestyle.top=hardtop + ((winheight-menuobj.contentheight)/2) + 'px'
}
if(del)
	delayshow = setTimeout("menuobj.thestyle.visibility='visible'",2000);
else
	menuobj.thestyle.visibility='visible';	
curx = x;
return false

}


function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"
curx=-1
window.status="";
}

function dynamichide(e){
if (ie4&&!menuobj.contains(e.toElement))
delayhidemenu(5000)
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
curx=-1
}

function delayhidemenu(delay){
if (window.delayshow)
	clearTimeout(delayshow)

if (ie4||ns6||ns4)
delayhide=setTimeout("hidemenu()",delay)
}

function clearhidemenu(x){
if (window.delayhide)
clearTimeout(delayhide)
if(!(curx==x))
	curx=-1
}

function highlightmenu(e,state){
if (document.all)
source_el=event.srcElement
else if (document.getElementById)
source_el=e.target
if (source_el.className=="menuitems"){
source_el.id=(state=="on")? "mouseoverstyle" : ""
}
else{
while(source_el.id!="popmenu"){
source_el=document.getElementById? source_el.parentNode : source_el.parentElement
if (source_el.className=="menuitems"){
source_el.id=(state=="on")? "mouseoverstyle" : ""
}
}
}
}


if (ie4||ns6)
document.onclick=hidemenu

