/* ================================================== 
  pvSuite.
  ================================================ */
/**
  * jQuery pvSlider v1.0
  *
  * Copyright 2011, Carl Walsh
  * Free to use and abuse under the MIT license.
  * http://www.opensource.org/licenses/mit-license.php
  */
(function($) {
  /**
    * pvSliderObject
    *
    * - This class is the backbone of pvSlider. All the 'real' work is
    * done here.
    */
  var pvSliderObject = (function() {
    //This is only required for prototyping.
    function pvSliderObject(){
      //Seeing as this is called every time a slider is made.
      //Lets use that.
      console.log('New pvSlider Instance Made!');
    }

    /**
      * Initialise(options, jThis);
      *
      * - This function is the core function. Lots of peleminary stuff
      * is done here before activating the slider.
      *
      * @options - The user defined options for this instance.
      * @jThis - The jquery 'this' value for this instace.
      */
    pvSliderObject.prototype.initialise = function(jThis, options) {
        var pThis;

        //Get this slider instance.
        this.slider = $(jThis);

        //Create @options - Over ride default options with any user defined options.
      this.options = options;

      //Get the slides - the sliders children.
        this.slides = this.slider.children();

        //Get the biggest height and width of the slides
        pThis = this;
        this.slides.each(function(){
          //Width
          var slideWidth = $(this).width();
          if(slideWidth > pThis.slideWidth || pThis.slideWidth === undefined){
            pThis.slideWidth = slideWidth;
          }

          //Height
          var slideHeight = $(this).height();
          if(slideHeight > pThis.slideHeight || pThis.slideHeight === undefined){
            pThis.slideHeight = slideHeight;
          }
        });

        //Get the number of slides. We add two to account for the clones we create.
        this.countSlides = this.slides.length + 2;
      
      //Clones
      var first_clone = this.slides.first().clone();
      var last_clone = this.slides.last().clone();
        //Create a clone of the first slide at the end of the slider.
        this.slider.append(first_clone);
        //Create a clone of the last slide at the begining of the slider.
        this.slider.prepend(last_clone);

        //re-index the children :)
        this.slides = this.slider.children();

        //Set up the pvItems div, this wraps all slides.
        this.items = $('<div class="pvItems"></div>').css({
            'width': this.slideWidth * this.countSlides,
            'position': 'absolute',
            'top': 0,
            'right': 'auto',
            'left': -this.slideWidth
        });
        this.slider.wrapInner(this.items);
        this.items = this.slider.children('.pvItems');

        //Wrap the newly made pvItems in another div called pvSlider.
        this.pvSlider = $('<div class="pvSlider"></div>').css({
            'overflow': 'hidden',
            'width': this.slideWidth,
            'position': 'relative',
        'height': this.slideHeight
        });
        this.items.wrap(this.pvSlider);
        this.pvSlider = this.slider.children('.pvSlider');

        //Apply, some basic styles to each slide.
        this.slides.css({
            'float': 'left',
            'width': this.slideWidth
        });

        //Add some last-child and first child classes to the cloned slides.
        this.slides.last().addClass('last-child');
        this.slides.first().addClass('first-child');

        //If this instance requires generated controls. Lets make em.
        if (this.options.controls) {
          //Create the pvControls div.
          this.controls = $('<div class="pvControls"></div>').css({
              'display': 'block',
              'text-align': this.options.controls_position
            });
            this.slider.append(this.controls);
            this.controls = this.slider.children('.pvControls');

            //For each slide, make a control button. But not for the clones. Duh.
            pThis = this;
            this.slides.not('.first-child, .last-child').each(function(i) {
              pThis.controls.append('<a class="pvControl" href="#" style="display: inline-block;" data-slide="' + (i + 1) + '"></a>');
            });

            //Get each button - The controls children.
            this.buttons = this.controls.children();
            //alert(this.buttons)

            //Set the first button to the current slide.
        this.buttons.first().addClass('current');

        //Bind a click event on all buttons, to change slides accordingly.
        pThis = this;
            this.buttons.bind('click', function() {
              if (!$(this).hasClass('current')) {
                //Slide to the correct slide.
                  pThis.slide(parseInt($(this).data('slide')));
                  return false;
              }
            });
        }

        //If this instance requires generated directional controls. Lets make em.
        if (this.options.directional) {
          //Create the pvDirectional div.
          this.directional = $('<div class="pvDirectional"></div>').css({
              'display': 'block',
              'text-align': this.options.directional_position
            });
            this.slider.append(this.directional);
            this.directional = this.slider.children('.pvDirectional');

            //Make two directions. Left and right.
            this.directional.append('<a class="pvDirection pvDirectionLeft pvDirectionEnd" href="#" style="display: inline-block;" data-slide="0"></a>');

            this.directional.append('<a class="pvDirection pvDirectionRight" href="#" style="display: inline-block;" data-slide="2"></a>');

            this.directions = this.directional.children('.pvDirection');

          //Bind a click event on all buttons, to change slides accordingly.
          pThis = this;
            this.directions.bind('click', function() {
              if (!$(this).hasClass('pvDirectionEnd')) {
                //Slide to the correct slide.
                  theSlide = parseInt($(this).attr('data-slide'));
                  pThis.slide(theSlide);
              }
              return false;
            });
        }

        //If this instance needs to stop on hover. Set it up.
        //Oh but, only if the auto option is also true. 
        //Otherwise we could trigger some un-intended autopilot.
        pThis = this;
        if (this.options.stop_on_hover && this.options.auto) {
            this.pvSlider.hover(function() {
              //False means no, so nothing will movie.
              pThis.options.auto = false;
              //Also kill the current queue if any.
              pThis.softStop();
              return true;
            }, function() {
              //if False means no, the true means yes.
              pThis.options.auto = true;
              //Jump start the system. STAT.
              pThis.start();
            });
        }


        //Whoa. That was a journey. All thats left to do, is start the slider.
        //Oh wait, that is ofcorse if the auto option is set to ture. Obviously.
        if(this.options.auto){
          this.start(); 
        }
      };

      /**
      * adjust()
      *
      * - The function does two things.
      * - 1. It checks if we have hit a cloned slide. If we have,
      * it will jump us to the correct location.
      * - 2. If auto is enabled, it will restart the loop.
      */
      pvSliderObject.prototype.adjust = function() {
        if (parseInt(this.items.css('left')) === -this.slideWidth * (this.countSlides - 1)) {
            this.items.css({
              'left': '-' + this.slideWidth + 'px'
            });
        }

        if (this.options.auto) {
            this.start();
        }
      };

      /**
      * slide()
      *
      * - Slides to a certain slide.
      *
      * @slide - the slide you would like to go to.
      */
      pvSliderObject.prototype.slide = function(slide) {
        var pThis = this;
        //Stop any exsisting loops.

        this.stop();

        this.items.animate({
            'left': (-this.slideWidth * slide) + 'px'
        }, this.options.speed, this.options.easing, function() {
            //Adjust the slider.
            pThis.adjust();
        });
      
        //Update the control system.
        //Only if controls are enabled, though.
        if (this.options.controls) {
          this.controlsUpdate(slide);
        }

        //Update the directional system.
        //Only if directions are enabled, though.
        if (this.options.directional) {
          this.directionUpdate(slide);
        }
      };

      /**
      * controlsUpdate()
      *
      * - Ensures that the controls are up to date.
      *
      * @slide - The current slide.
      */
      pvSliderObject.prototype.controlsUpdate = function(slide) {
        this.buttons.each(function(){
          if($(this).hasClass('current')){
            $(this).removeClass('current');
          }
        });
        
        if (slide > this.buttons.length) {
            slide = 1;
        }

        this.buttons.each(function(control) {
            if (control + 1 === slide) {
              $(this).addClass('current');
            }
        });
      };

      /**
      * directionUpdate()
      *
      * - Ensures that the directions are up to date.
      *
      * @slide - The current slide.
      */
      pvSliderObject.prototype.directionUpdate = function(slide) {
        pThis = this;
        this.directions.each(function(){
          if($(this).hasClass('pvDirectionLeft')){
            newData = slide - 1;
            if(newData == 0){
              $(this).addClass('pvDirectionEnd');
            } else {
              $(this).removeClass('pvDirectionEnd');
            }
          } else {
            newData = slide + 1;
            if((pThis.countSlides-2) == slide || (pThis.countSlides-1) == slide){
              $(this).addClass('pvDirectionEnd');
            } else {
              $(this).removeClass('pvDirectionEnd');
            }
          }

          $(this).attr("data-slide", newData);
        });
      };

      /**
      * start()
      *
      * - Stats the loop.
      * - We use two setTimeouts to fix a small bug that was occuring.
      */
      pvSliderObject.prototype.start = function() {
        var pThis = this;
        this.slideTimeout = setTimeout(function() {
            setTimeout(pThis.slide(((parseInt($( pThis.items).css('left')) * -1) / pThis.slideWidth) + 1), 10);
        }, this.options.delay - 10);
      };

    /**
      * stop() [HARD]
      *
      * - Stops the loop.
      * - Also stops the current animation, if any.
      */
      pvSliderObject.prototype.stop = function() {
        clearTimeout(this.slideTimeout);
        $(this.items).stop();
      };

      /**
      * softStop() [SOFT]
      *
      * - Stops the loop.
      * - Doesn't stop any animations.
      */
      pvSliderObject.prototype.softStop = function() {
        clearTimeout(this.slideTimeout);
      };
    
      return pvSliderObject;
  })();

  times = 0;
  $.fn.pvSlider = function(user_options){
  //Only execute the slider, if there is one or more slides.
  //Other wise this is a waste of time.
  if($(this).children('div, figure').length > 0){
    /**
      * default_options{}
      *
      * - The default options of pvSlider.
      *
      * @delay - The time (ms) between slide changes.
      * @speed - The speed of the slide animate.
      * @easing - The easing effect used on animations.
      * @controls - Should controls be enabled on the slider? (true/false).
      * @stop_on_hover - Should the slider stop when hovered? (true/false).
      * @auto - Is the slider allowed to just fly automatic? (true/false).
      * 
      */
      default_options = {
        delay: 2500,
        speed: 500,
        easing: 'linear',
        controls: true,
        controls_position: 'center',
        stop_on_hover: true,
        auto: true,
        directional: false,
        directional_position: 'center',
        direction: 'left'
      };

    $(this).each(function(){

      var options = $.extend(default_options, user_options);

      uid = times++;
      //$(this).addClass(String(uid));
      window['pv' + uid] = new pvSliderObject;
        window['pv' + uid].initialise(this, options);
    });
  }
}
})(jQuery);
window.log = function(){
  log.history = log.history || [];
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});

