// JavaScript Document
// anziif_init.js 
// ------------------------
// ANZIIF | Chinese 

// JS Initilisation of important page elements/states : 


// NB To be replaced by more appropriate server-side XSLT functionality when possible : 
// this function 'manually' identifies the current page (by matching current URL) and marks the relevant 
// nav menu item accordingly ...
var setCurrentNavItem = function() { 
	var $items = $('#side.nav li');  // get all nav items 
	// loop thru items, find match and apply '.current' classname 
	$items.each( function() { 
		if ( window.location.href.indexOf( $(this).find('a').attr('href') ) >= 0  ) { 
			$(this).addClass('current'); 
			//if (window['console']) { console.log( $(this).text() + ' : current' ); }
			return false; 
		} 
	}); 
} 


$(document).ready( function() { 

	// clunky func to set current page indicator in nav sidebar 
	setCurrentNavItem(); 
	
	// add zebra support to all tables 
	$('table tr:odd').addClass('odd'); 

	// swap sidenav classname on hover (except in homepage) 
	$('#side.nav li:not(li.current)').bind('mouseenter', function() { 
		$(this).addClass('hover'); 
	}).bind('mouseleave', function() { 
		$(this).removeClass('hover'); 
	}).bind('click', function() { 
		window.location.href = $(this).find('a').attr('href'); 
	}); 
	
	// invoke banner slider controller 
	$('#slider1').bxSlider(); 
	
}); 

