/*
 * RYaccordion.js - A jQuery Plugin
 * A jQuery plugin for creating accordions and expanding navigations.
 *
 * By Andy Tennison (andrew@tennisons.com / http://www.tennisons.com)
 * For Radley Yeldar (http://www.ry.com/)
 *
 * Version 1.0.1
 * May 5th, 2009
 *
 * Copyright (c) 2009 Andy Tennison
 * Dual licensed under the MIT and GPL licenses.
*/

(function($){$.fn.RYaccordion=function(n){var o=$.extend({},$.fn.RYaccordion.defaults,n);s(this);var p=[];var q=[];var r={};if(jQuery.easing['jswing']==undefined){o.animation='swing'};return this.each(function(g){var h=0;return $(this).children(o.pane).each(function(i){var f={$panes:$(this),$trigger:$(this).children(o.trigger),$inner:$(this).children(o.inner),paneStatus:false};q[i]=f;p[g]=q;if(o.defaultOpen=='-1'){var x=p[g][i];j(x)}else if(o.defaultOpen>='0'&&o.defaultOpen==i){var x=p[g][o.defaultOpen];j(x)}else if(o.defaultOpen=='class'&&p[g][i].$panes.hasClass(o.defaultOpenClass)){var x=p[g][i];j(x)};p[g][i].$trigger.bind("mouseenter mouseleave",function(e){$(this).toggleClass("hover")}).bind("click",function(e){e.preventDefault();var x=p[g][i];if(x.$inner.is(':visible')&&(o.closeAll||h>1)){l(x)}else if(!x.$inner.is(':visible')&&o.autoCollapse){$.each(p[g],function(a,b){var c=b.paneStatus;if(c===true&&a!=i){var x=p[g][a];l(x)}else if(a==i){var x=p[g][i];k(x)}})}else if(!x.$inner.is(':visible')&&!o.autoCollapse){var d=$(this).parent(o.pane);k(x)}})});function j(a){a.$trigger.addClass('on');a.$inner.css({display:'block'});h=h+1;a.paneStatus=true;var b='increase';m(b,a)}function k(a){a.$trigger.addClass('on');if(o.direction=='horz'){a.$inner.animate({'width':'show'},{duration:o.speedOpen,easing:o.animation})}else{a.$inner.animate({'height':'show'},{duration:o.speedOpen,easing:o.animation})}h=h+1;a.paneStatus=true;var b='increase';m(b,a)}function l(a){a.$trigger.removeClass('on');if(o.direction=='horz'){a.$inner.animate({'width':'hide'},{duration:o.speedClose,easing:o.animation})}else{a.$inner.animate({'height':'hide'},{duration:o.speedClose,easing:o.animation})}h=h-1;a.paneStatus=false;var b='decrease';m(b,a)}function m(x,a){if(o.fs_active&&x=='decrease'){a.$trigger.find(o.fs_tag).animate({fontSize:o.fs_originalSize},{duration:o.speedOpen,easing:o.animation})}else if(o.fs_active&&x=='increase'){a.$trigger.find(o.fs_tag).animate({fontSize:o.fs_newSize},{duration:o.speedOpen,easing:o.animation})}}})};function s(a){if(window.console&&window.console.log){window.console.log('hilight selection count: '+a.size())}}})(jQuery);

$.fn.RYaccordion.defaults = {
	// set default HTML elements (all can be '.classes' or 'tags' such as <h1> or <a>)
	pane: 'li',						// wraps each pane
	trigger: '.RYA_trigger',		// clickable part
	inner: '.RYA_inner',			// collapsable part
	
	// vertical='vert' or horizontal='horz'
	direction: 'vert',

	// set initial state
	defaultOpen: 0,					// ('class'/-1/-2/0+) which slot to open on load: 'class' = set class on html / -1 = all open / -2 = all shut / 0 (or higher, 0 = first) = that slide
	defaultOpenClass: '.current',	// if 'class' is used above, define the class name here
	
	// set has panes open and close
	autoCollapse: true,				// (true/false) true = shut open when new is clicked, false = all stay open
	closeAll: true,					// (true/false) false = cannot shut self, true = can shut self
	
	// animation options
	animation: 'easeInOutCirc',		// requires easing plugin to work, if not present default linear will be used.
	speedOpen: 500,					// !open speed
	speedClose: 500,					// have a guess..! yep close speed
	
	// extending EXAMPLE 1 - increasing font-size
	fs_active: false,
	fs_originalSize: '1.6em',	// needs to match CSS
	fs_newSize: '2em',			
	fs_tag: 'h3'	
};
