﻿/* Function for Image Rollovers */

$(function() {
  $('.rollover').hover(function() {
    $(this).attr('src', $(this).attr('src').replace( /_Out/i, '_Over' ));
  }, function() {
    $(this).attr('src', $(this).attr('src').replace( /_Over/i, '_Out' ));
  });
});

function checkText(objTB, strText, isFocus) {

  strText = jQuery.trim(strText);
  objTB.value = jQuery.trim(objTB.value);

  if (isFocus) {

    if (objTB.value == strText) {
      objTB.value = '';
    }

  } else {

    if (objTB.value == '') {
      objTB.value = strText;
    }

  }

}

/* Slideshow */
function slideSwitch(slideCat, activeCat) {

  var $active = $('#' + slideCat + ' DIV.' + activeCat);

  if ($active.length == 0) $active = $('#' + slideCat + ' DIV:last');

  // use this to pull the divs in the order they appear in the markup
  var $next = $active.next().length ? $active.next()
          : $('#' + slideCat + ' DIV:first');

  // uncomment below to pull the divs randomly
  var $sibs = $active.siblings();
  var rndNum = Math.floor(Math.random() * $sibs.length);
  var $next = $($sibs[rndNum]);

  $active.addClass('last-' + activeCat);

  $next.css({ opacity: 0.0 })
          .addClass(activeCat)
          .animate({ opacity: 1.0 }, 1000, function() {
            $active.removeClass(activeCat + ' last-' + activeCat);
          });
}
