var cur_down = null;
var cur_down_mi = null;

var accordian_up_arrow = 'accordian-arrow-closed.png';
var accordian_over_arrow = 'accordian-arrow-open.png';
var accordian_down_arrow = 'accordian-arrow-open.png';

$(function() {
	$('.accordian_tab').hover(
		function() {
			if (cur_down != this) {
				$(this).parent().children('.accordian_tab').children('.btn').attr('src', '/media/images/'+accordian_over_arrow);
			}
		},
		function() {
			if (cur_down != this) {
				$(this).parent().children('.accordian_tab').children('.btn').attr('src', '/media/images/'+accordian_up_arrow);
			}
		}
	);
	
	//Main Accordion Functions
	$('.accordian_content').hide(0);
	$('.accordian_tab').click(function() {
		$('.accordian_content').hide('fast');
		$('.btn').attr('src', '/media/images/'+accordian_up_arrow);
		
		if (cur_down != this) {
			$(this).parent().children('.accordian_tab').children('.btn').attr('src', '/media/images/'+accordian_down_arrow);
			$(this).parent().children('.accordian_content').show('fast');
			cur_down = this;
		} else {
			$(this).parent().children('.accordian_content').hide('fast');
			cur_down = null;
		}
		return false;
	});

	var link = location.hash.substr(1);
	if (link != '') {
		$('#'+link+' .accordian_tab').click();
		//$.scrollTo($('#'+link+' .accordian_tab').parent(), 200);
	}
	
	//Secondary Accordian Functions
	$('.more-info-content').hide(0);
	$('.more-info-tab').click(function() {
		$('.more-info-content').hide('fast');
		$('.more-info-tab img').attr('src', '/media/images/more-info-arrow-up.png');
		
		if (cur_down_mi != this) {
			$(this).parent().children('.more-info-content').show('fast', function() {
				//$.scrollTo($(this).parent(), 200);
				$(this).parent().children('.more-info-tab').children().children('.more-info-tab img').attr('src', '/media/images/more-info-arrow-down.png');
			});
			cur_down_mi = this;
		} else {
			$(this).parent().children('.more-info-content').hide('fast');
			cur_down_mi = null;
		}
		return false;
	});

});
