/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/**
*	Carta Accordion
*	Author: Stefano Giliberti (kompulsive@gmail.com)
*	(winterbits.com)
*/
(function(jQuery) {
	jQuery.fn.wb_accordion = function(options) {
	
		/* Presets */
		var defaults = {
			slide: ".slide", // slide selector
			first: 1, // slide to open first
			fullwidth: 730, // open slide width
			height: 308, // slides height
			dropshadow: true,
			hoveropacity: 0.5,
			hovercolor: "#FFF",
			speed: 700,
			easing: "easeOutExpo" // optional
		};
		var options = jQuery.extend(defaults, options);
		
		//
		return this.each(function() {
			
			var slides = jQuery(this).find(options.slide);
			slides.css({
				"width": options.fullwidth,
				"height": options.height
			})
			.parent()
			.css("height", options.height)
						
			var count = slides.length,
				minwidth = (jQuery(this).width() - options.fullwidth) / (count - 1),
				tabindex = options.first - 1,
				last = jQuery(this).find(options.slide + ":eq(" + tabindex + ")"),
				easing = (jQuery.easing.def) ? options.easing : "linear",
				slideimages = jQuery(this).find(options.slide).children("img").hide()
				
			//
			open(jQuery(this).find(options.slide + ":eq(" + tabindex + ")"));
			
			jQuery(this).find(options.slide + ":not(:eq(" + tabindex + "))").css("width", minwidth)
						
			slideimages.each(function(i) {	
				jQuery(this).delay(i*200).fadeIn()
			})
			
			jQuery(this).find(options.slide).prepend('<div class="overlay"></span>')
			jQuery(this).find(options.slide).children("div").hide()
			
			jQuery(options.slide)
				.find(".overlay")
				.css("position", "absolute")
				.css("width", jQuery(this).width())
				.css("height", jQuery(this).height())
				.css("z-index", "50")
				.css("background", options.hovercolor)
				.hide()
			
			
			if (options.dropshadow) {	
				jQuery(this).find(options.slide + ":not(:last-child)").prepend('<div class="drop-shadow"></span>');
				jQuery(this).find(".drop-shadow").css("height", options.height);
			}
						
			jQuery(this).find(options.slide).hoverIntent(function(){
				if (!jQuery(this).hasClass("open")) {
					close(last);
					open(this);
					last = this;
				}
			}, function(){});
			
			jQuery(this).find(options.slide).hover(function(){
				jQuery(this).siblings(options.slide).find(".overlay").show().css("opacity", options.hoveropacity);
			}, function(){
				jQuery(this).siblings(options.slide).find(".overlay").hide();
			})
			
			function open(tab) {
				jQuery(tab)
					.addClass("open")
					.animate({ width: options.fullwidth }, { queue: false, duration: options.speed, "easing": easing })
				if (jQuery(tab).find("div").length)	
					jQuery(tab)
						.find("div:not(.drop-shadow, .overlay)")
						.delay(options.speed / 2)
						.slideDown(100)
			}
			
			function close(tab) {
				if (jQuery(tab).find("div").length) {			
					jQuery(tab)
						.find("div:not(.drop-shadow, .overlay)")
						.stop(true, true)
						.hide()
				}
				jQuery(tab)
					.removeClass("open")
					.animate({ width: minwidth }, { queue: false, duration: options.speed, "easing": easing })
			}
						
		})
		//
		
	}
})(jQuery)

