<!-- 2008-09-03 - Oscar -->
/*******************************
Replace
 http://libertyinternation.com.hk
 https://libertyinternation.com.hk
To 
 http://www.libertyinternation.com.hk
 https://www.libertyinternation.com.hk
*******************************/

if ( location.href.toLowerCase().indexOf("http://libertyinternational.com.hk")==0 )
	location.href = location.href.replace("http://", "http://www.");
if ( location.href.toLowerCase().indexOf("https://libertyinternational.com.hk")==0 )
	location.href = location.href.replace("https://", "https://www.");



<!-- Dynamic Menu JavaScript -->

/*******************************
 MENU OPTIONS AND DEFAULT VALUES
    bgColorOn           = "#001D61"
    bgColorOff          = "#405689"
    fontColorOn         = "#FFFFFF"
    fontColorOff        = "#FFFFFF"
    borderColor         = "#FFFFFF"
    borderWidth         = 1
    cellTopPad          = 5
    cellBottomPad       = 5
    cellLeftPad         = 22
    cellRightPad        = 22

*******************************/

/*******************************
TO USE, CREATE NavBar() WITH STARTING X,Y COOORDS
var navbar = new NavBar(0, 143);
var menu;

ADD Menu() WITH MENU NAME AND MENU WIDTH
NOTE: TO ALLOW TOP IMAGE ROLLOVER, JS IMAGE NAME MUST BE <MENUNAME>Top_(on|off)
ADD Menu TO NavBar
menu = new Menu("Personal", 192);
navbar.addMenu(menu);

UPDATE MENU OPTIONS BY ASSIGN NEW VALUES TO MENU OBJECT (CHOOSE FROM OPTIONS ABOVE)
menu.bgColorOn = "orange";

ADD SUBMENUS TO MENU WITH TEXT IN MENU AND LINK
menu.addSubmenu("My Policy", "/omapps/ContentServer?pagename=pm/PrimaryPage&pid=992377920770&dir=/personal/HomePage");

AFTER ADDING ALL MENUS/SUBMENUS, BUILD NavBar
navbar.build();

TO POSITION MENUS IN ORDER HORIZONTALLY, CALL positionMenus()
navbar.positionMenus();

OTHERWISE POSITION MENUS INDIVIDUALLY USING moveLayerTo(),
PASSING HANDLE TO MENU'S CSS OBJECT (STORED IN ARRAY IN NavBar) AND X,Y COORDS
moveLayerTo(navbar.menus[1].css,578,117);

BE SURE TO INCLUDE THE FOLLOWING STYLES IN YOUR CSS:

.menu{
    border: none;
    cursor: hand;
    margin: 0;
    padding: 0;
    position: absolute;
    visibility: hidden;
    z-index: 1;
}
.submenu{
    border: none;
    border-width: 0;
    margin: 0;
    padding: 0;
    top: 0px;
    z-index: 2;
}
.menutext a{
    color: #FFFFFF;
    font-family: Arial, Verdana, Geneva, Helvetica, sans-serif;
    font-size: 8pt;
    font-weight: bold;
    text-decoration: none;
}

*******************************/

//browser detection vars
var isNav4, isDOM, isIE4;
if (document.getElementById) {
    //Netscape 6/IE 5
    isDOM = true;
} else if (document.all) {
    //IE 4
    isIE4 = true;
} else if (document.layers) {
    //Netscape 4
    isNav4 = true;
}

//POPUP MENU ROLLOVER OPTIONS

var allSet = false;
var timer = 0;
var currentTopNav = "";
var origWidth;
var origHeight;

// Reload page in case of a browser resize.
if (isNav4) {
    origWidth  = window.innerWidth;
    origHeight = window.innerHeight;
	window.onresize = navBarReload;
}
function navBarReload() {
    if (isNav4 && origWidth == window.innerWidth && origHeight == window.innerHeight)
        return;
    // For IE, reload on a timer in case the Windows 'Show window contents while
    // dragging' display option is on.
    if (isIE4)
        setTimeout('window.location.href = window.location.href', 2000);
    else
        window.location.href = window.location.href;
}

