/* INPUT HINT */
(function($) {
  $.fn.inputhint = function(options) {
      // iterate and reformat each matched element
      return this.each(function() {
          // cache this:
          var obj = $(this);
          // get value hint
          var ogval = obj.val();
          obj.focus(function(){
              if( obj.val() == ogval ){
                  obj.val('');
                  obj.css( 'font-style', 'normal' );
              } else { null; };
          });
          obj.blur(function(){
              if( obj.val() == "" ){
                  obj.val(ogval);
                  obj.css( 'font-style', 'italic' );
              };
          });
      });
  };
})(jQuery);

/* SLIDER */
(function($) {
  $.fn.bdmslider = function(options) {
    var opts = $.extend({}, $.fn.bdmslider.defaults, options);
    // iterate and reformat each matched element
    return this.each(function() {
      var obj = $(this);
      var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
      var slides = obj.children(o.element);
      var currentslide = 0;
      var loopcount = 1;
      var slidetimer;
      
      function slide(slideid){
        slides.eq(slideid).fadeIn(o.speed);
        slides.eq(currentslide).fadeOut(o.speed);
        currentslide = slideid;
        loopcount ++;
        timer();
      }
      
      function timer(){
        slidetimer = setTimeout(function(){
          if (loopcount <= o.loops){
            if( currentslide == slides.length -1 ){
              slide(0);
            } else {
              slide(currentslide + 1);
            }
          }
        }, o.timeout);
      }
      timer();
    });
  };
$.fn.bdmslider.defaults = {
  element: 'img',   // the slide element
  loops: 20,        // how many times the whole slideshow loops
  speed: 2000,      // the in/out speed of the transition
  timeout: 5000     // length between transitions
};
})(jQuery);
