//  CASCADING POPUP MENUS v5.1  
//      by Angus Turnbull       
//  http://www.twinhelix.com   
//    Visit for more scripts!   

// *** (2) MENU DATA ***
//
// Read this section VERY CAREFULLY, it explains how to arrange and tweak the menus themselves.
// To use this script you must create one or more PopupMenu() objects, that will contain all
// the menu data and settings used. This demo contains one, named 'pMenu', although you can
// have as many totally separate menus as you want on one page.
//    Next we add menus and items to the object, using its startMenu() and addItem()
// commands. Each menu object MUST contain one menu named 'root', which is the first, always
// visible menu. The syntax of the startMenu() command is:
//
// startMenu('menu name', Vertical menu (true/false)?, left, top, width, default ItemStyle
//  for items in this menu, optional parent frame/window or layer in which this menu resides);
//
// In order, the parameters are a name for the menu like 'root' or 'mFile', which you can use to
// refer to this menu from other menus, to pop it out.
//    Next, pass 'true' if you want this to be a vertical stacked menu or 'false' if you want this
// to be a horizontal menu bar. You can orientate each menu differently this way.
//   The Left and Top positions allow you to locate this menu either absolutely from the page or
// relative to menu item that pops it out. If you want to offset this menu from the item that pops
// it out, set the positions as NUMBERS, e.g. 130, 10 would put the upper-left corner of this menu
// 130px across and 10px down from the upper-left corner of the item that popped it out.
//   If you put '130', '10' as positions in QUOTES, you can position the menu from the upper-left
// corner of the whole page. These strings can also include formulae to centre or scroll the menu,
// examples are included later on. Note: the 'root' menu is always positioned from the page corner.
//    The 'width' depends on the orientation of the menu -- for vertical menus it's the width,
// for horizontal menus it is the height. Basically, it's the constant dimension for all the items.
//    The parent window or layer parameter is optional, if not specified the current window is
// used -- this example does not use frames. See the frameset example file if you're using them,
// they are strings that when evaluated return a reference, like 'window.top'.
//
// Once you have created a menu, you add items to that menu using the addItem() command.
// You must give it THREE compulsory parameters: 1) The HTML/text to display in the item. 2) The
// menuname/filename/URL the item activates. 3) The action type or target frame of that item.
// All other parameters are optional -- you can override the menu's default ItemStyle with the
// item's own, and optionally override that was well by specifying a list of parameters in the
// same order as an ItemStyle, to give each item its own dimensions / colours etc.
// See the example menu below for an example of these extras...
//
// addItem('Text', 'URL or menuname', 'action type', optional ItemStyle, length, spacing,
//  'popout indicator', popout indicator position, etc... in the same order as ItemStyles);
//
// The third parameter, 'action type', tells the script what to do with the second parameter.
// You can tell the script to load a file in the current window or a particular frame, tell it
// to pop out a menu, or tell it to run a JavaScript command. You do these like this:
//
// addItem('Text', 'file.html', ''); //blank means opens up 'file.html' in the current window.
// addItem('Text', 'file.html', 'parent.content');  //opens 'file.html' in a frame named 'content'.
// addItem('Text', 'menuName', 'sm:');  //pops out another submenu called 'menuName'.
// addItem('Text', 'alert("Hello")', 'js:');  //runs a JavaScript command when clicked.
//
// Frame names should be valid JavaScript syntax, e.g. 'top.frameName' or 'parent.popupWin',
// evaluated from the the window containing the main script (this one). Also, this system means
// 'sm:' items aren't normally clickable. If you do want to add click or mouseover actions to
// items, see the "Optional Code" section of the script below.
// 
// See the example below if this seems complicated, it's quite easy once you get the hang of it.
// Thanks to Martin J. Cole for originally suggesting the syntax!
// If you want more information, there's a FAQ (Frequently Asked Questions) section on my
// site: http://www.twinhelix.com, on the 'Popup Menus' page, or try the 'Site Forums" perhaps.



