$(document).ready(function() {
	/* removed 20100412 brad (not using Google search any longer)
	if (document.getElementById('site-search-inpage')){
		document.getElementById('site-search-inpage').action = "/search/results/";
	} else {
		document.getElementById('site-search').action = "/search/results/";
	}
	*/
	
	$('.article table.stripe').each(function(){
		$('tbody tr:odd').addClass('alt');
	});
	
	// Autopopulate forms fields
	$('form.autopopulate').each(function(){
		var fieldLabel = $('label.structural',this).text();
		$('input.populate',this).val(fieldLabel).focus(function(){
			if (this.value == fieldLabel){$(this).val('');};
		}).blur(function(){
			if (this.value == ''){$(this).val(searchFieldLabel);};
		});
	});
	
	// FAQ List
	var urlHash = window.location.hash,
		$answer = $('.answer').hide();
	
	if (urlHash) {$('.answer',urlHash).slideToggle(750);}
	
	//if we are coming from the search results page, open the question and highlight the search terms
	if(typeof(searchTerms) !== 'undefined') {
		replaceText = '/'+searchTerms+'/i';
		replaceWith = '<span class="highlight">'+searchTerms+'</span>';
		$('li:contains("'+searchTerms+'") .answer').show();
		temp = $('div#main-in').html().replace(eval(replaceText),replaceWith);
		$('div#main-in').html(temp);
	}
	

	$('.faq-list h4 a').click(function() {
		$('.answer',this.hash).slideToggle(750);
		return false;
	});

	// Personal Calendar Export slider
	$('#cal-options').hide();
	$('#add-cal a').click(function(){
		$('#cal-options').slideToggle('normal');
		return false;
	});
	$('body').click(function(){$('#cal-options').slideUp('normal');});	

});