//(function(d){var s=function(l,o){var f=d.extend({},d.fn.nivoSlider.defaults,o),g={currentSlide:0,currentImage:"",totalSlides:0,randAnim:"",running:!1,paused:!1,stop:!1},e=d(l);e.data("nivo:vars",g);e.css("position","relative");e.addClass("nivoSlider");var j=e.children();j.each(function(){var c=d(this),h="";c.is("img")||(c.is("a")&&(c.addClass("nivo-imageLink"),h=c),c=c.find("img:first"));var b=c.width();b==0&&(b=c.attr("width"));var k=c.height();k==0&&(k=c.attr("height"));b>e.width()&&e.width(b); k>e.height()&&e.height(k);h!=""&&h.css("display","none");c.css("display","none");g.totalSlides++});if(f.startSlide>0){if(f.startSlide>=g.totalSlides)f.startSlide=g.totalSlides-1;g.currentSlide=f.startSlide}g.currentImage=d(j[g.currentSlide]).is("img")?d(j[g.currentSlide]):d(j[g.currentSlide]).find("img:first");d(j[g.currentSlide]).is("a")&&d(j[g.currentSlide]).css("display","block");e.css("background",'url("'+g.currentImage.attr("src")+'") no-repeat');e.append(d('<div class="nivo-caption"><p></p></div>').css({display:"none", opacity:f.captionOpacity}));var t=function(c){var h=d(".nivo-caption",e);if(g.currentImage.attr("title")!=""&&g.currentImage.attr("title")!=void 0){var b=g.currentImage.attr("title");b.substr(0,1)=="#"&&(b=d(b).html());h.css("display")=="block"?h.find("p").fadeOut(c.animSpeed,function(){d(this).html(b);d(this).fadeIn(c.animSpeed)}):h.find("p").html(b);h.fadeIn(c.animSpeed)}else h.fadeOut(c.animSpeed)};t(f);var i=0;!f.manualAdvance&&j.length>1&&(i=setInterval(function(){m(e,j,f,!1)},f.pauseTime)); f.directionNav&&(e.append('<div class="nivo-directionNav"><a class="nivo-prevNav">'+f.prevText+'</a><a class="nivo-nextNav">'+f.nextText+"</a></div>"),f.directionNavHide&&(d(".nivo-directionNav",e).hide(),e.hover(function(){d(".nivo-directionNav",e).show()},function(){d(".nivo-directionNav",e).hide()})),d("a.nivo-prevNav",e).live("click",function(){if(g.running)return!1;clearInterval(i);i="";g.currentSlide-=2;m(e,j,f,"prev")}),d("a.nivo-nextNav",e).live("click",function(){if(g.running)return!1;clearInterval(i); i="";m(e,j,f,"next")}));if(f.controlNav){var r=d('<div class="nivo-controlNav"></div>');e.append(r);for(var n=0;n<j.length;n++)if(f.controlNavThumbs){var p=j.eq(n);p.is("img")||(p=p.find("img:first"));f.controlNavThumbsFromRel?r.append('<a class="nivo-control" rel="'+n+'"><img src="'+p.attr("rel")+'" alt="" /></a>'):r.append('<a class="nivo-control" rel="'+n+'"><img src="'+p.attr("src").replace(f.controlNavThumbsSearch,f.controlNavThumbsReplace)+'" alt="" /></a>')}else r.append('<a class="nivo-control" rel="'+ n+'">'+(n+1)+"</a>");d(".nivo-controlNav a:eq("+g.currentSlide+")",e).addClass("active");d(".nivo-controlNav a",e).live("click",function(){if(g.running)return!1;if(d(this).hasClass("active"))return!1;clearInterval(i);i="";e.css("background",'url("'+g.currentImage.attr("src")+'") no-repeat');g.currentSlide=d(this).attr("rel")-1;m(e,j,f,"control")})}f.keyboardNav&&d(window).keypress(function(c){if(c.keyCode=="37"){if(g.running)return!1;clearInterval(i);i="";g.currentSlide-=2;m(e,j,f,"prev")}if(c.keyCode== "39"){if(g.running)return!1;clearInterval(i);i="";m(e,j,f,"next")}});f.pauseOnHover&&e.hover(function(){g.paused=!0;clearInterval(i);i=""},function(){g.paused=!1;i==""&&!f.manualAdvance&&(i=setInterval(function(){m(e,j,f,!1)},f.pauseTime))});e.bind("nivo:animFinished",function(){g.running=!1;d(j).each(function(){d(this).is("a")&&d(this).css("display","none")});d(j[g.currentSlide]).is("a")&&d(j[g.currentSlide]).css("display","block");i==""&&!g.paused&&!f.manualAdvance&&(i=setInterval(function(){m(e, j,f,!1)},f.pauseTime));f.afterChange.call(this)});var q=function(c,h,b){for(var k=0;k<h.slices;k++){var a=Math.round(c.width()/h.slices);k==h.slices-1?c.append(d('<div class="nivo-slice"></div>').css({left:a*k+"px",width:c.width()-a*k+"px",height:"0px",opacity:"0",background:'url("'+b.currentImage.attr("src")+'") no-repeat -'+(a+k*a-a)+"px 0%"})):c.append(d('<div class="nivo-slice"></div>').css({left:a*k+"px",width:a+"px",height:"0px",opacity:"0",background:'url("'+b.currentImage.attr("src")+'") no-repeat -'+ (a+k*a-a)+"px 0%"}))}},u=function(c,h,b){for(var k=Math.round(c.width()/h.boxCols),a=Math.round(c.height()/h.boxRows),f=0;f<h.boxRows;f++)for(var e=0;e<h.boxCols;e++)e==h.boxCols-1?c.append(d('<div class="nivo-box"></div>').css({opacity:0,left:k*e+"px",top:a*f+"px",width:c.width()-k*e+"px",height:a+"px",background:'url("'+b.currentImage.attr("src")+'") no-repeat -'+(k+e*k-k)+"px -"+(a+f*a-a)+"px"})):c.append(d('<div class="nivo-box"></div>').css({opacity:0,left:k*e+"px",top:a*f+"px",width:k+"px", height:a+"px",background:'url("'+b.currentImage.attr("src")+'") no-repeat -'+(k+e*k-k)+"px -"+(a+f*a-a)+"px"}))},m=function(c,h,b,f){var a=c.data("nivo:vars");a&&a.currentSlide==a.totalSlides-1&&b.lastSlide.call(this);if((!a||a.stop)&&!f)return!1;b.beforeChange.call(this);f?(f=="prev"&&c.css("background",'url("'+a.currentImage.attr("src")+'") no-repeat'),f=="next"&&c.css("background",'url("'+a.currentImage.attr("src")+'") no-repeat')):c.css("background",'url("'+a.currentImage.attr("src")+'") no-repeat'); a.currentSlide++;if(a.currentSlide==a.totalSlides)a.currentSlide=0,b.slideshowEnd.call(this);if(a.currentSlide<0)a.currentSlide=a.totalSlides-1;a.currentImage=d(h[a.currentSlide]).is("img")?d(h[a.currentSlide]):d(h[a.currentSlide]).find("img:first");b.controlNav&&(d(".nivo-controlNav a",c).removeClass("active"),d(".nivo-controlNav a:eq("+a.currentSlide+")",c).addClass("active"));t(b);d(".nivo-slice",c).remove();d(".nivo-box",c).remove();if(b.effect=="random"&&(h=["sliceDownRight","sliceDownLeft", "sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],a.randAnim=h[Math.floor(Math.random()*(h.length+1))],a.randAnim==void 0))a.randAnim="fade";if(b.effect.indexOf(",")!=-1&&(h=b.effect.split(","),a.randAnim=h[Math.floor(Math.random()*h.length)],a.randAnim==void 0))a.randAnim="fade";a.running=!0;if(b.effect=="sliceDown"||b.effect=="sliceDownRight"||a.randAnim=="sliceDownRight"||b.effect=="sliceDownLeft"|| a.randAnim=="sliceDownLeft"){q(c,b,a);var e=0,g=0,h=d(".nivo-slice",c);if(b.effect=="sliceDownLeft"||a.randAnim=="sliceDownLeft")h=d(".nivo-slice",c)._reverse();h.each(function(){var a=d(this);a.css({top:"0px"});g==b.slices-1?setTimeout(function(){a.animate({height:"100%",opacity:"1.0"},b.animSpeed,"",function(){c.trigger("nivo:animFinished")})},100+e):setTimeout(function(){a.animate({height:"100%",opacity:"1.0"},b.animSpeed)},100+e);e+=50;g++})}else if(b.effect=="sliceUp"||b.effect=="sliceUpRight"|| a.randAnim=="sliceUpRight"||b.effect=="sliceUpLeft"||a.randAnim=="sliceUpLeft"){q(c,b,a);g=e=0;h=d(".nivo-slice",c);if(b.effect=="sliceUpLeft"||a.randAnim=="sliceUpLeft")h=d(".nivo-slice",c)._reverse();h.each(function(){var a=d(this);a.css({bottom:"0px"});g==b.slices-1?setTimeout(function(){a.animate({height:"100%",opacity:"1.0"},b.animSpeed,"",function(){c.trigger("nivo:animFinished")})},100+e):setTimeout(function(){a.animate({height:"100%",opacity:"1.0"},b.animSpeed)},100+e);e+=50;g++})}else if(b.effect== "sliceUpDown"||b.effect=="sliceUpDownRight"||a.randAnim=="sliceUpDown"||b.effect=="sliceUpDownLeft"||a.randAnim=="sliceUpDownLeft"){q(c,b,a);var j=g=e=0,h=d(".nivo-slice",c);if(b.effect=="sliceUpDownLeft"||a.randAnim=="sliceUpDownLeft")h=d(".nivo-slice",c)._reverse();h.each(function(){var a=d(this);g==0?(a.css("top","0px"),g++):(a.css("bottom","0px"),g=0);j==b.slices-1?setTimeout(function(){a.animate({height:"100%",opacity:"1.0"},b.animSpeed,"",function(){c.trigger("nivo:animFinished")})},100+e): setTimeout(function(){a.animate({height:"100%",opacity:"1.0"},b.animSpeed)},100+e);e+=50;j++})}else if(b.effect=="fold"||a.randAnim=="fold")q(c,b,a),g=e=0,d(".nivo-slice",c).each(function(){var a=d(this),f=a.width();a.css({top:"0px",height:"100%",width:"0px"});g==b.slices-1?setTimeout(function(){a.animate({width:f,opacity:"1.0"},b.animSpeed,"",function(){c.trigger("nivo:animFinished")})},100+e):setTimeout(function(){a.animate({width:f,opacity:"1.0"},b.animSpeed)},100+e);e+=50;g++});else if(b.effect== "fade"||a.randAnim=="fade"){q(c,b,a);var i=d(".nivo-slice:first",c);i.css({height:"100%",width:c.width()+"px"});i.animate({opacity:"1.0"},b.animSpeed*2,"",function(){c.trigger("nivo:animFinished")})}else if(b.effect=="slideInRight"||a.randAnim=="slideInRight")q(c,b,a),i=d(".nivo-slice:first",c),i.css({height:"100%",width:"0px",opacity:"1"}),i.animate({width:c.width()+"px"},b.animSpeed*2,"",function(){c.trigger("nivo:animFinished")});else if(b.effect=="slideInLeft"||a.randAnim=="slideInLeft")q(c,b, a),i=d(".nivo-slice:first",c),i.css({height:"100%",width:"0px",opacity:"1",left:"",right:"0px"}),i.animate({width:c.width()+"px"},b.animSpeed*2,"",function(){i.css({left:"0px",right:""});c.trigger("nivo:animFinished")});else if(b.effect=="boxRandom"||a.randAnim=="boxRandom"){u(c,b,a);var m=b.boxCols*b.boxRows,e=g=0,h=s(d(".nivo-box",c));h.each(function(){var a=d(this);g==m-1?setTimeout(function(){a.animate({opacity:"1"},b.animSpeed,"",function(){c.trigger("nivo:animFinished")})},100+e):setTimeout(function(){a.animate({opacity:"1"}, b.animSpeed)},100+e);e+=20;g++})}else if(b.effect=="boxRain"||a.randAnim=="boxRain"||b.effect=="boxRainReverse"||a.randAnim=="boxRainReverse"||b.effect=="boxRainGrow"||a.randAnim=="boxRainGrow"||b.effect=="boxRainGrowReverse"||a.randAnim=="boxRainGrowReverse"){u(c,b,a);var m=b.boxCols*b.boxRows,l=e=g=0,n=0,o=[];o[l]=[];h=d(".nivo-box",c);if(b.effect=="boxRainReverse"||a.randAnim=="boxRainReverse"||b.effect=="boxRainGrowReverse"||a.randAnim=="boxRainGrowReverse")h=d(".nivo-box",c)._reverse();h.each(function(){o[l][n]= d(this);n++;n==b.boxCols&&(l++,n=0,o[l]=[])});for(h=0;h<b.boxCols*2;h++){for(var f=h,p=0;p<b.boxRows;p++)f>=0&&f<b.boxCols&&(function(e,f,h,g,k){var i=d(o[e][f]),j=i.width(),l=i.height();(b.effect=="boxRainGrow"||a.randAnim=="boxRainGrow"||b.effect=="boxRainGrowReverse"||a.randAnim=="boxRainGrowReverse")&&i.width(0).height(0);g==k-1?setTimeout(function(){i.animate({opacity:"1",width:j,height:l},b.animSpeed/1.3,"",function(){c.trigger("nivo:animFinished")})},100+h):setTimeout(function(){i.animate({opacity:"1", width:j,height:l},b.animSpeed/1.3)},100+h)}(p,f,e,g,m),g++),f--;e+=100}}},s=function(c){for(var d,b,e=c.length;e;d=parseInt(Math.random()*e),b=c[--e],c[e]=c[d],c[d]=b);return c},v=function(c){this.console&&typeof console.log!="undefined"&&console.log(c)};this.stop=function(){if(!d(l).data("nivo:vars").stop)d(l).data("nivo:vars").stop=!0,v("Stop Slider")};this.start=function(){if(d(l).data("nivo:vars").stop)d(l).data("nivo:vars").stop=!1,v("Start Slider")};f.afterLoad.call(this);return this};d.fn.nivoSlider= function(l){return this.each(function(){var o=d(this);if(o.data("nivoslider"))return o.data("nivoslider");var f=new s(this,l);o.data("nivoslider",f)})};d.fn.nivoSlider.defaults={effect:"random",slices:15,boxCols:8,boxRows:4,animSpeed:500,pauseTime:3E3,startSlide:0,directionNav:!0,directionNavHide:!0,controlNav:!0,controlNavThumbs:!1,controlNavThumbsFromRel:!1,controlNavThumbsSearch:".jpg",controlNavThumbsReplace:"_thumb.jpg",keyboardNav:!0,pauseOnHover:!0,manualAdvance:!1,captionOpacity:0.8,prevText:"Prev", nextText:"Next",beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){},lastSlide:function(){},afterLoad:function(){}};d.fn._reverse=[].reverse})(jQuery);

