﻿function vsb_tab_select(obj, selecttype)
{
    var tableobj = obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
    
    if(selecttype == false && tableobj.getAttribute("vsb_tab_mouseover") == "false")
        return;
    var newtab = (obj.cellIndex - 1)/2;
    var curtab = new Number(tableobj.getAttribute("vsb_tab_cur"));
    if(curtab == newtab)
        return;
        
    var tabtype = tableobj.getAttribute("vsb_tab_type");
    var tabnum = new Number(tableobj.getAttribute("vsb_tab_num"));
        
    
    tableobj.rows[curtab + 2].style.display="none";
    tableobj.rows[newtab + 2].style.display="";
    
    
    var tabcells = tableobj.rows[0].cells[0].getElementsByTagName("TABLE")[0].rows[0].cells;
    
    tabcells[curtab * 2 + 1].className = "vsb_tab_td_" + tabtype;
    tabcells[newtab * 2 + 1].className = "vsb_tab_td_f_" + tabtype;
    
    if(curtab == 0)
    {
        tabcells[curtab * 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/l.gif";
        tabcells[curtab * 2 + 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/l_r.gif";
    }
    else if(curtab + 1 == tabnum)
    {
        tabcells[curtab * 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/l_r.gif";
        tabcells[curtab * 2 + 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/r.gif";
    }
    else        
    {
        tabcells[curtab * 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/l_r.gif";
        tabcells[curtab * 2 + 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/l_r.gif";
    }

    if(newtab == 0)
    {
        tabcells[newtab * 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/lf.gif";
        tabcells[newtab * 2 + 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/lf_r.gif";
    }
    else if(newtab + 1 == tabnum)
    {
        tabcells[newtab * 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/l_rf.gif";
        tabcells[newtab * 2 + 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/rf.gif";
    }
    else
    {
        tabcells[newtab * 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/l_rf.gif";
        tabcells[newtab * 2 + 2].childNodes[0].src = "/system/resource/pagescript/vsb_tab/" + tabtype + "/lf_r.gif";
    }        
    
    tableobj.setAttribute("vsb_tab_cur",  newtab);
}

