/************************************************ 
 * By Bengt J Lindstrom
 ************************************************/
/*
 * The Menu Class
 */
function Menu() {
    this.menuItems = new Array();
    this.foldout = false;
    this.addMenuItem = Menu_addMenuItem;
    this.create = Menu_create;
    return this;
}

function Menu_addMenuItem(item) {
    if (item.active || (item.submenu && item.submenu.foldout)) {
        this.foldout = true;
    }   
    this.menuItems.push(item);
}

function Menu_create(level) {
    var i, l = 0;
    if (level) {
        l = level;
    }
    if (l == 0) {
        document.writeln('<table border="0" cellspacing="0" cellpadding="0">');
        //document.writeln('<tr><td><img src="img/divider.gif"></td></tr>');
    }
    for (i=0; i < this.menuItems.length; i++) {
        var c = 'menu_level_'+l;
        var item = this.menuItems[i];
        if (item.active){
            c = c + ' menu_item_active';
        }
        document.writeln('<tr class="'+c+'"><td height="26"><span class="menu_level_'+l+'_indent">');
		
        if (l == 0){
            var img;
            if (item.submenu && item.submenu.foldout) {
                img = "img/menuButton-on.jpg";
            } else {
                img = "img/menuButton-off.jpg";
            }           
            document.writeln('<img src="'+img+'" align="right">');
        } else {
            document.writeln('');
        }
        if (item.active) {
            document.writeln('&nbsp;&nbsp; '+item.label+'');
        } else {
            document.writeln('&nbsp;&nbsp;<a href="'+item.href+'" class="'+c+'">'+item.label+'</a>');
        }

        document.writeln('</span></td></tr>');
        if (item.submenu && (item.submenu.foldout || item.active)) {
            item.submenu.create(l + 1);
        }
        if (l == 0) {
            document.writeln('<tr><td><img src="img/menuDivider.gif"></td></tr>');
        }
    }
    if (l == 0) {
        document.writeln('</table>');
    }
}
/*
 * The MenuItem Class
 */
function MenuItem(label, href, submenu) {
    this.label = label;
    this.href = href;
    this.submenu = null;
    this.active = false;
    this.testIfActive = MenuItem_testIfActive;
    if (submenu) {
        this.submenu = submenu;
    }
    this.testIfActive();
    if (this.active && submenu) {
        this.submenu.foldout = true;
    }
    return this;
}

function MenuItem_testIfActive() {
    var url = this.href;
    if (url.charAt(0) == '/') {
        url = location.protocol + "//" + location.hostname + url;
    } else if (url.indexOf("://") == -1) {
        url = location.protocol + "//" + location.hostname + location.pathname.substring(0, location.pathname.lastIndexOf("/", location.pathname.length)+1) + url;
    }
    if (url == location.href) {
        this.active = true;
    }
}

    //menu start  
    var menu = new Menu(); // variabel för huvudmenyn

	// Menu.addMenuItem(label, href, subMenu)

	// HEM START
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Home", "index.htm", submenu));
	// HEM SLUT
	
	// OM IDI START
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Consultancy", "consultancy.htm", submenu));	
	submenu.addMenuItem(new MenuItem("Technical Training", "technical.htm"));
	submenu.addMenuItem(new MenuItem("Team Building", "teambuilding.htm"));
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("IDI", "idi.htm", submenu));
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Websites", "websites.htm", submenu));
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Links", "links.htm", submenu));

	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Contact Us", "contact.htm", submenu));
	// OM IDI SLUT



