/*
 * jQuery Tools 1.2.5 - The missing UI library for the Web
 * 
 * [tabs, tabs.slideshow]
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 * File generated: Thu Nov 11 10:18:40 GMT 2010
 */
	
	
/**
* @license
* jQuery Tools @VERSION Tabs- The basics of UI design.
*
* NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
*
* http://flowplayer.org/tools/tabs/
*
* Since: November 2008
* Date: @DATE
*/
(function ($) {

  // static constructs
  $.tools = $.tools || {
    version: '@VERSION'
  };

  $.tools.tabs = {

    conf: {
      tabs: 'a',
      current: 'current',
      onBeforeClick: null,
      onClick: null,
      effect: 'default',
      initialIndex: 0,
      event: 'click',
      rotate: false,

      // 1.2
      history: false,
						
						// Custom resize config
						resizeHeight: 0
    },

    addEffect: function (name, fn) {
      effects[name] = fn;
    }

  };

  var effects = {

    // simple "toggle" effect
    'default': function (i, done) {
      this.getPanes().hide().eq(i).show();
      done.call();
    },

    /*
     configuration:
     - fadeOutSpeed (positive value does "crossfading")
     - fadeInSpeed
     */
    fade: function (i, done) {

      var conf = this.getConf(),
          speed = conf.fadeOutSpeed,
          panes = this.getPanes();

      if (speed) {
        panes.fadeOut(speed);
      } else {
        panes.hide();
      }

      panes.eq(i).fadeIn(conf.fadeInSpeed, done);
    },

    // for basic accordions
    slide: function (i, done) {
      this.getPanes().slideUp(200);
      this.getPanes().eq(i).slideDown(400, done);
    },

    /**
     * AJAX effect
     */
    ajax: function (i, done) {
      this.getPanes().eq(0).load(this.getTabs().eq(i).attr("href"), done);
    }
  };

  var w;

  /**
   * Horizontal accordion
   *
   * @deprecated will be replaced with a more robust implementation
   */
  $.tools.tabs.addEffect("horizontal", function (i, done) {

    // store original width of a pane into memory
    if (!w) {
      w = this.getPanes().eq(0).width();
    }

    // set current pane's width to zero
    this.getCurrentPane().animate({
      width: 0
    }, function () {
      $(this).hide();
    });

    // grow opened pane to it's original width
    this.getPanes().eq(i).animate({
      width: w
    }, function () {
      $(this).show();
      done.call();
    });

  });


  function Tabs(root, paneSelector, conf) {

    var self = this,
        trigger = root.add(this),
        tabs = root.find(conf.tabs),
        panes = paneSelector.jquery ? paneSelector : root.children(paneSelector),
        current;


    // make sure tabs and panes are found
    if (!tabs.length) {
      tabs = root.children();
    }
    if (!panes.length) {
      panes = root.parent().find(paneSelector);
    }
    if (!panes.length) {
      panes = $(paneSelector);
    }


    // public methods
    $.extend(this, {
      click: function (i, e) {
        var tab = tabs.eq(i);

        if (typeof i == 'string' && i.replace("#", "")) {
          tab = tabs.filter("[href*=" + i.replace("#", "") + "]");
          i = Math.max(tabs.index(tab), 0);
        }

        if (conf.rotate) {
          var last = tabs.length - 1;
          if (i < 0) {
            return self.click(last, e);
          }
          if (i > last) {
            return self.click(0, e);
          }
        }

        if (!tab.length) {
          if (current >= 0) {
            return self;
          }
          i = conf.initialIndex;
          tab = tabs.eq(i);
        }

        // current tab is being clicked
        if (i === current) {
          return self;
        }

        // possibility to cancel click action
        e = e || $.Event();
        e.type = "onBeforeClick";
        trigger.trigger(e, [i]);
        if (e.isDefaultPrevented()) {
          return;
        }

        // call the effect
        effects[conf.effect].call(self, i, function () {

          // onClick callback
          e.type = "onClick";
          trigger.trigger(e, [i]);
        });

        // default behaviour
        current = i;
        tabs.removeClass(conf.current);
        tab.addClass(conf.current);
								
								//
								//
								// Custom panel resizing
								//
								//
								if( conf.resizeHeight > 0 ){
										var container = panes.parent(),
										heightThreshold = conf.resizeHeight,
										imgHeight = panes.eq(current).find('img').height(),
										newTop = ( imgHeight < heightThreshold ) ? ( heightThreshold - imgHeight ) / 2 : 0 ;
										
										// Vertically center image if shorter than height threshold
										container.height( imgHeight ).animate({
											top : newTop
										}, 1000);
								}
								
        return self;
      },

      getConf: function () {
        return conf;
      },

      getTabs: function () {
        return tabs;
      },

      getPanes: function () {
        return panes;
      },

      getCurrentPane: function () {
        return panes.eq(current);
      },

      getCurrentTab: function () {
        return tabs.eq(current);
      },

      getIndex: function () {
        return current;
      },

      next: function () {
        return self.click(current + 1);
      },

      prev: function () {
        return self.click(current - 1);
      },

      destroy: function () {
        tabs.unbind(conf.event).removeClass(conf.current);
        panes.find("a[href^=#]").unbind("click.T");
        return self;
      }

    });

    // callbacks
    $.each("onBeforeClick,onClick".split(","), function (i, name) {

      // configuration
      if ($.isFunction(conf[name])) {
        $(self).bind(name, conf[name]);
      }

      // API
      self[name] = function (fn) {
        if (fn) {
          $(self).bind(name, fn);
        }
        return self;
      };
    });


    if (conf.history && $.fn.history) {
      $.tools.history.init(tabs);
      conf.event = 'history';
    }

    // setup click actions for each tab
    tabs.each(function (i) {
      $(this).bind(conf.event, function (e) {
        self.click(i, e);
        return e.preventDefault();
      });
    });

    // cross tab anchor link
    panes.find("a[href^=#]").bind("click.T", function (e) {
      self.click($(this).attr("href"), e);
    });

    // open initial tab
    if (location.hash && conf.tabs == "a" && root.find("[href=" + location.hash + "]").length) {
      self.click(location.hash);

    } else {
      if (conf.initialIndex === 0 || conf.initialIndex > 0) {
        self.click(conf.initialIndex);
      }
    }

  }


  // jQuery plugin implementation
  $.fn.tabs = function (paneSelector, conf) {

    // return existing instance
    var el = this.data("tabs");
    if (el) {
      el.destroy();
      this.removeData("tabs");
    }

    if ($.isFunction(conf)) {
      conf = {
        onBeforeClick: conf
      };
    }

    // setup conf
    conf = $.extend({}, $.tools.tabs.conf, conf);


    this.each(function () {
      el = new Tabs($(this), paneSelector, conf);
      $(this).data("tabs", el);
    });

    return conf.api ? el : this;
  };

})(jQuery);