(function($){$.fn.mobilyslider=function(options){var defaults={content:".sliderContent",children:"div",transition:"horizontal",animationSpeed:300,autoplay:false,autoplaySpeed:3000,pauseOnHover:false,bullets:true,arrows:true,arrowsHide:true,prev:"prev",next:"next",animationStart:function(){},animationComplete:function(){}};var sets=$.extend({},defaults,options);return this.each(function(){var $t=$(this),item=$t.children(sets.content).children(sets.children),l=item.length-1,w=item.width(),h=item.height(),step=0,play,bullets,arrows,z,active,bullet;var slider={init:function(){slider.data();if(sets.bullets){slider.bullets.create()}if(sets.arrows){slider.arrows.create()}if(sets.autoplay){slider.autoplay()}slider.triggers()},data:function(){item.each(function(i){$(this).css("z-index",-(i-l))});if(sets.transition=="fade"){item.hide().eq(0).show()}},zindex:{prev:function(){step==l?item.eq(0).css("z-index",l+3):item.css("z-index",l+1);item.eq(step).css("z-index",l+4).next(item).css("z-index",l+2)},next:function(){item.css("z-index",l+1).eq(step).css("z-index",l+3).prev(item).css("z-index",l+2)},bullets:function(){item.css("z-index",l+1).eq(active).css("z-index",l+2);item.eq(step).css("z-index",l+3)},trigger:function(){if(z==1){slider.zindex.next()}else{if(z==-1){slider.zindex.prev()}else{if(z==0){slider.zindex.bullets()}}}}},slide:{left:function(sign){sets.animationStart.call(this);item.eq(step).animate({left:sign+"="+w},sets.animationSpeed,function(){slider.zindex.trigger()}).animate({left:0},sets.animationSpeed+200,function(){sets.animationComplete.call(this)})},top:function(sign){sets.animationStart.call(this);item.eq(step).animate({top:sign+"="+h},sets.animationSpeed,function(){slider.zindex.trigger()}).animate({top:0},sets.animationSpeed+200,function(){sets.animationComplete.call(this)})},fade:function(){sets.animationStart.call(this);item.fadeOut(sets.animationSpeed).eq(step).fadeIn(sets.animationSpeed,function(){sets.animationComplete.call(this)})}},animation:{previous:function(){step==0?step=l:step--;z=-1;switch(sets.transition){case"horizontal":slider.slide.left("-");break;case"vertical":slider.slide.top("+");break;case"fade":slider.slide.fade();break}},next:function(){step==l?step=0:step++;z=1;switch(sets.transition){case"horizontal":slider.slide.left("+");break;case"vertical":slider.slide.top("-");break;case"fade":slider.slide.fade();break}}},autoplay:function(){play=setInterval(function(){slider.animation.next();if(sets.bullets){setTimeout(function(){slider.bullets.update()},sets.animationSpeed+300)}},sets.autoplaySpeed)},pause:function(){clearInterval(play)},bullets:{create:function(){$t.append($("<div />").addClass("sliderBullets"));bullets=$t.find(".sliderBullets");for(i=0;i<=l;i++){bullets.append($("<a />").attr({href:"#",rel:i}).text(i))}},trigger:function(){bullet=bullets.find("a");bullet.eq(0).addClass("active");bullet.click(function(){var b=$(this),rel=b.attr("rel");active=bullet.filter(".active").attr("rel");step=rel;sign=rel>active?"+":"-";z=0;if(!b.hasClass("active")){switch(sets.transition){case"horizontal":slider.slide.left(sign);break;case"vertical":slider.slide.top(sign);break;case"fade":slider.slide.fade();break}}bullet.removeClass("active");b.addClass("active");return false})},update:function(){bullet.removeClass("active").eq(step).addClass("active")}},arrows:{create:function(){$t.append($("<div />").addClass("sliderArrows"));arrows=$t.find(".sliderArrows");arrows.append($("<a />").attr("href","#").addClass(sets.prev).text("Previous"));arrows.append($("<a />").attr("href","#").addClass(sets.next).text("Next"))},trigger:function(){arrows.find("."+sets.prev).click(function(){slider.animation.previous();if(sets.bullets){slider.bullets.update()}return false});arrows.find("."+sets.next).click(function(){slider.animation.next();if(sets.bullets){slider.bullets.update()}return false});if(sets.arrowsHide){arrows.hide();$t.hover(function(){arrows.show()},function(){arrows.hide()})}}},triggers:function(){if(sets.arrows){slider.arrows.trigger()}if(sets.bullets){slider.bullets.trigger()}if(sets.pauseOnHover){$t.hover(function(){slider.pause()},function(){slider.autoplay()})}}};slider.init()})}}(jQuery));
/*
	
	jQuery selectBox (version 1.0.6)
	
		A cosmetic, styleable replacement for SELECT elements.
	
		Homepage:   http://abeautifulsite.net/blog/2011/01/jquery-selectbox-plugin/
		Demo page:  http://labs.abeautifulsite.net/projects/js/jquery/selectBox/
		
		Copyright 2011 Cory LaViska for A Beautiful Site, LLC.
		
	Features:

		- Supports OPTGROUPS
		- Supports standard dropdown controls
		- Supports multi-select controls (i.e. multiple="multiple")
		- Supports inline controls (i.e. size="5")
		- Fully accessible via keyboard
		- Shift + click (or shift + enter) to select a range of options in multi-select controls
		- Type to search when the control has focus
		- Auto-height based on the size attribute (to use, omit the height property in your CSS!)
		- Tested in IE7-IE9, Firefox 3-4, recent webkit browsers, and Opera
	
	
	License:
		
		Licensed under both the MIT license and the GNU GPLv2 (same as jQuery: http://jquery.org/license)
	
	
	Usage:
		
		Link to the JS file:
			
			<script src="jquery.selectbox.min.js" type="text/javascript"></script>
		
		Add the CSS file (or append contents to your own stylesheet):
		
			<link href="jquery.selectbox.min.css" rel="stylesheet" type="text/css" />
		
		To create:
			
			$("SELECT").selectBox([settings]);
	
	
	Settings:
		
		To specify settings, use this syntax: $("SELECT").selectBox('settings', { settingName: value, ... });
			
			menuTransition: ['default', 'slide', 'fade'] - the show/hide transition for dropdown menus
			menuSpeed: [integer, 'slow', 'normal', 'fast'] - the show/hide transition speed
	
	
	Methods:
		
		To call a method use this syntax: $("SELECT").selectBox('methodName', [options]);
		
			create - Creates the control (default method)
			destroy - Destroys the selectBox control and reverts back to the original form control
			disable - Disables the control (i.e. disabled="disabled")
			enable - Enables the control
			value - if passed with a value, sets the control to that value; otherwise returns the current value
			options - pass in either a string of HTML or a JSON object to replace the existing options
			control - returns the selectBox control element (an anchor tag) for working with directly
	
	
	Events:
		
		Events are fired on the original select element. You can bind events like this:
			
			$("SELECT").selectBox().change( function() { alert( $(this).val() ); } );
			
			focus - Fired when the control gains focus
			blur - Fired when the control loses focus
			change - Fired when the value of a control changes
	
	
	Change Log:
		
		v1.0.0 (2011-04-03) - Complete rewrite with added support for inline and multi-select controls
		v1.0.1 (2011-04-04) - Fixed options method so it doesn't destroy/recreate the control when called.
		                    - Added a check for iOS devices (their native controls are much better for 
		                      touch-based devices; you can still use selectBox API methods for theme)
		                    - Fixed issue where IE window would lose focus on XP
		                    - Fixed premature selection issue in Webkit browsers
		v1.0.2 (2011-04-13) - Fixed auto-height for inline controls when control is invisible on load
		                    - Removed auto-width for dropdown and inline controls; now relies 100% on CSS
		                      for setting the width
		                   	- Added 'control' method for working directly with the selectBox control
		v1.0.3 (2011-04-22) - Fixed bug in value method that errored if the control didn't exist
		v1.0.4 (2011-04-22) - Fixed bug where controls without any options would render with incorrect heights
		v1.0.5 (2011-04-22) - Removed 'tick' image in lieu of background colors to indicate selection
		                    - Clicking no longer toggles selected/unselected in multi-selects; use CTRL/CMD and 
		                      SHIFT like in normal browser controls
		                    - Fixed bug where inline controls would not receive focus unless tabbed into
		v1.0.6 (2011-04-29) - Fixed bug where inline controls could be "dragged" when selecting an empty area
		
		                      
	Known Issues:
	
		- The blur and focus callbacks are not very reliable in IE7. The change callback works fine.
	
*/
if(jQuery) (function($) {
	
	$.extend($.fn, {
		
		selectBox: function(method, data) {
			
			var typeTimer, typeSearch = '';
			
			
			//
			// Private methods
			//
			
			
			var init = function(select, data) {
				
				// Disable for iOS devices (their native controls are more suitable for a touch device)
				if( navigator.userAgent.match(/iPad|iPhone/i) ) return false;
				
				// Element must be a select control
				if( select.tagName.toLowerCase() !== 'select' ) return false;
				
				select = $(select);
				if( select.data('selectBox-control') ) return false;
				
				var control = $('<a class="selectBox" />'),
					inline = select.attr('multiple') || parseInt(select.attr('size')) > 1;
				
				var settings = data || {};
				
				// Inherit class names, style, and title attributes
				control
					.addClass(select.attr('class'))
					.attr('style', select.attr('style') || '')
					.attr('title', select.attr('title') || '')
					.attr('tabindex', parseInt(select.attr('tabindex')))
					.css('display', 'inline-block')
					.bind('focus.selectBox', function() {
						if( this !== document.activeElement ) $(document.activeElement).blur();
						if( control.hasClass('selectBox-active') ) return;
						control.addClass('selectBox-active');
						select.trigger('focus');
					})
					.bind('blur.selectBox', function() {
						if( !control.hasClass('selectBox-active') ) return;
						control.removeClass('selectBox-active');
						select.trigger('blur');
					});
				
				if( select.attr('disabled') ) control.addClass('selectBox-disabled');
				
				// Generate control
				if( inline ) {
					
					//
					// Inline controls
					//
					var options = getOptions(select, 'inline');
					
					control
						.append(options)
						.data('selectBox-options', options)
						.addClass('selectBox-inline')
						.addClass('selectBox-menuShowing')
						.bind('keydown.selectBox', function(event) {
							handleKeyDown(select, event);
						})
						.bind('keypress.selectBox', function(event) {
							handleKeyPress(select, event);
						})
						.bind('mousedown.selectBox', function(event) {
							if( $(event.target).is('A.selectBox-inline') ) event.preventDefault();
							if( !control.hasClass('selectBox-focus') ) control.focus();
						})
						.insertAfter(select);
					
					// Auto-height based on size attribute
					if( !select[0].style.height ) {
						
						var size = select.attr('size') ? parseInt(select.attr('size')) : 5;
						
						// Draw a dummy control off-screen, measure, and remove it
						var tmp = control
							.clone()
							.removeAttr('id')
							.css({
								position: 'absolute',
								top: '-9999em'
							})
							.show()
							.appendTo('body');
						tmp.find('.selectBox-options').html('<li><a>\u00A0</a></li>');
						optionHeight = parseInt(tmp.find('.selectBox-options A:first').html('&nbsp;').outerHeight());
						tmp.remove();
						
						control.height(optionHeight * size);
						
					}
					
					disableSelection(control);
					
				} else {
					
					//
					// Dropdown controls
					//
					
					var label = $('<span class="selectBox-label" />'),
						arrow = $('<span class="selectBox-arrow" />');
					
					label.text( $(select).find('OPTION:selected').text() || '\u00A0' );
					
					var options = getOptions(select, 'dropdown');
					options.appendTo('BODY');
					
					control
						.data('selectBox-options', options)
						.addClass('selectBox-dropdown')
						.append(label)
						.append(arrow)
						.bind('mousedown.selectBox', function(event) {
							if( control.hasClass('selectBox-menuShowing') ) {
								hideMenus();
							} else {
								event.stopPropagation();
								// Webkit fix to prevent premature selection of options
								options.data('selectBox-down-at-x', event.screenX).data('selectBox-down-at-y', event.screenY);
								showMenu(select);
							}
						})
						.bind('keydown.selectBox', function(event) {
							handleKeyDown(select, event);
						})
						.bind('keypress.selectBox', function(event) {
							handleKeyPress(select, event);
						})
						.insertAfter(select);
					
					disableSelection(control);
						
				}
				
				// Store data for later use and show the control
				select
					.addClass('selectBox')
					.data('selectBox-control', control)
					.data('selectBox-settings', settings)
					.hide();
				
			};
			
			
			var getOptions = function(select, type) {
				
				var options;
				
				switch( type ) {
					
					case 'inline':
						

						options = $('<ul class="selectBox-options" />');
						
						if( select.find('OPTGROUP').length ) {
							
							select.find('OPTGROUP').each( function() {
								
								var optgroup = $('<li class="selectBox-optgroup" />');
								optgroup.text($(this).attr('label'));
								options.append(optgroup);
								
								$(this).find('OPTION').each( function() {
									var li = $('<li />'),
										a = $('<a />');
									li.addClass( $(this).attr('class') );
									a.attr('rel', $(this).val()).text( $(this).text() );
									li.append(a);
									if( $(this).attr('disabled') ) li.addClass('selectBox-disabled');
									if( $(this).attr('selected') ) li.addClass('selectBox-selected');
									options.append(li);
								});
								
							});
						
						} else {
						
							select.find('OPTION').each( function() {
								var li = $('<li />'),
									a = $('<a />');
								li.addClass( $(this).attr('class') );
								a.attr('rel', $(this).val()).text( $(this).text() );
								li.append(a);
								if( $(this).attr('disabled') ) li.addClass('selectBox-disabled');
								if( $(this).attr('selected') ) li.addClass('selectBox-selected');
								options.append(li);
							});
							
						}
						
						options
							.find('A')
								.bind('mouseover.selectBox', function(event) {
									addHover(select, $(this).parent());
								})
								.bind('mouseout.selectBox', function(event) {
									removeHover(select, $(this).parent());
								})
								.bind('mousedown.selectBox', function(event) {
									event.preventDefault(); // Prevent options from being "dragged"
									if( !select.selectBox('control').hasClass('selectBox-active') ) select.selectBox('control').focus();
								})
								.bind('mouseup.selectBox', function(event) {
									hideMenus();
									selectOption(select, $(this).parent(), event);
								});
						
						disableSelection(options);
						
						return options;
					
					case 'dropdown':
						
						options = $('<ul class="selectBox-dropdown-menu selectBox-options" />');
						
						if( select.find('OPTGROUP').length ) {
							
							select.find('OPTGROUP').each( function() {
								
								var optgroup = $('<li class="selectBox-optgroup" />');
								optgroup.text($(this).attr('label'));
								options.append(optgroup);
								
								$(this).find('OPTION').each( function() {
									var li = $('<li />'),
										a = $('<a />');
									li.addClass( $(this).attr('class') );
									a.attr('rel', $(this).val()).text( $(this).text() );
									li.append(a);
									if( $(this).attr('disabled') ) li.addClass('selectBox-disabled');
									if( $(this).attr('selected') ) li.addClass('selectBox-selected');
									options.append(li);
								});
								
							});
							
						} else {
							
							if( select.find('OPTION').length > 0 ) {
								select.find('OPTION').each( function() {
									var li = $('<li />'),
										a = $('<a />');
									li.addClass( $(this).attr('class') );
									a.attr('rel', $(this).val()).text( $(this).text() );
									li.append(a);
									if( $(this).attr('disabled') ) li.addClass('selectBox-disabled');
									if( $(this).attr('selected') ) li.addClass('selectBox-selected');
									options.append(li);
								});
							} else {
								options.append('<li>\u00A0</li>');
							}
							
						}
						
						options
							.data('selectBox-select', select)
							.css('display', 'none')
							.appendTo('BODY')
							.find('A')
								.bind('mousedown.selectBox', function(event) {
									event.preventDefault(); // Prevent options from being "dragged"
									if( event.screenX === options.data('selectBox-down-at-x') && event.screenY === options.data('selectBox-down-at-y') ) {
										options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');
										hideMenus();
									}
								})
								.bind('mouseup.selectBox', function(event) {
									if( event.screenX === options.data('selectBox-down-at-x') && event.screenY === options.data('selectBox-down-at-y') ) {
										return;
									} else {
										options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');
									}
									selectOption(select, $(this).parent());
									hideMenus();
								}).bind('mouseover.selectBox', function(event) {
									addHover(select, $(this).parent());
								})
								.bind('mouseout.selectBox', function(event) {
									removeHover(select, $(this).parent());
								});
						
						disableSelection(options);
						
						return options;
					
				}
				
			};
			
			
			var destroy = function(select) {
				
				select = $(select);
				
				var control = select.data('selectBox-control');
				if( !control ) return;
				var options = control.data('selectBox-options');
				
				options.remove();
				control.remove();
				select
					.removeClass('selectBox')
					.removeData('selectBox-control')
					.removeData('selectBox-settings')
					.show();
				
			};
			
			
			var showMenu = function(select) {
				
				select = $(select);
				var control = select.data('selectBox-control'),
					settings = select.data('selectBox-settings'),
					options = control.data('selectBox-options');
				if( control.hasClass('selectBox-disabled') ) return false;
				
				hideMenus();
				
				// Show menu
				options.css({
					width: control.outerWidth() - (parseInt(control.css('borderLeftWidth')) + parseInt(control.css('borderLeftWidth'))),
					top: control.offset().top + control.outerHeight() - (parseInt(control.css('borderBottomWidth'))),
					left: control.offset().left
				});
				
				switch( settings.menuTransition ) {
					
					case 'fade':
						options.fadeIn(settings.menuSpeed);
						break;
					
					case 'slide':
						options.slideDown(settings.menuSpeed);
						break;
					
					default:
						options.show(settings.menuSpeed);
						break;
					
				}
				
				// Center on selected option
				var li = options.find('.selectBox-selected:first');
				keepOptionInView(select, li, true);
				addHover(select, li);
				
				control.addClass('selectBox-menuShowing');
				
				$(document).bind('mousedown.selectBox', function(event) {
					if( $(event.target).parents().andSelf().hasClass('selectBox-options') ) return;
					hideMenus();
				});
				
			};
			
			
			var hideMenus = function() {
				
				if( $(".selectBox-dropdown-menu").length === 0 ) return;
				$(document).unbind('mousedown.selectBox');
				
				$(".selectBox-dropdown-menu").each( function() {
					
					var options = $(this),
						select = options.data('selectBox-select'),
						control = select.data('selectBox-control'),
						settings = select.data('selectBox-settings');
					
					switch( settings.menuTransition ) {
						
						case 'fade':
							options.fadeOut(settings.menuSpeed);
							break;
						
						case 'slide':
							options.slideUp(settings.menuSpeed);
							break;
							
						default:
							options.hide(settings.menuSpeed);
							break;
						
					}
					
					control.removeClass('selectBox-menuShowing');
					
				});
				
			};
			
			
			var selectOption = function(select, li, event) {
				
				select = $(select);
				li = $(li);
				var control = select.data('selectBox-control'),
					settings = select.data('selectBox-settings');
				
				if( control.hasClass('selectBox-disabled') ) return false;
				if( li.length === 0 || li.hasClass('selectBox-disabled') ) return false;
				
				if( select.attr('multiple') ) {
					
					// If event.shiftKey is true, this will select all options between li and the last li selected
					if( event.shiftKey && control.data('selectBox-last-selected') ) {
						
						li.toggleClass('selectBox-selected');
						
						var affectedOptions;
						if( li.index() > control.data('selectBox-last-selected').index() ) {
							affectedOptions = li.siblings().slice(control.data('selectBox-last-selected').index(), li.index());
						} else {
							affectedOptions = li.siblings().slice(li.index(), control.data('selectBox-last-selected').index());
						}
						
						affectedOptions = affectedOptions.not('.selectBox-optgroup, .selectBox-disabled');
						
						if( li.hasClass('selectBox-selected') ) {
							affectedOptions.addClass('selectBox-selected');
						} else {
							affectedOptions.removeClass('selectBox-selected');
						}
						
					} else if( event.metaKey ) {
						li.toggleClass('selectBox-selected');
					} else {
						li.siblings().removeClass('selectBox-selected');
						li.addClass('selectBox-selected');
					}
					
				} else {
					li.siblings().removeClass('selectBox-selected');
					li.addClass('selectBox-selected');
				}
				
				if( control.hasClass('selectBox-dropdown') ) {
					control.find('.selectBox-label').text(li.text());
				}
				
				// Update original control's value
				var i = 0, selection = [];
				if( select.attr('multiple') ) {
					control.find('.selectBox-selected A').each( function() {
						selection[i++] = $(this).attr('rel');
					});
				} else {
					selection = li.find('A').attr('rel');
				}
				
				// Remember most recently selected item
				control.data('selectBox-last-selected', li);
				
				// Change callback
				if( select.val() !== selection ) {
					select.val(selection);
					select.trigger('change');
				}
				
				return true;
				
			};
			
			
			var addHover = function(select, li) {
				select = $(select);
				li = $(li);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options');
				
				options.find('.selectBox-hover').removeClass('selectBox-hover');
				li.addClass('selectBox-hover');
			};
			
			
			var removeHover = function(select, li) {
				select = $(select);
				li = $(li);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options');
				options.find('.selectBox-hover').removeClass('selectBox-hover');
			};
			
			
			var keepOptionInView = function(select, li, center) {
				
				if( !li || li.length === 0 ) return;
				
				select = $(select);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options'),
					scrollBox = control.hasClass('selectBox-dropdown') ? options : options.parent(),
					top = parseInt(li.offset().top - scrollBox.position().top),
					bottom = parseInt(top + li.outerHeight());
				
				if( center ) {
					scrollBox.scrollTop( li.offset().top - scrollBox.offset().top + scrollBox.scrollTop() - (scrollBox.height() / 2) );
				} else {
					if( top < 0 ) {
						scrollBox.scrollTop( li.offset().top - scrollBox.offset().top + scrollBox.scrollTop() );
					}
					if( bottom > scrollBox.height() ) {
						scrollBox.scrollTop( (li.offset().top + li.outerHeight()) - scrollBox.offset().top + scrollBox.scrollTop() - scrollBox.height() );
					}
				}
				
			};
			
			
			var handleKeyDown = function(select, event) {
				
				//
				// Handles open/close and arrow key functionality
				//
				
				select = $(select);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options'),
					totalOptions = 0,
					i = 0;
				
				if( control.hasClass('selectBox-disabled') ) return;
				
				switch( event.keyCode ) {
					
					case 8: // backspace
						event.preventDefault();
						typeSearch = '';
						break;
					
					case 9: // tab
					case 27: // esc
						hideMenus();
						removeHover(select);
						break;
					
					case 13: // enter
						if( control.hasClass('selectBox-menuShowing') ) {
							selectOption(select, options.find('LI.selectBox-hover:first'), event);
							if( control.hasClass('selectBox-dropdown') ) hideMenus();
						} else {
							showMenu(select);
						}
						break;
						
					case 38: // up
					case 37: // left
						
						event.preventDefault();
						
						if( control.hasClass('selectBox-menuShowing') ) {
							
							var prev = options.find('.selectBox-hover').prev('LI');
							totalOptions = options.find('LI:not(.selectBox-optgroup)').length;
							i = 0;
							
							while( prev.length === 0 || prev.hasClass('selectBox-disabled') || prev.hasClass('selectBox-optgroup') ) {
								prev = prev.prev('LI');
								if( prev.length === 0 ) prev = options.find('LI:last');
								if( ++i >= totalOptions ) break;
							}
							
							addHover(select, prev);
							keepOptionInView(select, prev);
							
						} else {
							showMenu(select);
						}
						
						break;
						
					case 40: // down
					case 39: // right
					
						event.preventDefault();
						
						if( control.hasClass('selectBox-menuShowing') ) {
							
							var next = options.find('.selectBox-hover').next('LI');
							totalOptions = options.find('LI:not(.selectBox-optgroup)').length;
							i = 0;
							
							while( next.length === 0 || next.hasClass('selectBox-disabled') || next.hasClass('selectBox-optgroup') ) {
								next = next.next('LI');
								if( next.length === 0 ) next = options.find('LI:first');
								if( ++i >= totalOptions ) break;
							}
							
							addHover(select, next);
							keepOptionInView(select, next);
							
						} else {
							showMenu(select);
						}
						
						break;
						
				}
				
			};
			
			
			var handleKeyPress = function(select, event) {
				
				//
				// Handles type-to-find functionality
				//
				
				select = $(select);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options');
				
				if( control.hasClass('selectBox-disabled') ) return;
				
				switch( event.keyCode ) {
					
					case 9: // tab
					case 27: // esc
					case 13: // enter
					case 38: // up
					case 37: // left
					case 40: // down
					case 39: // right
						// Don't interfere with the keydown event!
						break;
					
					default: // Type to find
						
						if( !control.hasClass('selectBox-menuShowing') ) showMenu(select);
						
						event.preventDefault();
						
						clearTimeout(typeTimer);
						typeSearch += String.fromCharCode(event.charCode || event.keyCode);
						
						options.find('A').each( function() {
							if( $(this).text().substr(0, typeSearch.length).toLowerCase() === typeSearch.toLowerCase() ) {
								addHover(select, $(this).parent());
								keepOptionInView(select, $(this).parent());
								return false;
							}
						});
						
						// Clear after a brief pause
						typeTimer = setTimeout( function() { typeSearch = ''; }, 1000);
						
						break;
						
				}
				
			};
			
			
			var enable = function(select) {
				select = $(select);
				select.attr('disabled', false);
				var control = select.data('selectBox-control');
				if( !control ) return;
				control.removeClass('selectBox-disabled');
			};
			
			
			var disable = function(select) {
				select = $(select);
				select.attr('disabled', true);
				var control = select.data('selectBox-control');
				if( !control ) return;
				control.addClass('selectBox-disabled');
			};
			
			
			var setValue = function(select, value) {
				select = $(select);
				select.val(value);
				value = select.val();
				var control = select.data('selectBox-control');
				if( !control ) return;
				var settings = select.data('selectBox-settings'),
					options = control.data('selectBox-options');
				
				// Update label
				control.find('.selectBox-label').text( $(select).find('OPTION:selected').text() || '\u00A0' );
				
				// Update control values
				options.find('.selectBox-selected').removeClass('selectBox-selected');
				options.find('A').each( function() {
					if( typeof(value) === 'object' ) {
						for( var i = 0; i < value.length; i++ ) {
							if( $(this).attr('rel') == value[i] ) {
								$(this).parent().addClass('selectBox-selected');
							}
						}
					} else {
						if( $(this).attr('rel') == value ) {
							$(this).parent().addClass('selectBox-selected');
						}
					}
				});
				
				if( settings.change ) settings.change.call(select);
				
			};
			
			
			var setOptions = function(select, options) {
				
				select = $(select);
				var control = select.data('selectBox-control'),
					settings = select.data('selectBox-settings');
				
				switch( typeof(data) ) {
					
					case 'string':
						select.html(data);
						break;
						
					case 'object':
						select.html('');
						for( var i in data ) {
							if( data[i] === null ) continue;
							if( typeof(data[i]) === 'object' ) {
								var optgroup = $('<optgroup label="' + i + '" />');
								for( var j in data[i] ) {
									optgroup.append('<option value="' + j + '">' + data[i][j] + '</option>');
								}
								select.append(optgroup);
							} else {
								var option = $('<option value="' + i + '">' + data[i] + '</option>');
								select.append(option);
							}
						}
						break;
					
				}
				
				if( !control ) return;
				
				// Remove old options
				control.data('selectBox-options').remove();
				
				// Generate new options
				var type = control.hasClass('selectBox-dropdown') ? 'dropdown' : 'inline',
					options = getOptions(select, type);
				control.data('selectBox-options', options);
				
				switch( type ) {
					case 'inline':
						control.append(options);
						break;
					case 'dropdown':
						control.find('.selectBox-label').text( $(select).find('OPTION:selected').text() || '\u00A0' );
						$("BODY").append(options);
						break;
				}
				
			};
			
			
			var disableSelection = function(selector) {
				$(selector)
					.css('MozUserSelect', 'none')
					.bind('selectstart', function(event) {
						event.preventDefault();
					});
			};
			
			
			//
			// Public methods
			//
			
			
			switch( method ) {
				
				case 'control':
					return $(this).data('selectBox-control');
					break;
				
				case 'settings':
					if( !data ) return $(this).data('selectBox-settings');
					$(this).each( function() {
						$(this).data('selectBox-settings', $.extend(true, $(this).data('selectBox-settings'), data));
					});
					break;
				
				case 'options':
					$(this).each( function() {
						setOptions(this, data);
					});
					break;
				
				case 'value':
					if( !data ) return $(this).val();
					$(this).each( function() {
						setValue(this, data);
					});
					break;
				
				case 'enable':
					$(this).each( function() {
						enable(this);
					});
					break;
				
				case 'disable':
					$(this).each( function() {
						disable(this);
					});
					break;
				
				case 'destroy':
					$(this).each( function() {
						destroy(this);
					});
					break;
				
				default:
					$(this).each( function() {
						init(this, method);
					});
					break;
				
			}
			
			return $(this);
			
		}
		
	});
	
})(jQuery);







