/*
* based on http://www.zurb.com/playground/inline-form-labels
*/

jQuery(document).ready(function() {

  jQuery('.loginbox input').change(function() {
  var x = jQuery(this).parent();
  jQuery(x).addClass("indent");
  });

  jQuery('.loginbox input').focus(function() {
  var x = jQuery(this).parent();
  jQuery(x).addClass("indent");
  });
  
  jQuery(".loginbox input").blur(function() {
  var x = jQuery(this).parent();
    if(jQuery(x).children('input').val() == '') {
      jQuery(x).removeClass("indent");
    }
  });
  
});

jQuery(document).ready(function() {

  jQuery('.gal-image').click(function() {
    var _this = this;
    jQuery("#main-image").attr("src", jQuery(_this).children("img").attr("src"));
    return false;
  });


});

function slideSwitch() {

    var active = jQuery('.carousel .fst-ch IMG.active');
    var active2 = jQuery('.carousel .snd-ch IMG.active');

    if(!active) {
      return;
    }

    if ( active.length == 0 ) active = jQuery('.carousel .fst-ch IMG:last');
    if ( active2.length == 0 ) active2 = jQuery('.carousel .snd-ch IMG:last');

    // use this to pull the images in the order they appear in the markup
    var next =  active.next().length ? active.next()
        : jQuery('.carousel .fst-ch IMG:first');

    // use this to pull the images in the order they appear in the markup
    var next2 =  active2.next().length ? active2.next()
        : jQuery('.carousel .snd-ch IMG:first');

    active.addClass('last-active');
    active2.addClass('last-active');

    next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 700, function() {
            active.removeClass('active last-active');
        });

    next2.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 700, function() {
            active2.removeClass('active last-active');
        });
}

jQuery(function() {
    setInterval( "slideSwitch()", 3000 );
});