// A PopupMenu() object must be passed its own name so it can reference itself when the menu
// is active. We also use a 'with' block to work with its properties and functions below.
var pMenu = new PopupMenu('pMenu');
with (pMenu)
{

// *** MOVE OR CENTRE THE MENU HERE ***
// To centre it, or scroll with the window etc, just include a global variable or formula as one
// of the positions. This script includes my page object, which has several useful methods, namely
// 'page.winW()', 'page.winH()', 'page.scrollY()' and 'page.scrollX()'. These return the current
// dimensions of the visible window area and the scroll position of the window, which can be
// used to position menus however you want. Try replacing the first startMenu() below with one of
// these commented lines, and scroll/resize the window to see how they work.

//startMenu('root', false, 'page.winW()/2 - pMenu.menu.root[0].menuW/2', 0, 17, hBar); // Centres.
//startMenu('root', false, 10, 'page.scrollY()', 17, hBar); // Floats with window as you scroll.
//startMenu('root', false, 10, 0, 17, hBar, 'frameName'); // To create in subframe.

// The 'root' menu is horizontal, positioned at (x = 10, y = 0) and is 17px high, and items
// by default use the colours and dimensions in the 'hBar' ItemStyle defined above.
// This menu is also positioned over a similarly-coloured table in the HTML document above.
startMenu('root', false, 195, 132, 34, hBar);

// The text is a space then 'File', and this item pops out the 'mFile' submenu when moused over
// as we've set 'sm:' as the action type. If you want to assign a click action (e.g. navigating to
// a file) to one of these 'sm:' items, see the 'Optional Code' section below.
// Next is an example of a Javascript function embedded in the menu, to open a new window...
// Also, note the extra optional 4th and 5th parameters -- this menu item is 80px long,
// rather than the default length from the ItemStyle.
addItem('<img src="/images/nbar-charter.gif" width=64 height=34 border=0>', 'mCharter', 'sm:', hBar, 64);
addItem('<img src="/images/nbar-maintenance.gif" width=102 height=34 border=0>', 'mMaintenance', 'sm:', hBar, 102);
addItem('<img src="/images/nbar-rental.gif" width=52 height=34 border=0>', 'mRental', 'sm:', hBar, 52);
addItem('<img src="/images/nbar-instruction.gif" width=86 height=34 border=0>', 'mInstruction', 'sm:', hBar, 86);
addItem('<img src="/images/nbar-service.gif" width=59 height=34 border=0>', 'mService', 'sm:', hBar, 59);
addItem('<img src="/images/nbar-sales.gif" width=49 height=34 border=0>', '/sales/index.html', '', hBar, 49);

// This is a vertical menu positioned 0px across and 22px down from its trigger, and is 80px wide.
// The URLs are set to # here, be sure to replace them with your path/file names or JS functions!
// Also note how all the types are '', indicating these links open in the current frame.
startMenu('mCharter', true, 0, 35, 125, subM);
addItem('Charter Information', '/charter/index.html', '');
addItem('Contact', '/charter/chartercontact.html', '');
addItem('Video', '/charter/video.html', '');
addItem('View Aircraft', 'mCharterAircraft', 'sm:');
addItem('Pilots', '/charter/pilots.html', '');
addItem('Travel Analysis', '/charter/travelanalysis.htm', '');
addItem('Newsletter', '/charter/newsletter.html', '');
addItem('Facebook Page', 'http://www.facebook.com/pages/Eau-Claire-WI/Heartland-Aviation-Inc/78197597028', '');

startMenu('mService', true, 0, 35, 125, subM);
addItem('Line Services', '/service/index.html', '');
addItem('Air Nav Info', 'http://www.airnav.com/airport/KEAU/HEARTLAND', '');


startMenu('mRental', true, 0, 35, 120, subM);
addItem('Rental Info', '/rental/index.html', '');	
addItem('Rental Schedule', '/rental/rentalschedule.cfm', '');

startMenu('mInstruction', true, 0, 35, 180, subM);
addItem('Flight Instruction Info', '/instruction/index.html', '');	
addItem('Recreational Pilot Certificate', '/instruction/index.html#recreational', '');
addItem('Private Pilot Certificate', '/instruction/index.html#private', '');
addItem('Instrument Pilot Certificate', '/instruction/index.html#instrument', '');
addItem('Commerical Pilot Certificate', '/instruction/index.html#commercial', '');
addItem('Fly In & Chili Feed Photos', '/flyin/photos.html', '');
addItem('Facebook Page', 'http://www.facebook.com/pages/Eau-Claire-WI/Heartland-Aviation-Inc/78197597028', '');

startMenu('mCharterAircraft', true, 125, 0, 180, subM);
addItem('Citation III','/charter/CitationIII.htm','');
addItem('Citation II','/charter/CitationII.htm','');
addItem('Citation II Air Ambulance','/charter/airambulance.html','');

startMenu('mMaintenance', true, 0, 35, 180, subM);
addItem('Maintenance', '/maintenance/index.html', '');	
addItem('Citation Phase V', '/maintenance/phaseinspection.html', '');
addItem('Twin Cessna Spar Strap Mod', '/maintenance/sparmod.html', '');
addItem('Cessna 400 Series Gear AD', '/maintenance/gearad.html', '');
addItem('Parts', '/maintenance/parts.htm', '');
addItem('Facebook Page', 'http://www.facebook.com/pages/Eau-Claire-WI/Heartland-Aviation-Inc/78197597028', '');

// Popout slightly left of its trigger, for fun...

//startMenu('mHelp', true, -10, 22, 80, subM);

// Instead of using spaces to indent, consider 'text-indent' in the stylesheet class perhaps?

//addItem('&nbsp; &nbsp; Contents', '#', '');
//addItem('&nbsp; &nbsp; Search', '#', '');

// Here's an example of adding extra optional parameters to the addItem() command.
// This item uses the subM ItemSyle (regardless of what the rest of this menu uses), is 22px long,
// has 0px spacing after it, and a lesser-than-sign popout indicator positioned 3px from the left
// edge of this item. Note that the parameters after the ItemStyle name are in the same order as
// the ItemStyle command itself, and you can have as many as you want (e.g. background colours).
//addItem('&nbsp; &nbsp; About', 'mAbout', 'sm:', subM, 22, 0, '&lt;', 3);

// This is across but not down... a horizontal popout.

//startMenu('mReopen', true, 85, 0, 120, button);
// Again these items have their own ItemStyles, and unique lengths / spacings specified.

//addItem('Recent Doc 1:<br />Schedule', '#', '', button, 35);
//addItem('Recent Doc 2:<br />Cunning Plan', '#', '', button, 35, 5);

// Back to the normal submenu ItemStyle for this next item.

//addItem('Etc. etc...', '#', '', subM);

// This uses the subBlank ItemStyle which gives the items no borders when dim. The border around
// the whole menu comes from a JavaScript function in the "Menu Effects" section.

//startMenu('mConvert', true, 85, 0, 80, subBlank);
//addItem('Windows', '#', '');
//addItem('Unix', '#', '');
//addItem('Macintosh', '#', '');

// Leftwards popout with a negative x and y relative to its trigger. Custom height too.
//startMenu('mAbout', true, -85, -18, 80, subM);
//addItem('Leftwards!<br>And up!', '#', '', subM, 40);


// You can assign 'oncreate' events to specific menus. By default, the script has only one for
// the root menu that shows it when it is created. You may wish to change it to something like the
// following, which uses the animation function to show the menu, or delay its show altogether.
//menu.root[0].oncreate = function()
// { this.visNow=true; pMenu.position('root'); pMenu.showMenu('root') }

// Uncomment these lines to make specific menus show popouts on click rather than on mouseover.
//menu.root[0].subsOnClick = true;
//menu.mFile[0].subsOnClick = true;

// You can also customise hide or show delays (in milliseconds) to the menus. Defaults are:
//showDelay = 0;
//hideDelay = 500;
// Specify hideDelay as zero if you want to disable autohiding, and showDelay as a couple of
// hundred if you don't want the menus showing instantaneously when moused over.

// End of 'with (pMenu)' block. That's one menu object created, now we have to activate it...

}


// You can create another menu object here if you want multiple menus on a page.
// Every menu object MUST have a menu named 'root' in it, as that's always visible.
// You can name the other menus in it anything you want.

//var anotherMenu = new PopupMenu('anotherMenu');
//with (anotherMenu)
//{
// startMenu('root', .....);
// ... make menus here ...
//}

// Then remember to add it to the event section below...

