jQuery(document).ready(function($) {

  // function to detect browser rgba support (from jquery.color)
  var support = {}, div = document.createElement( "div" ), div_style = div.style;
  div_style.cssText = "background-color:rgba(150,255,150,.5)";
  support.rgba = div_style.backgroundColor.indexOf( "rgba" ) > -1;

  // attach 'changed' style to input elements
  $('input, textarea').change(function() {
    $(this).addClass('changed');
  });

  // clear input textfields of generated content once focused; put back text if
  // not changed
  $('.clear-on-focus:not(.content-cleared)').focus(function() {
    $(this).data('text', String($(this).attr('value')));
    $(this).attr('value', '').addClass('content-cleared');
  });
  $('.clear-on-focus, .content-cleared').blur(function() {
    if ($(this).attr('value') === '') {
      $(this).attr('value', $(this).data('text')).removeClass('content-cleared');
    }
  });
  
  // animate hover states for nav items
  $('#nav-primary ul.menu li:not(.current-menu-item, .current-page-ancestor)').mouseover(function() {
    if (support.rgba) { // jquery.color detector for browser rgba support 
      $(this).dequeue().animate({backgroundColor: '#b4c3c5'}, 250);
    }
  })
  $('#nav-primary ul.menu li:not(.current-menu-item, .current-page-ancestor)').mouseout(function() {
    if (support.rgba) {  
      $(this).dequeue().animate({backgroundColor: 'transparent'}, 250)
    }
  })
  
  // move the slideshow images to their header position on the home page
  $('.home .slideshow').appendTo('#home-slideshow');
  
  // cycle the how slideshow slides
  delay = 0;
  $('.slideset').each(function() {
    $(this).cycle({timeout : 8000, delay : delay});
    delay += 1000;
  });

});