/**
 * @license
 * jQuery Tools @VERSION Slideshow - Extend it.
 *
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 *
 * http://flowplayer.org/tools/tabs/slideshow.html
 *
 * Since: September 2009
 * Date: @DATE
 */
(function ($) {

  var tool;

  tool = $.tools.tabs.slideshow = {

    conf: {
      next: '.forward',
      prev: '.backward',
      disabledClass: 'disabled',
      autoplay: false,
      autopause: true,
      interval: 3000,
      clickable: true,
      api: false
    }
  };

  function Slideshow(root, conf) {

    var self = this,
        fire = root.add(this),
        tabs = root.data("tabs"),
        timer, stopped = true;


    // next / prev buttons


    function find(query) {
      var el = $(query);
      return el.length < 2 ? el : root.parent().find(query);
    }

    var nextButton = find(conf.next).click(function () {
      tabs.next();
    });

    var prevButton = find(conf.prev).click(function () {
      tabs.prev();
    });


    // extend the Tabs API with slideshow methods
    $.extend(self, {

      // return tabs API
      getTabs: function () {
        return tabs;
      },

      getConf: function () {
        return conf;
      },

      play: function () {

        // do not start additional timer if already exists
        if (timer) {
          return self;
        }

        // onBeforePlay
        var e = $.Event("onBeforePlay");
        fire.trigger(e);
        if (e.isDefaultPrevented()) {
          return self;
        }


        // construct new timer
        timer = setInterval(tabs.next, conf.interval);
        stopped = false;

        // onPlay
        fire.trigger("onPlay");

        return self;
      },

      pause: function () {

        if (!timer) {
          return self;
        }

        // onBeforePause
        var e = $.Event("onBeforePause");
        fire.trigger(e);
        if (e.isDefaultPrevented()) {
          return self;
        }

        timer = clearInterval(timer);

        // onPause
        fire.trigger("onPause");

        return self;
      },

      // when stopped - mouseover won't restart
      stop: function () {
        self.pause();
        stopped = true;
      }

    });

    // callbacks
    $.each("onBeforePlay,onPlay,onBeforePause,onPause".split(","), function (i, name) {

      // configuration
      if ($.isFunction(conf[name])) {
        $(self).bind(name, conf[name]);
      }

      // API methods
      self[name] = function (fn) {
        return $(self).bind(name, fn);
      };
    });


    /* when mouse enters, slideshow stops */
    if (conf.autopause) {
      tabs.getTabs().add(nextButton).add(prevButton).add(tabs.getPanes()).hover(self.pause, function () {
        if (!stopped) {
          self.play();
        }
      });
    }

    if (conf.autoplay) {
      self.play();
    }

    if (conf.clickable) {
      tabs.getPanes().click(function () {
        tabs.next();
      });
    }

    // manage disabling of next/prev buttons
    if (!tabs.getConf().rotate) {

      var disabled = conf.disabledClass;

      if (!tabs.getIndex()) {
        prevButton.addClass(disabled);
      }

      tabs.onBeforeClick(function (e, i) {
        prevButton.toggleClass(disabled, !i);
        nextButton.toggleClass(disabled, i == tabs.getTabs().length - 1);
      });
    }
  }

  // jQuery plugin implementation
  $.fn.slideshow = function (conf) {

    // return existing instance
    var el = this.data("slideshow");
    if (el) {
      return el;
    }

    conf = $.extend({}, tool.conf, conf);

    this.each(function () {
      el = new Slideshow($(this), conf);
      $(this).data("slideshow", el);
    });

    return conf.api ? el : this;
  };

})(jQuery);
	
	
/*
(function(c){function p(d,b,a){var e=this,l=d.add(this),h=d.find(a.tabs),i=b.jquery?b:d.children(b),j;h.length||(h=d.children());i.length||(i=d.parent().find(b));i.length||(i=c(b));c.extend(this,{click:function(f,g){var k=h.eq(f);if(typeof f=="string"&&f.replace("#","")){k=h.filter("[href*="+f.replace("#","")+"]");f=Math.max(h.index(k),0)}if(a.rotate){var n=h.length-1;if(f<0)return e.click(n,g);if(f>n)return e.click(0,g)}if(!k.length){if(j>=0)return e;f=a.initialIndex;k=h.eq(f)}if(f===j)return e;
g=g||c.Event();g.type="onBeforeClick";l.trigger(g,[f]);if(!g.isDefaultPrevented()){o[a.effect].call(e,f,function(){g.type="onClick";l.trigger(g,[f])});j=f;h.removeClass(a.current);k.addClass(a.current);return e}},getConf:function(){return a},getTabs:function(){return h},getPanes:function(){return i},getCurrentPane:function(){return i.eq(j)},getCurrentTab:function(){return h.eq(j)},getIndex:function(){return j},next:function(){return e.click(j+1)},prev:function(){return e.click(j-1)},destroy:function(){h.unbind(a.event).removeClass(a.current);
i.find("a[href^=#]").unbind("click.T");return e}});c.each("onBeforeClick,onClick".split(","),function(f,g){c.isFunction(a[g])&&c(e).bind(g,a[g]);e[g]=function(k){k&&c(e).bind(g,k);return e}});if(a.history&&c.fn.history){c.tools.history.init(h);a.event="history"}h.each(function(f){c(this).bind(a.event,function(g){e.click(f,g);return g.preventDefault()})});i.find("a[href^=#]").bind("click.T",function(f){e.click(c(this).attr("href"),f)});if(location.hash&&a.tabs=="a"&&d.find("[href="+location.hash+"]").length)e.click(location.hash);
else if(a.initialIndex===0||a.initialIndex>0)e.click(a.initialIndex)}c.tools=c.tools||{version:"1.2.5"};c.tools.tabs={conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",rotate:false,history:false},addEffect:function(d,b){o[d]=b}};var o={"default":function(d,b){this.getPanes().hide().eq(d).show();b.call()},fade:function(d,b){var a=this.getConf(),e=a.fadeOutSpeed,l=this.getPanes();e?l.fadeOut(e):l.hide();l.eq(d).fadeIn(a.fadeInSpeed,b)},slide:function(d,
b){this.getPanes().slideUp(200);this.getPanes().eq(d).slideDown(400,b)},ajax:function(d,b){this.getPanes().eq(0).load(this.getTabs().eq(d).attr("href"),b)}},m;c.tools.tabs.addEffect("horizontal",function(d,b){m||(m=this.getPanes().eq(0).width());this.getCurrentPane().animate({width:0},function(){c(this).hide()});this.getPanes().eq(d).animate({width:m},function(){c(this).show();b.call()})});c.fn.tabs=function(d,b){var a=this.data("tabs");if(a){a.destroy();this.removeData("tabs")}if(c.isFunction(b))b=
{onBeforeClick:b};b=c.extend({},c.tools.tabs.conf,b);this.each(function(){a=new p(c(this),d,b);c(this).data("tabs",a)});return b.api?a:this}})(jQuery);
(function(c){function p(g,a){function m(f){var e=c(f);return e.length<2?e:g.parent().find(f)}var b=this,i=g.add(this),d=g.data("tabs"),h,j=true,n=m(a.next).click(function(){d.next()}),k=m(a.prev).click(function(){d.prev()});c.extend(b,{getTabs:function(){return d},getConf:function(){return a},play:function(){if(h)return b;var f=c.Event("onBeforePlay");i.trigger(f);if(f.isDefaultPrevented())return b;h=setInterval(d.next,a.interval);j=false;i.trigger("onPlay");return b},pause:function(){if(!h)return b;
var f=c.Event("onBeforePause");i.trigger(f);if(f.isDefaultPrevented())return b;h=clearInterval(h);i.trigger("onPause");return b},stop:function(){b.pause();j=true}});c.each("onBeforePlay,onPlay,onBeforePause,onPause".split(","),function(f,e){c.isFunction(a[e])&&c(b).bind(e,a[e]);b[e]=function(q){return c(b).bind(e,q)}});a.autopause&&d.getTabs().add(n).add(k).add(d.getPanes()).hover(b.pause,function(){j||b.play()});a.autoplay&&b.play();a.clickable&&d.getPanes().click(function(){d.next()});if(!d.getConf().rotate){var l=
a.disabledClass;d.getIndex()||k.addClass(l);d.onBeforeClick(function(f,e){k.toggleClass(l,!e);n.toggleClass(l,e==d.getTabs().length-1)})}}var o;o=c.tools.tabs.slideshow={conf:{next:".forward",prev:".backward",disabledClass:"disabled",autoplay:false,autopause:true,interval:3E3,clickable:true,api:false}};c.fn.slideshow=function(g){var a=this.data("slideshow");if(a)return a;g=c.extend({},o.conf,g);this.each(function(){a=new p(c(this),g);c(this).data("slideshow",a)});return g.api?a:this}})(jQuery);
*/
