$(document).ready(function(){

	$(".news li").click(function(event){
		var postid = this.id;
		post_id = postid.split('_');
		top.location = website_url+"/?p="+post_id[1];
	});
	
	$("ul#nav").superfish();
	
	// ---------------------
	// Homepage Tabs
	// ---------------------
	$('.recent-news-content').find('.tabbed-content').eq(0).show();
	$('.recent-news-tabs a').click(function(){
		
		$('.recent-news-tabs li').removeClass('active');
		$(this).parent().addClass('active');
		
		var position = $(this).parent().index();
		$('.recent-news-content').find('.tabbed-content').hide();
		$('.recent-news-content').find('.tabbed-content').eq(position).fadeIn('normal');
		
		return false;
		
	});
	
	$('a').each(function() {
		var a = new RegExp('/' + window.location.host + '/');
		if(this.href != '' && this.href != '#' && !a.test(this.href)) {
			$(this).click(function(event) {
				event.preventDefault();
				event.stopPropagation();
				window.open(this.href, '_blank');
			});
		}
	});
	
	// ---------------------
	// Tag Dropdown Slider
	// ---------------------
	$("#tagDropdownWindow").hide();
	$("a.tagDropdownActive").hide();
	
	$("a.tagDropdown").click(function(event){  
		$("a.tagDropdownActive").show();
		$("#tagDropdownWindow").slideDown("fast");
		
		$("#findCenterDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.findCenterDropdownActive").hide();
		$("#issuesDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.issuesDropdownActive").hide();
		$("#centerDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.centerDropdownActive").hide();
		$("#companyDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.companyDropdownWindow").hide();
	});
	
	$("a.tagDropdownActive").click(function(event){
		$("#tagDropdownWindow").slideUp("fast", function() {
			$(this).hide();
		});
		$(this).hide();
	});
	
	// ---------------------
	// Issues Dropdown Slider
	// ---------------------
	$("#issuesDropdownWindow").hide();
	$("a.issuesDropdownActive").hide();
	
	$("a.issuesDropdown").click(function(event){  
		$("a.issuesDropdownActive").show();
		$("#issuesDropdownWindow").slideDown("fast");
		
		$("#findCenterDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.findCenterDropdownActive").hide();
		$("#tagDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.tagDropdownActive").hide();
		$("#centerDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.centerDropdownActive").hide();
		$("#companyDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.companyDropdownWindow").hide();
	});
	
	$("a.issuesDropdownActive").click(function(event){
		$("#issuesDropdownWindow").slideUp("fast", function() {
			$(this).hide();
		});
		$(this).hide();
	});
	
	// ---------------------
	// Company Dropdown Slider
	// ---------------------
	$("#companyDropdownWindow").hide();
	$("a.companyDropdownActive").hide();
	
	$("a.companyDropdown").click(function(event){  
		$("a.companyDropdownActive").show();
		$("#companyDropdownWindow").slideDown("fast");
		
		$("#findCenterDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.findCenterDropdownActive").hide();
		$("#tagDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.tagDropdownActive").hide();
		$("#centerDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.centerDropdownActive").hide();
		$("#issuesDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.issuesDropdownWindow").hide();
	});
	
	$("a.companyDropdownActive").click(function(event){
		$("#companyDropdownWindow").slideUp("fast", function() {
			$(this).hide();
		});
		$(this).hide();
	});
	
	// ---------------------
	// Center Dropdown Slider
	// ---------------------
	$("#centerDropdownWindow").hide();
	$("a.centerDropdownActive").hide();
	
	$("a.centerDropdown").click(function(event){  
		$("a.centerDropdownActive").show();
		$("#centerDropdownWindow").slideDown("fast");
		
		$("#findCenterDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.findCenterDropdownActive").hide();
		$("#issuesDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.issuesDropdownActive").hide();
		$("#tagDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.tagDropdownActive").hide();
		$("#companyDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.companyDropdownWindow").hide();
	});
	
	$("a.centerDropdownActive").click(function(event){
		$("#centerDropdownWindow").slideUp("fast", function() {
			$(this).hide();
		});
		$(this).hide();
	});
	
	// ---------------------
	// Find a Center Dropdown Slider
	// ---------------------
	$("#findCenterDropdownWindow").hide();
	$("a.findCenterDropdownActive").hide();
	
	$("a.findCenterDropdown").click(function(event){  
		$("a.findCenterDropdownActive").show();
		$("#findCenterDropdownWindow").slideDown("fast");
		
		$("#issuesDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.issuesDropdownActive").hide();
		$("#tagDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.tagDropdownActive").hide();
		$("#centerDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.centerDropdownActive").hide();
		$("#companyDropdownWindow").slideUp("fast", function() { $(this).hide(); }); $("a.companyDropdownWindow").hide();
	});
	
	$("a.findCenterDropdownActive").click(function(event){
		$("#findCenterDropdownWindow").slideUp("fast", function() {
			$(this).hide();
		});
		$(this).hide();
	});

});
