﻿var selectedMenu = null;
var canHide = true;
function ShowDDL(control) {
    if (!canHide)
        return;
    canHide = false;
    if (control.className.indexOf('click') != -1)
        control = control.parentNode;
    for (var i = 0; i < control.childNodes.length; i++) {
        if (control.childNodes[i].className && control.childNodes[i].className.indexOf('items') != -1) {
            if (control.childNodes[i].className.indexOf('show') == -1) {
                selectedMenu = control;
                setTimeout('canHide = true;', 100);
                control.childNodes[i].className = control.childNodes[i].className + ' show';
            }
            else {
                selectedMenu = null;
                control.childNodes[i].className = control.childNodes[i].className.replace(' show', ' ');
                canHide = true;
            }
            break;
        }
    }
}
function SelectDDLValue(control, clientId, postBackUrl) {
    var pBack = false;
    for (var i = 0; i < control.parentNode.parentNode.childNodes.length; i++) {
        if (control.parentNode.parentNode.childNodes[i].className && control.parentNode.parentNode.childNodes[i].className.indexOf('text') != -1)
            control.parentNode.parentNode.childNodes[i].innerHTML = control.childNodes[0].nodeValue;
        if (control.parentNode.parentNode.childNodes[i].id && control.parentNode.parentNode.childNodes[i].id.indexOf('hlValue') != -1) {
            pBack = control.parentNode.parentNode.childNodes[i].value != control.childNodes[1].innerHTML;
            control.parentNode.parentNode.childNodes[i].value = control.childNodes[1].innerHTML;
        }
    }
    if (clientId && postBackUrl && pBack)
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(clientId, '', false, '', postBackUrl, false, true));
}
function HideDDL(wait, control) {
    if (selectedMenu != null && control != selectedMenu && (wait || canHide)) {
        ShowDDL(selectedMenu);
        selectedMenu = null;
        canHide = true;
    }
}
function getObj(x) {
    if (typeof x != 'string') return x;
    else if (Boolean(document.getElementById)) return document.getElementById(x);
    else return null;
}
function setLanCookie(value) {
    setCookie("Language", value, '/');
}
function setCookie(name, value, path, domain, secure) {
    expires = new Date();
    expires.setTime(expires.getTime() + (24 * 60 * 365));
    document.cookie = name + "=" + escape(value) +
	("; expires=" + expires.toGMTString()) +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}
function ExpandTerms(id) {
    getObj(id + '-tbody').className = '';
    getObj(id + '-collapse').className = '';
    getObj(id + '-collapse-img').className = '';
    getObj(id + '-expand').className = 'invisible';
    getObj(id + '-expand-img').className = 'invisible';
}
function CollapseTerms(id) {
    getObj(id + '-tbody').className = 'invisible';
    getObj(id + '-collapse').className = 'invisible';
    getObj(id + '-collapse-img').className = 'invisible';
    getObj(id + '-expand').className = '';
    getObj(id + '-expand-img').className = '';
}
function ECTerms(id) {
    if (getObj(id + '-tbody').className == '')
        CollapseTerms(id);
    else
        ExpandTerms(id);
}
function openPopup(src, w, h) {
    openPopup(src, w, h, 'no');
}

function openPopup(src, w, h, sb) {
    var p = 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=' + sb + ',resizable=yes,status=yes,width=' + w + ',height=' + h + ',left=' + (screen.availWidth / 2 - 520 / 2) + ',top=' + (screen.availHeight / 2 - 520 / 2);
    var popup = window.open(src, 'popupTarget', p);
}
