/*
 * Toggle Template Script
 * Copyright © 2010 OMC
 * All rights reserved.
*/
		
	jQuery().ready(function(){

		/* second simple accordion with special markup
		------------------------------------------------------------------------------------------ */
		
		$("#toggle-content-wrapper").accordion({
			header:'h2',
			collapsible: true,
			active:false,
			animated:false
		});
		
		/* Toggle
		------------------------------------------------------------------------------------------ */
		
		//rollover and cursor style
		$("#toggle-wrapper div.toggle-header").bind('click',ToggleExtra).addClass('normal')
		.hover(
		function () {
		  $(this).addClass("hover");
		},
		function () {
		  $(this).removeClass("hover");
			}
		);
		
		// Adds functionality to accordian 1.6 (if used in content area only) to close opened item if clicked twice.
	  function ToggleExtra()
	  {
			var highlight = 'highlight';
			var normal = 'normal';
			var defaultselector = 'selected'; // for accordian plugin
			var $this = $(this);
			var $parentcollection = $(this).parent().children(':even');
		
			if ($this.hasClass(normal)) // not yet open
			{
				$parentcollection.removeClass(highlight).addClass(normal);	
				$this.next('div').toggle();
				$this.addClass(highlight).removeClass(normal).addClass('default_selector');
			} 
			else   // already open
			{
				$parentcollection.removeClass(highlight).addClass(normal);	
				$this.removeClass(highlight).addClass(normal).removeClass(defaultselector);
				$this.next('div').toggle();
			}
	  }
		
		// accordian custom parameters	
		jQuery("#toggle-wrapper").accordion({
			header:'.toggle-header',
			collapsible: true,
			active:false,
			animated:false
		});
		
	 // inserts unique id's into the accordian blocks and allows auto opening of them from url using hash
	 $("#toggle-wrapper").children("div.toggle-header").each(function(i){
		var $this = $(this);
		$this.attr("id","toggleitem_" + i );
	 });
	
	 $(window.location.hash).trigger('click');	
	 
});
	

