var alpha = 0;
var show_handle = null;
var hide_handle = null;
var speed       = 20; 

function changeFilter(obj, num)
{ 
    if (obj) 
    {
        obj.style.filter  = "Alpha(Opacity=" + num + ")"; 
        obj.style.opacity = num / 100; 
    }
}

function showTip(id)
{ 
    try 
    {
        var obj = $(id);    

        if (alpha < 100 + speed) 
        {
            alpha += speed;
            changeFilter(obj, alpha);
        } 

        if (alpha >= 100) 
        {
            clearInterval(show_handle); 
        }  
    } 
    catch (e) 
    {
    }
}

function hideTip(id)
{ 
    try 
    {
        var obj = $(id);

        alpha = 0;
        changeFilter(obj, 0);
        clearInterval(hide_handle);          
    } 
    catch (e) 
    {
    }
} 

function show(id)
{
    try 
    {
        hideAll(id);

        alpha   = 0;
        cur_obj = $(id);

        var info_id = id + "_info";  
        var msg_id  = id + "_msg";
        
        $(info_id).style.display = "block";
        
        if (cur_obj.name == "auth_code") 
        {
            cur_obj.className = 'auth_code_focus';
        }
        else 
        {
            $(msg_id).innerHTML = "";
            cur_obj.className   = 'focus';
        }        

        if (show_handle) 
        {
            clearInterval(show_handle);
        }

        if (alpha <= 100) 
        {
            show_handle = setInterval("showTip('" + info_id + "')", 1);        
        }
    } 
    catch (e) 
    {
    }
}

function hide(id)
{ 
    try 
    {
        cur_obj = $(id);
        if (cur_obj.name == "auth_code") 
        {
            alert(auth_code);
            cur_obj.className = 'auth_code';
        }
        else 
        {
            cur_obj.className = '';
        }

        var info_id = id + "_info";  
        
        $(info_id).style.display = "none";        

        if (alpha > 0) 
        {
            hide_handle = setInterval("hideTip('" + info_id + "')", 1);
        }
    } 
    catch (e) 
    {
    }
}

function defaultFocus(id)
{
    var objs = document.getElementsByTagName("input");  

    for (var i = 0; i < objs.length; i++) 
    {
        var obj = objs[i];

        if (obj.className == 'focus') 
        {
            break;
        }
    }

    if (i == objs.length) 
    {
        document.getElementById(id).select();
    }
}

function hideAll(id)
{   
    var objs = document.getElementsByTagName("input");  

    for (var i = 0; i < objs.length; i++) 
    {
        var obj      = objs[i];

        if (id != obj.id) 
        {   
            var info_id  = obj.id + '_info';
            var obj_info = $(info_id);

            if (obj_info && (obj_info.style.display == '' || obj_info.style.display == 'block')) 
            {
                changeFilter(obj_info, 0);
                obj_info.style.display = 'none';

                if (obj.name == 'auth_code') 
                {
                    obj.className = 'auth_code';
                }
            }
        }
    }
}

function divOnclick(event, id)
{
    try 
    {   
        div_obj = window.event.srcElement;   
    } 
    catch (e) 
    { 
        div_obj = event.target  
    }

    if (!id && (div_obj.nodeName).toLowerCase() != "input")
    {
        hideAll(id);
    }
}

//document.onclick=divOnclick;
