﻿var timeout = 300;
var closetimer = 0;
var ddmenuitem = 0;

// open hidden layer
function mopen(id) {
    // cancel close timer
    mcancelclosetime();

    // close old layer
    if (ddmenuitem) {
        ddmenuitem.style.visibility = 'hidden';
        ddmenuitem.parentNode.firstChild.style.backgroundColor = "#FFF";
        ddmenuitem.parentNode.firstChild.style.color = "Black";
    }

    // get new layer and show it
    ddmenuitem = document.getElementById(id);
    ddmenuitem.style.visibility = 'visible';

    // As we want the parent item to stay highlighted we need to do it here rather than in css
    ddmenuitem.parentNode.firstChild.style.backgroundColor = "#BE1E2D";
    ddmenuitem.parentNode.firstChild.style.color = "White";
}
// close showed layer
function mclose() {
    if (ddmenuitem) {
        ddmenuitem.style.visibility = 'hidden';
        ddmenuitem.parentNode.firstChild.style.backgroundColor = "#FFF";
        ddmenuitem.parentNode.firstChild.style.color = "Black";
    }
}

// go close timer
function mclosetime() {
    closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime() {
    if (closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;

        if (ddmenuitem) {
        }

    }
}

// close layer when click-out
document.onclick = mclose;

function showPrivacy() {
    myRef = window.open('./privacy.aspx', 'mywin', 'left=20,top=20,width=550,height=620,toolbar=0,resizable=0, scrollbars=1');
}

