/**
 * Tabbar切换函数
 *
 * @params str  tabitem_id  Tabbar选项ID
 * @params str  tabbody_id  Tabbar内容ID
 * @params obj  event       兼容事件对象
 */
function tabbar( tabitem_id, tabbody_id, event,  callback)
{
    /* 发生事件的对象 */
    var obj = window.ActiveXObject ? window.event.srcElement : event.target;

    /* 无效的事件源 */
    if( obj.className == 'on' || obj.tagName.toLowerCase() != 'span' ) return false;

    var tabitem = document.getElementById(tabitem_id).childNodes[0];
    var tabbody = document.getElementById(tabbody_id).childNodes[0];

    do{
        /* 无效Tabbar项 */
        if( !tabitem.tagName || tabitem.tagName.toLowerCase() != 'span' ) continue;

        /* 过滤空白节点 */
        while( !tabbody.tagName || tabbody.tagName.toLowerCase() != 'div' ){
            tabbody = tabbody.nextSibling;
        }

        /* 撤销已选中项 */
        if( tabitem.className == 'on' ){
            tabitem.className = ''; tabbody.style.display = 'none';
        }

        /* 设置新选中项 */
        if( tabitem == obj ){
            tabitem.className = 'on'; tabbody.style.display = 'block';
			if( typeof(callback) == 'function' ){
                callback.call(tabitem);
            }
        }

        tabbody = tabbody.nextSibling;
    }while( tabitem = tabitem.nextSibling );
}

function tabitem( tabitem_id, event, callback )
{
    /* 发生事件的对象 */
    var obj = window.ActiveXObject ? window.event.srcElement : event.target;

    /* 无效的事件源 */
    if( obj.className == 'on' || obj.tagName.toLowerCase() != 'span' ) return false;

    var tabitem = document.getElementById(tabitem_id).childNodes[0];

    do{
        /* 无效Tabbar项 */
        if( !tabitem.tagName || tabitem.tagName.toLowerCase() != 'span' ) continue;

        /* 撤销已选中项 */
        if( tabitem.className == 'on' ){
            tabitem.className = '';
        }

        /* 设置新选中项 */
        if( tabitem == obj ){
            tabitem.className = 'on';

            if( typeof(callback) == 'function' ){
                callback.call(tabitem);
            }
        }
    }while( tabitem = tabitem.nextSibling );
}

/**
 * Tabitem 首页搜索回调函数
 */
function tabitemc_indexsearch()
{
	document.getElementById('searchtype').value=this.getAttribute('custom') ;
}


function index_package_change()
{
	document.getElementById('tabitem-lib-a').setAttribute('href',this.getAttribute('href'));
}
