//
// Hubbard House Javascript
//
// Author: Fred Boyle / Subtle Tech / We Inspire (http://subtletech.com)
//

//
// Hide and show the text in a form field on focus on blur, respectivley.
function clear_it(object){
  object.each(function(){
    $(this).bind("focus", function(){
      var orig_text = $(this).val();
      $(this).val('');
      $(this).bind("blur", function(){
        orig_text = ($(this).val() !== "") ? $(this).val() : orig_text ;
        $(this).val(orig_text);
      });
    });
  });
}
//

// function to validate e-news signup form
function _validate_enews_signup() {
  
  $('#enews-signup').submit(function(e) {
  
    field = $("#fields_email", this);
    field_val = field.val();
  
    if( field_val == "" || field_val == "Email" ) {
      field.focus();
      alert("Please provide your e-mail address.");
      return false;
    }
    
    return true;
    
  });
  
}
//

// link builder for cycle nav
function pagerBuild(index, elem) {
	return "<li><a href='#'>" + (index + 1) + "</a></li>";
}
//

$(document).ready(function(){ 
  
  //
  clear_it( $('#enews-signup input') );
  
  //
  //_validate_enews_signup();
  
  // home page slideshow
  if(jQuery().cycle) {
  
    $('.slideshow').cycle({
      slideExpr: 'li:not(.slide-nav)',
  		fx: 'fade',
		  //speed: 3000,
		  timeout: 10000,
  		pauseOnPagerHover: 1,
  		pager: '.slide-nav',
  		activePagerClass: 'current'
  	});
  
  };
  
});