/**
 * Flash (http://jquery.lukelutman.com/plugins/flash)
 * A jQuery plugin for embedding Flash movies.
 * 
 * Version 1.0
 * November 9th, 2006
 *
 * Copyright (c) 2006 Luke Lutman (http://www.lukelutman.com)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 * 
 * Inspired by:
 * SWFObject (http://blog.deconcept.com/swfobject/)
 * UFO (http://www.bobbyvandersluis.com/ufo/)
 * sIFR (http://www.mikeindustries.com/sifr/)
 * 
 * IMPORTANT: 
 * The packed version of jQuery breaks ActiveX control
 * activation in Internet Explorer. Use JSMin to minifiy
 * jQuery (see: http://jquery.lukelutman.com/plugins/flash#activex).
 *
 **/ 
;(function(){
	
var $$;

/**
 * 
 * @desc Replace matching elements with a flash movie.
 * @author Luke Lutman
 * @version 1.0.1
 *
 * @name flash
 * @param Hash htmlOptions Options for the embed/object tag.
 * @param Hash pluginOptions Options for detecting/updating the Flash plugin (optional).
 * @param Function replace Custom block called for each matched element if flash is installed (optional).
 * @param Function update Custom block called for each matched if flash isn't installed (optional).
 * @type jQuery
 *
 * @cat plugins/flash
 * 
 * @example $('#hello').flash({ src: 'hello.swf' });
 * @desc Embed a Flash movie.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { version: 8 });
 * @desc Embed a Flash 8 movie.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { expressInstall: true });
 * @desc Embed a Flash movie using Express Install if flash isn't installed.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { update: false });
 * @desc Embed a Flash movie, don't show an update message if Flash isn't installed.
 *
**/
$$ = jQuery.fn.flash = function(htmlOptions, pluginOptions, replace, update) {
	
	// Set the default block.
	var block = replace || $$.replace;
	
	// Merge the default and passed plugin options.
	pluginOptions = $$.copy($$.pluginOptions, pluginOptions);
	
	// Detect Flash.
	if(!$$.hasFlash(pluginOptions.version)) {
		// Use Express Install (if specified and Flash plugin 6,0,65 or higher is installed).
		if(pluginOptions.expressInstall && $$.hasFlash(6,0,65)) {
			// Add the necessary flashvars (merged later).
			var expressInstallOptions = {
				flashvars: {  	
					MMredirectURL: location,
					MMplayerType: 'PlugIn',
					MMdoctitle: jQuery('title').text() 
				}					
			};
		// Ask the user to update (if specified).
		} else if (pluginOptions.update) {
			// Change the block to insert the update message instead of the flash movie.
			block = update || $$.update;
		// Fail
		} else {
			// The required version of flash isn't installed.
			// Express Install is turned off, or flash 6,0,65 isn't installed.
			// Update is turned off.
			// Return without doing anything.
			return this;
		}
	}
	
	// Merge the default, express install and passed html options.
	htmlOptions = $$.copy($$.htmlOptions, expressInstallOptions, htmlOptions);
	
	// Invoke $block (with a copy of the merged html options) for each element.
	return this.each(function(){
		block.call(this, $$.copy(htmlOptions));
	});
	
};
/**
 *
 * @name flash.copy
 * @desc Copy an arbitrary number of objects into a new object.
 * @type Object
 * 
 * @example $$.copy({ foo: 1 }, { bar: 2 });
 * @result { foo: 1, bar: 2 };
 *
**/
$$.copy = function() {
	var options = {}, flashvars = {};
	for(var i = 0; i < arguments.length; i++) {
		var arg = arguments[i];
		if(arg == undefined) continue;
		jQuery.extend(options, arg);
		// don't clobber one flash vars object with another
		// merge them instead
		if(arg.flashvars == undefined) continue;
		jQuery.extend(flashvars, arg.flashvars);
	}
	options.flashvars = flashvars;
	return options;
};
/*
 * @name flash.hasFlash
 * @desc Check if a specific version of the Flash plugin is installed
 * @type Boolean
 *
**/
$$.hasFlash = function() {
	// look for a flag in the query string to bypass flash detection
	if(/hasFlash\=true/.test(location)) return true;
	if(/hasFlash\=false/.test(location)) return false;
	var pv = $$.hasFlash.playerVersion().match(/\d+/g);
	var rv = String([arguments[0], arguments[1], arguments[2]]).match(/\d+/g) || String($$.pluginOptions.version).match(/\d+/g);
	for(var i = 0; i < 3; i++) {
		pv[i] = parseInt(pv[i] || 0);
		rv[i] = parseInt(rv[i] || 0);
		// player is less than required
		if(pv[i] < rv[i]) return false;
		// player is greater than required
		if(pv[i] > rv[i]) return true;
	}
	// major version, minor version and revision match exactly
	return true;
};
/**
 *
 * @name flash.hasFlash.playerVersion
 * @desc Get the version of the installed Flash plugin.
 * @type String
 *
**/
$$.hasFlash.playerVersion = function() {
	// ie
	try {
		try {
			// avoid fp6 minor version lookup issues
			// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
			var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
			try { axo.AllowScriptAccess = 'always';	} 
			catch(e) { return '6,0,0'; }				
		} catch(e) {}
		return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
	// other browsers
	} catch(e) {
		try {
			if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
				return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
			}
		} catch(e) {}		
	}
	return '0,0,0';
};
/**
 *
 * @name flash.htmlOptions
 * @desc The default set of options for the object or embed tag.
 *
**/
$$.htmlOptions = {
	height: 240,
	flashvars: {},
	pluginspage: 'http://www.adobe.com/go/getflashplayer',
	src: '#',
	type: 'application/x-shockwave-flash',
	width: 320		
};
/**
 *
 * @name flash.pluginOptions
 * @desc The default set of options for checking/updating the flash Plugin.
 *
**/
$$.pluginOptions = {
	expressInstall: false,
	update: true,
	version: '6.0.65'
};
/**
 *
 * @name flash.replace
 * @desc The default method for replacing an element with a Flash movie.
 *
**/
$$.replace = function(htmlOptions) {
	this.innerHTML = '<div class="alt">'+this.innerHTML+'</div>';
	jQuery(this)
		.addClass('flash-replaced')
		.prepend($$.transform(htmlOptions));
};
/**
 *
 * @name flash.update
 * @desc The default method for replacing an element with an update message.
 *
**/
$$.update = function(htmlOptions) {
	var url = String(location).split('?');
	url.splice(1,0,'?hasFlash=true&');
	url = url.join('');
	var msg = '<p>This content requires the Flash Player. <a href="http://www.adobe.com/go/getflashplayer">Download Flash Player</a>. Already have Flash Player? <a href="'+url+'">Click here.</a></p>';
	this.innerHTML = '<span class="alt">'+this.innerHTML+'</span>';
	jQuery(this)
		.addClass('flash-update')
		.prepend(msg);
};
/**
 *
 * @desc Convert a hash of html options to a string of attributes, using Function.apply(). 
 * @example toAttributeString.apply(htmlOptions)
 * @result foo="bar" foo="bar"
 *
**/
function toAttributeString() {
	var s = '';
	for(var key in this)
		if(typeof this[key] != 'function')
			s += key+'="'+this[key]+'" ';
	return s;		
};
/**
 *
 * @desc Convert a hash of flashvars to a url-encoded string, using Function.apply(). 
 * @example toFlashvarsString.apply(flashvarsObject)
 * @result foo=bar&foo=bar
 *
**/
function toFlashvarsString() {
	var s = '';
	for(var key in this)
		if(typeof this[key] != 'function')
			s += key+'='+encodeURIComponent(this[key])+'&';
	return s.replace(/&$/, '');		
};
/**
 *
 * @name flash.transform
 * @desc Transform a set of html options into an embed tag.
 * @type String 
 *
 * @example $$.transform(htmlOptions)
 * @result <embed src="foo.swf" ... />
 *
 * Note: The embed tag is NOT standards-compliant, but it 
 * works in all current browsers. flash.transform can be
 * overwritten with a custom function to generate more 
 * standards-compliant markup.
 *
**/
$$.transform = function(htmlOptions) {
	htmlOptions.toString = toAttributeString;
	if(htmlOptions.flashvars) htmlOptions.flashvars.toString = toFlashvarsString;
	return '<embed ' + String(htmlOptions) + '/>';		
};

/**
 *
 * Flash Player 9 Fix (http://blog.deconcept.com/2006/07/28/swfobject-143-released/)
 *
**/
if (window.attachEvent) {
	window.attachEvent("onbeforeunload", function(){
		__flash_unloadHandler = function() {};
		__flash_savedUnloadHandler = function() {};
	});
}
	
})();








