// Dave Thomas #A00730628 Comp 1950  13/01/2011
// Ajax Loading
var ie_map_open = false;

$(document).ready(function () {
	
	init();
	

});


function init() {
	initExpandables();
	initTable();
	$('#content').hide();
	$('#content').fadeIn('slow');
}

function initTable() {
	$('.contact_table tr td:nth-child(2)').css({'width':'250px','height':'20px'});
	$('.hide_table table').hide();
	$('.hide_table').click(function() { $('table', this).toggle('slow'); $(this).siblings('.hide_table').find('table').fadeOut('slow'); });
}


//Expandable Box Functions
function initExpandables() {
	
		
	$('.expandable').each(function () {
		
		var values = $(this).attr('id').split(',');
		var move_to = values[0];		
		var bottom = values[1];	
		var height = values[2];	
		
		$(this).css({ 'height' : '50px'});
		$(this).show('slow');
		$(this).css({ 'bottom' : bottom });
		
		$(this).toggle(function () {
			$(this).animate({ 'height' : height, 'bottom': move_to });
			var arrow = $('.arrow', this);
			arrow.attr('src', '/img/' + getDirection(arrow) + 'arrow.png');
			if ($.browser.msie) { ie_map_open = true; }
			 }, function () {
				$(this).animate({ 'height' : '50px', 'bottom': bottom }); 
				var arrow = $('.arrow', this);			
				arrow.attr('src', '/img/' + getDirection(arrow) + 'arrow.png');
				if ($.browser.msie) { ie_map_open = false; }
			});
		
		$('a', this).click(function () {
			window.location = $(this).attr('href');
			
		});
	});
	
	
} 

function getDirection(arrow){
	var direction = 'down';
	if (arrow.attr('src').indexOf('down') > 0 ) {
		direction = 'up';
	} 
	return direction;
}


