﻿
//var j$ = jQuery.noConflict();

$(document).ready(function() {
centerTopMenu();
centerSubMenu();
});

function centerSubMenu() {
    var contentHolder = $('#SubMenu');
    if (contentHolder == null) {
        return;
    }
    var noOfItems = $('#SubMenu .submenuItem').length;
    
    var items = $('#SubMenu .submenuItem');
    var totalwidth = 0;
    items.each(function(index) {
        var setWidth = $(this).find("a").width();
        setWidth = setWidth + 50;
        totalwidth += setWidth;
        $(this).css("width", setWidth + "px");
    });
    
    
    $('#SubMenu').css("width", totalwidth + "px");
    
}


function centerTopMenu() {
    var contentHolder = $('#TopMenu');
    if (contentHolder == null) {
        return;
    }
    var noOfItems = $('#TopMenu .menuItem').length;

    var items = $('#TopMenu .menuItem');
    var totalwidth = 0;
    items.each(function(index) {
        var setWidth = $(this).find("a").width();
        setWidth = setWidth + 50;
        totalwidth += setWidth;
        $(this).css("width", setWidth + "px");
    });


    $('#TopMenu').css("width", totalwidth + "px");

}


String.prototype.trim = function() {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function GoHome(hemnet, homeurl) {
    if (hemnet == "True") {
        var skWin = window.open(homeurl, "skwin", "");
    }
    else
        window.location = homeurl;
}

function PopupWindow(url, width, height) {
    var win = window.open(url, "skeppsholmen_popup", "width=" + width + ",height=" + height + ",scrollbars=1");
    win.focus();
}
