var active = false;
var index = null;
var IE = /*@cc_on!@*/false;
$(document).ready(function(){
	if( IE ){
		$('a span img, a div img').click(function(){
			window.location.href = $(this).closest('a').attr('href');
		});
	}
	
	
	$('#more-menu').load("/resources/ajax-pages/more-menu.html",function(){
		$('#more-menu-close').click(function(){
			$('#more-menu,#navigation-bottom').animate({height:"toggle"},'slow');			
			return false;
		});
	});
	
	$('#providers').click(function(){
		$('#more-menu,#navigation-bottom').animate({height:'toggle'});
		return false;
	});
	
	$('#navigation').children().bind('mouseover',function(){
		active = true;		
	});
	
	$('#navigation').bind('mouseout',function(){
		active = false;
	});
	
	$('#navigation').mouseout(function(){
		setTimeout(function(){
			if(index != null && !active){
				$('#navigation a').eq(index).addClass('active')
			}
		},1000);
	});
	
	$('#navigation a').hover(function(){
		if( index == null ){
			$('#navigation a').each(function(){
				if( $(this).hasClass('active') ){
					index = $(this).index();
					$(this).removeClass('active');
				}
			});
		}else{
			$('#navigation a').eq(index).removeClass('active')
		}

	});
	
	if( $('#tb-tabs').length > 0 ){
		$('#tb-tabs div').click(function(){
			var id = $(this).attr('id');
			if( $('#'+id).find("a") == true ){
				window.location.href=$(this).attr('href');
				return;
			}else{
				if( !$(this).hasClass('active') ){
					$('.textbox-con div.content').each(function(){
						$(this).addClass('inactive');
						$(this).hide();
					});
					if( !$('#content-'+id).hasClass('no-scroll') )
						$('.textbox-con').css('overflow-y','auto');
					else
						$('.textbox-con').css('overflow-y','hidden');
					
					
					$('#tb-tabs div').each(function(){
						$(this).removeAttr('class');
					});
					$('#'+id).addClass('active');
					$('#content-'+id).show().addClass('active')
				}
			}
		});		
	}
});
