function bcse_init(){

	$('.bcse-dropdown').each(function(){
		if($(this).find('li').length == 0){
			$(this).remove();
		}else{
			$('#top').append($(this));
		}
	});

	$('.top-bar li a').hover(bcse_tab_hover);
/*
	$('.bcse-dropdown').hover(function(){}, function(){
		$('.bcse-dropdown').css('display', 'none');
	});
*/

	if(typeof tabnum != 'undefined' && tabnum != ''){
		bcse_display_tab(tabnum);
	}

}

function bcse_tab_hover(){

	var tabid = $(this).parent().attr('id').replace('tab-', '');

	bcse_display_tab(tabid);

}

function bcse_display_tab(id){

	var tabid = 'tab-' + id;
	var tab = $('#' + tabid);

	var zindex = 200;

	var tabfound = false;
	$('.top-bar li').each(function(){
		$(this).css('zIndex', zindex);
		if(this.id == tabid){
			tabfound = true;
		}
		if(tabfound){
			zindex -= 10;
		}else{
			zindex += 10;
		}
	});

	var d = $('#dropdown-' + id);

	$('.bcse-dropdown').css('display', 'none');

	$('.tab-active').removeClass('tab-active');
	tab.addClass('tab-active');

	if(d.length > 0){
		bcse_display_dropdown(d);
	}
}

function bcse_display_dropdown(d, t){

	d.css({
		'display': 'block'
	});

}

$(document).ready(bcse_init);



