var navshown = false;
var navtimeout;
var subnavtimeout;

$(document).ready(function(){
	
	// Load shadowbox
	Shadowbox.init({
		handleOversize: "none",
		overlayOpacity: 0.9
	});
	
//	Cufon.replace('h1, h2, h3'); done in another file now
	
	// Tab code //
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	
	$('a.new-window').click(function(){
		window.open(this.href);
		return false;
	});
	//alert('hi');
	$('.question').click(function(){	
		
		if($(this).hasClass("active")){
			$(this).removeClass("active").addClass("inactive");	
			$(this).next().hide('slow');
			
		} else {
			$(this).removeClass("inactive").addClass("active");	
			$(this).next().show('slow');
			
		}
	});
	
	// Load accordion
	$('#accordion').accordion({
		icons: { 'header': 'arrow-right', 'headerSelected': 'arrow-down' },
		autoHeight: false,
		active: false,
		collapsible: true
	});
	
	/*$('table tr:even').addClass('even');
    $('table tr:odd').addClass('odd');
	$('table tr:gt(0) td:eq(0)').addClass('dark');
	$('table tr:eq(0)').addClass('header');*/

	$('table').each( function(index) {
		$('tr:even', this).addClass('even');
    	$('tr:odd', this).addClass('odd');
  	
	});
	
	
	/*
	 * Crisis response, find out more click
	 */
	$('#crisis_response_articles .article p a').bind('click', function(event){
		event.preventDefault();
		$(this).parent().siblings('.register').toggle();
	});
	
	/*
	 * Crisis response, view all workshops
	 */
	$('#crisis_response_articles #view_all_workshops a').bind('click', function(event){
		event.preventDefault();
		$(this).parent().hide();
		$(this).parent().siblings('#archived_workshops').show();
	});
	
	/*
	 * Crisis response right handside click functionality
	 */
	$('	.online-services #main .details img').bind('click', function(event){
		event.preventDefault();
		$(this).siblings('div.info').slideToggle();
	});


});

function hideDropDown() {
	if (navshown) {
		$('#drop_down').slideUp('slow');
		navshown = false;
	}
}
