function hide(this_obj,section_id)
{
        this_obj = document.getElementById(this_obj);
        this_obj.blur();
        document.getElementById(section_id).style.display = 'none';
}

var prev_this_obj;
var prev_section_id;

function show_hide(this_obj,section_id)
{
        show_hide_check(this_obj,section_id,true,0,0,'left');
}

function hide_check(this_obj, section_id)
{
        this_obj.blur();
        
        if(document.getElementById(section_id).style.display != 'none')
        {
                document.getElementById(section_id).style.display = 'none';
        
                if(this_obj.className == 'top_bar_link' || this_obj.className == 'drop_menu_toggler_container')
                {
                        this_obj.style.backgroundColor = '';
                }
                else if(this_obj.className == 'dropdown_box')
                {
                        this_obj.style.backgroundColor = '';
                }
        }
}

function show_hide_check(this_obj,section_id,check_prev,top_diff,left_diff,align)
{
        hidetooltip();
        this_obj = document.getElementById(this_obj);
        if(this_obj != prev_this_obj && prev_section_id != null && check_prev)
        {
                hide_check(prev_this_obj, prev_section_id);
        }
        this_obj.blur();
        if(document.getElementById(section_id).style.display == 'none')
        {
                var originalWidth = this_obj.offsetWidth;
                var originalHeight = this_obj.offsetHeight;
                var offsetLeft = 0;
                var offsetTop = originalHeight;
                
                var temp_time_select = this_obj;
        
                while (temp_time_select)
                {
                        offsetLeft += temp_time_select.offsetLeft;
                        offsetTop += temp_time_select.offsetTop;
                        temp_time_select = temp_time_select.offsetParent;
                }
                
                var new_left = parseInt(offsetLeft+left_diff);
                var new_top = parseInt(offsetTop+top_diff);
                
                document.getElementById(section_id).style.left = new_left+"px";
                document.getElementById(section_id).style.top = new_top+"px";
                
                document.getElementById(section_id).style.display = '';
                
                var this_obj_width = parseInt(this_obj.clientWidth);
                var section_width = parseInt(document.getElementById(section_id).clientWidth);
                
                if(this_obj_width > section_width)
                {
                        document.getElementById(section_id).style.width = this_obj_width+"px";
                }
                else if(align == 'right')
                {
                        new_left -= (section_width - this_obj_width);
                        
                        document.getElementById(section_id).style.left = new_left+"px";
                }
                
                if(this_obj.className == 'top_bar_link' || this_obj.className == 'drop_menu_toggler_container')
                {
                        this_obj.style.backgroundColor = '#FFFFFF';
                }
                else if(this_obj.className == 'dropdown_box')
                {
                        this_obj.style.backgroundColor = '#F0F0F0';
                }
                
                if(section_id == 'common_nav_search')
                {
                        document.getElementById('search_input').focus();
                }
        }
        else
        {
                hide_check(this_obj, section_id);
        }
        
        prev_this_obj = this_obj;
        prev_section_id = section_id;
}

function show_hide_drop_menu(i_drop_menu_toggler_id, i_drop_menu_id, align)
{
        reset_hide_drop_menu();
        
        drop_menu = document.getElementById(i_drop_menu_id);
        drop_menu_id = i_drop_menu_id;
        
        if(drop_menu.style.display == "none" || prev_drop_menu_id != i_drop_menu_id)
        {
                if(prev_drop_menu_id != i_drop_menu_id && prev_drop_menu_id != "")
                {
                        //show_hide_check(prev_drop_menu_toggler_id, prev_drop_menu_id, false);
                        
                        hide_check(document.getElementById(prev_drop_menu_toggler_id), prev_drop_menu_id);
                }
                
                prev_drop_menu_id = i_drop_menu_id;
                prev_drop_menu_toggler_id = i_drop_menu_toggler_id;
                
                show_hide_check(i_drop_menu_toggler_id, i_drop_menu_id, false, -1, -1, align);
        }
}

var hide_drop_menu_timer

function hide_drop_menu()
{
        reset_hide_drop_menu();
        hide_drop_menu_timer = setTimeout("actual_hide_drop_menu()",500);
}

function reset_hide_drop_menu()
{
        clearTimeout(hide_drop_menu_timer);
}

function actual_hide_drop_menu()
{
        hide_check(document.getElementById(prev_drop_menu_toggler_id), prev_drop_menu_id);
}

var drop_menu = "";
var drop_menu_id = "";

var drop_menu_toggler = "";
var drop_menu_toggler_id = "";

var prev_drop_menu_id = "";
var prev_drop_menu_toggler_id = "";

function drop_menu_mouseover(i_drop_menu_toggler_id, i_drop_menu_id)
{
        drop_menu_toggler_id = i_drop_menu_toggler_id;
        drop_menu_id = i_drop_menu_id;

        reset_hide_drop_menu();
}

function drop_menu_mouseout()
{
        hide_drop_menu();
}
