// Input Hints plugin by Remy Sharp
// http://plugins.jquery.com/project/hint

jQuery.fn.hint = function () {
  return this.each(function (){
    // get jQuery version of 'this'
    var t = jQuery(this);
    // get it once since it won't change
    var title = t.attr('title');
    // only apply logic if the element has the attribute
    if (title) {
      // on blur, set value to title attr if text is blank
      t.blur(function (){
        if (t.val() == '') {
          t.val(title);
          t.addClass('blur');
        }
      });
      // on focus, set value to blank if current value
      // matches title attr
      t.focus(function (){
        if (t.val() == title) {
          t.val('');
          t.removeClass('blur');
        }
      });

      // clear the pre-defined text when form is submitted
      t.parents('form:first()').submit(function(){
          if (t.val() == title) {
              t.val('');
              t.removeClass('blur');
          }
      });

      // now change all inputs to title
      t.blur();
    }
  });
}

// Common functions used on pages
$(document).ready(function(){

// Google search box hint "Enter search keywords".
// Uses jQuery Input Hints plug-in (code is above)
// jQuery below says: use the hint function on
//   an input box with a type of 'text' AND an id of 'q'.
    //$('input:text[id="q"]').hint();
    //$('input:text[id="searchcontacts"]').hint();

// Table striping
    $('table:not([class="noborder"]):not([class="calendar"]):not([summary="Contact Details"]) tr:not([th])').removeClass('even');

    $('table:not([class="noborder"]):not([class="calendar"]):not([summary="Contact Details"]) tbody tr:nth-child(odd)').addClass('even');

 });


// Remove space from final paragraph in a feature/notice/success/error box
$(document).ready(function() {
    if ($.browser.msie) {
    	$("div.feature p:last-child").addClass('last-p');
    	$("div.notice p:last-child").addClass('last-p');
    	$("div.error p:last-child").addClass('last-p');
    	$("div.success p:last-child").addClass('last-p');
    }
});


