/************************************************ 
 * 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/arrow-on.gif";
            } else {
                img = "/img/arrow-off.gif";
            }           
            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/divider.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ï¿½ huvudmenyn

	// Menu.addMenuItem(label, href, subMenu)

	// HEM START
	//var submenu = new Menu();
	//menu.addMenuItem(new MenuItem("Home.se Startsida", "index.php", submenu));
	// HEM SLUT
	
	// HOME START
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Home Mail &amp; Internet", "/home.php", submenu));
	// submenu.addMenuItem(new MenuItem("Small home", "smallHome.php"));
	// submenu.addMenuItem(new MenuItem("Medium home", "mediumHome.php"));
	// submenu.addMenuItem(new MenuItem("Large home", "largeHome.php"));
	// submenu.addMenuItem(new MenuItem("Secure PC", "securePC.php"));
		
	// SMALBAND START
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Smalband", "/smalband.php", submenu));
	
	// BREDBAND START
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Bredband", "/bredband.php", submenu));

	// MIN PROFIL START
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Min Profil", "/minProfil.php", submenu));
	
	// SUPPORT START
	var submenu = new Menu();
	submenu.addMenuItem(new MenuItem("Modemuppkoppling PC", "/modemuppkopplingPC.php"));
	submenu.addMenuItem(new MenuItem("Modemuppkoppling MAC", "/modemuppkopplingMAC.php"));
	submenu.addMenuItem(new MenuItem("Outlook express", "/outlookExpress.php"));
	submenu.addMenuItem(new MenuItem("Webmailen", "/webmailen.php"));
	submenu.addMenuItem(new MenuItem("Vanliga fr&aring;gor", "/vanligaFragor.php"));
	submenu.addMenuItem(new MenuItem("Abuse/missbruk", "/abuse.php"));
	submenu.addMenuItem(new MenuItem("Avtalsvilkor", "/avtalsvillkor.php"));
	submenu.addMenuItem(new MenuItem("Tips", "tips.php"));
	submenu.addMenuItem(new MenuItem("Driftsinformation", "/driftsinformation.php"));
	menu.addMenuItem(new MenuItem("Support", "/support.php", submenu));
	
	// WEBHOTELL START
	var submenu = new Menu();
	//submenu.addMenuItem(new MenuItem("V&aring;ra Webhotell", "varaWebhotell.php"));
	//submenu.addMenuItem(new MenuItem("Mer om Webhotell", "merOmWebhotell.php"));
	//submenu.addMenuItem(new MenuItem("Mitt Webhotell", "mittWebhotell.php"));
	//submenu.addMenuItem(new MenuItem("Tips", "webhotellTips.php"));
	//submenu.addMenuItem(new MenuItem("Vanliga fr&aring;gor", "webhotellVanligaFragor.php"));
	menu.addMenuItem(new MenuItem("Webhotell", "/webhotell.php", submenu));
	
	// HOME HARDDRIVE START
	var submenu = new Menu();
	menu.addMenuItem(new MenuItem("Home Harddrive", "http://www.storegate.se/partners/home/0017c90.html?flash=yes", submenu));
	
	// SÖKMOTORREGISTRERING START
	//var submenu = new Menu();
	//menu.addMenuItem(new MenuItem("S&ouml;kmotor-optimering", "sokmotorregistrering.php", submenu));

// rensa lösenordsfältet
function ClearPasswordTimer() {
	setTimeout("window.document.forms[0].elements['password'].value = ''",10000);
}
