﻿if (!is_ie6) {
jQuery(document).ready(function(){
	//function for displaying a particular target
	function faqTargetSelect (linkTarget) {
		jQuery('.faq-answer').css('position','absolute').css('top','0').hide();
		jQuery('#-'+linkTarget).css('position','relative').css('float','left').show();
		//jQuery('#faq-search-box').accordion('activate',false);
		window.location.hash = '#'+linkTarget;
	}
	//set up array of questions
	var questions = Array();
	//hide the "back to top links"
	jQuery('#content-primary .incidental').hide();
	//hide all answers and build the DOM properly
	jQuery('#content-primary h2 a').each(function() {
		$(this).parent().parent().attr('id','-'+$(this).attr('name'));
		$(this).parent().parent().attr('class','faq-answer');
		$(this).parent().parent().hide();
		//define this item in the questions array
		if ($(this).attr('name') != 'start') {
			questions[questions.length] = {value:$(this).attr('name'),label:$(this).html()};
		}
		$(this).attr('name','');
	});
	//configure the navigation accordion
	jQuery('#faq-section-navigation').accordion({
		active:false,
		autoHeight:false,
		collapsible:true
	});
	//add event listeners to navigation accordion links
	jQuery('#faq-section-navigation ul a').click(function() {
		var linkTarget = $(this).attr('href').substring(1);
		faqTargetSelect(linkTarget);	})
	//show search box and make it an accordion
	jQuery('#faq-search-box').show().accordion({
		active:false,
		collapsible:true
	});
	jQuery('#faq-search-input').autocomplete({
		minLength:0,
		source:questions,
		focus: function(event, ui) {
			$('#faq-search-input').val(ui.item.label);
			return false;
		},
		select: function(event, ui) {
			$('#faq-search-input').val('');
			faqTargetSelect(ui.item.value);
			return false;
		}
	}).data( "autocomplete" );
	//check hash for current FAQ to jump to
	var linkTarget = window.location.hash.substring(1);
	if (linkTarget.length != 0) {
		faqTargetSelect(linkTarget);
	}else {
		faqTargetSelect('start');
	}
});
}