// http://www.stemkoski.com/stupid-simple-jquery-accordion-menu/

$(document).ready(function() {

  //create a variable based on the url variable, if any
  var urlPath = document.location.search.split("="); // grabs url and splits at =
  var openThis = urlPath[1]; // sets openThis to the URL value
  if (openThis == null) { openThis = 0; } // if no variable, use 0
  else if (openThis == 'income') { openThis = 0; }
  else if (openThis == 'sales') { openThis = 1; }
  else if (openThis == 'corporate') { openThis = 1; }
  else if (openThis == 'withholding') { openThis = 1; }
  else if (openThis == 'business') { openThis = 1; }

	//accordion button action	
	$('div.accordionbutton').click(function() {
	  var $this = $(this);
	  if ($this.is('.accordionbuttonactive')) { // close if it's already open
      $('div.accordioncontent').slideUp('normal');
      $('div.accordionbutton').removeClass('accordionbuttonactive');
	  }
    else {
      $('div.accordioncontent').slideUp('normal');	
      $('div.accordionbutton').removeClass('accordionbuttonactive');
      $this.addClass('accordionbuttonactive');
      $this.next().slideDown('normal');
    }
	}); // end of click function
 
	//close all on page load	
	$('div.accordioncontent').hide();

  //open the one specified in the url variable and set the active button
	$('div.accordioncontent:eq('+openThis+')').show();
	$('div.accordionbutton').removeClass('accordionbuttonactive');
	$('div.accordionbutton:eq('+openThis+')').addClass('accordionbuttonactive');
 
});