
/// -----------------------------------------------------------------------------
/// <procedure>jquery ready</procedure>
/// <summary>
/// 	Uses the jquery library to do the following:
///		- animate the name anchor links
///		- pop external links into a new window
///		- lightbox functionality for popup images
///		- navigation highlighting as we are using dw templates
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// 	[Gavin Bruce] 11/2008 Created gav@chillburn.com
/// </history>
/// -----------------------------------------------------------------------------

$(document).ready(function(){
	
	//animate anchor links
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body')
				.animate({scrollTop: targetOffset}, 500);
				return false;
			}
		}
	});
	
	
	//pop external links in a new window
	$("a[href*='http://']").not("a[href^='http://localhost']").not("a[href^='http://dev.tricky.com.au']").not("a[href^='http://skmconsulting.com']").not("a[href^='http://www.skmconsulting.com']").click(function() {
		window.open($(this).attr('href'));
		return false;
	});
	$("a[href*='mms://']").click(function() {
		window.open($(this).attr('href'));
		return false;
	});
	
	//lightbox
	$('a[@rel*=lightbox]').lightBox({
		overlayOpacity: 0.6,
		imageLoading: '../images/lightbox-ico-loading.gif',
		imageBtnClose: '../images/lightbox-btn-close.gif',
		imageBtnPrev: '../images/lightbox-btn-prev.gif',
		imageBtnNext: '../images/lightbox-btn-next.gif'
	}); 

	//the chief executive's message page has a 2 lightbox links to the same image. therefore, there were 2 images in the lightbox array showing the next / previous buttons. we do not want this so this is the workaround. using a different rel for each of the 2 links.
	$('a[@rel*=lightbx1]').lightBox({
		overlayOpacity: 0.6,
		imageLoading: '../images/lightbox-ico-loading.gif',
		imageBtnClose: '../images/lightbox-btn-close.gif',
		imageBtnPrev: '../images/lightbox-btn-prev.gif',
		imageBtnNext: '../images/lightbox-btn-next.gif'
	}); 

	$('a[@rel*=lightbx2]').lightBox({
		overlayOpacity: 0.6,
		imageLoading: '../images/lightbox-ico-loading.gif',
		imageBtnClose: '../images/lightbox-btn-close.gif',
		imageBtnPrev: '../images/lightbox-btn-prev.gif',
		imageBtnNext: '../images/lightbox-btn-next.gif'
	}); 

	$('a[@rel*=lightbx3]').lightBox({
		overlayOpacity: 0.6,
		imageLoading: '../images/lightbox-ico-loading.gif',
		imageBtnClose: '../images/lightbox-btn-close.gif',
		imageBtnPrev: '../images/lightbox-btn-prev.gif',
		imageBtnNext: '../images/lightbox-btn-next.gif'
	}); 


	//highlight nav
	var pathname = window.location.pathname;
	
	if (pathname.indexOf('/2007-2008-highlights') != -1) {
		$('#navigation').find('li:eq(0)').addClass('selectednav');
		
	} else if (pathname.indexOf('/who-we-are') != -1) {
		$('#navigation').find('li:eq(1)').addClass('selectednav');
		
	} else if (pathname.indexOf('/chief-executives-message') != -1) {
		$('#navigation').find('li:eq(2)').addClass('selectednav');
		
	} else if (pathname.indexOf('/2008-at-a-glance') != -1) {
		$('#navigation').find('li:eq(3)').addClass('selectednav');
		
	} else if (pathname.indexOf('/towards-a-sustainable-future') != -1) {
		$('#navigation').find('li:eq(5)').addClass('selectednavtwolines');
		
	} else if (pathname.indexOf('/skm-at-work') != -1) {
		$('#navigation').find('li:eq(7)').addClass('selectednav');
		
	} else if (pathname.indexOf('/skm-in-the-community') != -1) {
		$('#navigation').find('li:eq(8)').addClass('selectednav');
		
	} else if (pathname.indexOf('/skm-fiscally') != -1) {
		$('#navigation').find('li:eq(9)').addClass('selectednav');
		
	} else if (pathname.indexOf('/skm-and-clients') != -1) {
		$('#navigation').find('li:eq(10)').addClass('selectednav');
		
	} else if (pathname.indexOf('/buildings-and-infrastructure') != -1) {
		$('#navigation').find('li:eq(12)').addClass('selectednav');
		
	} else if (pathname.indexOf('/mining-and-metals') != -1) {
		$('#navigation').find('li:eq(13)').addClass('selectednav');
		
	} else if (pathname.indexOf('/power-and-industry') != -1) {
		$('#navigation').find('li:eq(14)').addClass('selectednav');
		
	} else if (pathname.indexOf('/water-and-environment') != -1) {
		$('#navigation').find('li:eq(15)').addClass('selectednav');
		
	} else if (pathname.indexOf('/corporate-goverance') != -1) {
		$('#navigation').find('li:eq(17)').addClass('selectednav');
		
	} else if (pathname.indexOf('/download-pdf') != -1) {
		$('#navigation').find('li:eq(19)').addClass('selectednav');
		
	} else if (pathname.indexOf('/order-printed-report') != -1) {
		$('#navigation').find('li:eq(20)').addClass('selectednav');
		
	}
	

	//hightlight topnav
	if (pathname.indexOf('/case-studies/dampier-port') != -1) {
		$('#toplinks').find('li:eq(1) > a').addClass('selectedtopnav');
		
	} else if (pathname.indexOf('/case-studies/skilled-park') != -1) {
		$('#toplinks').find('li:eq(2) > a').addClass('selectedtopnav');
		
	} else if (pathname.indexOf('/case-studies/greater-gabbard') != -1) {
		$('#toplinks').find('li:eq(3) > a').addClass('selectedtopnav');
		
	}
	
	//just a little hover effect on the board comittees table.
	/*
	$('.dg tr').mouseover(function() {
		$(this).animate({backgroundColor: "#d1e5f1"}, 500);
	});
	$('.dg tr').mouseout(function() {
		$(this).animate({backgroundColor: "#E5F1F8"}, 500);
	});
	*/
		

});