/*********** NAVBAR FUNCTIONS ************/
function NavBar(x, y){
    //NavBar Constructor
    this.menus = new Array();
    this.left = x;
    this.top = y;
    this.build = NavBarBuild;
    this.addMenu = NavBarAddMenu;
    this.positionMenus = NavBarPositionMenus;
}
function NavBarBuild(){
    //Create NavBar and Menu Objects
    for (var i=0; i<this.menus.length; i++) {
        this.menus[i].build();
        this.menus[i].defineObjects();
    }
    allSet=true;
}
function NavBarAddMenu(menu){
    //Add Menu to NavBar
    this.menus[this.menus.length] = menu;
    menu.top= this.top;
}
function NavBarPositionMenus(){
    //Evenly Position Menus across screen
    var x = this.left;
    for (var i=0; i<this.menus.length; i++) {
        moveLayerTo(this.menus[i].css, x, this.top);
        x += this.menus[i].width;
    }
}
/***********   MENU FUNCTIONS ************/
function Menu(name, menuWidth){
    //Menu Constructor
    this.bgColorOn          = "#001D61";                                      
    this.bgColorOff         = "#405689";                                      
    this.fontColorOn        = "#FFFFFF";                                      
    this.fontColorOff       = "#FFFFFF";                                      
    this.borderColor        = "#FFFFFF";                                      
    this.borderWidth        = 1;                                              
    this.cellTopPad         = 5;
    this.cellBottomPad      = 5;                                              
    this.cellLeftPad        = 22;                                             
    this.cellRightPad       = 22;                                             

    this.name = name + "Menu";
    this.submenus = new Array();
    this.width = menuWidth;
    this.addSubmenu = MenuAddSubmenu;
    this.build = MenuBuild;
    this.defineObjects = MenuDefineObjects;
}
function MenuBuild(){
    //Create Menu HTML Layer
    var str = "";
	var topText = "";
	var middleText = "";
	var bottomText = "";
    var colspan = 3;
    if (this.name == navbar.menus[0].name) {
        colspan = 2;
    }
	
	topText += "<div class=\"menu\" id=\""+this.name+"\" onmouseover=\"overLayer();\" onmouseout=\"delayHideLayer('"+this.name+"');\">"+
					"<table border=0 cellpadding=0 cellspacing=0 width="+this.width+">"+
					"<tr>"+
					"<td width=\""+this.width+"\" colspan=\""+colspan+"\" bgcolor=\""+this.borderColor+"\" valign=\"top\" align=\"left\"><img src=\"/image/1x1trans.gif\" width=\"1\" height=\""+this.borderWidth+"\" border=\"0\"></td>"+
					"</tr>";
    if (this.submenus.length == 0) {
        //for some reason, if there aren't any submenus in the first menu, all the layers get messed.
        //just add dummy text to fake layer (this won't get shown on menu hover)
        middleText = ".";
    }else{
        for (i=0; i<this.submenus.length; i++) {
            middleText += "<tr>";
            if (this.name != navbar.menus[0].name) {
                middleText += "<td width=\""+this.borderWidth+"\" bgcolor=\""+this.borderColor+"\" valign=\"top\" align=\"left\"><img src=\"/image/1x1trans.gif\" width=\""+this.borderWidth+"\" height=\"1\" border=\"0\"></td>";
            }
            middleText += "<td width=\""+this.width+"\" valign=\"top\" align=\"left\" bgcolor=\""+this.bgColorOff+"\">"+
            "<div id=\""+this.submenus[i].name+"\" class=\"submenu\" onclick=\"goToLink('"+this.submenus[i].link+"');\" onmouseover=\"highlight('"+this.name+"', '"+this.submenus[i].name+"', '"+this.bgColorOn+"', '"+this.fontColorOn+"');\" onmouseout=\"highlight('"+this.name+"', '"+this.submenus[i].name+"', '"+this.bgColorOff+"', '"+this.fontColorOff+"');\">"+
            "<table width=100% border=0 cellspacing=0 cellpadding=0>"+
            "<tr>"+
            "<td width=\"1\" valign=\"top\" align=\"left\" colspan=\"3\"><img src=\"/image/1x1trans.gif\" width=\"\" height=\""+this.cellTopPad+"\" border=\"0\"></td>"+
            "</tr>"+
            "<tr>"+
            "<td width=\""+this.cellLeftPad+"\" valign=\"top\" align=\"left\"><img src=\"/image/1x1trans.gif\" width=\""+this.cellLeftPad+"\" height=\"1\" border=\"0\"></td>"+
            "<td width=\""+eval(parseInt(this.width)-12)+"\" valign=\"middle\" align=\"left\" class=\"menutext\"><a onmouseover=\"highlight('"+this.name+"', '"+this.submenus[i].name+"', '"+this.bgColorOn+"', '"+this.fontColorOn+"');\" onmouseout=\"highlight('"+this.name+"', '"+this.submenus[i].name+"', '"+this.bgColorOff+"', '"+this.fontColorOff+"');\" href=\""+this.submenus[i].link+"\" id=\""+this.submenus[i].name+"_link\"><span style=\"color: "+this.fontColorOff+"\">"+this.submenus[i].text+"</span></a></td>"+
            "<td width=\""+this.cellRightPad+"\" valign=\"top\" align=\"left\"><img src=\"/image/1x1trans.gif\" width=\""+this.cellRightPad+"\" height=\"1\" border=\"0\"></td>"+
            "</tr>"+
            "<tr>"+
            "<td width=\"1\" valign=\"top\" align=\"left\" colspan=\"3\"><img src=\"/image/1x1trans.gif\" width=\"\" height=\""+this.cellBottomPad+"\" border=\"0\"></td>"+
            "</tr>"+
            "</table>"+
            "</div>"+
            "</td>"+
            "<td width=\""+this.borderWidth+"\" bgcolor=\""+this.borderColor+"\" valign=\"top\" align=\"left\"><img src=\"/image/1x1trans.gif\" width=\""+this.borderWidth+"\" height=\"1\" border=\"0\"></td>"+
            "</tr>"+
            "<tr><td width=\""+this.width+"\" colspan=\""+colspan+"\" bgcolor=\""+this.borderColor+"\" valign=\"top\" align=\"left\"><img src=\"/image/1x1trans.gif\" width=\"1\" height=\""+this.borderWidth+"\" border=\"0\"></td></tr>";
        }
    }
    bottomText += "</table></div>";
	document.write(topText+middleText+bottomText);
	

	/*
    str += "<div class=\"menu\" id=\""+this.name+"\" onmouseover=\"overLayer();\" onmouseout=\"delayHideLayer('"+this.name+"');\">";
    str += "<table border=0 cellpadding=0 cellspacing=0 width="+this.width+">";
    str += "<tr>";
    str += "<td width=\""+this.width+"\" colspan=\""+colspan+"\" bgcolor=\""+this.borderColor+"\" valign=\"top\" align=\"left\"><img src=\"/corp/images/1x1trans.gif\" width=\"1\" height=\""+this.borderWidth+"\" border=\"0\"></td>";
    str += "</tr>";
    for (i=0; i<this.submenus.length; i++) {
        str += "<tr>";
        if (this.name != navbar.menus[0].name) {
            str += "<td width=\""+this.borderWidth+"\" bgcolor=\""+this.borderColor+"\" valign=\"top\" align=\"left\"><img src=\"/corp/images/1x1trans.gif\" width=\""+this.borderWidth+"\" height=\"1\" border=\"0\"></td>";
        }
        str += "<td width=\""+this.width+"\" valign=\"top\" align=\"left\" bgcolor=\""+this.bgColorOff+"\">";
        str += "<div id=\""+this.submenus[i].name+"\" class=\"submenu\" onclick=\"goToLink('"+this.submenus[i].link+"');\" onmouseover=\"highlight('"+this.name+"', '"+this.submenus[i].name+"', '"+this.bgColorOn+"', '"+this.fontColorOn+"');\" onmouseout=\"highlight('"+this.name+"', '"+this.submenus[i].name+"', '"+this.bgColorOff+"', '"+this.fontColorOff+"');\">";
        str += "<table width=100% border=0 cellspacing=0 cellpadding=0>";
        str += "<tr>";
        str += "<td width=\"1\" valign=\"top\" align=\"left\" colspan=\"3\"><img src=\"/corp/images/1x1trans.gif\" width=\"\" height=\""+this.cellTopPad+"\" border=\"0\"></td>";
        str += "</tr>";
        str += "<tr>";
        str += "<td width=\""+this.cellLeftPad+"\" valign=\"top\" align=\"left\"><img src=\"/corp/images/1x1trans.gif\" width=\""+this.cellLeftPad+"\" height=\"1\" border=\"0\"></td>";
        str += "<td width=\""+eval(parseInt(this.width)-12)+"\" valign=\"middle\" align=\"left\" class=\"menutext\"><a onmouseover=\"highlight('"+this.name+"', '"+this.submenus[i].name+"', '"+this.bgColorOn+"', '"+this.fontColorOn+"');\" onmouseout=\"highlight('"+this.name+"', '"+this.submenus[i].name+"', '"+this.bgColorOff+"', '"+this.fontColorOff+"');\" href=\""+this.submenus[i].link+"\" id=\""+this.submenus[i].name+"_link\"><span style=\"color: "+this.fontColorOff+"\">"+this.submenus[i].text+"</span></a></td>";
        str += "<td width=\""+this.cellRightPad+"\" valign=\"top\" align=\"left\"><img src=\"/corp/images/1x1trans.gif\" width=\""+this.cellRightPad+"\" height=\"1\" border=\"0\"></td>";
        str += "</tr>";
        str += "<tr>";
        str += "<td width=\"1\" valign=\"top\" align=\"left\" colspan=\"3\"><img src=\"/corp/images/1x1trans.gif\" width=\"\" height=\""+this.cellBottomPad+"\" border=\"0\"></td>";
        str += "</tr>";
        str += "</table>";
        str += "</div>";
        str += "</td>";
        str += "<td width=\""+this.borderWidth+"\" bgcolor=\""+this.borderColor+"\" valign=\"top\" align=\"left\"><img src=\"/corp/images/1x1trans.gif\" width=\""+this.borderWidth+"\" height=\"1\" border=\"0\"></td>";
        str += "</tr>";
        str += "<tr><td width=\""+this.width+"\" colspan=\""+colspan+"\" bgcolor=\""+this.borderColor+"\" valign=\"top\" align=\"left\"><img src=\"/corp/images/1x1trans.gif\" width=\"1\" height=\""+this.borderWidth+"\" border=\"0\"></td></tr>";
    }
    str += "</table>";
    str += "</div>";
    document.write(str);
	*/

}
function MenuDefineObjects(){
    //set menu objects/methods
    if (isDOM) {
        this.css = document.getElementById(this.name).style;
        this.evnt = document.getElementById(this.name);
    } else if (isIE4) {
        this.css = document.all[this.name].style;
        this.evnt = document.all[this.name];
    } else if (isNav4) {
        this.css = eval("document." + this.name);
        this.evnt = eval("document." + this.name);
    }
    this.evnt.onmouseover = overLayer;
    this.evnt.onmouseout = delayHideLayer;
    //set submenus objects/methods
    for (i=0; i<this.submenus.length; i++) {
        var sub = this.submenus[i];
        if (isDOM) {
            sub.css = document.getElementById(sub.name).style;
            sub.evnt = document.getElementById(sub.name);
            //sub.css.padding = "3px";
        } else if (isIE4) {
            sub.css = document.all[sub.name].style;
            sub.evnt = document.all[sub.name];
            //sub.css.padding = "3px";
        } else if (isNav4) {
            sub.css = eval('document.'+this.name+'.document.'+sub.name);
            sub.evnt = eval('document.'+this.name+'.document.'+sub.name);
        }
        //sub.evnt.onmouseover = highlight;
        //sub.evnt.onmouseout = highlight;
    }
}
function MenuAddSubmenu(text, link){
    //Add Submenu to Menu
    var subMenu = new SubMenu(this.name, this.name + this.submenus.length, text, link);
    this.submenus[this.submenus.length] = subMenu;
}
function MenuPosition(x,y){
    //Move Menu to Coordinates
    moveLayerTo(this.css, x, this.top);
}
/***********  SUBMENU FUNCTIONS ************/
function SubMenu(parent, name, text, link){
    //SubMenu Constructor
    this.parent = parent;
    this.name = name;
    this.text = text;
    this.link = link;
}
/***********  LAYER/EFFECTS UTILITY FUNCTIONS ************/
function moveLayerTo(layer, x, y) {
    //Move specified layer to coordinates
    if (isIE4 || isDOM) {
        layer.left = x;
        layer.top  = y;
    } else if (isNav4) {
        layer.moveTo(x-7, y-7);
    }
}
function swap(imgName,state) {
    //switch image src to new state (on/off)
    if (imgName.length > 0) {
        document.images[imgName].src = eval(imgName+"_"+state+".src");
    }
}
function highlight(main, submenu, bgColor, fontColor){
    //Change submenu colors on mouseover
    if (isDOM) {
        var menu = document.getElementById(submenu).style;
        var link = document.getElementById(submenu+"_link").style;
        link.color = fontColor;
        menu.backgroundColor = bgColor;
    } else if (isIE4) {
        var menu = document.all[submenu].style;
        menu.backgroundColor = bgColor;
    } else if (isNav4) {
        //var menu = eval("document." + main + ".document." + submenu);
        //menu.bgColor = bgColor;
    }
}
function selectTopNav(navName){
    //turns on menu
    swap(navName, 'on');
    currentTopNav = navName;
}
function showLayer(show, hasTopNav){
    if (allSet) {
        //hide all other layers, and display this one
        clearTimeout(timer);
        hideLayers();   
        for (var i=0; i<navbar.menus.length; i++) {
            if (navbar.menus[i].name == show) {
				if (hasTopNav) {
					selectTopNav(show+"Top");
				}
                navbar.menus[i].css.visibility = 'visible';
            }
        }
    }
}
function hideLayers(){
    if (allSet) {
        //make all menu layers hidden and turn off top level nav button
        for (var i=0; i<navbar.menus.length; i++) {
            swap(currentTopNav, 'off');
            navbar.menus[i].css.visibility = 'hidden';
        }
    }
}
function hideLayer(layer){
    //hide current layer and turn off top level nav button
    for (var i=0; i<navbar.menus.length; i++) {
        if (navbar.menus[i].name == layer) {
            navbar.menus[i].css.visibility = 'hidden';
        }
    }
}
function overLayer(){
    //keep layer visible while mouse over
    clearTimeout(timer);
}
function delayHideLayer(layer){
    //hide layer after delay
    clearTimeout(timer);
    timer = setTimeout("hideLayers('"+layer+"')", 300);
}
function goToLink(url){
    //Change pages location, used in Menus
    location = url;
}

