
function load() {
    checkPanelDivs();
}

window.onload = load;

function activeMenu1(id) {
    var anchors = document.getElementsByTagName('a');
    for (i=0;i<anchors.length;i++) {
        if (anchors[i].id.indexOf('menu1_') != -1) {
            anchors[i].className = anchors[i].className.replace('active', '');
        }
    }
    document.getElementById('menu1_' + id).className += ' active';
}

function activeMenu2(id) {
    var anchors = document.getElementsByTagName('a');
    for (i=0;i<anchors.length;i++) {
        if (anchors[i].id.indexOf('menu2_') != -1) {
            anchors[i].className = anchors[i].className.replace('active', '');
        }
    }
    document.getElementById('menu2_' + id).className += ' active';
}

function clearField(id, defaultText) {
    if (document.getElementById(id).value == defaultText) {
        document.getElementById(id).value = '';
    }
}

function checkPanelDivs() {
    var p1 = document.getElementById('panel1');
    var p2 = document.getElementById('panel2');
    var p3 = document.getElementById('panel3');
    if (p1) {
        var p1Height = 0;
        var p2Height = 0;
        var p3Height = 0;
        if (p1.offsetHeight) {
            p1Height = p1.offsetHeight;
            if (p2 != null) p2Height = p2.offsetHeight;
            if (p3 != null) p3Height = p3.offsetHeight;
        } else if (p1.style.pixelHeight) { 
            p1Height = p1.style.pixelHeight;  
            if (p2 != null) p2Height = p2.style.pixelHeight;  
            if (p3 != null) p3Height = p3.style.pixelHeight; 
        }

        var newHeight = p1Height;
        if (newHeight < p2Height) newHeight = p2Height;
        if (newHeight < p3Height) newHeight = p3Height;

	p1.style.height = newHeight + 'px';
	if (p2 != null) p2.style.height = newHeight + 'px';
	if (p3 != null) p3.style.height = newHeight + 'px';
    }
}

function checkAttachment(id) {
    if (document.getElementById(id).value.length > 0) {
        document.getElementById(id + 'check').value = 'true';
    } else {
        document.getElementById(id + 'check').value = 'false';
    }
}

function showPopup(title, text, url) {
    if (document.getElementById('popupOuter')) {
/*
        if (document.all) {
            var x = screen.width;
            var y = screen.height;
        } else if (document.layers) {
            var x = window.outerWidth;
            var y = window.outerHeight;
        }
        x = (x/2)-175;
        y = (y/2)-160;
        var qPopup = window.open('/trendmicro/question_popup.jsp?' + popupURL + '&lang=' + lang,'noanswer','width=350,height=320,scrollbars=no,resizable=no,menubars=no,toolbars=no,status=no,top=' + y + ',left=' + x + ',screenX=' + x + ',screenY=' + y + '');
*/

        // get window height
        if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
        }
        document.getElementById('popupOuter').style.width = myWidth + 'px';
        if (document.body.scrollHeight > myHeight) {
            document.getElementById('popupOuter').style.height = document.body.scrollHeight + 'px';
        } else {
            document.getElementById('popupOuter').style.height = myHeight + 'px';
        }

        var popupMax = 480;
        var popupHeight = myHeight-180;
        if (popupHeight > popupMax) {
            popupHeight = popupMax;
        }
        document.getElementById('popupText').style.height = popupHeight + 'px';
        document.getElementById('popupFrame').style.height = popupHeight + 'px';

        var top = ((myHeight-popupHeight)/2)-20;
        document.getElementById('popupInner').style.posTop = top;
        document.getElementById('popupInner').style.top = top + 'px';
        document.getElementById('popupInner').pageY = top;

        var left = (myWidth-600)/2;
        document.getElementById('popupInner').style.posLeft = left;
        document.getElementById('popupInner').style.left = left + 'px';
        document.getElementById('popupInner').pageX = left;

        if (title != null) {
            document.getElementById('popupBannerText').innerHTML = '<h2>' + title + '</h2>';
            document.getElementById('popupBanner').style.display = 'block';
        }
        if (text != null) {
            document.getElementById('popupText').innerHTML = text;
            document.getElementById('popupText').style.display = 'block';
        }
        if (url != null) {
            document.getElementById('popupIframe').src = url;
            document.getElementById('popupFrame').style.display = 'block';
        }

        document.getElementById('popupOuter').style.display = 'block';
    }
}

function togglePopup() {
    if (document.getElementById('popupOuter')) {
        document.getElementById('popupBanner').style.display = 'none';
        document.getElementById('popupText').style.display = 'none';
        document.getElementById('popupFrame').style.display = 'none';
        document.getElementById('popupOuter').style.display = 'none';
    }
}

function checkPopup() {
    if (document.getElementById('popupOuter')) {
        // get window height
        if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
        }
        document.getElementById('popupOuter').style.width = myWidth + 'px';
        if (document.body.scrollHeight > myHeight) {
            document.getElementById('popupOuter').style.height = document.body.scrollHeight + 'px';
        } else {
            document.getElementById('popupOuter').style.height = myHeight + 'px';
        }

        var popupMax = 480;
        var popupHeight = myHeight-180;
        if (popupHeight > popupMax) {
            popupHeight = popupMax;
        }
        document.getElementById('popup').style.height = popupHeight + 'px';

        var top = ((myHeight-popupHeight)/2)-20;
        document.getElementById('popupInner').style.posTop = top;
        document.getElementById('popupInner').style.top = top + 'px';
        document.getElementById('popupInner').pageY = top;

        var left = (myWidth-600)/2;
        document.getElementById('popupInner').style.posLeft = left;
        document.getElementById('popupInner').style.left = left + 'px';
        document.getElementById('popupInner').pageX = left;

        document.getElementById('popupOuter').style.display = 'block';
   }
}