order='date';page='1';cnl =0;
function sel_sort(id_val, tp, search_text)
{
	sel_id = id_val;

	if(!($doc('sivw')))	if((sel_id == 'vw') || (sel_id == 'vw7') ) sel_id = 'vw1';
	if(!($doc('sivw')))	if((sel_id == 'cmt') || (sel_id == 'cmt7') ) sel_id = 'cmt1';
	
	if((sel_id == 'vtp') || (sel_id == 'vtm') || (sel_id == 'vt')) sel_id = 'vt1';
	if((sel_id == 'vt1') || (sel_id == 'vtp1') || (sel_id == 'vtm1') ) sel_id = 'vt1';
	if((sel_id == 'vt7') || (sel_id == 'vtp7') || (sel_id == 'vtm7') ) sel_id = 'vt1';
	
	if((sel_id == 'cmt1') || (sel_id == 'cmt7') || (sel_id == 'cmt') ) sel_id = 'cmt7';
	
	$('#tabs_list li').removeClass('active');
	$('#si' + sel_id).addClass('active');

	order = id_val;

	if(tp == 'video')	return channel_video(page<0 ? page:1);
	if(tp == 'search')	return search_video(1);
	if(tp == 'authors')	return authors_list(order, page<0 ? page:1);
	
	return channel_list(1);
}

subsort = ''
function sel_sort_sub(sSubSort)
{
	subsort = sSubSort;
	return channel_list(1);
}

function channel_list(nPage)
{
	wait('lst');
	if(typeof nPage != 'undefined') page = nPage;
	x_channel_list(cnl, order, page, '', subsort, show_statica)
	return false;
}

function channel_video(nPage)
{
	wait('lst');
	if(typeof nPage != 'undefined') page = nPage;
	x_channel_video(cnl, order, page, show_statica)
	return false;
}

function search_video(nPage)
{
	wait('lst');
	if(typeof nPage != 'undefined') page = nPage;
	x_search_video(search_text, order, page, show_statica)
	return false;
	
}

function channel_list_page(nPage)
{
	wait('lst');
    window.scrollTo(0, $('#lst').offset().top - 31);
	if(typeof nPage != 'undefined') page = nPage;
	x_channel_list(cnl, order, page, '', subsort, show_statica)
	return false;
}
function channel_list_order(sOorder){order = sOorder; return channel_list(1);}
function channel_video_page(nPage){return channel_video(nPage);}
function search_video_page(nPage){return search_video(nPage);}


function cnl_video(tag_id, cnl_id, obj, tp)
{
	wait(tag_id);
	x_cnl_slider(tag_id, cnl_id, obj, tp, show_statica);
	return false;
}


function subsCnl(cnl_id)
{
	x_subsCnl(cnl_id, show_statica);
	return false;
}

function unsubsCnl(cnl_id)
{
	x_unsubsCnl(cnl_id, show_statica);
	return false;
}

cnPage = 1;
FnCnl = 'all';
cnOrder = 'date';
search_text ='';
var FltCnl = FltCnl | 0;
function SelTab(sFnCnl)
{
    search_text = '';
    cnPage = 1;
    page  = 1;
    FnCnl = sFnCnl;
    return ChanelVideoEx();
}

bFirst = 0;
function ChanelVideoEx()
{
    wait('lst');
    x_channel_video_ex(cnl, cnOrder, cnPage, FnCnl, search_text, bFirst, FltCnl,  show_statica);
    return false;
}

function ChanelVideoOrder(sOrder)
{
    cnOrder = sOrder;
    return ChanelVideoEx();
}

function ChanelVideoExPage(nPage)
{
    cnPage = nPage;
    window.scrollTo(0, $('#lst').offset().top - 31);
    return ChanelVideoEx();
}
